Skip to content

Strip content mapper known extensions as part of moduleSuffixes lookups - #65417

Open
Andrew Branch (andrewbranch) wants to merge 1 commit into
microsoft:mainfrom
andrewbranch:content-mapper-module-suffixes
Open

Andrew Branch (andrewbranch) wants to merge 1 commit into
microsoft:mainfrom
andrewbranch:content-mapper-module-suffixes

Conversation

@andrewbranch

@andrewbranch Andrew Branch (andrewbranch) commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Fixes #64548 and partly #65047 (comment)

Copilot AI balanced review requested due to automatic review settings November 9, 2026 23:33
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 9, 2026
@typescript-automation typescript-automation Bot added Author: Team For Milestone Bug PRs that fix a bug with a specific milestone labels Nov 9, 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.

🟢 Approval recommended

No active review issues were identified for the change to module-suffix handling of content-mapper extensions.

No open issues 🎉

What changed in this PR

Fixes #64548 by making the native compiler insert moduleSuffixes before registered content-mapper extensions, so card.box correctly probes card.web.box rather than card.box.web.

Changes:

  • Recognizes the longest registered extension when no built-in extension matches.
  • Adds regression coverage for compound extensions, fallback resolution, built-in extensions, and unchanged extensionless-import behavior.
  • Adds resolution, diagnostic, and content-mapper baselines.
File Description
tsc/​testdata/​tests/​cases/​compiler/​contentMapperModuleSuffixes.ts Adds module-suffix regression cases.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperModuleSuffixes.trace.json Records expected file probes and resolution results.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperModuleSuffixes.errors.txt Records the expected unresolved extensionless import.
tsc/​testdata/​baselines/​reference/​compiler/​contentMapperModuleSuffixes.contentmapper Records mapped platform variants and fallback content.
tsc/​internal/​module/​resolver.go Recognizes mapper extensions before inserting module suffixes.

Review effort: Balanced


ext := tspath.RootedFilePathFromPath(fileName.path).Extension()
if ext == "" && len(r.resolver.extraExtensions) > 0 {
ext = tspath.RootedFilePathFromPath(fileName.path).LongestExtension(r.resolver.extraExtensions, tspath.CaseSensitive)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Note that recognition of built-in file extensions is also case-sensitive in most places throughout the compiler.

@github-project-automation github-project-automation Bot moved this from Not started to Needs merge in PR Backlog Nov 10, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Milestone Bug PRs that fix a bug with a specific milestone

Projects

Status: Needs merge

Development

Successfully merging this pull request may close these issues.

Content mappers: moduleSuffixes probes card.foo.web instead of card.web.foo for a registered extension

3 participants