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

feat: allow multiple nuxt in a single process #30510

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

huang-julien
Copy link
Member

@huang-julien huang-julien commented Jan 9, 2025

🔗 Linked issue

unblocked by nitrojs/nitro#2983 ❤️
fix nuxt/test-utils#537
fix nuxt/test-utils#1034
resolve nuxt/test-utils#664
fix #22565

📚 Description

This PR allows to create multiple Nuxt instance within a single process.

We were previously setting a Nuxt Singleton with unctx. This means that we can only run a single Nuxt instance in a single process.

By using asyncLocalStorage, we'll be able to track an unique id for each buildNuxt and initNuxt -> allowing to run these in parallel and all useNuxt() within it. It also convert nuxtCtx to be a getter so it retrieves the correct namespace with ASyncLocalStorage

For backward compatibility, we'll keep a fallback global singleton of the first Nuxt instance that is being set. This behavior will be removed in V4 or V5. We can also add a .run on the Nuxt instance in Nuxt 4.

next step: merge all nuxt test within a single job

Copy link

stackblitz bot commented Jan 9, 2025

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link

socket-security bot commented Jan 9, 2025

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/unstorage@1.14.4 Transitive: environment, filesystem +10 1.29 MB pi0

View full report↗︎

@huang-julien
Copy link
Member Author

/ecosystem-ci run

@nuxt-ecosystem-ci
Copy link

📝 Ran ecosystem CI on 0b4781e: Open

suite result latest scheduled
content failure success
ui failure failure
image failure success
pinia failure success
examples failure success
bridge failure success
vite-pwa failure success
docus failure success
og-image failure success
histoire failure failure
elk failure failure
devtools failure failure
fonts failure failure
scripts failure success
icon failure success
test-utils failure success
module-builder failure success
sanity-module failure success
sitemap failure success
i18n-module failure success
werewolves-assistant failure failure
storybook failure failure

starter, example-layers-monorepo, nuxt-com, cli, tailwindcss

@huang-julien
Copy link
Member Author

ecosystem ci fails due to typecheck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant