Skip to content

Enable native ESM extension bundle - #9614

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

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

Conversation

@dibarbet

@dibarbet dibarbet commented Aug 3, 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.

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 — 360 tests passed
  • npm run test:integration:untrusted — 1 test passed

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
Copilot AI review requested due to automatic review settings August 3, 2026 20:59
@dibarbet
dibarbet requested a review from a team as a code owner August 3, 2026 20:59
Comment thread package.json
"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",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Had we been blowing away our signature or invalidating it?

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

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 a createRequire(import.meta.url) banner for CJS interop.
  • Update packaging order to bundle before JS signing, and update signing to include .mjs outputs.
  • Update VS Code debug outFiles patterns to include both .js and .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 thread esbuild.js
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
Copilot AI review requested due to automatic review settings August 4, 2026 00:35

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.

Copilot's findings

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

Comment on lines 21 to +25
<FilesToSign Include="$(OutDir)*.js">
<Authenticode>MicrosoftSHA2</Authenticode>
</FilesToSign>
<FilesToSign Include="$(OutDir)*.mjs">
<Authenticode>MicrosoftSHA2</Authenticode>
@dibarbet

dibarbet commented Aug 4, 2026

Copy link
Copy Markdown
Member Author

Superseded by #9630 on dev/esm-extension-pilot so the updated branch trigger runs CI. The replacement PR is part of stack #9634.

@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