Skip to content

fix(scripts): preserve consent when reusing script consumers - #961

Merged
harlan-zw merged 1 commit into
mainfrom
fix/registry-consent-trigger-reuse
Oct 12, 2026
Merged

harlan-zw merged 1 commit into
mainfrom
fix/registry-consent-trigger-reuse

Conversation

@harlan-zw

Copy link
Copy Markdown
Collaborator

🔗 Linked issue

Related to #949, addresses items 1 and 2.

📚 Description

Later calls without options could load a consent-gated script before consent was accepted.
Registry entries with trigger: false also blocked later composable calls.

Implicit consumers now preserve the existing loading condition for browser scripts and npm SDKs.
Registry trigger: false stays at module level; explicit composable triggers still work.

Registry settings reach composables without infrastructure triggers. Later consumers observe the shared script without adding a loading condition.

🤖 AI disclosure: Harlan Agent Kit modified this description. My AI open-source policy.

@vercel

vercel Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated
scripts-playground Ready Ready Preview Oct 12, 2026 1:32pm UTC

Request Review

@harlan-zw harlan-zw added harlan-agent-review Approve automated work for the current issue state or pull request head commit. harlan-agent-review-required Pull request triage requires an adversarial Review for this head commit. and removed harlan-agent-review Approve automated work for the current issue state or pull request head commit. labels Oct 12, 2026
@pkg-pr-new

pkg-pr-new Bot commented Oct 12, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/scripts-devtools@961
npm i https://pkg.pr.new/@nuxt/scripts@961

commit: 51070ac

@github-actions

Copy link
Copy Markdown

📦 Package Size

⚠️ 4 size metrics grew

📚 22 runtime dependencies (no change)

Package output Gzipped Δ
@nuxt/scripts · dist/runtime 104 kB → 104 kB 🔴 +155 B (+0.1%)
@nuxt/scripts · export . 26 kB → 26 kB 🔴 +29 B (+0.1%)
@nuxt/scripts · published payload 222 kB → 223 kB 🔴 +184 B (+0.1%)
@nuxt/scripts · composables runtime 7.8 kB → 7.8 kB 🔴 +37 B (+0.5%)
All tracked output (25)
Package output Gzipped Raw
@nuxt/scripts-cli · runtime dependencies 72 kB 355 kB ✅
@nuxt/scripts-cli · dependency magicast 72 kB 355 kB ✅
@nuxt/scripts-cli · export . 3.4 kB 12 kB ✅
@nuxt/scripts-cli · published payload 3.4 kB 12 kB ✅
@nuxt/scripts · runtime dependencies 543 kB 2.40 MB ✅
@nuxt/scripts · dependency @oxc-project/types 0 B 0 B ✅
@nuxt/scripts · dependency @vueuse/core 178 kB 720 kB ✅
@nuxt/scripts · dependency @vueuse/shared 39 kB 152 kB ✅
@nuxt/scripts · dependency lru-cache 141 kB 623 kB ✅
@nuxt/scripts · dependency semver 25 kB 72 kB ✅
@nuxt/scripts · dependency sirv 8.8 kB 21 kB ✅
@nuxt/scripts · dependency unstorage 70 kB 225 kB ✅
@nuxt/scripts · dependency valibot 82 kB 590 kB ✅
@nuxt/scripts · dist/runtime 104 kB 306 kB 🔴
@nuxt/scripts · export . 26 kB 106 kB 🔴
@nuxt/scripts · export ./registry 30 kB 94 kB ✅
@nuxt/scripts · export ./stats 13 kB 92 kB ✅
@nuxt/scripts · export ./types-source 49 kB 247 kB ✅
@nuxt/scripts · published payload 223 kB 846 kB 🔴
@nuxt/scripts · app runtime 176 B 658 B ✅
@nuxt/scripts · components runtime 2.5 kB 6.4 kB ✅
@nuxt/scripts · composables runtime 7.8 kB 26 kB 🔴
@nuxt/scripts · registry runtime 46 kB 136 kB ✅
@nuxt/scripts · server runtime 30 kB 89 kB ✅
@nuxt/scripts · utils runtime 2.9 kB 8.1 kB ✅
Runtime dependencies (22)
Package Dependency Requested Resolved Cost
@nuxt/scripts-cli magicast ^0.5.5 0.5.5 📦 72 kB gzip
@nuxt/scripts-cli pathe ^2.0.3 2.0.3 ♻️ free via Nuxt 4.6.0
@nuxt/scripts @nuxt/kit ^4.6.0 4.6.0 ♻️ free via Nuxt 4.6.0
@nuxt/scripts @oxc-project/types ^0.153.0 0.153.0 📦 0 B gzip
@nuxt/scripts @vueuse/core ^15.0.0 15.0.0 📦 178 kB gzip
@nuxt/scripts @vueuse/shared ^15.0.0 15.0.0 📦 39 kB gzip
@nuxt/scripts consola ^3.4.2 3.4.2 ♻️ free via Nuxt 4.6.0
@nuxt/scripts defu ^6.1.7 6.1.7 ♻️ free via Nuxt 4.6.0
@nuxt/scripts lru-cache ^11.5.3 11.5.3 📦 141 kB gzip
@nuxt/scripts magic-string ^1.4.3 1.4.3 ♻️ free via Nuxt 4.6.0
@nuxt/scripts ofetch ^1.5.1 1.5.1 ♻️ free via Nuxt 4.6.0
@nuxt/scripts ohash ^2.0.12 2.0.12 ♻️ free via Nuxt 4.6.0
@nuxt/scripts oxc-walker ^1.1.1 1.1.1 ♻️ free via Nuxt 4.6.0
@nuxt/scripts pathe ^2.0.3 2.0.3 ♻️ free via Nuxt 4.6.0
@nuxt/scripts semver ^7.8.5 7.8.5 📦 25 kB gzip
@nuxt/scripts sirv ^3.0.2 3.0.2 📦 8.8 kB gzip
@nuxt/scripts std-env ^4.3.0 4.3.0 ♻️ free via Nuxt 4.6.0
@nuxt/scripts ufo ^1.6.4 1.6.4 ♻️ free via Nuxt 4.6.0
@nuxt/scripts ultrahtml ^1.7.0 1.7.0 ♻️ free via Nuxt 4.6.0
@nuxt/scripts unplugin ^3.4.0 3.4.0 ♻️ free via Nuxt 4.6.0
@nuxt/scripts unstorage ^1.17.5 1.17.5 📦 70 kB gzip
@nuxt/scripts valibot ^1.5.0 1.5.0 📦 82 kB gzip

Baseline: main_@_f8ebc7c5___2026-10-12 · gzip is the comparison metric · changes below 16 B gzip are ignored

@coderabbitai

coderabbitai Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c5beb19d-2dde-49c2-b0bd-5a88562603a7

📥 Commits

Reviewing files that changed from the base of the PR and between f8ebc7c and 51070ac.


📒 Files selected for processing (13)
  • docs/content/docs/1.guides/1.registry-scripts.md
  • packages/script/src/module.ts
  • packages/script/src/runtime/composables/useScript.ts
  • packages/script/src/runtime/utils.ts
  • test/e2e/basic.test.ts
  • test/fixtures/basic/nuxt.config.ts
  • test/fixtures/basic/pages/consent-trigger.vue
  • test/nuxt-runtime/npm-script-consent.nuxt.test.ts
  • test/unit/leaflet-registry.test.ts
  • test/unit/maplibre-registry.test.ts
  • test/unit/registry-readiness.test.ts
  • test/unit/speedcurve-primer.test.ts
  • test/unit/utils.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.



📝 Walkthrough

Walkthrough

Registry script options now remove trigger: false from runtime defaults while retaining other options. When a script is already registered and a caller omits a trigger, runtime registration selects a manual trigger. The guide documents trigger behavior for reused scripts. New fixtures and tests cover consent, infrastructure-only, manual, explicit-trigger, and shared PostHog consumers.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes


Merge Risk: ⚪ Minimal · up to 51070

The reviewed changes have no identified issue requiring correction before merge; normal checks still apply.

Pre-merge checks | Passed 4 | Failed 1

❌ 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 11 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: preserving consent behavior when reusing script consumers.
Description check Passed The description directly explains the consent-loading issue, registry trigger behavior, intended fix, and related issue. It is clearly related to the changeset.
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.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 11 files. (2 skipped: 2 unsupported.)


  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@harlan-zw harlan-zw added the harlan-agent-running An Agent holds a Task on this issue or pull request right now. label Oct 12, 2026
@harlan-zw

harlan-zw commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator Author

🤖 MERGED

Harlan Agent Kit posted this automated review. It is not Harlan's personal review or approval. AI open source policy. Last updated: 2026-10-12 14:15 UTC.

GitHub merged this pull request.

No material findings were recorded.

Cancelled from the dashboard.

@harlan-zw harlan-zw removed the harlan-agent-running An Agent holds a Task on this issue or pull request right now. label Oct 12, 2026
@harlan-zw
harlan-zw merged commit e2100bb into main Oct 12, 2026
16 checks passed
@harlan-zw
harlan-zw deleted the fix/registry-consent-trigger-reuse branch October 12, 2026 14:03
@harlan-zw harlan-zw removed the harlan-agent-review-required Pull request triage requires an adversarial Review for this head commit. label Oct 12, 2026

This branch was successfully deployed

1 active deployment
Preview — 51070ac7 Deployed Oct 12, 2026 by vercel[bot]
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