Skip to content

feat: content mapper (v4 alpha) - #6170

Draft
johnsoncodehk wants to merge 638 commits into
masterfrom
feat/vue-content-mapper
Draft

johnsoncodehk wants to merge 638 commits into
masterfrom
feat/vue-content-mapper

Conversation

@johnsoncodehk

@johnsoncodehk johnsoncodehk commented Aug 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Vue Language Tools v4 type-checks .vue files with TypeScript 7.1's own tsc through a Content Mapper (@vue/content-mapper), with no separate vue-tsc binary. The TypeScript code generation of Vue files lives in @vue/content-mapper, on top of @vue/language-core's parse / IR layer, and runs only inside the Content Mapper.

The Vue language server no longer generates or reads TypeScript code for Vue files. It works from the .vue source, language-core's IR and script analysis, Vue's own types (GlobalComponents, GlobalDirectives, JSX.IntrinsicElements) and the TS 7.1 span map of the file TypeScript checks, which it reaches through the TypeScript API of the editor's TS 7.1 language server. It treats the files of any contentMappers entry as Vue files, so it also works with a Vue Content Mapper other than @vue/content-mapper. v4 supports TypeScript 7.1 only.

Quick start

// tsconfig.json
{
  "compilerOptions": { "noEmit": true },
  "contentMappers": [
    {
      "package": "@vue/content-mapper",
      "extensions": [".vue"],
      "options": { "target": 3.5 }
    },
    // VitePress markdown: same package, picked by `format` (default "sfc")
    {
      "package": "@vue/content-mapper",
      "extensions": [".vue.md"],
      "options": { "format": "vitepress" }
    }
  ]
}
npm i -D typescript@beta @vue/content-mapper   # content mappers ship in TypeScript 7.1 (7.1.0-beta and later)
tsc --runExternalCode                          # replaces `vue-tsc --noEmit`

Vue compiler options go directly under options. Add "languageFeatures": false there for CLI-only type-checking.

Breaking changes

Projects (tsconfig and CLI type-checking)

  • vue-tsc is removed. Use tsc --runExternalCode.

  • The Content Mapper parses with the TS 7.1 typescript package that resolves from the project directory (the tsconfig's directory, or the working directory for an inferred project), and fails to open a project from which none resolves. --typescript= / VUE_CONTENT_MAPPER_TYPESCRIPT are removed.

  • Vue options live only under contentMappers[].options. The tsconfig's top-level vueCompilerOptions is no longer read, and contentMappers is replaced wholesale through extends (a config with its own array does not inherit the base config's entries).

  • A file that no contentMappers entry covers gets no Vue features. The language server creates a Vue language plugin for every entry of the file's project, whichever Content Mapper package it names, with the entry's options as its Vue compiler options.

  • strictTemplates, strictVModel and all checkUnknown* options are removed. Template checking follows TypeScript's defaults: lang="ts" is strict, lang="js" follows checkJs / @ts-check. The permissive modes dropped specific error codes, and the Content Mapper protocol only suppresses by span, never by code.

  • A template tag refers to the <script setup> binding of its name, whatever it is imported from, like @vue/compiler-sfc. Components are no longer detected by the import's file extension.

  • Unknown components and directives are always reported, so declare them. This needs Vue 3.3, so the minimum target is now 3.3.

    declare module 'vue' {
      interface GlobalComponents { Foo: typeof import('./Foo.vue').default }
      interface GlobalDirectives { vTooltip: typeof import('./v-tooltip').default }
    }
  • skipTemplateCodegen is removed. The template code and the template scope are always generated, so type checking, template completion and component meta no longer silently degrade. Setting it reports a removed-option diagnostic.

  • vitePressExtensions / petiteVueExtensions are replaced by options.format ("sfc" by default, "vitepress" or "petite-vue"), set per entry instead of inferred from the extension.

  • experimentalModelPropName is replaced by vModelPropName, keyed by tag: { "my-input": "value", "my-switch": "checked", "f-radio-field": false }. Entries match in any casing, are merged over built-in native rules that follow @vue/compiler-dom, and can be overridden per file with <!-- @vModelPropName { ... } -->. false binds no prop. Components mapped to another prop (e.g. custom elements) now check writing that prop back to the v-model expression instead of an update:modelValue event. The old name and the old prop-keyed shape report an option diagnostic with the converted value.

  • Vue no longer resolves CSS or asset module specifiers, and resolveStyleImports is removed. CSS belongs to separate CSS Content Mapper packages (e.g. a Content Mapper version of css-modules-kit). <style module src> is now an ordinary import that types $style, so an unresolvable src reports TS2307.

