mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(nuxt): allow resolving client nuxt app to singleton (#20639)
This commit is contained in:
parent
ddbb847979
commit
1da25c8069
@ -53,7 +53,11 @@ if (process.client) {
|
||||
import.meta.webpackHot.accept()
|
||||
}
|
||||
|
||||
// eslint-disable-next-line
|
||||
let vueAppPromise: Promise<any>
|
||||
|
||||
entry = async function initApp () {
|
||||
if (vueAppPromise) { return vueAppPromise }
|
||||
const isSSR = Boolean(
|
||||
window.__NUXT__?.serverRendered ||
|
||||
document.getElementById('__NUXT_DATA__')?.dataset.ssr === 'true'
|
||||
@ -79,9 +83,11 @@ if (process.client) {
|
||||
await nuxt.callHook('app:error', err)
|
||||
nuxt.payload.error = (nuxt.payload.error || err) as any
|
||||
}
|
||||
|
||||
return vueApp
|
||||
}
|
||||
|
||||
entry().catch((error: unknown) => {
|
||||
vueAppPromise = entry().catch((error: unknown) => {
|
||||
console.error('Error while mounting app:', error)
|
||||
})
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ describe.skipIf(isWindows || process.env.TEST_BUILDER === 'webpack' || process.e
|
||||
|
||||
it('default client bundle size', async () => {
|
||||
stats.client = await analyzeSizes('**/*.js', publicDir)
|
||||
expect(roundToKilobytes(stats.client.totalBytes)).toMatchInlineSnapshot('"94.1k"')
|
||||
expect(roundToKilobytes(stats.client.totalBytes)).toMatchInlineSnapshot('"94.2k"')
|
||||
expect(stats.client.files.map(f => f.replace(/\..*\.js/, '.js'))).toMatchInlineSnapshot(`
|
||||
[
|
||||
"_nuxt/entry.js",
|
||||
|
Loading…
Reference in New Issue
Block a user