Repository navigation
Bundle the extension, so the .vsix carries its dependencies as resolved - #45
Merged
Merged
Conversation
Kinflou
force-pushed
the
deps/bundle-esbuild
branch
from
November 16, 2026 00:09
1d34a3c to
00e549b
Compare
Kinflou
marked this pull request as ready for review
November 16, 2026 00:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #44, which is merged; this is rebased on it, so the diff is only the bundling commit.
The bug
The
.vsixhas never carried the dependencies it was resolved to.vsce package --yarnbuilds its file list fromyarn list --prod, which hoists for the production tree only, and then copies the top-levelnode_modules/<name>from the real install, where the development dependencies decide what is hoisted. So each package gets whichever copy is most common among all dependencies, not the one its dependent asked for. Measured on the.vsixofmain(after #44, CI run 43778646724,test-vsix):vscode-languageclientasks forminimatch3.1.5 (eslint 8's copy; 3.1.2 in v0.1.0-dev.59)minimatch^5.1.0, which is locked at 5.1.9 and was never packaged: novscode-languageclient/node_modulesin the.vsixbrace-expansion2.1.8minimatch3 asks for is ^1; what 5.1.9 asks for is ^2It happened to work (
vscode-languageclientonly usesnew minimatch.Minimatch(...)), but any change to the development tree could change what ships; it was about to (see the eslint pull request, whereminimatch10 would have been packaged, a version that needs Node 18 or later).The fix
scripts/bundle.mjsbundlessrc/extension.tswith esbuild into one file,dist/extension.js:cjs,platform: node,vscodeexternal,target: node16(VS Code ^1.75's extension host is Node 16.14). Everyrequireis resolved by Node's rules from the file that makes it, sovscode-languageclientgets its ownminimatch5.1.9.mainis./dist/extension.js.vscode:prepublishisyarn compile && yarn bundle:production:tscstays as the type check (a type error still fails packaging), then the production bundle, minified, with no source map.yarn bundleis the development build (unminified, with a map).tscalso stays what buildsout/foryarn test(node --test out/*.test.js) and forscripts/flatpak-e2e.cjs, which loadsout/resolve.js; the Flatpak workflow's compile job runsyarn compileand uploadsout/, so neither changed. The Flatpak workflow runs on this pull request and passes.vsce package --yarnisvsce package --no-dependencieseverywhere (ci.yml, release.yml, scripts/package.sh): vsce no longer lists or copies dependencies, and--yarnonly selected how it listed them..vscodeignoreaddsnode_modules/**andout/**as well, so nothing but the bundle and the non-JavaScript assets is packaged.esbuildis a devDependency, pinned exactly (0.28.2).vscode-languageclientstays independencies: it is a runtime dependency, now bundled..gitignore, the F5 launch config and task (bundle,dist/), README and QUICKSTART follow.idpSchema.generated.json, which was a separate file underout/, is part of the bundle (resolveJsonModule).What the package holds, before and after
Release (
universal) package, from CI artifacts:main(#44)dist/extension.js(384.2 KB)extension/node_modules/**vscode-languageclient,semver,vscode-languageserver-protocol,vscode-jsonrpc,vscode-languageserver-types,balanced-match,minimatch,brace-expansionextension/out/**coreRev.js,extension.js,idpSchema.js,idpSchema.generated.json,resolve.jsextension/dist/extension.jsEverything else is the same 20 files (manifest,
package.json, readme and changelog, LICENSE, QUICKSTART, TESTING, language configurations,renovate.json, example, font, icons, the three grammars and their notices). The five platform packages are the same plus the language server binary (23 files, 3.5 to 4 MB). The new check on thePackagejobs prints... 23 files, no node_modules, main is ./dist/extension.jsfor each.Which
minimatchis in the bundleThe production build prints every package that went in (
scripts/bundle.mjs --report, run byvscode:prepublish, in the Package Test log):It is read from esbuild's metafile (the files it actually bundled), not from a grep of the minified output, where no version string survives.
minimatch5.1.9 andbrace-expansion2.1.8 are both outside every open advisory range, so the shipped alerts are cleared by what is packaged, not only by the lock.Does it activate
The release.yml smoke test runs the language server binary, not the extension, and nothing in the repo starts the extension in an editor (no
@vscode/test-electron), so I added what CI can check:scripts/check-package.sh(Package Test and every release.ymlPackagejob): the.vsixhasdist/extension.js,mainpoints to it, and it has nonode_modulesand noout/. A package that regresses to the old shape fails.scripts/check-bundle.cjs, in Package Test, on Node 16.20.2 (the extension host of the oldest allowed editor): unzips the package, loadsextension/dist/extension.jsthe way the editor does withvscodestubbed, and requiresactivate()anddeactivate()to be exported. It passed:node v16.20.2: loading ... loaded: exports activate() and deactivate(). It catches a module the bundle needs but lacks and syntax Node 16 cannot parse. It does not callactivate(), which needs an editor; that I could not test.CI
All checks pass on this pull request: Lint and Compile, Package Test, Config schema, Language server pin, Flatpak (VSCodium sandbox), and Release Extension with all six
Packagejobs.