ReviewOS

stacks/stx

vscode: the TypeScript server plugin is registered by file path, so tsserver never loads it

#2026
Closed chris opened this 9 days ago ·
9 days ago

The stx TypeScript server plugin never loads. contributes.typescriptServerPlugins named it by file path, ./dist/typescript-stx-plugin.js, and tsserver only loads plugins by package name. VS Code 1.128.1 (TypeScript 6.0.3), running the extension against a scratch project with typescript.tsserver.log: verbose, logs:

Loading global plugin ./dist/typescript-stx-plugin.js
Enabling plugin ./dist/typescript-stx-plugin.js from candidate paths: <extension>,...
Skipped loading plugin ./dist/typescript-stx-plugin.js because only package name is allowed plugin name

A second fault was hidden behind it: the bundle came from export default init, so module.exports was { default: init }. tsserver calls module.exports directly and would have skipped it as "did not expose a proper factory function".

Fix:

  • contribute the plugin as the package @stacksjs/stx-typescript-plugin, which tsserver resolves from <extension>/node_modules (the probe location VS Code passes)
  • the build writes that package (a forwarder to dist/typescript-stx-plugin.js) and bundles the plugin through an entry that sets module.exports to the factory
  • vsce package --no-dependencies leaves out everything under node_modules, so scripts/package.ts adds the package to the VSIX after vsce writes it, and release publishes that VSIX

With the fix, the same VS Code logs Loading @stacksjs/stx-typescript-plugin from <extension> ... [stx-plugin] TypeScript stx plugin initialized ... Plugin validation succeeded, both from --extensionDevelopmentPath and from the packaged VSIX installed into a clean extensions dir.

Sign in to comment on this issue.