Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nuxt): avoid recursive import in nitro renderer #18948

Merged
merged 2 commits into from
Feb 10, 2023

Conversation

pi0
Copy link
Member

@pi0 pi0 commented Feb 10, 2023

πŸ”— Linked issue

resolves #18789

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Nuxt renderer.ts depending on #internal/nitro exporting both useNitroApp (from nitro/runtime/app) and defineRenderHandler (from nitro/runtime/renderer which is ALSO depending on runtime/app). This makes a recusive dependency which rollup was supposed to solve, but well, it doesn't for time being :}

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codesandbox
Copy link

codesandbox bot commented Feb 10, 2023

CodeSandbox logoCodeSandbox logoΒ  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

Copy link
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

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

This looks good to me.

One comment: within nuxt we are now bound to the file structure of nitro despite the #internal prefix, which means we probably need to use a ~ constraint for nitropack unless we can guarantee not to change this structure until the next major release.

A second concern about this warning more generally - what about auto-imports for useNitroApp (or Nuxt composables from #app) - could that cause this to fail, again, in an end-user project, in certain situations? Options to consider:

  • Auto-importing instead from the specific file rather than the index.
  • Bundling some runtime directories into a single file.

wdyt?

@pi0
Copy link
Member Author

pi0 commented Feb 10, 2023

I tested, it won't happen for user-land usecases. Both auto-imported useNitroApp and importing from #imports works fine (nitro has fallbacked #imports too with auto imports disabled).

#internal/app is safe but we should indeed think to switch to #imports once was sure is safe enough. It also gives typescript features.

@danielroe danielroe added this pull request to the merge queue Feb 10, 2023
Merged via the queue into main with commit 7111b6c Feb 10, 2023
@danielroe danielroe deleted the fix/nitro-recursive-dep branch February 10, 2023 16:33
@danielroe danielroe mentioned this pull request Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Circular dependency in nuxt with nitropack
2 participants