Skip to content

Conversation

@BobbieGoede
Copy link
Member

🔗 Linked issue

📚 Description

I guess this is kind of an (unmarked) internal function, we probably shouldn't expand it if we want users to directly use exsolve instead.

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@danielroe danielroe changed the title fix(kit): add extensions option for resolveModule feat(kit): add extensions option for resolveModule Sep 26, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 26, 2025

Open in StackBlitz

@nuxt/kit

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

nuxt

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

@nuxt/rspack-builder

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

@nuxt/schema

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

@nuxt/vite-builder

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

@nuxt/webpack-builder

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

commit: 429858c

@coderabbitai
Copy link

coderabbitai bot commented Sep 26, 2025

Walkthrough

  • Introduced a new optional property extensions?: string[] to the ResolveModuleOptions interface in packages/kit/src/internal/esm.ts.
  • Modified resolveModule to use options?.extensions if provided; otherwise it falls back to the default list ['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'].
  • No other files or exports changed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed The pull request description references the internal resolveModule function and the decision to avoid exposing it directly to users, which is somewhat related to the change of adding an extensions option for that function.
Title Check ✅ Passed The title succinctly and accurately describes the primary change of adding an extensions option to resolveModule, aligns with the changeset’s intent, and follows conventional commit styling.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link

@coderabbitai coderabbitai bot 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

🧹 Nitpick comments (1)
packages/kit/src/internal/esm.ts (1)

36-41: Avoid shadowing exsolve’s built-in extension list

By unconditionally supplying our own default list we start to drift from exsolve’s evolving defaults (and today we already omit values like .node). That regression bites anyone relying on those built-ins unless they set extensions themselves. Let’s only pass extensions when the caller provides them so we preserve existing behaviour.

 export function resolveModule (id: string, options?: ResolveModuleOptions) {
-  return resolveModulePath(id, {
-    // eslint-disable-next-line @typescript-eslint/no-deprecated
-    from: options?.url ?? options?.paths ?? [import.meta.url],
-    extensions: options?.extensions ?? ['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'],
-  })
+  return resolveModulePath(id, {
+    // eslint-disable-next-line @typescript-eslint/no-deprecated
+    from: options?.url ?? options?.paths ?? [import.meta.url],
+    ...(options?.extensions ? { extensions: options.extensions } : {}),
+  })
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 50febbb and 1585c3e.

📒 Files selected for processing (1)
  • packages/kit/src/internal/esm.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

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

Follow standard TypeScript conventions and best practices

Files:

  • packages/kit/src/internal/esm.ts
🧠 Learnings (1)
📓 Common learnings
Learnt from: GalacticHypernova
PR: nuxt/nuxt#29661
File: packages/kit/src/template.ts:227-229
Timestamp: 2024-11-28T21:22:40.496Z
Learning: 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.
⏰ 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). (1)
  • GitHub Check: code
🔇 Additional comments (1)
packages/kit/src/internal/esm.ts (1)

11-12: Doc note looks good

Thanks for documenting the default extensions; that will help downstream callers.

@codspeed-hq
Copy link

codspeed-hq bot commented Sep 26, 2025

CodSpeed Performance Report

Merging #33328 will not alter performance

Comparing BobbieGoede:fix/resolve-module-extensions-option (429858c) with main (ca76b89)1

Summary

✅ 10 untouched

Footnotes

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

@danielroe danielroe added enhancement and removed bug labels Oct 6, 2025
@danielroe danielroe merged commit 27fe465 into nuxt:main Oct 7, 2025
47 checks passed
@github-actions github-actions bot mentioned this pull request Oct 7, 2025
@github-actions github-actions bot mentioned this pull request Oct 23, 2025
@github-actions github-actions bot mentioned this pull request Oct 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants