Skip to content

fix(kit): improve TS extension stripping/substitutions - #35233

Merged
danielroe merged 2 commits into
mainfrom
fix/tsconfig-paths-mts
May 31, 2026
Merged

danielroe merged 2 commits into
mainfrom
fix/tsconfig-paths-mts

Conversation

@danielroe

Copy link
Copy Markdown
Member

🔗 Linked issue

nitrojs/nitro#4297

📚 Description

spotted this when testing nuxt v5 nightly - ../node_modules/nitro/h3 isn't valid when h3.mjs and h3.d.mts are the extensions

https://stackblitz.com/edit/node-4mtandbr

@github-actions github-actions Bot added 5.x 🐛 bug Something isn't working as expected labels May 31, 2026
@coderabbitai

coderabbitai Bot commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f22b2ef1-00cc-4f8c-914e-2a035238c7fb

📥 Commits

Reviewing files that changed from the base of the PR and between 15189e8 and 10caaa0.

📒 Files selected for processing (2)
  • eslint.config.mjs
  • tsconfig.json
✅ Files skipped from review due to trivial changes (1)
  • tsconfig.json

Walkthrough

This PR improves TypeScript path substitution resolution by replacing a simple extension-stripping regex with a filesystem-aware helper. The new getPathSubstitution function detects specific extension patterns and checks disk for corresponding TypeScript declaration files (.d.ts, .d.mts, .d.cts), rewrites paths accordingly, and falls back to relative paths when no matches exist. Two existing callsites in alias and config path resolution are updated to use this helper. A new test with multiple fixture files validates that _generateTypes correctly rewrites compilerOptions.paths entries for Nitro aliases, including scenarios with injected -hooked targets and declaration file availability.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarises the main change: improving TypeScript extension stripping and path substitutions to fix import resolution issues.
Description check ✅ Passed The description is related to the changeset, identifying a specific issue with TypeScript extension handling in Nuxt v5 and referencing a related upstream issue.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/tsconfig-paths-mts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@danielroe
danielroe force-pushed the fix/tsconfig-paths-mts branch from a360ce9 to 10caaa0 Compare May 31, 2026 19:58
@pkg-pr-new

pkg-pr-new Bot commented May 31, 2026

Copy link
Copy Markdown

Open in StackBlitz

@nuxt/kit

npm i https://pkg.pr.new/@nuxt/kit@35233

@nuxt/nitro-server

npm i https://pkg.pr.new/@nuxt/nitro-server@35233

nuxt

npm i https://pkg.pr.new/nuxt@35233

@nuxt/rspack-builder

npm i https://pkg.pr.new/@nuxt/rspack-builder@35233

@nuxt/schema

npm i https://pkg.pr.new/@nuxt/schema@35233

@nuxt/vite-builder

npm i https://pkg.pr.new/@nuxt/vite-builder@35233

@nuxt/webpack-builder

npm i https://pkg.pr.new/@nuxt/webpack-builder@35233

commit: 10caaa0

@codspeed

codspeed Bot commented May 31, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 14.23%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 1 improved benchmark
✅ 19 untouched benchmarks
⏩ 3 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ loadNuxt in the basic test fixture 445.3 ms 389.8 ms +14.23%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing fix/tsconfig-paths-mts (10caaa0) with main (2bab300)2

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (a2138f1) during the generation of this report, so 2bab300 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@danielroe
danielroe merged commit ad3c88e into main May 31, 2026
46 of 48 checks passed
@danielroe
danielroe deleted the fix/tsconfig-paths-mts branch May 31, 2026 20:28
@github-actions github-actions Bot mentioned this pull request May 31, 2026
2 of 5 tasks
danielroe added a commit that referenced this pull request Jun 2, 2026
This was referenced Jun 1, 2026
danielroe added a commit that referenced this pull request Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5.x 🐛 bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant