Enable native ESM extension bundle - #9630
Closed
dibarbet wants to merge 2 commits into
Closed
Conversation
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
Contributor
There was a problem hiding this comment.
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.mjswith 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
.mjsoutputs.
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
JoeRobich
approved these changes
Aug 4, 2026
Member
Author
|
Superseded by #9635, which consolidates the complete native ESM migration into one final-state commit and removes intermediate workaround history. |
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.
Summary
dist/extension.mjsusing esbuild's ESM format.createRequire(import.meta.url)..mjs, and bundle before signing.This replaces #9614 so the rebuilt branch runs the
dev/*CI trigger on currentmain. The original PR remains open.Follow-up dependency work
46 bundled modules currently need
createRequire. The highest-priority dependencies that callrequire("vscode")arevscode-languageclient,microsoft.aspnetcore.razor.vscode, and@vscode/extension-telemetry; these will be evaluated in a later stack layer.Validation
npm run packagenpm run test:unit— 514 tests passednpm run test:integration:untrusted— 1 test passed