-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
feat(kit): add extensions option for resolveModule
#33328
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(kit): add extensions option for resolveModule
#33328
Conversation
|
|
extensions option for resolveModuleextensions option for resolveModule
@nuxt/kit
nuxt
@nuxt/rspack-builder
@nuxt/schema
@nuxt/vite-builder
@nuxt/webpack-builder
commit: |
Walkthrough
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
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. Comment |
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
🧹 Nitpick comments (1)
packages/kit/src/internal/esm.ts (1)
36-41: Avoid shadowing exsolve’s built-in extension listBy 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 setextensionsthemselves. Let’s only passextensionswhen 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
📒 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 goodThanks for documenting the default extensions; that will help downstream callers.
CodSpeed Performance ReportMerging #33328 will not alter performanceComparing Summary
Footnotes |
🔗 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
exsolveinstead.