Skip to content

fix: npm-mode registry scripts stored at $$scripts instead of $scripts#623

Merged
harlan-zw merged 1 commit intonuxt:mainfrom
zizzfizzix:fix/npm-mode-scripts-double-dollar-sign
Mar 4, 2026
Merged

fix: npm-mode registry scripts stored at $$scripts instead of $scripts#623
harlan-zw merged 1 commit intonuxt:mainfrom
zizzfizzix:fix/npm-mode-scripts-double-dollar-sign

Conversation

@zizzfizzix
Copy link
Contributor

Summary

  • Fixes a bug where npm-mode registry scripts (e.g. PostHog) were silently stored at nuxtApp.$$scripts instead of nuxtApp.$scripts, making them inaccessible via the typed API

Root Cause

Nuxt's plugin provide mechanism automatically prepends $ to every key. The generated plugin was returning { provide: { $scripts: ... } } — with an explicit $ already in the key — causing Nuxt to double it to $$scripts.

Fix

Remove the extra $ from the generated provide key (Option A as suggested by @harlan-zw):

- return { provide: { $scripts: { ... } } }
+ return { provide: { scripts: { ... } } }

Nuxt's provide then adds $$scripts

No type changes needed — the type declaration already correctly declares NuxtApp.$scripts.

Closes #622

…ipts

Nuxt's plugin `provide` mechanism automatically prepends `$` to every key
returned from a plugin's `provide` object. The generated plugin was returning
`{ provide: { $scripts: ... } }` — with an explicit `$` already in the key —
causing Nuxt to produce `$$scripts` instead of `$scripts`.

Fix: remove the extra `$` from the generated provide key so Nuxt produces the
correct `$scripts` property, matching both the CDN-mode path and the declared
types.

Fixes nuxt#622
@vercel
Copy link
Contributor

vercel bot commented Mar 4, 2026

@zizzfizzix is attempting to deploy a commit to the Nuxt Team on Vercel.

A member of the Team first needs to authorize it.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 4, 2026

Open in StackBlitz

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

commit: b7f704d

@coderabbitai
Copy link

coderabbitai bot commented Mar 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6edfdf89-232e-4971-8631-8f42a63ad8a9

📥 Commits

Reviewing files that changed from the base of the PR and between 52556ef and 7a7cfe2.

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

📝 Walkthrough

Walkthrough

The change corrects a bug where npm-mode registry scripts were inaccessible via the typed API. The template plugin's provide key is modified from $scripts to scripts, allowing Nuxt's provide() mechanism to automatically prepend the $ prefix and produce the correct $scripts property. Previously, the double-prefixing resulted in scripts being stored at $$scripts, making them unreachable through the intended nuxtApp.$scripts interface. This is a one-line modification with no logic or error-handling changes.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 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%. 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 accurately describes the main change: fixing the bug where scripts are stored at $$scripts instead of $scripts by removing the extra $ from the provide key.
Description check ✅ Passed The description covers the main required sections: it explains the bug, root cause, and fix with code diff. It properly follows the template with type of change identified and linked issue referenced.
Linked Issues check ✅ Passed The PR successfully implements Option A from issue #622 by removing the extra $ from the provide key, changing { provide: { $scripts: ... } } to { provide: { scripts: ... } }, which fixes the double-$ bug.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing issue #622. The single modification to src/templates.ts (changing the provide key from $scripts to scripts) is entirely related to the stated objective with no extraneous alterations.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

@harlan-zw
Copy link
Collaborator

Looks like some CI issues but happy to merge and I'll fix these up myself. Thanks!

@harlan-zw harlan-zw merged commit 3163bad into nuxt:main Mar 4, 2026
3 of 5 checks passed
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.

npm-mode registry scripts stored at $$scripts instead of $scripts, making them inaccessible via the typed API

2 participants