fix: provide SpeedCurve snippet fallback#811
Conversation
|
@sjh9714 is attempting to deploy a commit to the Nuxt Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughThis PR resolves a build failure where unregistered SpeedCurve configuration caused the runtime to import a non-existent virtual module. The fix ensures the virtual module always emits: with empty content when SpeedCurve is unregistered, or with actual LUX snippet when registered. A runtime guard prevents initialization if the snippet is missing. Documentation now reflects the opt-in behavior and new fallback strategy. A test fixture validates behavior in the unregistered scenario. Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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. 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)
packages/script/src/runtime/registry/speedcurve.ts (1)
5-11:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winUpdate outdated comment to reflect new fallback behavior.
The comment states that non-registered users "hit a build error from the unresolved virtual," but after this PR the virtual module is always emitted with an empty fallback. The comment should reflect the current behavior.
📝 Proposed update
-// Virtual: emitted by the Nuxt module only when `speedcurve` is registered in -// `scripts.registry`. Contents inline the LUX primer resolved from the -// user-installed `@speedcurve/lux` peer dep at build time. Non-registered -// users hit a build error from the unresolved virtual; registered users -// without the peer dep get an install hint when the export is read. +// Virtual: always emitted by the Nuxt module. When `speedcurve` is registered +// in `scripts.registry`, contents inline the LUX primer resolved from the +// user-installed `@speedcurve/lux` peer dep at build time. When unregistered, +// exports an empty string fallback. Registered users without the peer dep get +// a build error with an install hint.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/script/src/runtime/registry/speedcurve.ts` around lines 5 - 11, Update the top-of-file comment in packages/script/src/runtime/registry/speedcurve.ts to reflect that the virtual module '`#build/nuxt-scripts-speedcurve-snippet`' is always emitted and now provides an empty fallback when the peer dependency is missing (so non-registered users no longer get a build error); locate the comment block above the import of luxSnippetSource and replace the sentence claiming non-registered users "hit a build error from the unresolved virtual" with text stating the virtual is always emitted with an empty fallback and registered users without the peer dep receive an install hint when the export is read.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@packages/script/src/runtime/registry/speedcurve.ts`:
- Around line 5-11: Update the top-of-file comment in
packages/script/src/runtime/registry/speedcurve.ts to reflect that the virtual
module '`#build/nuxt-scripts-speedcurve-snippet`' is always emitted and now
provides an empty fallback when the peer dependency is missing (so
non-registered users no longer get a build error); locate the comment block
above the import of luxSnippetSource and replace the sentence claiming
non-registered users "hit a build error from the unresolved virtual" with text
stating the virtual is always emitted with an empty fallback and registered
users without the peer dep receive an install hint when the export is read.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2952dc96-9415-4452-b14c-2e65641b174a
📒 Files selected for processing (4)
docs/content/scripts/speedcurve.mdpackages/script/src/module.tspackages/script/src/runtime/registry/speedcurve.tstest/fixtures/basic/pages/tpc/speedcurve-unregistered.vue
|
Thanks :) |
Summary
Fixes #810.
useScriptSpeedCurvecan now be imported in apps that have not registeredscripts.registry.speedcurvebecause the module always emits#build/nuxt-scripts-speedcurve-snippet. Unregistered apps get an empty primer fallback; registered apps still resolve@speedcurve/luxand keep the install hint if it is missing.Changes
useScriptSpeedCurvewithout registry config.Testing
pnpm install --frozen-lockfilepnpm --filter @nuxt/scripts dev:preparepnpm exec nuxt preparepnpm exec nuxt build test/fixtures/basic(failed before the fix with unresolvednuxt-scripts-speedcurve-snippet; passes after)pnpm exec vitest run --project unit test/unit/speedcurve-primer.test.ts test/unit/speedcurve-config.test.ts test/unit/speedcurve-auto-tracker.test.tspnpm exec eslint packages/script/src/module.ts packages/script/src/runtime/registry/speedcurve.ts --max-warnings=0Verification gap:
pnpm exec nuxt build test/fixtures/speedcurvereached client/server/Nitro build, then failed with a local macOSENAMETOOLONGscanning Nitro output under this long workspace path.Note: I used Codex while preparing this change, reviewed the final diff, and ran the listed checks locally.