fix(module): make features config partial to allow selective overrides#331
fix(module): make features config partial to allow selective overrides#331huang-julien merged 1 commit intomainfrom
Conversation
commit: |
📝 WalkthroughWalkthroughThe Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/module.ts (1)
40-47:⚠️ Potential issue | 🟠 MajorRegister the
#shared/hints-configalias in the Nitro build pipeline to prevent module resolution failure.The
html-validate/nitro.plugin.tsimportsgetFeatureOptionsfromsrc/runtime/core/features.ts, which has a static import of#shared/hints-config. When Nitro builds, it will fail to resolve this alias because it is only registered innuxt.options.alias(Vite/Nuxt build context), not innuxt.options.nitro.alias. Thewrite: trueflag writes the file to disk but does not configure the alias mapping for the Nitro resolver.Add the alias to
nuxt.options.nitro.aliasafter the template is resolved:Fix: propagate alias to Nitro build
nuxt.options.alias['#shared/hints-config'] = hintsConfig.dst + nuxt.options.nitro.alias = nuxt.options.nitro.alias || {} + nuxt.options.nitro.alias['#shared/hints-config'] = hintsConfig.dst🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/module.ts` around lines 40 - 47, The alias for '#shared/hints-config' is only being set on nuxt.options.alias (Vite) and not propagated to the Nitro resolver, causing module resolution failures during Nitro build; after creating the template via addTemplate (hints-config.mjs) and obtaining hintsConfig.dst, also set nuxt.options.nitro.alias['#shared/hints-config'] = hintsConfig.dst so Nitro can resolve the static import in src/runtime/core/features.ts; ensure this runs after addTemplate returns and uses the same hintsConfig.dst value as nuxt.options.alias['#shared/hints-config'].
🧹 Nitpick comments (1)
src/module.ts (1)
40-45: 💤 Low valueNit: compute template content directly inside
getContents.The intermediate
hintsConfigContentvariable is only used as the return value ofgetContents. Inlining it is more idiomatic (matching the pattern shown in the official Nuxt KitaddTemplatedocs) and removes the risk of a stale capture if the surrounding code is ever refactored.♻️ Proposed refactor
- const hintsConfigContent = `export const features = ${JSON.stringify(options.features)}` - const hintsConfig = addTemplate({ + const hintsConfig = addTemplate({ filename: 'hints-config.mjs', - getContents: () => hintsConfigContent, + getContents: () => `export const features = ${JSON.stringify(options.features)}`, write: true, })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/module.ts` around lines 40 - 45, The temporary variable hintsConfigContent should be inlined into the template factory to avoid a stale capture; update the addTemplate call that creates 'hints-config.mjs' so getContents returns the string directly (e.g., compute `export const features = ${JSON.stringify(options.features)}` inside getContents) and remove the unused hintsConfigContent variable; keep filename 'hints-config.mjs' and write: true as-is.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/module.ts`:
- Around line 40-47: The alias for '#shared/hints-config' is only being set on
nuxt.options.alias (Vite) and not propagated to the Nitro resolver, causing
module resolution failures during Nitro build; after creating the template via
addTemplate (hints-config.mjs) and obtaining hintsConfig.dst, also set
nuxt.options.nitro.alias['#shared/hints-config'] = hintsConfig.dst so Nitro can
resolve the static import in src/runtime/core/features.ts; ensure this runs
after addTemplate returns and uses the same hintsConfig.dst value as
nuxt.options.alias['#shared/hints-config'].
---
Nitpick comments:
In `@src/module.ts`:
- Around line 40-45: The temporary variable hintsConfigContent should be inlined
into the template factory to avoid a stale capture; update the addTemplate call
that creates 'hints-config.mjs' so getContents returns the string directly
(e.g., compute `export const features = ${JSON.stringify(options.features)}`
inside getContents) and remove the unused hintsConfigContent variable; keep
filename 'hints-config.mjs' and write: true as-is.
🔗 Linked issue
📚 Description