Enable native ESM extension bundle - #9614
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
JoeRobich
reviewed
Aug 3, 2026
| "omnisharptest:integration": "npm run packageDev && npx ts-node tasks/tests/omnisharptestIntegration.ts", | ||
| "omnisharptest:unit": "npm run compileDev && npx ts-node tasks/tests/omnisharptestUnit.ts", | ||
| "package": "npm run compile && npm run signJs && node esbuild.js --production", | ||
| "package": "npm run compile && node esbuild.js --production && npm run signJs", |
Member
There was a problem hiding this comment.
Had we been blowing away our signature or invalidating it?
JoeRobich
approved these changes
Aug 3, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates the packaged VS Code C# extension bundle from CommonJS to native ESM output (dist/extension.mjs) via esbuild, adjusting signing and debug configuration to support the new .mjs artifact.
Changes:
- Switch esbuild bundling output from CJS (
extension.js) to ESM (extension.mjs) and inject acreateRequire(import.meta.url)banner for CJS interop. - Update packaging order to bundle before JS signing, and update signing to include
.mjsoutputs. - Update VS Code debug
outFilespatterns to include both.jsand.mjs.
Show a summary per file
| File | Description |
|---|---|
| package.json | Points extension entrypoint at dist/extension.mjs and reorders package to bundle before signing. |
| msbuild/signing/signJs/signJs.proj | Adds .mjs to the set of files Authenticode-signed. |
| esbuild.js | Switches esbuild output format to ESM and adds a banner for createRequire interop. |
| .vscode/launch.json | Expands debugger outFiles patterns to match .mjs as well as .js. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 1
Comment on lines
+51
to
+54
| format: 'esm', | ||
| banner: { | ||
| js: `import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);`, | ||
| }, |
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
Comment on lines
21
to
+25
| <FilesToSign Include="$(OutDir)*.js"> | ||
| <Authenticode>MicrosoftSHA2</Authenticode> | ||
| </FilesToSign> | ||
| <FilesToSign Include="$(OutDir)*.mjs"> | ||
| <Authenticode>MicrosoftSHA2</Authenticode> |
Member
Author
|
Superseded by #9630 on |
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.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— 360 tests passednpm run test:integration:untrusted— 1 test passed