Skip to content

Add --disableDynamicImportExtensionRewriting - #65289

Merged
Andrew Branch (andrewbranch) merged 3 commits into
microsoft:mainfrom
andrewbranch:disableDynamicImportExtensionRewriting
Nov 3, 2026
Merged

Andrew Branch (andrewbranch) merged 3 commits into
microsoft:mainfrom
andrewbranch:disableDynamicImportExtensionRewriting

Conversation

@andrewbranch

Copy link
Copy Markdown
Member

--disableDynamicImportExtensionRewriting disables emission of the emit helper that rewrites file extensions in non-literal 'import()' and 'require()' calls when --rewriteRelativeImportExtensions is enabled.

Prerequisite for #65047

Copilot AI balanced review requested due to automatic review settings November 3, 2026 20:08
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 3, 2026
@typescript-automation typescript-automation Bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 3, 2026

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.

🟡 Changes recommended

Disabling dynamic-import extension rewriting still triggers erroneous helper diagnostics with importHelpers, potentially blocking output, and changing the option does not invalidate cached semantic diagnostics.

1 open issue
5 files not reviewed
  • tsc/internal/core/options_generated.go: Generated file
  • tsc/internal/diagnostics/diagnostics_generated.go: Generated file
  • tsc/internal/testrunner/options_generated.go: Generated file
  • tsc/internal/tsoptions/declarations_generated.go: Generated file
  • tsc/internal/tsoptions/options_generated.go: Generated file
What changed in this PR

Adds --disableDynamicImportExtensionRewriting to the native TypeScript compiler, allowing runtime extension rewriting to be disabled while retaining string-literal rewriting. This supports the content-mapper filtering planned in #65047.

Changes:

  • Registers the option across compiler configuration, API types, schemas, and command-line help.
  • Updates CommonJS and ES module transforms to respect the option.
  • Adds compiler test variants and emit baselines for both option values.
File Description
tsc/​testdata/​tests/​cases/​compiler/​rewriteRelativeImportExtensionsDynamicImportCjs.ts Tests both option values with NodeNext CommonJS.
tsc/​testdata/​tests/​cases/​compiler/​disableDynamicImportExtensionRewriting.ts Adds import and require coverage across module modes.
tsc/​testdata/​baselines/​reference/​tsc/​commandLine/​help-all.js Records the new option’s help text.
tsc/​testdata/​baselines/​reference/​compiler/​rewriteRelativeImportExtensionsDynamicImportCjs(disabledynamicimportextensionrewriting=true).js Records NodeNext output without runtime rewriting.
tsc/​testdata/​baselines/​reference/​compiler/​rewriteRelativeImportExtensionsDynamicImportCjs(disabledynamicimportextensionrewriting=false).js Records NodeNext output with runtime rewriting.
tsc/​testdata/​baselines/​reference/​compiler/​disableDynamicImportExtensionRewriting(disabledynamicimportextensionrewriting=true,module=preserve).js Records preserve-mode output with rewriting disabled.
tsc/​testdata/​baselines/​reference/​compiler/​disableDynamicImportExtensionRewriting(disabledynamicimportextensionrewriting=true,module=esnext).js Records ESNext output with rewriting disabled.
tsc/​testdata/​baselines/​reference/​compiler/​disableDynamicImportExtensionRewriting(disabledynamicimportextensionrewriting=true,module=commonjs).js Records CommonJS output with rewriting disabled.
tsc/​testdata/​baselines/​reference/​compiler/​disableDynamicImportExtensionRewriting(disabledynamicimportextensionrewriting=false,module=preserve).js Records preserve-mode output with rewriting enabled.
tsc/​testdata/​baselines/​reference/​compiler/​disableDynamicImportExtensionRewriting(disabledynamicimportextensionrewriting=false,module=esnext).js Records ESNext output with rewriting enabled.
tsc/​testdata/​baselines/​reference/​compiler/​disableDynamicImportExtensionRewriting(disabledynamicimportextensionrewriting=false,module=commonjs).js Records CommonJS output with rewriting enabled.
tsc/​internal/​tsoptions/​options_generated.go Adds parsing, merging, serialization, and emit/build tracking.
tsc/​internal/​tsoptions/​declarations_generated.go Registers the command-line option.
tsc/​internal/​transformers/​moduletransforms/​esmodule.go Gates runtime rewriting in ES module output.
tsc/​internal/​transformers/​moduletransforms/​commonjsmodule.go Gates runtime rewriting in CommonJS output.
tsc/​internal/​testrunner/​options_generated.go Enables test variations for the option.
tsc/​internal/​diagnostics/​diagnostics_generated.go Adds the generated help message.
tsc/​internal/​diagnostics/​diagnosticMessages.json Defines the option’s help message.
tsc/​internal/​diagnostics/​diagnosticMessages.generated.json Adds the generated message catalog entry.
tsc/​internal/​core/​options_generated.go Adds option storage, cloning, and equality checks.
tools/​scripts/​tsc/​options.ts Defines option metadata and ordering.
packages/​typescript/​src/​api/​proto.generated.ts Exposes the option in raw API types.
packages/​typescript/​src/​api/​compilerOptions.generated.ts Exposes the option in compiler API types.
packages/​typescript/​schemas/​tsconfig.schema.json Adds TypeScript configuration schema support.
packages/​typescript/​schemas/​jsconfig.schema.json Adds JavaScript configuration schema support.

Review effort: Balanced

Comment thread tools/scripts/tsc/options.ts Resolved

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.

🟢 Approval recommended

No active review issues are reported for the new option to disable dynamic-import extension rewriting.

No open issues 🎉

1 resolved since last review
5 files not reviewed
  • tsc/internal/core/options_generated.go: Generated file
  • tsc/internal/diagnostics/diagnostics_generated.go: Generated file
  • tsc/internal/testrunner/options_generated.go: Generated file
  • tsc/internal/tsoptions/declarations_generated.go: Generated file
  • tsc/internal/tsoptions/options_generated.go: Generated file

Review effort: Balanced

@RyanCavanaugh

Copy link
Copy Markdown
Member

We're using isStringLiteralLike ("foo" and NoSubstitutionLiteral) in checker but isStringLiteral in the emitter ("foo" only) - intentional or oversight?

@andrewbranch

Copy link
Copy Markdown
Member Author

It was a previous oversight. Fixed in the latest commit.

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.

🟢 Approval recommended

No active review issues are recorded for the change adding an option to disable runtime dynamic-import extension rewriting.

No open issues 🎉

5 files not reviewed
  • tsc/internal/core/options_generated.go: Generated file
  • tsc/internal/diagnostics/diagnostics_generated.go: Generated file
  • tsc/internal/testrunner/options_generated.go: Generated file
  • tsc/internal/tsoptions/declarations_generated.go: Generated file
  • tsc/internal/tsoptions/options_generated.go: Generated file

Review effort: Balanced

@andrewbranch
Andrew Branch (andrewbranch) added this pull request to the merge queue Nov 3, 2026
Merged via the queue into microsoft:main with commit b5f1eff Nov 3, 2026
34 checks passed
@andrewbranch
Andrew Branch (andrewbranch) deleted the disableDynamicImportExtensionRewriting branch November 3, 2026 22:41
@github-project-automation github-project-automation Bot moved this from Needs merge to Done in PR Backlog Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants