Skip to content

fix: add v0 migration warnings and docs for breaking config changes - #679

Merged
harlan-zw merged 5 commits into
mainfrom
fix/v0-migration-warnings
Mar 29, 2026
Merged

fix: add v0 migration warnings and docs for breaking config changes#679
harlan-zw merged 5 commits into
mainfrom
fix/v0-migration-warnings

Conversation

@harlan-zw

@harlan-zw harlan-zw commented Mar 29, 2026

Copy link
Copy Markdown
Collaborator

🔗 Linked issue

Related to #594

❓ Type of change

  • 📖 Documentation
  • 🐞 Bug fix
  • 👌 Enhancement
  • ✨ New feature
  • 🧹 Chore
  • ⚠️ Breaking change

📚 Description

v0 users upgrading to v1 hit silent failures when using renamed or removed config keys. This PR adds build time detection and auto migration for reverseProxyInterceptproxy, warns on missing triggers, and documents the changes in the migration guide.

Config migration (normalize.ts, module.ts):

  • New migrateDeprecatedRegistryKeys() runs before normalization, detecting reverseProxyIntercept in flat objects, nested scriptOptions, and array tuples. Auto rewrites to proxy (without clobbering existing values) and emits a [nuxt-scripts] prefixed warning.
  • true shorthand emits a deprecation warning pointing to { trigger: 'onNuxtReady' }
  • Missing trigger warning fires when user-provided input fields exist without an explicit trigger, filtering out env-var-only defaults to avoid false positives
  • trigger: false supported as explicit infrastructure-only opt-out (proxy routes, types, bundling registered; no <script> tag injected)
  • 6 unit tests for migrateDeprecatedRegistryKeys, additional tests for true deprecation and trigger: false

Docs updates:

  • true replaced with { trigger: 'onNuxtReady' } across all registry script docs
  • Migration guide expanded with "Scripts No Longer Auto-Load" section, before/after examples, and condensed config migration table
  • trigger: false clarified: registers infrastructure only, useful when loading via component/composable

Migration guide (v0-to-v1.md):

  • Added reverseProxyInterceptproxy rename documentation
  • Added Google Maps component consolidation section (AdvancedMarkerElement → Marker rename, PinElement removal, markers/centerMarker prop removal)

Detect and auto-migrate `reverseProxyIntercept` to `proxy` in registry
config with a build warning. Document the rename and Google Maps
component consolidation in the v0-to-v1 migration guide.
@vercel

vercel Bot commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
scripts-playground Ready Ready Preview, Comment Mar 29, 2026 4:50am

@pkg-pr-new

pkg-pr-new Bot commented Mar 29, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/scripts@679

commit: e7ab836

@coderabbitai

coderabbitai Bot commented Mar 29, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Migration docs and examples updated to replace boolean registry enablement (true) with explicit trigger objects (e.g., { trigger: 'onNuxtReady' }). Documentation now clarifies registry entries do not auto-load unless a trigger is present and documents trigger: false for infrastructure-only entries and a build warning when trigger is omitted. Code adds migrateDeprecatedRegistryKeys(registry, warn) to migrate reverseProxyInterceptproxy across tuple, nested, and top-level shapes with warnings; expands trigger types to include false; normalizeRegistryConfig accepts an optional warn and warns on true shorthand. Module emits warnings if input exists but no trigger. Tests updated accordingly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: adding migration warnings and documentation updates for breaking configuration changes from v0 to v1.
Description check ✅ Passed The description comprehensively relates to the changeset, detailing config migration logic, deprecation warnings, new unit tests, and documentation updates across multiple files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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/v0-migration-warnings

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/script/src/normalize.ts (1)

43-60: Consider deduplicating the warning message construction.

The same warning template is repeated across branches; extracting a tiny helper will reduce drift risk.

