Skip to content

fix(module): make features config partial to allow selective overrides#331

Merged
huang-julien merged 1 commit intomainfrom
fix/partial-features-config
May 4, 2026
Merged

fix(module): make features config partial to allow selective overrides#331
huang-julien merged 1 commit intomainfrom
fix/partial-features-config

Conversation

@benjamincanac
Copy link
Copy Markdown
Member

🔗 Linked issue

📚 Description

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 4, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/hints@331

commit: 090e57e

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

📝 Walkthrough

Walkthrough

The ModuleOptions.features property type was changed from Features to Partial<Features>, making individual feature flags optional in module configuration. The module serializes options.features into the generated hints-config.mjs file using JSON.stringify(), allowing the exported features object to omit unspecified entries.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The PR description is empty of actual implementation details, containing only the repository's contribution template without any custom explanation of the change rationale or impact. Add a description explaining why partial features config is needed, what problem it solves, and how it enables selective overrides. Include any relevant context or related issues.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: making features config partial to allow selective overrides, which aligns with the core modification in ModuleOptions.features type.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/partial-features-config

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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

Copy link
Copy Markdown

@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.

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 | 🟠 Major

Register the #shared/hints-config alias in the Nitro build pipeline to prevent module resolution failure.

The html-validate/nitro.plugin.ts imports getFeatureOptions from src/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 in nuxt.options.alias (Vite/Nuxt build context), not in nuxt.options.nitro.alias. The write: true flag writes the file to disk but does not configure the alias mapping for the Nitro resolver.

Add the alias to nuxt.options.nitro.alias after 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 value

Nit: compute template content directly inside getContents.

The intermediate hintsConfigContent variable is only used as the return value of getContents. Inlining it is more idiomatic (matching the pattern shown in the official Nuxt Kit addTemplate docs) 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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 27a2892d-c26a-455f-ae13-6b0a43e44f9a

📥 Commits

Reviewing files that changed from the base of the PR and between 1881ee1 and 090e57e.

📒 Files selected for processing (1)
  • src/module.ts

@huang-julien huang-julien merged commit 4d8759f into main May 4, 2026
9 checks passed
@huang-julien huang-julien deleted the fix/partial-features-config branch May 4, 2026 17:50
@huang-julien huang-julien mentioned this pull request May 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants