Skip to content

Port TypeScript PR #62320: Allow --module commonjs --moduleResolution bundler#2757

Merged
jakebailey merged 2 commits intomainfrom
copilot/port-commonjs-module-resolution
Mar 24, 2026
Merged

Port TypeScript PR #62320: Allow --module commonjs --moduleResolution bundler#2757
jakebailey merged 2 commits intomainfrom
copilot/port-commonjs-module-resolution

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 11, 2026

Ports microsoft/TypeScript#62320. --moduleResolution bundler is now permitted with --module commonjs, since bundler resolution coherently resolves package.json "exports" conditions using "require" when emitting CommonJS.

  • internal/compiler/program.go: Uncommented the bundler+module compatibility check (previously gated behind // !!! Reenable once we don't map old moduleResolution kinds to bundler) and added moduleKind != core.ModuleKindCommonJS to the allow list alongside ModuleKindPreserve and non-Node ESM kinds.
  • Baselines: 4 .diff files deleted (Go output now matches TS reference exactly); 4 error baselines updated to emit TS5095 for node18/node20/nodenext + bundler combinations that remain disallowed.

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

… bundler

Uncomments and updates the bundler+module compatibility check in
verifyCompilerOptions() to allow ModuleKindCommonJS with bundler
moduleResolution. Updates the diagnostic to use the new message that
includes 'commonjs' in the allowed values list.

Updates 4 test baselines and removes 4 .diff files that are no longer
needed since Go output now matches TypeScript reference.

Co-authored-by: jakebailey <5341706+jakebailey@users.noreply.github.com>
Copilot AI changed the title [WIP] Port support for --module commonjs and --moduleResolution bundler Port TypeScript PR #62320: Allow --module commonjs --moduleResolution bundler Feb 11, 2026
Copilot AI requested a review from jakebailey February 11, 2026 06:34
@jakebailey jakebailey marked this pull request as ready for review March 2, 2026 22:14
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Ports TypeScript PR #62320 to align tsgo compiler option validation with upstream: --moduleResolution bundler is now allowed when emitting CommonJS (--module commonjs), because bundler resolution can select "require"-based package.json "exports" conditions for CJS emit.

Changes:

  • Re-enabled and updated the bundler/module compatibility check to permit ModuleKindCommonJS alongside preserve and non-Node ESM module kinds.
  • Updated submodule conformance error baselines to reflect upstream diagnostics (TS5095 now emitted for remaining disallowed Node module kind + bundler combinations).
  • Removed several .diff baselines where the Go output now matches the TS reference exactly.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/compiler/program.go Updates option validation to allow moduleResolution=bundler with module=commonjs, matching upstream TS behavior.
testdata/baselines/reference/submodule/conformance/bundlerOptionsCompat.errors.txt Baseline updates to include TS5095 alongside existing TS5109 for disallowed combinations.
testdata/baselines/reference/submodule/conformance/bundlerDirectoryModule(module=nodenext,moduleresolution=bundler).errors.txt Baseline updates to include TS5095 for nodenext + bundler.
testdata/baselines/reference/submodule/conformance/bundlerDirectoryModule(module=node20,moduleresolution=bundler).errors.txt Baseline updates to include TS5095 for node20 + bundler.
testdata/baselines/reference/submodule/conformance/bundlerDirectoryModule(module=node18,moduleresolution=bundler).errors.txt Baseline updates to include TS5095 for node18 + bundler.
testdata/baselines/reference/submodule/conformance/*.diff Deletes .diff files that are now empty due to full baseline alignment.

@jakebailey jakebailey added this pull request to the merge queue Mar 2, 2026
@jakebailey jakebailey removed this pull request from the merge queue due to a manual request Mar 2, 2026
@jakebailey
Copy link
Copy Markdown
Member

Going to wait to merge this around the same time as the node10 deprecation error.

@jakebailey jakebailey added this pull request to the merge queue Mar 24, 2026
Merged via the queue into main with commit c17c14e Mar 24, 2026
24 checks passed
@jakebailey jakebailey deleted the copilot/port-commonjs-module-resolution branch March 24, 2026 23:07
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.

4 participants