Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/nuxtPublic

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

Open
OrbisK wants to merge5 commits intonuxt:main
base:main
Choose a base branch
Loading
fromOrbisK:fix/extensions-mts

Conversation

@OrbisK
Copy link
Member

@OrbisKOrbisK commentedDec 10, 2025
edited
Loading

📚 Description

Related tonuxt/ui#5630

I was wondering why.mts is missing here 🤔

Note

There may be other places in which we can add '.mts'.

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz CodeflowRun & review this pull request inStackBlitz Codeflow.

@coderabbitai
Copy link

coderabbitaibot commentedDec 10, 2025
edited
Loading

Walkthrough

This 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

  • PR#29799 — Modifies module resolution logic in module/install.ts; closely related to this PR's changes to resolution extensions.
  • PR#32857 — Adjusts resolve.ts handling and extension normalization; directly related to the expanded default extension list in resolve.ts.
  • PR#29955 — Changes resolution behavior in module/install.ts (loadNuxtModuleInstance/resolve paths); overlaps with this PR's extension/order updates.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.You can run@coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check nameStatusExplanation
Title check✅ PassedThe title accurately describes the main change: adding.mts file extension support to resolver defaults across multiple files in the codebase.
Description check✅ PassedThe description references a related change and explains the motivation (.mts was missing from the resolver), which aligns with the changeset that adds.mts and other extensions across multiple resolver configuration files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

✨ Issue Enrichment is now available for GitHub issues!

CodeRabbit can now help you manage issues more effectively:

  • Duplicate Detection — Identify similar or duplicate issues
  • Related Issues & PRs — Find relevant issues and PR's from your repository
  • Suggested Assignees — Find the best person to work on the issue
  • Implementation Planning — Generate detailed coding plans for engineers and agents
Disable automatic issue enrichment

To disable automatic issue enrichment, add the following to your.coderabbit.yaml:

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.

❤️ Share

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

@pkg-pr-new
Copy link

pkg-pr-newbot commentedDec 10, 2025
edited
Loading

Open in StackBlitz

@nuxt/kit

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

@nuxt/nitro-server

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

nuxt

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

@nuxt/rspack-builder

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

@nuxt/schema

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

@nuxt/vite-builder

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

@nuxt/webpack-builder

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

commit:84b98fb

@codspeed-hq
Copy link

codspeed-hqbot commentedDec 10, 2025
edited
Loading

CodSpeed Performance Report

Merging#33845 willnot alter performance

ComparingOrbisK:fix/extensions-mts (ab9a613) withmain (ac906ce)1

Summary

✅ 10 untouched

Footnotes

  1. No successful run was found onmain (86d67b2) during the generation of this report, soac906ce was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

Co-authored-by: Alexander Lichter <github@lichter.io>
extensions:{
$resolve:(val):string[]=>{
constextensions=['.js','.jsx','.mjs','.ts','.tsx','.vue']
constextensions=['.js','.jsx','.mjs','.ts','.tsx','.mts','.vue']
Copy link
Member

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

OrbisK, danielroe, and TheAlexLichter reacted with thumbs up emoji
Copy link

@coderabbitaicoderabbitaibot left a 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

resolveTypePath includes.tsx and.jsx in theextensions array but thesubpath branch only strips classic JS/TS suffixes:

returnr.replace(/(?:\.d)?\.[mc]?[jt]s$/,'')

Should a type entry resolve to.tsx or.jsx, the extension will remain intact, unlike.js,.ts,.mjs,.cjs,.mts, or.cts cases. 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 defaultextensions set is sensible and backwards compatible (existing precedence for.ts is 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 extended

Including.mts and.cts (and normalising.coffee with 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

📥 Commits

Reviewing files that changed from the base of the PR and betweenab9a613 and84b98fb.

📒 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.ts
  • packages/kit/src/internal/esm.ts
  • packages/kit/src/plugin.ts
  • packages/kit/test/generate-types.spec.ts
  • packages/kit/src/resolve.ts
  • packages/webpack/src/presets/base.ts
  • packages/kit/src/module/install.ts
  • packages/nuxt/src/core/external-config-files.ts
  • packages/nuxt/src/core/utils/types.ts
  • packages/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.ts
  • packages/kit/src/internal/esm.ts
  • packages/kit/src/plugin.ts
  • packages/kit/test/generate-types.spec.ts
  • packages/kit/src/resolve.ts
  • packages/webpack/src/presets/base.ts
  • packages/kit/src/module/install.ts
  • packages/nuxt/src/core/external-config-files.ts
  • packages/nuxt/src/core/utils/types.ts
  • packages/schema/src/config/vite.ts
**/*.{test,spec}.{ts,tsx,js}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Write unit tests for core functionality usingvitest

Files:

  • packages/nuxt/test/page-metadata.test.ts
  • packages/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 practices
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 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.ts
  • packages/kit/src/internal/esm.ts
  • packages/kit/src/plugin.ts
  • packages/kit/test/generate-types.spec.ts
  • packages/kit/src/resolve.ts
  • packages/webpack/src/presets/base.ts
  • packages/kit/src/module/install.ts
  • packages/nuxt/src/core/external-config-files.ts
  • packages/nuxt/src/core/utils/types.ts
  • packages/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.ts
  • packages/kit/test/generate-types.spec.ts
  • packages/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 needed

Applied to files:

  • packages/nuxt/test/page-metadata.test.ts
  • packages/kit/src/module/install.ts
  • packages/nuxt/src/core/utils/types.ts
  • packages/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 practices

Applied to files:

  • packages/nuxt/test/page-metadata.test.ts
  • packages/kit/src/internal/esm.ts
  • packages/kit/src/plugin.ts
  • packages/kit/test/generate-types.spec.ts
  • packages/kit/src/resolve.ts
  • packages/kit/src/module/install.ts
  • packages/nuxt/src/core/utils/types.ts
  • packages/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 consistently

Applied to files:

  • packages/nuxt/test/page-metadata.test.ts
  • packages/kit/src/module/install.ts
  • packages/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.ts
  • packages/kit/test/generate-types.spec.ts
  • packages/kit/src/resolve.ts
  • packages/webpack/src/presets/base.ts
  • packages/kit/src/module/install.ts
  • packages/nuxt/src/core/external-config-files.ts
  • packages/nuxt/src/core/utils/types.ts
  • packages/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 components

Applied to files:

  • packages/kit/src/module/install.ts
  • packages/nuxt/src/core/utils/types.ts
  • packages/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 names

Applied 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 consistently

The extendedextensions lists here look coherent and will allow modules shipped as.mts,.cts,.tsx or.jsx to be resolved both viaresolveModuleWithOptions andloadNuxtModuleInstance. 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 defaults

Updating the testmockNuxt.options.extensions to cover.cjs,.tsx/.jsx and.mts/.cts keeps 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 variants

The newresolve.extensions set for webpack sensibly adds.cjs,.mts and.cts and places.js before.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 support

The updatedvite.resolve.extensions now 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 extraction

Adding'cts' and'mts' to the extension loop usefully extends coverage sogetRouteMeta is 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.jsx and.tsx, broadening support for JSX-based modules. The JSDoc comment correctly reflects the implementation.

Note: The PR title mentions adding.mts, but.mts and.cts were already present. The actual changes add.jsx and 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 inresolveModule, ensuring consistent module resolution behaviour across the kit. The addition of.jsx support and reordering aligns with the broader changes in this PR.

Note: The same extension reordering implications noted inpackages/kit/src/internal/esm.ts apply here as well.

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

Reviewers

@huang-julienhuang-julienhuang-julien left review comments

@coderabbitaicoderabbitai[bot]coderabbitai[bot] left review comments

@TheAlexLichterTheAlexLichterTheAlexLichter approved these changes

@danielroedanielroeAwaiting requested review from danielroedanielroe is a code owner

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@OrbisK@TheAlexLichter@huang-julien@danielroe

[8]ページ先頭

©2009-2025 Movatter.jp