fix(cloudflare): use explicit imports in dev plugin instead of #imports#4009
Open
vinayakkulkarni wants to merge 1 commit intonitrojs:v2from
Open
fix(cloudflare): use explicit imports in dev plugin instead of #imports#4009vinayakkulkarni wants to merge 1 commit intonitrojs:v2from
#imports#4009vinayakkulkarni wants to merge 1 commit intonitrojs:v2from
Conversation
…rts` The cloudflare dev plugin (`plugin.dev.ts`) imports `useRuntimeConfig` and `getRequestURL` from `#imports`, which is a virtual module that depends on Nitro's auto-import system being enabled. When used with Nuxt's `compatibilityVersion: 5` (which sets `nitroAutoImports: false` by default), the `#imports` virtual module is never created, causing the dev server to fail with: Error: Could not load .nuxt/imports (imported by nitropack/dist/presets/cloudflare/runtime/plugin.dev.mjs): ENOENT: no such file or directory Replace `#imports` with explicit imports from `nitropack/runtime` and `h3`, consistent with how `defineNitroPlugin` is already imported from `nitropack/runtime` in other runtime files. Closes nuxt/nuxt#34282
|
@vinayakkulkarni is attempting to deploy a commit to the Nitro Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
✨ 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Cloudflare dev plugin (
plugin.dev.ts) importsuseRuntimeConfigandgetRequestURLfrom#imports, which is a virtual module that depends on Nitro's auto-import system being enabled.When used with Nuxt's
compatibilityVersion: 5(which setsnitroAutoImports: falseby default), the#importsvirtual module is never created, causing the dev server to fail:Root Cause
compatibilityVersion: 5defaultsnitroAutoImportstofalse(source)imports: falseto Nitro, disabling the unimport system entirely#importsvirtual module (nitro.options.virtual["#imports"]) relies onnitro.unimport?.toExports()which returns empty or is never registered#imports— all other 50+ preset plugins don't use itFix
Replace
#importswith explicit imports fromnitropack/runtimeandh3, consistent with how other Nitro runtime files already import these utilities:Also updated
NitroAppPlugintype import from"nitropack"to"nitropack/types"for consistency with other runtime files (e.g.,src/runtime/internal/plugin.ts).Reproduction
#importswithcompatibilityVersion: 5+compatibilityDate: 'latest'nuxt/nuxt#34282Minimal config that triggers the bug (all three required):
Workaround (until this fix is released):
Closes nuxt/nuxt#34282