Skip to content

Fix broken .vsix packaging: ship native deps + platform-specific builds - #4

Merged
KirtiJha merged 1 commit into
mainfrom
claude/vsix-packaging-AAlOm
Jun 4, 2026
Merged

KirtiJha merged 1 commit into
mainfrom
claude/vsix-packaging-AAlOm

Conversation

@KirtiJha

@KirtiJha KirtiJha commented Jun 4, 2026

Copy link
Copy Markdown
Owner

The bug

The extension is esbuild-bundled, with native modules (@lancedb/lancedb, apache-arrow) marked external because they can't be inlined into the JS bundle. But .vscodeignore blanket-excluded node_modules, so a packaged .vsix shipped zero dependency files β€” the vector-store native binary was simply missing, and the extension would fail on install. It only ever worked when run from source (where node_modules is on disk).

Proven before the fix with vsce ls:

total files: 18
node_modules files: 0   ← @lancedb/lancedb, apache-arrow, SDKs all missing

This predates the embedding work β€” it affects the core vector store today.

The fix

1. Reclassify dependencies by the bundling rule. A package belongs in dependencies (and must ship) iff it's in the esbuild --external list; everything esbuild bundles into dist/ moves to devDependencies. Verified against the actual built bundle β€” externals appear as runtime require()s, bundled deps don't:

@lancedb/lancedb: 1   @anthropic-ai/sdk: 1   @google/generative-ai: 1   (present β†’ ship)
diff/minimatch/openai/sql.js/ulid/zod/react/react-dom: 0   (bundled β†’ devDeps)

2. .vscodeignore stops blanket-ignoring node_modules (vsce already includes only dependencies), trims dependency cruft (*.ts/*.map/*.md, test/docs dirs), and drops dev-only files (.vscode, scripts, .github).

3. Platform-specific packaging. Each native binary is ~74 MB, so one universal .vsix would be ~370 MB. Added scripts/package-target.mjs (npm run package:target) and a Release workflow that builds one .vsix per target (linux x64/arm64, darwin x64/arm64, win32 x64), cross-fetching the correct native package on each runner.

4. CI guard. The build now fails if the @lancedb native binary ever falls out of the package again.

5. Cleanup. Removed a stale --external:vectordb flag; added @vscode/vsce as a devDependency; documented the packaging model in CONTRIBUTING.md.

Verified end-to-end (locally)

  • vsce ls after the fix: ships @lancedb/lancedb + platform binary + apache-arrow + SDK closure; excludes react/diff/openai.
  • Actually built code-historian-linux-x64-1.0.0.vsix (28 MB) and confirmed lancedb.linux-x64-gnu.node and dist/extension.js are inside it.
  • npm ci lockfile in sync, with all 5 platform packages present for cross-builds.
  • βœ… Typecheck, lint (0 errors), 46 tests, full build.

Note

This is independent of PR #3 (neural embeddings) and fixes the more urgent, already-merged @lancedb/lancedb case. Because the fix is general (ship the dependencies closure), when PR #3 merges its @xenova/transformers/onnxruntime-node optional deps are handled automatically β€” though onnxruntime ships all-platform binaries in one package, so a follow-up .vscodeignore trim per target would further shrink those builds.

https://claude.ai/code/session_014bNJaULcYHnDkqUP6HcemQ


Generated by Claude Code

…uilds

The extension is esbuild-bundled with native modules (@lancedb/lancedb,
apache-arrow) marked `external` because they can't be inlined. But
.vscodeignore blanket-excluded node_modules, so a packaged .vsix contained
ZERO dependency files β€” the vector-store binary was missing and the extension
broke on install. It only ever worked when run from source (node_modules on
disk). Proven via `vsce ls`: 18 files, 0 from node_modules.

Fix:
- Reclassify dependencies by the bundling rule: a package belongs in
  `dependencies` iff it's in the esbuild `--external` list (must ship);
  everything esbuild bundles moves to `devDependencies`. Verified against the
  built bundle (externals appear as runtime require()s, bundled deps don't).
  Net: dependencies = @lancedb/lancedb, apache-arrow, @anthropic-ai/sdk,
  @google/generative-ai; diff/minimatch/openai/sql.js/ulid/zod/react/react-dom
  -> devDependencies.
- .vscodeignore: stop blanket-ignoring node_modules (vsce already ships only
  `dependencies`); trim dependency cruft (*.ts/*.map/*.md, test/docs dirs);
  drop dev-only files (.vscode, scripts, .github). Verified: the native
  lancedb binary is now inside the produced .vsix.
- Platform-specific packaging: each native binary is ~74 MB, so a single
  all-platforms .vsix would be ~370 MB. Added scripts/package-target.mjs
  (`npm run package:target`) and a Release workflow that builds one .vsix per
  OS/arch (linux x64/arm64, darwin x64/arm64, win32 x64), cross-fetching the
  right native package on the runner.
- CI guard: fail the build if the @lancedb native binary ever falls out of the
  package again.
- Remove stale `--external:vectordb` (package no longer used).
- Add @vscode/vsce as a devDependency; docs in CONTRIBUTING + CHANGELOG.

Verified locally: produced code-historian-linux-x64-1.0.0.vsix (28 MB)
containing the native binary and dist/. Typecheck, lint (0 errors), 46 tests,
and build all pass; `npm ci` lockfile in sync with all 5 platform packages.
@KirtiJha
KirtiJha merged commit 9329ee3 into main Jun 4, 2026
2 checks passed
@KirtiJha
KirtiJha deleted the claude/vsix-packaging-AAlOm branch June 4, 2026 12:33
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.

2 participants