Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.5k
fix: add.mts file extension in resolver default#33845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
|
coderabbitaibot commentedDec 10, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
WalkthroughThis PR expands and reorders the sets of file extensions used across multiple resolver and build configurations. Changes add support for .js, .jsx, .tsx, .cjs, .mts and .cts (and reorder existing entries) in resolver defaults and tests (packages/schema, kit, nuxt, webpack, vite, tests). It also fixes the webpack external-config check to use '.coffee' with a leading dot. No control flow, error handling or exported/public API signatures were changed. Possibly related PRs
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Tip ✨ Issue Enrichment is now available for GitHub issues!CodeRabbit can now help you manage issues more effectively:
Disable automatic issue enrichmentTo disable automatic issue enrichment, add the following to your issue_enrichment:auto_enrich:enabled:false Thanks for usingCodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
pkg-pr-newbot commentedDec 10, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@nuxt/kit@nuxt/nitro-servernuxt@nuxt/rspack-builder@nuxt/schema@nuxt/vite-builder@nuxt/webpack-buildercommit: |
codspeed-hqbot commentedDec 10, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
CodSpeed Performance ReportMerging#33845 willnot alter performanceComparing Summary
Footnotes |
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Alexander Lichter <github@lichter.io>
packages/schema/src/config/common.ts Outdated
| extensions:{ | ||
| $resolve:(val):string[]=>{ | ||
| constextensions=['.js','.jsx','.mjs','.ts','.tsx','.vue'] | ||
| constextensions=['.js','.jsx','.mjs','.ts','.tsx','.mts','.vue'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Maybe should we have an unique const (named liekDEFAULT_JS_FILE_EXT) for all js file extensions to reduce risks ?
And this could be done for other kind of file extensions too by having one for jsx for example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/nuxt/src/core/utils/types.ts (1)
6-20:Extend suffix-stripping regex to cover TSX/JSX files
resolveTypePathincludes.tsxand.jsxin theextensionsarray but thesubpathbranch only strips classic JS/TS suffixes:returnr.replace(/(?:\.d)?\.[mc]?[jt]s$/,'')Should a type entry resolve to
.tsxor.jsx, the extension will remain intact, unlike.js,.ts,.mjs,.cjs,.mts, or.ctscases. This creates an asymmetry that could affect downstream path handling in the TypeScript configuration.Extend the regex to include TSX/JSX:
- return r.replace(/(?:\.d)?\.[mc]?[jt]s$/, '')+ return r.replace(/(?:\.d)?\.[mc]?(?:[jt]s|[jt]sx)$/, '')This simple pattern avoids catastrophic backtracking and ensures consistent behaviour across all resolvable extensions.
🧹 Nitpick comments (2)
packages/kit/src/resolve.ts (1)
201-202:Default resolver extensions correctly expanded (consider centralising)The richer default
extensionsset is sensible and backwards compatible (existing precedence for.tsis preserved while adding.js, TSX/JSX and MTS/CTS plus.json). To avoid future drift between the various extension arrays (here, in kit/module install, Vite schema, webpack preset, etc.), it may be worth hoisting a shared constant for the canonical JS/TS extension set and reusing it across these call sites.packages/nuxt/src/core/external-config-files.ts (1)
40-42:External webpack config detection correctly extendedIncluding
.mtsand.cts(and normalising.coffeewith a dot) makes the webpack external-config check consistent with the Vite/nitro checks and the central resolver behaviour. If more config checks are added in future, you might consider sharing a common extension set to avoid divergence, but this change itself is sound.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
packages/kit/src/internal/esm.ts(2 hunks)packages/kit/src/module/install.ts(2 hunks)packages/kit/src/plugin.ts(1 hunks)packages/kit/src/resolve.ts(1 hunks)packages/kit/test/generate-types.spec.ts(1 hunks)packages/nuxt/src/core/external-config-files.ts(1 hunks)packages/nuxt/src/core/utils/types.ts(1 hunks)packages/nuxt/test/page-metadata.test.ts(1 hunks)packages/schema/src/config/common.ts(1 hunks)packages/schema/src/config/vite.ts(1 hunks)packages/webpack/src/presets/base.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/schema/src/config/common.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx,vue}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Follow standard TypeScript conventions and best practices
Files:
packages/nuxt/test/page-metadata.test.tspackages/kit/src/internal/esm.tspackages/kit/src/plugin.tspackages/kit/test/generate-types.spec.tspackages/kit/src/resolve.tspackages/webpack/src/presets/base.tspackages/kit/src/module/install.tspackages/nuxt/src/core/external-config-files.tspackages/nuxt/src/core/utils/types.tspackages/schema/src/config/vite.ts
**/*.{ts,tsx,js,jsx,vue}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.{ts,tsx,js,jsx,vue}: Use clear, descriptive variable and function names
Add comments only to explain complex logic or non-obvious implementations
Keep functions focused and manageable (generally under 50 lines), and extract complex logic into separate domain-specific files
Remove code that is not used or needed
Use error handling patterns consistently
Files:
packages/nuxt/test/page-metadata.test.tspackages/kit/src/internal/esm.tspackages/kit/src/plugin.tspackages/kit/test/generate-types.spec.tspackages/kit/src/resolve.tspackages/webpack/src/presets/base.tspackages/kit/src/module/install.tspackages/nuxt/src/core/external-config-files.tspackages/nuxt/src/core/utils/types.tspackages/schema/src/config/vite.ts
**/*.{test,spec}.{ts,tsx,js}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Write unit tests for core functionality using
vitest
Files:
packages/nuxt/test/page-metadata.test.tspackages/kit/test/generate-types.spec.ts
🧠 Learnings (11)
📓 Common learnings
Learnt from: GalacticHypernovaRepo: nuxt/nuxt PR: 29661File: packages/kit/src/template.ts:227-229Timestamp: 2024-11-28T21:22:40.496ZLearning: In `packages/kit/src/template.ts`, when updating the `EXTENSION_RE` regular expression for TypeScript configuration, avoid using patterns like `(\.\w+)+$` as they can result in catastrophic backtracking.Learnt from: CRRepo: nuxt/nuxt PR: 0File: .github/copilot-instructions.md:0-0Timestamp: 2025-11-25T11:42:16.132ZLearning: Applies to **/*.{ts,tsx,vue} : Follow standard TypeScript conventions and best practicesLearnt from: CRRepo: nuxt/nuxt PR: 0File: .github/copilot-instructions.md:0-0Timestamp: 2025-11-25T11:42:16.132ZLearning: Applies to **/*.{ts,tsx,js,jsx,vue} : Use error handling patterns consistently📚 Learning: 2024-11-28T21:22:40.496Z
Learnt from: GalacticHypernovaRepo: nuxt/nuxt PR: 29661File: packages/kit/src/template.ts:227-229Timestamp: 2024-11-28T21:22:40.496ZLearning: In `packages/kit/src/template.ts`, when updating the `EXTENSION_RE` regular expression for TypeScript configuration, avoid using patterns like `(\.\w+)+$` as they can result in catastrophic backtracking.Applied to files:
packages/nuxt/test/page-metadata.test.tspackages/kit/src/internal/esm.tspackages/kit/src/plugin.tspackages/kit/test/generate-types.spec.tspackages/kit/src/resolve.tspackages/webpack/src/presets/base.tspackages/kit/src/module/install.tspackages/nuxt/src/core/external-config-files.tspackages/nuxt/src/core/utils/types.tspackages/schema/src/config/vite.ts
📚 Learning: 2024-12-12T12:36:34.871Z
Learnt from: huang-julienRepo: nuxt/nuxt PR: 29366File: packages/nuxt/src/app/components/nuxt-root.vue:16-19Timestamp: 2024-12-12T12:36:34.871ZLearning: In `packages/nuxt/src/app/components/nuxt-root.vue`, when optimizing bundle size by conditionally importing components based on route metadata, prefer using inline conditional imports like:```jsconst IsolatedPage = route?.meta?.isolate ? defineAsyncComponent(() => import('#build/isolated-page.mjs')) : null```instead of wrapping the import in a computed property or importing the component unconditionally.Applied to files:
packages/nuxt/test/page-metadata.test.ts
📚 Learning: 2025-11-25T11:42:16.132Z
Learnt from: CRRepo: nuxt/nuxt PR: 0File: .github/copilot-instructions.md:0-0Timestamp: 2025-11-25T11:42:16.132ZLearning: Applies to **/*.{test,spec}.{ts,tsx,js} : Write unit tests for core functionality using `vitest`Applied to files:
packages/nuxt/test/page-metadata.test.tspackages/kit/test/generate-types.spec.tspackages/schema/src/config/vite.ts
📚 Learning: 2025-11-25T11:42:16.132Z
Learnt from: CRRepo: nuxt/nuxt PR: 0File: .github/copilot-instructions.md:0-0Timestamp: 2025-11-25T11:42:16.132ZLearning: Applies to **/e2e/**/*.{ts,tsx,js} : Write end-to-end tests using Playwright and `nuxt/test-utils`Applied to files:
packages/nuxt/test/page-metadata.test.ts
📚 Learning: 2025-11-25T11:42:16.132Z
Learnt from: CRRepo: nuxt/nuxt PR: 0File: .github/copilot-instructions.md:0-0Timestamp: 2025-11-25T11:42:16.132ZLearning: Applies to **/*.{ts,tsx,js,jsx,vue} : Remove code that is not used or neededApplied to files:
packages/nuxt/test/page-metadata.test.tspackages/kit/src/module/install.tspackages/nuxt/src/core/utils/types.tspackages/schema/src/config/vite.ts
📚 Learning: 2025-11-25T11:42:16.132Z
Learnt from: CRRepo: nuxt/nuxt PR: 0File: .github/copilot-instructions.md:0-0Timestamp: 2025-11-25T11:42:16.132ZLearning: Applies to **/*.{ts,tsx,vue} : Follow standard TypeScript conventions and best practicesApplied to files:
packages/nuxt/test/page-metadata.test.tspackages/kit/src/internal/esm.tspackages/kit/src/plugin.tspackages/kit/test/generate-types.spec.tspackages/kit/src/resolve.tspackages/kit/src/module/install.tspackages/nuxt/src/core/utils/types.tspackages/schema/src/config/vite.ts
📚 Learning: 2025-11-25T11:42:16.132Z
Learnt from: CRRepo: nuxt/nuxt PR: 0File: .github/copilot-instructions.md:0-0Timestamp: 2025-11-25T11:42:16.132ZLearning: Applies to **/*.{ts,tsx,js,jsx,vue} : Use error handling patterns consistentlyApplied to files:
packages/nuxt/test/page-metadata.test.tspackages/kit/src/module/install.tspackages/nuxt/src/core/utils/types.ts
📚 Learning: 2024-11-05T15:22:54.759Z
Learnt from: GalacticHypernovaRepo: nuxt/nuxt PR: 26468File: packages/nuxt/src/components/plugins/loader.ts:24-24Timestamp: 2024-11-05T15:22:54.759ZLearning: In `packages/nuxt/src/components/plugins/loader.ts`, the references to `resolve` and `distDir` are legacy code from before Nuxt used the new unplugin VFS and will be removed.Applied to files:
packages/kit/src/plugin.tspackages/kit/test/generate-types.spec.tspackages/kit/src/resolve.tspackages/webpack/src/presets/base.tspackages/kit/src/module/install.tspackages/nuxt/src/core/external-config-files.tspackages/nuxt/src/core/utils/types.tspackages/schema/src/config/vite.ts
📚 Learning: 2025-11-25T11:42:16.132Z
Learnt from: CRRepo: nuxt/nuxt PR: 0File: .github/copilot-instructions.md:0-0Timestamp: 2025-11-25T11:42:16.132ZLearning: Applies to **/*.vue : Use `<script setup lang="ts">` and the composition API when creating Vue componentsApplied to files:
packages/kit/src/module/install.tspackages/nuxt/src/core/utils/types.tspackages/schema/src/config/vite.ts
📚 Learning: 2025-11-25T11:42:16.132Z
Learnt from: CRRepo: nuxt/nuxt PR: 0File: .github/copilot-instructions.md:0-0Timestamp: 2025-11-25T11:42:16.132ZLearning: Applies to **/*.{ts,tsx,js,jsx,vue} : Use clear, descriptive variable and function namesApplied to files:
packages/nuxt/src/core/utils/types.ts
🧬 Code graph analysis (1)
packages/kit/src/plugin.ts (1)
packages/kit/src/context.ts (1)
tryUseNuxt(51-54)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: build
- GitHub Check: code
🔇 Additional comments (8)
packages/kit/src/module/install.ts (1)
223-224:Module resolution extensions broadened consistentlyThe extended
extensionslists here look coherent and will allow modules shipped as.mts,.cts,.tsxor.jsxto be resolved both viaresolveModuleWithOptionsandloadNuxtModuleInstance. Keeping the two arrays in sync is good; no issues from this change as-is.Also applies to: 260-261
packages/kit/test/generate-types.spec.ts (1)
26-27:Mock extensions kept in sync with runtime defaultsUpdating the test
mockNuxt.options.extensionsto cover.cjs,.tsx/.jsxand.mts/.ctskeeps type-generation tests aligned with the actual resolver behaviour. Looks good.packages/webpack/src/presets/base.ts (1)
149-155:Webpack resolve extensions updated to cover JS/TS variantsThe new
resolve.extensionsset for webpack sensibly adds.cjs,.mtsand.ctsand places.jsbefore.mjs, bringing it closer in line with the Vite configuration while still allowing user overrides viactx.config.resolve. No issues spotted.packages/schema/src/config/vite.ts (1)
28-29:Vite resolver extensions aligned with broader Nuxt supportThe updated
vite.resolve.extensionsnow matches the extended JS/TS landscape (.cjs, .mts, .cts, TSX/JSX) and aligns ordering with the webpack preset and external-config checks. This should make cross-tooling resolution more predictable.packages/nuxt/test/page-metadata.test.ts (1)
21-28:Tests now cover CTS/MTS page files for metadata extractionAdding
'cts'and'mts'to the extension loop usefully extends coverage sogetRouteMetais asserted to work for those TS module variants as well, in line with the new resolver support elsewhere. Looks good.packages/kit/src/internal/esm.ts (2)
12-12:LGTM! JSX/TSX support addition improves module resolution.The extension list now includes
.jsxand.tsx, broadening support for JSX-based modules. The JSDoc comment correctly reflects the implementation.Note: The PR title mentions adding
.mts, but.mtsand.ctswere already present. The actual changes add.jsxand reorder the extension priority.Also applies to: 41-41
41-41: No action required. The file and function are new additions, not reorderings of existing code. The extension array['.js', '.mjs', '.ts', '.cjs', '.tsx', '.jsx', '.mts', '.cts']is the default for the newly introducedresolveModule()function and does not represent a breaking change in existing resolution behaviour.Likely an incorrect or invalid review comment.
packages/kit/src/plugin.ts (1)
37-37:LGTM! Extension list is now consistent withpackages/kit/src/internal/esm.ts.The fallback extension array now matches the default extensions used in
resolveModule, ensuring consistent module resolution behaviour across the kit. The addition of.jsxsupport and reordering aligns with the broader changes in this PR.Note: The same extension reordering implications noted in
packages/kit/src/internal/esm.tsapply here as well.
Uh oh!
There was an error while loading.Please reload this page.
📚 Description
Related tonuxt/ui#5630
I was wondering why
.mtsis missing here 🤔Note
There may be other places in which we can add '.mts'.