-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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(nuxt): namespace global variables for multi-app support #27263
base: main
Are you sure you want to change the base?
feat(nuxt): namespace global variables for multi-app support #27263
Conversation
Run & review this pull request in StackBlitz Codeflow. |
f30a78c
to
b2ff8da
Compare
@@ -50,6 +50,7 @@ export default defineNuxtPlugin({ | |||
} | |||
Object.assign(nuxtApp.payload, await nuxtApp.runWithContext(getNuxtClientPayload)) | |||
// For backwards compatibility - TODO: remove later |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still wondering if we have to set the payload here / why it was marked for compat only?
b2ff8da
to
2c3f046
Compare
@@ -409,6 +409,7 @@ export const nuxtConfigTemplate: NuxtTemplate = { | |||
`export const vueAppRootContainer = ${ctx.nuxt.options.app.rootId ? `'#${ctx.nuxt.options.app.rootId}'` : `'body > ${ctx.nuxt.options.app.rootTag}'`}`, | |||
`export const viewTransition = ${ctx.nuxt.options.experimental.viewTransition}`, | |||
`export const appId = ${JSON.stringify(ctx.nuxt.options.appId)}`, | |||
`export const multiApp = ${!!ctx.nuxt.options.future.multiApp}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that there are better and more explicit for this variable, eg: runningMultipleApp
, usingMultipleApp
.
Imo the current name is easy to be misleading to end users, and maybe also module developers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. runningMultiApp
sounds good to me. What do you think?
🔗 Linked issue
2nd task of #21635. Also linked to #25336 although it doesn't completely remove
window.__NUXT__
.📚 Description
This PR updates
window.__NUXT__
global variable to handle multi-app payloads and config by storing the data under theirappId
.Before:
After:
It also replaces scripts global IDs
__NUXT_DATA__
and__NUXT_LOGS__
with data attributes:Before:
After:
This will eventually allows the use of multiple Nuxt applications on a same page.
📝 To do:
future
/experimental
flagwindow.__NUXT__
update innuxt/test-utils
. See feat: add multi-app support for global var__NUXT__
test-utils#858