♻️ Suggested cleanup
 export function migrateDeprecatedRegistryKeys(
   registry: Record<string, unknown>,
   warn: (msg: string) => void,
 ): void {
+  const warnRename = (registryKey: string, from: string) =>
+    warn(`registry.${registryKey}: \`${from}\` has been renamed to \`proxy\`. Please update your config. Auto-migrating for now.`)
+
   for (const key of Object.keys(registry)) {
@@
       const opts = entry[1]
       if (opts && typeof opts === 'object' && 'reverseProxyIntercept' in opts) {
-        warn(`registry.${key}: \`reverseProxyIntercept\` has been renamed to \`proxy\`. Please update your config. Auto-migrating for now.`)
+        warnRename(key, 'reverseProxyIntercept')
         const o = opts as Record<string, unknown>
@@
       if ('reverseProxyIntercept' in obj) {
-        warn(`registry.${key}: \`reverseProxyIntercept\` has been renamed to \`proxy\`. Please update your config. Auto-migrating for now.`)
+        warnRename(key, 'reverseProxyIntercept')
         obj.proxy ??= obj.reverseProxyIntercept
         delete obj.reverseProxyIntercept
       }
@@
       if (so && typeof so === 'object' && 'reverseProxyIntercept' in so) {
-        warn(`registry.${key}: \`scriptOptions.reverseProxyIntercept\` has been renamed to \`proxy\`. Please update your config. Auto-migrating for now.`)
+        warnRename(key, 'scriptOptions.reverseProxyIntercept')
         const s = so as Record<string, unknown>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/script/src/normalize.ts` around lines 43 - 60, The warning text is
duplicated; extract a small helper (e.g., warnRenamed or warnFieldRename) and
replace the repeated warn(...) calls in normalize.ts so both top-level and
nested cases call that helper with the registry key and field path; keep the
existing message format including registry.${key}, the oldName
(reverseProxyIntercept), newName (proxy), and "Auto-migrating for now.", and do
not change the subsequent migration logic that sets proxy ??=
reverseProxyIntercept and deletes reverseProxyIntercept in the branches that
reference opts, obj, and obj.scriptOptions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/script/src/normalize.ts`:
- Around line 43-60: The warning text is duplicated; extract a small helper
(e.g., warnRenamed or warnFieldRename) and replace the repeated warn(...) calls
in normalize.ts so both top-level and nested cases call that helper with the
registry key and field path; keep the existing message format including
registry.${key}, the oldName (reverseProxyIntercept), newName (proxy), and
"Auto-migrating for now.", and do not change the subsequent migration logic that
sets proxy ??= reverseProxyIntercept and deletes reverseProxyIntercept in the
branches that reference opts, obj, and obj.scriptOptions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 81ee404c-3c78-4b50-bece-5ce12b03f46b

📥 Commits

Reviewing files that changed from the base of the PR and between a1595e0 and c2ab741.

📒 Files selected for processing (4)
  • docs/content/docs/4.migration-guide/1.v0-to-v1.md
  • packages/script/src/module.ts
  • packages/script/src/normalize.ts
  • test/unit/normalize.test.ts

In v0, all configured scripts auto-loaded. In v1, a trigger is required
for auto-loading. Emit a build warning when input fields are provided
without a trigger so v0 users know their scripts stopped loading.

Also expand the migration guide with a dedicated section explaining this
behavior change with before/after examples.
…rigger: false`

- `true` as a registry value now emits a deprecation warning; use
  `{ trigger: 'onNuxtReady' }` instead
- `trigger: false` is a valid explicit opt-out (infrastructure only)
- Missing trigger warning now checks key presence, not truthiness
- Update all docs to use explicit `{ trigger: 'onNuxtReady' }` instead of `true`
- Update scripts.nuxt.com code gen to emit trigger in all generated configs
…false positives

- Actually call migrateDeprecatedRegistryKeys() before normalization (was dead code)
- Add [nuxt-scripts] prefix to all warnings in normalize.ts for consistency
- Filter env-var-only defaults from trigger warning to avoid false positives
- Clarify trigger: false in migration guide (proxy routes, types, bundling only)
- Condense config migration table (details already covered in prose above)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
docs/content/docs/4.migration-guide/1.v0-to-v1.md (1)

223-223: Use active voice to satisfy lint style warning.

“...no <script> tag is injected” can be rewritten in active voice.

Suggested wording
-If you only need infrastructure without loading the script on the page, set `trigger: false` explicitly. This registers proxy routes, TypeScript types, and bundling config, but no `<script>`{lang="html"} tag is injected. Useful when you load the script yourself via a component or composable.
+If you only need infrastructure without loading the script on the page, set `trigger: false` explicitly. This registers proxy routes, TypeScript types, and bundling config, but Nuxt does not inject a `<script>`{lang="html"} tag. Useful when you load the script yourself via a component or composable.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/content/docs/4.migration-guide/1.v0-to-v1.md` at line 223, The sentence
uses passive voice ("no <script> tag is injected"); change it to active voice by
rephrasing it to explicitly name the actor and action—e.g., replace "but no
`<script>`{lang=\"html\"} tag is injected." with "but the integration does not
inject a `<script>`{lang=\"html`"} tag." Ensure the revised sentence appears in
the same paragraph that begins "If you only need infrastructure without loading
the script on the page, set `trigger: false` explicitly." and keep surrounding
wording about proxy routes, TypeScript types, and bundling config unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/content/docs/4.migration-guide/1.v0-to-v1.md`:
- Line 243: Update the migration note that currently implies `bundle` was
replaced by `trigger`: split the single sentence into two clear points — first
state that tuple/boolean shapes (e.g. `true` shorthand and array tuple syntax)
were replaced by a flat config shape (referencing the `{ id: '...' }` → `{ id:
'...', trigger: 'onNuxtReady' }` example), and second state that auto-loading
now requires an explicit `trigger` option; explicitly mention that `bundle`
remains a supported top-level flat option and is not replaced by `trigger` so
readers are not misled.

---

Nitpick comments:
In `@docs/content/docs/4.migration-guide/1.v0-to-v1.md`:
- Line 223: The sentence uses passive voice ("no <script> tag is injected");
change it to active voice by rephrasing it to explicitly name the actor and
action—e.g., replace "but no `<script>`{lang=\"html\"} tag is injected." with
"but the integration does not inject a `<script>`{lang=\"html`"} tag." Ensure
the revised sentence appears in the same paragraph that begins "If you only need
infrastructure without loading the script on the page, set `trigger: false`
explicitly." and keep surrounding wording about proxy routes, TypeScript types,
and bundling config unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b6fbc6b9-5461-4dae-88b6-a64a8bc6f62e

📥 Commits

Reviewing files that changed from the base of the PR and between 86413bb and e7ab836.

📒 Files selected for processing (3)
  • docs/content/docs/4.migration-guide/1.v0-to-v1.md
  • packages/script/src/module.ts
  • packages/script/src/normalize.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/script/src/module.ts
  • packages/script/src/normalize.ts

| `[{ id: '...' }, { bundle: true }]` | `{ id: '...' }` | Bundling is auto-enabled via capabilities; no need to opt in |
| `[{ id: '...' }, { trigger: 'onNuxtReady' }]` | `{ id: '...', trigger: 'onNuxtReady' }` | Array tuple syntax still works, but flat config is preferred |
| `googleAnalytics: 'mock'` | `googleAnalytics: 'mock'` | Unchanged; creates a stub for testing |
| `{ id: '...' }` | `{ id: '...', trigger: 'onNuxtReady' }` | Add an explicit `trigger` to auto-load. `true` shorthand, `bundle` option, and array tuple syntax are also replaced by flat config with `trigger`. |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Clarify bundle wording to avoid implying it was replaced by trigger.

Line 243 currently reads as if bundle was replaced by trigger, but bundle is still a supported flat top-level option (as shown later in this doc). Please split this into two points: (1) tuple/boolean shapes were replaced by flat config, and (2) auto-loading now requires trigger.

Suggested wording
-| `{ id: '...' }` | `{ id: '...', trigger: 'onNuxtReady' }` | Add an explicit `trigger` to auto-load. `true` shorthand, `bundle` option, and array tuple syntax are also replaced by flat config with `trigger`. |
+| `{ id: '...' }` | `{ id: '...', trigger: 'onNuxtReady' }` | Add an explicit `trigger` to auto-load. `true` shorthand and array tuple syntax are replaced by flat config. `bundle` remains supported as a flat top-level option when needed. |
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| `{ id: '...' }` | `{ id: '...', trigger: 'onNuxtReady' }` | Add an explicit `trigger` to auto-load. `true` shorthand, `bundle` option, and array tuple syntax are also replaced by flat config with `trigger`. |
| `{ id: '...' }` | `{ id: '...', trigger: 'onNuxtReady' }` | Add an explicit `trigger` to auto-load. `true` shorthand and array tuple syntax are replaced by flat config. `bundle` remains supported as a flat top-level option when needed. |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/content/docs/4.migration-guide/1.v0-to-v1.md` at line 243, Update the
migration note that currently implies `bundle` was replaced by `trigger`: split
the single sentence into two clear points — first state that tuple/boolean
shapes (e.g. `true` shorthand and array tuple syntax) were replaced by a flat
config shape (referencing the `{ id: '...' }` → `{ id: '...', trigger:
'onNuxtReady' }` example), and second state that auto-loading now requires an
explicit `trigger` option; explicitly mention that `bundle` remains a supported
top-level flat option and is not replaced by `trigger` so readers are not
misled.

@harlan-zw
harlan-zw merged commit 63d4da5 into main Mar 29, 2026
17 checks passed
@harlan-zw
harlan-zw deleted the fix/v0-migration-warnings branch March 29, 2026 05:29
@harlan-zw harlan-zw mentioned this pull request Apr 15, 2026
@harlan-zw
harlan-zw restored the fix/v0-migration-warnings branch August 14, 2026 03:40
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.

1 participant