Skip to content

feat: restore asar for node_modules - #324084

Merged
Robo (deepak1556) merged 14 commits into
mainfrom
robo/enable_asar_support
Jul 7, 2026
Merged

Robo (deepak1556) merged 14 commits into
mainfrom
robo/enable_asar_support

Conversation

@deepak1556

@deepak1556 Robo (deepak1556) commented Jul 2, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #228064
Fixes #319428
Fixes #269500

@deepak1556 Robo (deepak1556) self-assigned this Jul 2, 2026
Copilot AI review requested due to automatic review settings July 2, 2026 17:20
@deepak1556 Robo (deepak1556) changed the title Robo/enable asar support feat: restore asar for node_modules Jul 2, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores packaged-app ASAR support in the ESM world by re-enabling module and asset resolution from node_modules.asar (JS) and node_modules.asar.unpacked (native/WASM), and updates build/packaging to unpack the right payloads and trim unnecessary binaries (notably @microsoft/mxc-sdk).

Changes:

  • Reintroduce ASAR-aware module resolution for both CommonJS (bootstrap-node) and ESM (bootstrap-esm), and update amdX to resolve AMD-loaded node modules from ASAR in Electron contexts.
  • Standardize runtime paths to native binaries/WASM to prefer node_modules.asar.unpacked in packaged builds (Terminal sandbox, Copilot CLI/agent host, Tree-sitter/TextMate assets).
  • Optimize packaging by excluding non-target @microsoft/mxc-sdk architectures and updating universal app merge logic and module ignore rules.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/vs/workbench/services/treeSitter/browser/treeSitterLibraryService.ts Switch Tree-sitter WASM location selection to use unpacked node_modules for built installs.
src/vs/workbench/services/textMate/browser/textMateTokenizationFeatureImpl.ts Update oniguruma WASM fetch path selection for built installs.
src/vs/workbench/services/textMate/browser/backgroundTokenization/threadedBackgroundTokenizerFactory.ts Adjust worker-side oniguruma asset path selection for packaged builds.
src/vs/workbench/services/languageDetection/browser/languageDetectionWorkerServiceImpl.ts Enable ASAR-based module/model resource loading in built Electron contexts.
src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalSandboxService.ts Provide nativeModulesDir so terminal sandbox can find unpacked native binaries in packaged builds.
src/vs/sessions/electron-browser/sessions.ts Populate _VSCODE_PRODUCT_JSON global for ASAR path decisions (Agents window).
src/vs/platform/webWorker/browser/webWorkerServiceImpl.ts Propagate _VSCODE_PRODUCT_JSON into ESM worker bootstrap.
src/vs/platform/sandbox/common/terminalSandboxMxcRuntime.ts Thread nativeModulesDir into MXC runtime executable resolution.
src/vs/platform/sandbox/common/terminalSandboxEngine.ts Resolve ripgrep/MXC binaries from nativeModulesDir (supports unpacked layout).
src/vs/platform/agentHost/node/copilot/copilotAgent.ts Resolve Copilot CLI and MXC binaries from unpacked node_modules in built installs.
src/vs/platform/agentHost/node/copilot/agentHostSandboxEngine.ts Provide nativeModulesDir in agent host sandbox runtime info.
src/vs/platform/agentHost/node/commandAutoApprover.ts Resolve Tree-sitter WASM assets from unpacked node_modules in built installs.
src/vs/code/electron-browser/workbench/workbench.ts Populate _VSCODE_PRODUCT_JSON global for ASAR path decisions (main workbench).
src/vs/base/common/platform.ts Add hasElectronUserAgent helper for detecting Electron-backed workers.
src/vs/amdX.ts Restore ASAR selection for AMD node module loading and improve ASAR-aware fs usage.
src/bootstrap-node.ts Reintroduce CommonJS lookup-path injection for node_modules.asar in packaged Electron-as-node processes.
src/bootstrap-esm.ts Install an ESM resolution hook to resolve bare specifiers from node_modules.asar in packaged Electron contexts.
extensions/copilot/src/extension/chatSessions/copilotcli/node/test/nodePtyShim.spec.ts Add tests validating node-pty resolution from node_modules.asar.unpacked.
extensions/copilot/src/extension/chatSessions/copilotcli/node/test/appNodeModules.spec.ts New tests for shared app-root node_modules resolution helper.
extensions/copilot/src/extension/chatSessions/copilotcli/node/ripgrepShim.ts Use shared resolver to locate ripgrep in unpacked node_modules for packaged builds.
extensions/copilot/src/extension/chatSessions/copilotcli/node/nodePtyShim.ts Probe both node_modules and node_modules.asar.unpacked for node-pty binaries.
extensions/copilot/src/extension/chatSessions/copilotcli/node/copilotCli.ts Resolve MXC binaries from unpacked node_modules when applicable.
extensions/copilot/src/extension/chatSessions/copilotcli/node/appNodeModules.ts New helper for resolving paths across node_modules and node_modules.asar.unpacked.
extensions/copilot/src/extension/chatSessions/claude/node/claudeCodeAgent.ts Resolve built-in ripgrep path via shared resolver for packaged builds.
build/linux/dependencies-generator.ts Scan native modules from node_modules.asar.unpacked for dependency generation.
build/lib/test/copilot.test.ts Add tests ensuring MXC binaries are filtered to the target architecture.
build/lib/copilot.ts Add MXC architecture exclude filter helper for packaging.
build/gulpfile.vscode.ts Apply MXC exclude filter and adjust ASAR unpack/duplication patterns and Copilot ripgrep shim input path.
build/gulpfile.reh.ts Apply MXC exclude filter to REH packaging pipeline.
build/darwin/create-universal-app.ts Cross-copy MXC binaries and extend ASAR merge allowlist for arch-unique files.
build/.moduleignore Ignore signing _manifest artifacts from module payloads.

Comment thread src/vs/amdX.ts Resolved
@deepak1556
Robo (deepak1556) force-pushed the robo/enable_asar_support branch from b3173e9 to e617c31 Compare July 3, 2026 13:13
@deepak1556 Robo (deepak1556) added this to the 1.129.0 milestone Jul 3, 2026
@github-actions

github-actions Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Base: 62c7ad83 Current: 8e0bb767

No screenshot changes.

Robo (deepak1556) and others added 14 commits July 7, 2026 13:24
- bootstrap-esm: resolve bare specifiers via package self-reference so
  Node applies the package's real `exports`/`main` and ESM conditions.
  The previous CommonJS `require.resolve()` picked the `require`
  condition and loaded the CJS entry of dual CJS/ESM packages (e.g.
  playwright-core), which did not expose their named ESM exports.

- amdX: in `_nodeJSLoadScript`, read module files with the ASAR-aware
  `require('fs')` instead of `import('fs')`, which the resolution hook
  maps to the ASAR-unaware `original-fs` and therefore cannot read
  files inside the archive (e.g. @vscode/iconv-lite-umd).

- agentHost commandAutoApprover: load the tree-sitter `.wasm` files
  from node_modules.asar.unpacked in built apps (node_modules in dev).

- agentHost copilotAgent: resolve the @github/copilot-<platform> CLI
  and the @microsoft/mxc-sdk sandbox binaries from
  node_modules.asar.unpacked in built apps, and unpack
  @microsoft/mxc-sdk/bin so those executables can be spawned.

Co-authored-by: Copilot <[email protected]>
Two follow-up fixes for ASAR support:

- bootstrap-esm: resolve packages inside node_modules.asar with relative
  specifiers (require.resolve("./<pkg>/package.json") and "./<spec>")
  instead of bare specifiers. The archive directory is named
  node_modules.asar, so a bare-specifier resolution walks for a
  node_modules directory that does not exist and fails. This broke every
  native module imported from main.js in the packaged app
  (@vscode/spdlog, @vscode/sqlite3, native-keymap, @vscode/deviceid,
  @vscode/policy-watcher), preventing startup.

- create-universal-app: pass `singleArchFiles` so the universal merger
  allows files that are unique to a single arch inside the merged
  node_modules.asar (the @github/copilot-<arch> platform package and the
  arch-specific copilot/ripgrep binaries). These paths are ASAR-internal
  (top level, no node_modules prefix); without the allowlist the merge
  aborts with "Detected unique file ... not covered by allowList rule".

Co-authored-by: Copilot <[email protected]>
@deepak1556
Robo (deepak1556) force-pushed the robo/enable_asar_support branch from e617c31 to 941f580 Compare July 7, 2026 04:46
@deepak1556
Robo (deepak1556) marked this pull request as ready for review July 7, 2026 04:48
@deepak1556
Robo (deepak1556) enabled auto-merge (squash) July 7, 2026 04:48
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Anthony Kim (@anthonykim1)

Matched files:

  • src/vs/workbench/contrib/terminalContrib/chatAgentTools/common/terminalSandboxService.ts

TylerLeonhardt

Matched files:

  • src/vs/workbench/services/languageDetection/browser/languageDetectionWorkerServiceImpl.ts

@deepak1556
Robo (deepak1556) marked this pull request as draft July 7, 2026 04:51
auto-merge was automatically disabled July 7, 2026 04:51

Pull request was converted to draft

@deepak1556
Robo (deepak1556) force-pushed the robo/enable_asar_support branch 2 times, most recently from 17bc92c to b558827 Compare July 7, 2026 07:00
@deepak1556
Robo (deepak1556) marked this pull request as ready for review July 7, 2026 07:13
@deepak1556
Robo (deepak1556) enabled auto-merge (squash) July 7, 2026 07:13
@deepak1556
Robo (deepak1556) merged commit c9dda3b into main Jul 7, 2026
29 checks passed
@deepak1556
Robo (deepak1556) deleted the robo/enable_asar_support branch July 7, 2026 07:39
Robo (deepak1556) added a commit that referenced this pull request Jul 8, 2026
* Revert "fix: builtin resolution of electron modules via asar hook (#324861)"

This reverts commit 5928613.

* Revert "fix: restrict asar esm hook resolution to app resources (#324851)"

This reverts commit 89bc382.

* Revert "feat: restore asar for node_modules (#324084)"

This reverts commit c9dda3b.
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Aug 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slow update times on macOS Unnecessary platform binaries are shipped inside @microsoft/mxc-sdk ESM: restore support for ASAR

4 participants