Editor users

  • Formatting of .vue script blocks and template expressions is unavailable (document, range and on type), and so are folding, selection ranges and outline of script blocks and JSX closing tags. They ran on classic TypeScript, which TS 7.1 replaces, and TS 7.1 has no project-free syntactic API for a block that is not a file of a project. The tests are kept as expected failures, and the vue.format.script.* / vue.format.template.* settings are kept for when TypeScript adds the API. Known v4 regression versus v3. JSDoc comment templates still work: TS 7.1 provides them, tabstops included.
  • Renaming a binding leaves same-name shorthands untouched (:foo-bar, :count, { foo } in a template expression or in :class), so after the rename the template refers to a name that no longer exists, and renaming from the shorthand itself does nothing. v3 expanded them (:foo-bar="NEW", { foo: NEW }). Known v4 regression versus v3; it waits on TypeScript expanding a shorthand through span maps, and the tests are expected failures. A function, class, enum or destructured prop in an object shorthand of a template expression already expands ({ format: NEW }), since the generated code reads it as written.
  • Go to definition on a module specifier that leads to a Vue file through paths (import Foo from '@/Foo.vue') gives no result; a relative specifier and the default import name lead to the file. v3 led to the component. Known v4 regression versus v3; it waits on TypeScript resolving such specifiers (expected-fail test).
  • Accepting an auto-import completion in a wholly empty <script setup> or <script> of a component with a template inserts the import into the template; without a template it goes into the block. v3 (3.3.13, TypeScript 5.9.3) inserted it into the block in both cases. Known v4 regression versus v3; it waits on TypeScript placing a top-of-file import on the empty block (expected-fail test).
  • Reactivity Visualization resolves a script's identifiers through the checker of its TS 7.1 project instead of a classic TypeScript language service without a default library or imports, and no longer depends on laplacenoma. counter.n.value of another useCounter() call no longer counts as reading the n of const { n } = useCounter() (another instance), and a call of a variable that holds a named function expression now reads what the function reads. While the TypeScript language server has another text of the script, there is no analysis.
  • Vue LS provides no semantic tokens. Component coloring comes from the TextMate grammar; customize scope support.class.component.vue instead of the component token.
  • Vue LS provides no document highlights for embedded TypeScript. The TypeScript server answers those; _vue:documentHighlights-full is removed.
  • Twoslash queries (// ^? in script blocks, <!-- ^? --> in the template) are removed. TS 7.1 gives no twoslash queries in TypeScript files either (no inlay hint for a // ^? line from its language server, and no twoslash in its build), so a Vue-only version would make the same comment act differently in .vue and .ts files, and the template form was a convention of this project only.
  • Template tag completion only offers <script setup> bindings typed as components: a type with a construct signature, or an object with setup, render or template. Plain functions (functional components declared as setup bindings) are no longer offered.
  • Template expression completion is rebuilt around a __VLS_scope object, so TypeScript only completes real template scope members. The Vue language server supplements unused <script setup> bindings and template locals (v-for / slot props) as plain completion items. Globals are limited to the ones @vue/shared's isGloballyAllowed accepts.
  • Template tags resolve to the binding the template is checked against. A setup binding now shadows a global component of the same name (before, both were merged and definition went to the global one), <loading> refers to an imported Loading before a loading variable, a file refers to itself by its defineOptions name, and a narrowed binding (<Child> under v-if="Child") has its props.
  • Props completion and missing-props hints read the component type ($props of its construct signature, or the first parameter of its call signature), not the contextual type of the generated props object. A generic component's type parameters stay unresolved, and an overloaded component offers the props of its first construct signature. Components the old lookup missed (abstract construct signatures, a call signature intersected with new () => any) now get props.
  • With "languageFeatures": false the span map has no navigation segments, so rich hover, component definition and props completion have no answer in that project.
  • In VS Code, the Content Mapper of Vue files outside any tsconfig runs in the first local workspace folder, so TS 7.1 resolves from it. A window without a local workspace folder gets no Content Mapper for those files and logs an error. The extension no longer bundles TS 7.1.

Editor and client integrators (Neovim, Zed, Sublime, etc.)

  • Editors must provide the TypeScript API pipe. The client answers Vue LS's vue/typescriptApiConnection request by forwarding custom/initializeAPISession to the TS 7.1 language server (tsc --lsp --stdio, started with initializationOptions: { runExternalCode: true }), like v3's tsserver/request forwarding (see "Client Requirements" in the language server README). There is no fallback.
  • @vue/typescript-plugin is removed. Its _vue: tsserver requests are answered by the Vue language server through the TypeScript API, so drop the plugin from the client's tsserver configuration.
  • The server no longer needs TypeScript 5 or 6. The --tsdk parameter, its TypeScript 5/6 check and the typescript peer dependency are removed, and startServer / createVueLanguageServicePlugins take no ts argument.
  • Sync only Vue documents to the server. It treats the files of every contentMappers entry that the client syncs as Vue files, so the client selects them by language id (e.g. vue). Files outside any tsconfig get their entries from initializationOptions.contentMappers.

vue-component-meta users (Storybook, nuxt-component-meta, etc.)

  • vue-component-meta moves to the TypeScript 7.1 API and is async. typescript >=7.1.0-beta is a peer dependency. createChecker(tsconfig) returns an async-disposable checker whose getComponentMeta / getComponentMetas / getExportNames read files from disk with a fresh snapshot per query. createCheckerByJson, updateFile, deleteFile, reload, clearCache and getProgram are removed, and virtual files are not supported. The core is exported as pure functions that take a TypeScript Project.

  • vue-component-meta results are plain data. Each member's type is a TypeId into a shared ComponentMeta.types table of TypeNodes (text plus structure); objects and functions declared outside the project are not expanded. The schema / printer options (MetaCheckerOptions, PropertyMetaSchema), getTypeObject, getDeclarations, rawType, the event signature and ComponentMeta.type (TypeMeta) are removed, PropertyMeta is renamed PropMeta, and declarations are mapped ranges ({ file, start, end }).

    // v3
    const checker = createChecker('tsconfig.json', { schema: true });
    const meta = checker.getComponentMeta('src/Foo.vue');
    meta.props[0].type; // 'string | undefined'
    
    // v4
    await using checker = await createChecker('tsconfig.json');
    const meta = await checker.getComponentMeta('src/Foo.vue');
    meta.types[meta.props[0].type].text; // 'string | undefined'
  • Events have no description or tags yet. They come from the JSDoc of the event's call signature, which the TS 7.1 API does not expose for signatures (expected-fail test). Not a regression: 3.3.13 on TypeScript 5.9.3 also gives an empty description and no tags for a documented type-based or runtime defineEmits.

  • Props of a generic component have no default yet. Script setup defaults (withDefaults, a props destructure, defineModel) are read through the checker from the component's declaration, and Vue's types do not give a generic component its defaults (see Vue core; expected-fail tests). A regression: v3 read them from the source. vue-component-meta no longer depends on @vue/language-core.

Vue language plugin authors

  • VueLanguagePlugin is replaced by plugin modules that export one key per mode. This is a clean break with no adapter for v3 plugins. A module exports ir (formats, templateCompilers, resolveTemplateCompilerOptions) and/or codegen; a function, an array or an object with version fails to load with a message naming the migration. version, name, order, ctx.modules, parseSFC / updateSFC, compileSFCScript, compileSFCStyle, compileSFCTemplate and updateSFCTemplate are removed. A plugin takes its options from its plugins entry (ctx.config). See Plugins and the CHANGELOG.
  • Plugins no longer add or change embedded documents of the language service (getEmbeddedCodes, resolveEmbeddedCode). The documents, including the one of a pug template, are built in; custom blocks get the language of their own lang only. A format or template language belongs to the one plugin that provides its key, and providing a built-in key or another plugin's key is a load error. A template language returns its HTML and the mappings back to its source; language-core compiles the HTML and maps every position back once, so a plugin no longer receives a compiler or walks the AST. @vue/language-plugin-pug exports ir.templateCompilers.pug and depends on @vue/language-core for types only.
  • Plugins contribute to the generated TypeScript through a codegen export, read only by @vue/content-mapper (the language server and vue-component-meta never load it): codegen = ctx => ({ contribute(file) { … } }) returns script edits of the user's code (insertBefore / insertAfter / replace), template context types, props, emits and exposed types of script setup components, native element types, module declarations, named exports and the component's doc comment. Script edits never conflict with each other or with Vue's own transforms, and inserts move with the code that Vue moves. The CHANGELOG maps known v3 plugins (vue-router typed routes, vue-macros, ts-macro, weapp-vite, …) to their contribution. See Codegen plugins.
  • TypeScript code generation moves from @vue/language-core into @vue/content-mapper. The script, template and style codegen and the generated names live in the mapper; nothing generates the service script through embedded codes anymore, so the vue-tsx plugin is removed. language-core contains no TypeScript codegen. createVueLanguagePlugin and VueVirtualCode moved to @vue/language-service, and createVuePlugins is replaced by createIRPipeline.
  • language-core provides the analysis the codegen and the language server share. VueVirtualCode.scriptAnalysis exposes script ranges, setup bindings, local components and directives, and the template scope (collectTemplateScope: the identifiers each template expression references, the block scopes with their declared names and members, the narrowed setup bindings, inlay hints). The codegen reads it instead of walking the scopes itself, and throws when it has no entry for an expression it generates.
  • Every createVirtualCode returns an independent virtual code. The module-level registry that shared virtual codes between plugins of equal options is removed; sharing transforms across projects is left to the TypeScript host, which caches them by configIdentity.
  • Mapping data uses TS 7.1 span map features. VueCodeInformation, codeFeatures and allCodeFeatures are replaced by VueCodeMarker and SpanMapFeature bit groups (allFeatures, scriptFeatures, completionFeatures, ...). Volar.js v3 has no verification feature: diagnostics are suppressed through ignore directives over generated code.
  • Core receives format directly (refactor(language-core): select the SFC parser by format instead of a fake languageId #6295): isValidFile / parseSFC2, ctx.compilerOptions, requiredCompilerOptions and the compilerOptions parameter of createVueLanguagePlugin are gone; formats of plugins are selected by name through the format option.
  • A Vue language plugin parses every file it receives by vueCompilerOptions.format, not by the file's extension. getFormat, isContentMapperFile, withExtensionFormats and resolveContentMappers are removed from language-core, getRootLanguageId takes no file name, and BindingFlag.Component / getImportedComponents are removed from parseBindings.

CSS with a CSS Content Mapper

Vue only types what it owns: inline <style module> classes and scoped classes still come from Vue's own class extraction. Everything about CSS files themselves (resolving @import / @use, aliases and paths, and the types of a CSS module's exports) belongs to a separate CSS Content Mapper package, such as a Content Mapper version of css-modules-kit. The two sit side by side in contentMappers:

{
  "contentMappers": [
    { "package": "@vue/content-mapper", "extensions": [".vue"], "options": { "target": 3.5 } },
    // a CSS Content Mapper package (illustrative; not published yet)
    { "package": "<css-content-mapper>", "extensions": [".module.css"] }
  ]
}

<style module src="./foo.module.css"> becomes an ordinary default import of ./foo.module.css in the virtual code, so $style gets whatever types the CSS mapper gives that module, the same as importing it from a .ts file. Without a CSS mapper or a declare module '*.module.css' declaration, the import reports TS2307 instead of silently typing $style as any.

Until a CSS Content Mapper exists, @import / @use in <style> only get the CSS service's own relative and root path resolution. Go-to-definition through an alias @import also needs TypeScript's cross-file definition fallback (see Remaining work), the same gap as import B from '@/Comp.vue'.

Remaining work

language-tools

  • Merge and publish the submodules. volar.js pins a branch three commits ahead of its v3 branch, and services a branch five commits ahead of its master. Their packages are versioned 2.4.30 and 0.0.71, which npm already has without these changes, so the release workflow's "on npm" check passes against the old packages.
  • Known TextMate gaps for component coloring: isCustomElement, v-pre subtrees, pug / markdown / petite-vue templates, closing tags split across lines.

CSS (separate packages)

  • A Content Mapper version of css-modules-kit (or another CSS Content Mapper) that owns CSS resolution and CSS module types.
  • Sass partial / index resolution: needs a TypeScript module resolution hook, or the CSS mapper resolving them itself.

TypeScript

  • A project-free syntactic API (formatting, folding, selection ranges, outline, JSX closing tags) for code that is not a file of a project, such as a .vue script block or template expression. The Vue language server keeps the wiring for it (SyntacticApi); until then those features are unavailable (see Breaking changes).
  • Expanding a same-name shorthand of the source on rename through span maps, so that renaming expands template shorthands ({ foo }, :foo, :foo-bar).
  • Resolving the definition of a module specifier through paths when it leads to a file of a Content Mapper (import B from '@/Comp.vue'; expected-fail test).
  • The documentation of signatures in the API (Signature documentation comment and JSDoc tags), for the description and tags of component meta events (expected-fail test).
  • A parser in typescript/ast, or the host's parse in the Content Mapper transform request, and parse diagnostics from the API. The Content Mapper parses script blocks through a typescript/sync API process it starts, and approximates the parse diagnostics it needs by the erroneous nodes at the end of the code; both are labeled at their code location.
  • Separate origin / result feature masks in the span map (tag highlights, @event definition).
  • Map a navigation result that covers more than one segment instead of dropping it, or give the definition and the references of a quoted property name the same span. Interim: a scoped or CSS module class whose name is not an identifier (.foo-bar) is declared twice in the virtual code, once as an atom for definition and references and once verbatim for rename. Exit: when TypeScript maps either shape, the class is declared once.
  • Place a top-of-file import on a zero-width verbatim segment at the insertion point. The change tracker advances the point to the first verbatim segment that ends after it, which skips the zero-width copy of an empty script block and finds the template's first mapped char; with no verbatim template segment the point stays and maps into the block. The Content Mapper emits the same script segment with or without a template, and giving it every feature does not move the edit (expected-fail test).
  • Link the properties of a 1:1 key-remapping mapped type to the declarations they map from. Until then a directive that a spread in the Options API directives option registers resolves its type but links to nothing, and the on${Capitalize<K>} listener props of type-based emits link nothing once Vue core keeps the event declarations (expected-fail tests).
  • The Content Mappers of an inferred project in the API. For a tsconfig project the Vue language server reads parsedCommandLine.raw.contentMappers; for an inferred project raw is undefined, options carry no mapper options, and only the identity in SourceFile.contentMapper (contributorId[n] (name@version)) is visible. Until then the client also passes them in initializationOptions.contentMappers.
  • A declaration-only output extension. typescript.contentMapper.outputExtensions { ".vue": ".ts" } emits Comp.d.ts, but requires rewriteRelativeImportExtensions (TS18120) in every project that uses the mapper, and then rewrites ./Comp.vue in the emitted JS and declarations to ./Comp.ts / ./Comp.js, which are not emitted. Until then declarations stay Comp.d.vue.ts (dts snapshot tests).

Vue core

  • Blocking: types for the prop defaults of a generic component. Only an options component carries Defaults; the function form of defineComponent, the one that takes type parameters, fixes them to {}, and the defaults of a generic component stay inside its setup function. vue-component-meta reads all script setup defaults through the checker, so until then it reports no defaults for the props of a generic component (expected-fail tests; a regression from v3, in the CHANGELOG).
  • TypeEmitsToOptions should keep the declarations of the events. It maps over keyof T & string, which is not homomorphic, so the emits of a type-based defineEmits reach DefineComponent only as new symbols, and a parent's @foo-bar listener links to nothing in the child (expected-fail test). v3 did not link it either (checked on master with TypeScript 5.9), so this is not a regression.
Also in this PR

Full list in the CHANGELOG. These are the changes a reviewer or user would notice outside the breaking changes above.

  • @vue-ignore / @vue-expect-error in <template> become TS 7.1 diagnostic directives; an unused expect is reported at the original comment in every locale. Diagnostics of the codegen's own code are suppressed by ignore directives the codegen emits over it, so nothing filters diagnostics by code.
  • The remaining codegen @ts-ignores are on purpose: the construct call that infers generic and overloaded component props (element.ts, reason in test(language-core): cover the construct call of components and document its @ts-ignores #6301) and the guards for a possibly missing global JSX (localTypes.ts).
  • Fixes already upstreamed to master: fix(language-core): avoid non-null assertion in JS slot codegen #6289, fix(language-core): declare component context vars before slot code #6293, fix(language-core): use a const type parameter in __VLS_unwrap to keep literal bindings on TS 7.1 #6294, fix(language-core): type the $event parameter of inline handlers explicitly #6300.
  • SpanMapKind.Alias was evaluated and not adopted: it only changes names in diagnostic messages, and Vue's respellings are real names users act on.
  • TS 7.1's registerLspMiddleware was evaluated and not adopted: it only rewrites results inside the VS Code extension, so other editors would behave differently, and the gaps it could patch are fixed in TypeScript (listed under Remaining work).
  • Declarations emitted for a JS <script setup> component declare what its lang="ts" twin declares; they no longer export the codegen's type aliases.
  • A component's script identifier highlights its template tags again (selected html tag highlighting is incorrect #5487, element-plus tag highlight exception #5580).
  • useTemplateRef links and scoped-class links come from the template itself, so they also cover elements under @vue-skip and component refs with no typed template ref.
  • @vue/content-mapper reports plugins that fail to load, and a format that nothing provides, as option diagnostics; the language server recreates a project's Vue language plugin when one of its plugin files changes.
  • resolveVueCompilerOptions lives in language-core and is the one reader of an entry's options for @vue/content-mapper and the language server, so the editor and tsc generate the same virtual code.
  • configIdentity hashes the effective configuration instead of the files read while resolving it, so projects that reach the same Vue package through their own node_modules share transforms.
  • The VS Code extension recognizes .vue.md as VitePress by default (feat(vscode): default to recognizing .vue.md as VitePress files #5884) and registers .vue / .vue.md entries for inferred projects with TypeScript (Native Preview)'s registerContentMappers.
  • A project whose entry names another Vue Content Mapper gets Vue language features; the language server does not depend on @vue/content-mapper (a dev dependency for tests).
  • The Content Mapper transforms in its protocol process, without a worker pool (VUE_CONTENT_MAPPER_WORKERS is gone): every worker initialized the mapper again and started its own TypeScript API process. On 200 .vue files, 8 cores, medians of 10 interleaved runs of tsc --runExternalCode, user+sys / wall / largest RSS: pool with the default worker count 3.99s / 1.32s / 272MB, pool with one worker 2.50s / 1.23s / 228MB, no pool 2.33s / 1.06s / 221MB.
  • The type annotation of a v-slot parameter reads the template's bindings as the rest of the template does (typeof foo of a ref is the unwrapped value).
  • The props parameter of a defineModel default function can have the name of the runtime defineProps binding (was TS2502), and is typed through JSDoc in JavaScript (was TS8010).
  • Renaming a scoped class from its name in a string of :class renames it in the template and the style block.
  • Component meta gives the returned expression as the default of a prop whose default is an arrow function with a single-return block body.
  • The instance type of a script setup component, and its emitted declaration, give a prop that has a default without undefined: a withDefaults default at target 3.6, a props destructure default from target 3.5, and a defineModel default. All three go through the runtime props option that released Vue reads (__VLS_WithDefaults, which keeps each default's declaration). Target 3.6 used the __defaults option, which only the unmerged vuejs/core#12935 reads; no released Vue does (checked 3.5.44, 3.6.0-rc.6, 3.6.0-rc.13). v3 (3.3.13, TypeScript 5.9.3) also gave these props with undefined, except withDefaults below target 3.6.
  • At target 3.6, the instance type of a script setup component with a runtime defineProps argument includes its defineModel props; they were missing, in v3 too.
  • Component meta gives the default of a prop whose name is quoted in a props destructure or in the withDefaults defaults ('foo-bar'); it gave none.

Notes

  • The repo builds, lints and tests with typescript@7.1.0-beta from npm; no classic TypeScript is installed.
  • The tests of codegen plugin contributions, v-slot parameter types and the copies of the user's script assert tsc diagnostics, declaration emit and language server results of fixture projects, not the generated __VLS_* code. Each was checked by breaking the behavior in the code. What stays on generated code: where plugin edits land in the user's code and their mappings, the template scope that the codegen reads from the analysis, and no empty copy at the end of a block that ends with its default export, which no tried language server request or diagnostic tells apart.
  • Vue is pinned to 3.6.0-rc.6 in test-workspace (chore(deps): upgrade Vue to 3.6.0-rc.6 #6189).
pnpm test content-mapper

References

  • Content mapper hook: microsoft/typescript-go#4712 (merged), round 2: microsoft/TypeScript#63936 (merged)
@johnsoncodehk johnsoncodehk changed the title feat: content mapper prototype (WIP) Aug 20, 2026
@escaton

This comment was marked as resolved.

@escaton

This comment was marked as resolved.

@escaton

escaton commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Hi @johnsoncodehk would you mind publishing this as next, or v4-alpha version on npm?

@johnsoncodehk

Copy link
Copy Markdown
Member Author

@escaton Yes, I plan to do that, but before that, the removal of @vue/typescript-plugin needs to be completed.

@ismailkarsli

Copy link
Copy Markdown

I've been using this as a submodule for a few days now, and it works quite well for a simple application. It would be great if it were an alpha/development version.

@chybisov chybisov mentioned this pull request Oct 16, 2026
3 tasks done
johnsoncodehk and others added 10 commits November 28, 2026 18:36
…o the point at its end

The `;` that closes a truncated copy of a script block (#3632) was mapped to
the char after the end of the block, which the block does not have: a range
out of its source. It now maps to the point at the end. muggle-string 1.0.5
and later refuse a range out of its source, so the transform of such a file
threw a RangeError there.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…andle

A slice that a writer of a plugin cuts is a handle that each rewrite of the
script blocks replays as a slice of its own, but its type was the slice of a
muggle-string rewrite. Since muggle-string 1.0.4 only `cut` of a rewrite makes
such a slice, so the types no longer matched. `VueCodegenSlice` is now the
handle, `VueCodegenCode` and the options of `cut` are typed with it, the
transforms that the script generator shares with the builtin plugins take a
writer of either kind of slice, and the code of an interpolation, which goes
into a rewrite of the expression, is typed as pieces. No runtime change.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…urce does not write

The `div` that Pug adds to `.foo` is not in the template, so the offset of
its tag is -1, and its code was mapped to the range from there: 3 chars from
the char before the template. Its code now maps nowhere, and what is reported
at the tag maps to the point where the element starts. muggle-string 1.0.5
and later refuse a range out of its source, so the transform of such a
template threw a RangeError there.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
1.0.5 listed a slice that the generator renders by itself as not rendered, so
a `<script>` with a default export failed to transform (#6378); 1.0.6 takes
that back. The range excludes 1.0.5, and @vue/language-core and
@vue/content-mapper depend on the same version again.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…e at an offset

`getElementTagOffsets` gave -1 for the tag of an element that the template
does not write, as the `div` that Pug adds to `.foo`, and its users took it
for an offset: the language server asked TypeScript about the char before the
template, and the hints of missing props and the scope of the template
computed ranges from it. It now gives no offset for such a tag, so every user
says what it does then: an element maps no code to the tag, the language
server reads its attributes by the name of the tag and offers no import for
it, and the hints skip it. `getWrittenTagOffsets` is for the tags that the
source always writes, of components, `<template>` and `<slot>`, and throws
for one that it does not.

Both are in lib/template/elementTag, which the index of @vue/language-core
does not export: `getElementTagOffsets` is no longer part of its API.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A codegen plugin got its `config` and the `vueCompilerOptions`, and nothing
that tells where the project is, so it could not resolve a relative path of
its options: the mapper runs in a directory of its own (#6337). Its context
now has `projectDirectory`, the directory that the options of the entry
resolve from, as its `plugins` do: the directory of the tsconfig, or the
working directory of the mapper for a project without one.

What a codegen plugin generates can depend on the directory, so it is part of
the identity of a project that has one. Projects without a codegen plugin
share an identity across directories as before.
@github-actions

Copy link
Copy Markdown
Contributor

4.0.0-alpha.4 is on npm with dist-tag alpha (12 commits, run).

johnsoncodehk and others added 6 commits November 29, 2026 16:26
The fixes of master since the last merge, on the code that the branch moved
into @vue/content-mapper:

- #6346: the code generated after a copy of a script block starts on a new
  line where the text of the block ends its line without a line break. The
  rule lives in the render of a block rewrite; the tests of master are ported
  to tests/trailingLineBreak.spec.ts, but for its quick fix test, as the
  language server offers no fix for an unused declaration here.
- #6344: the hyphenated event name is passed to `__VLS_ResolveEvent`.
- #6335: taken as is.
- #6371, #6329: the fixtures pass without a change; the branch does not join
  the lines of the inference-only props copy and omits the wrapper of slot
  parameters by ranges. The fixture of #6322 binds `v-model` to a
  `string | undefined`, as the branch checks what `v-model` writes back.
- #6290, #6284: the document drop and the completions are those of the
  TypeScript language server on the branch; the changed code does not exist.
…workflow

GitHub answers anonymous requests of raw.githubusercontent.com with 429 once
the address of a runner is over its limit, which failed the tests on macOS
twice in a row. Requests with a token have a limit of their own.
…vue/content-mapper

`template-helpers.d.ts` and `vue-3.4-shims.d.ts` are only referenced by the
code that @vue/content-mapper generates, so a change of a helper type and of
the code that uses it was a change of two packages. They are in the `types`
directory of @vue/content-mapper now, which @vue/language-core no longer has.

`typesRoot` of the resolved options is `undefined` unless it is set, and the
code generator falls back to its own directory; its default in the schema is
`@vue/content-mapper/types`.
The grammar tests download five grammars of VS Code from
raw.githubusercontent.com on every run, on three platforms and for both
the push and the pull request run, and GitHub answers part of those
requests with 429. Sending the token of the workflow did not change
that: both runs after 25cb6b4 failed on all platforms with the token
set, so the token is taken out again.

The files are now cached under the hash of their lock file, shared by
the platforms. grammars-sync.ts already skips a file whose checksum
matches the lock, so a run with a restored cache makes no request. The
first run of a branch still downloads.
The hash of the lock file differs on Windows, where the checkout converts
line endings, so Windows never found the files that the Linux run saved.
Any saved set is restored now; grammars-sync.ts compares each file with
the checksum of the lock file and downloads the ones that differ.
@github-actions

Copy link
Copy Markdown
Contributor

4.0.0-alpha.5 is on npm with dist-tag alpha (13 commits, run).

johnsoncodehk added a commit that referenced this pull request Nov 30, 2026
…Vue accepts

`v-html` only took `string` and `v-text` only `string | number`, so a
nullable or boolean value was an error, which it was not before 4.0.
Vue does not set `innerHTML` for `null` and `undefined`, and passes
the value of `v-text` through `toDisplayString` like an interpolation.
`v-html` now takes `string | null | undefined` and `v-text` any value.

Reported in #6170 (comment)
lozinsky and others added 7 commits November 30, 2026 13:58
…` in JavaScript (#6394)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Johnson Chu <johnsoncodehk@gmail.com>
…up>` at module scope

With both script blocks or a generic component, the body of `<script setup>` is generated inside a function, and
only the imports before its first statement stayed outside: an import after it was reported as TS1232 (TS1473 in
JavaScript). Vue accepts an import anywhere at the top level of the block.
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

4.0.0-alpha.6 is on npm with dist-tag alpha (6 commits, run).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet