Skip to content

fix(vscode): skip hot-swap when TypeScript exports are getter-only - #6374

Merged
johnsoncodehk merged 2 commits into
vuejs:masterfrom
ondrhn:fix/issue-6373-vscode-skip-hot-swap-when
Dec 3, 2026
Merged

johnsoncodehk merged 2 commits into
vuejs:masterfrom
ondrhn:fix/issue-6373-vscode-skip-hot-swap-when

Conversation

@ondrhn

@ondrhn ondrhn commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

When the extension host restarts with a .ts file as the active editor, vscode.typescript-language-features activates first on onLanguage:typescript and the Vue extension is loaded while that activation is still in flight. patchTypeScriptExtension() only returns early when the TypeScript extension isActive, which is still false at that point, so it takes the hot-swap path for an already loaded module. The whole Vue extension then fails to load with TypeError: Cannot set property activate of #<Object> which has only a getter, and the restart prompt never appears.

The hot-swap was added in #5260, back when the TypeScript extension was bundled with webpack and its exports were writable data properties. It is now bundled with esbuild, so module.exports comes from __toCommonJS and every export is an enumerable getter without a setter; Object.assign writes through [[Set]] and therefore always throws. The block moves into reloadModuleExports() in registerModuleTransform.ts, which inspects the property descriptors first and returns false when the exports cannot be assigned, leaving the existing "Please restart the extension host to activate Vue support." prompt to handle the race. Only enumerable own properties are inspected, the same ones Object.assign would write, so the non-enumerable __esModule marker that tsc emits for CommonJS is ignored and writable exports still get swapped in place as before.

fix #6373

ondrhn and others added 2 commits November 23, 2026 18:04
VS Code bundles the TypeScript extension with esbuild since 1.110, so its
exports are getter-only properties and `Object.assign` throws while that
extension is still loading. Bail out instead and ask for a host restart.
@johnsoncodehk
johnsoncodehk merged commit 5ef5305 into vuejs:master Dec 3, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extension fails to activate with "Cannot set property activate of #<Object> which has only a getter" when the TypeScript extension loads first

2 participants