Skip to content

Enable native ESM extension bundle - #9630

Closed
dibarbet wants to merge 2 commits into
mainfrom
dev/esm-extension-pilot
Closed

Enable native ESM extension bundle#9630
dibarbet wants to merge 2 commits into
mainfrom
dev/esm-extension-pilot

Conversation

@dibarbet

@dibarbet dibarbet commented Aug 4, 2026

Copy link
Copy Markdown
Member

Summary

  • Emit the packaged extension as dist/extension.mjs using esbuild's ESM format.
  • Preserve CommonJS dependency compatibility with createRequire(import.meta.url).
  • Update debugging and signing to include .mjs, and bundle before signing.

This replaces #9614 so the rebuilt branch runs the dev/* CI trigger on current main. The original PR remains open.

Follow-up dependency work

46 bundled modules currently need createRequire. The highest-priority dependencies that call require("vscode") are vscode-languageclient, microsoft.aspnetcore.razor.vscode, and @vscode/extension-telemetry; these will be evaluated in a later stack layer.

Validation

  • npm run package
  • npm run test:unit — 514 tests passed
  • npm run test:integration:untrusted — 1 test passed
  • C# integration harness — 21 suites passed; 73 tests passed, 3 skipped

Emit the packaged extension as an ES module while preserving CommonJS dependency compatibility through createRequire. Include the ESM artifact in debugging and signing.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 720632a5-5bd9-43bb-9349-6c1a02fe3347
Temporarily define module-relative __filename and __dirname in the ESM banner so bundled CommonJS source continues to activate until its usages are converted.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 31a04314-b84f-48a8-8614-6538bce8352a
Copilot AI review requested due to automatic review settings August 4, 2026 20:20
@dibarbet
dibarbet requested a review from a team as a code owner August 4, 2026 20:20

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

Enables packaging the VS Code C# extension as a native ESM bundle (dist/extension.mjs), updates the build/debug/signing pipeline accordingly, and preserves CommonJS dependency compatibility via createRequire(import.meta.url) injected by esbuild.

Changes:

  • Switch esbuild output from CommonJS to ESM and emit dist/extension.mjs with a compatibility banner.
  • Update extension entrypoint (package.json#main) to point at the ESM bundle.
  • Adjust packaging order to bundle before signing, and expand debug/signing to include .mjs outputs.
Show a summary per file
File Description
package.json Points main to dist/extension.mjs and reorders package to bundle before JS signing.
msbuild/signing/signJs/signJs.proj Adds .mjs to the set of files submitted for signing.
esbuild.js Changes output format to ESM, injects createRequire/CommonJS globals, and writes dist/extension.mjs.
.vscode/launch.json Expands debug outFiles globs to include both .js and .mjs.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 1

Comment thread msbuild/signing/signJs/signJs.proj
@dibarbet

dibarbet commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

Superseded by #9635, which consolidates the complete native ESM migration into one final-state commit and removes intermediate workaround history.

@dibarbet dibarbet closed this Aug 4, 2026
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.

3 participants