From 13aae836e81a048948e5f5ed0553d1f34ca98b52 Mon Sep 17 00:00:00 2001 From: Edward Hibbert Date: Sat, 10 Jun 2023 10:11:26 +0100 Subject: [PATCH] perf(nuxt): import error component synchronously (#21406) --- packages/nuxt/src/app/components/nuxt-root.vue | 2 +- test/bundle.test.ts | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/nuxt/src/app/components/nuxt-root.vue b/packages/nuxt/src/app/components/nuxt-root.vue index 7dbac43d2e..08a9fc669e 100644 --- a/packages/nuxt/src/app/components/nuxt-root.vue +++ b/packages/nuxt/src/app/components/nuxt-root.vue @@ -13,8 +13,8 @@ import { useNuxtApp } from '#app/nuxt' import { isNuxtError, showError, useError } from '#app/composables/error' import { useRoute } from '#app/composables/router' import AppComponent from '#build/app-component.mjs' +import ErrorComponent from '#build/error-component.mjs' -const ErrorComponent = defineAsyncComponent(() => import('#build/error-component.mjs').then(r => r.default || r)) const IslandRenderer = process.server ? defineAsyncComponent(() => import('./island-renderer').then(r => r.default || r)) : () => null diff --git a/test/bundle.test.ts b/test/bundle.test.ts index a328b6381c..f601691038 100644 --- a/test/bundle.test.ts +++ b/test/bundle.test.ts @@ -25,18 +25,17 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM it('default client bundle size', async () => { stats.client = await analyzeSizes('**/*.js', publicDir) - expect(roundToKilobytes(stats.client.totalBytes)).toMatchInlineSnapshot('"98.5k"') + expect(roundToKilobytes(stats.client.totalBytes)).toMatchInlineSnapshot('"97.1k"') expect(stats.client.files.map(f => f.replace(/\..*\.js/, '.js'))).toMatchInlineSnapshot(` [ "_nuxt/entry.js", - "_nuxt/error-component.js", ] `) }) it('default server bundle size', async () => { stats.server = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir) - expect(roundToKilobytes(stats.server.totalBytes)).toMatchInlineSnapshot('"62.9k"') + expect(roundToKilobytes(stats.server.totalBytes)).toMatchInlineSnapshot('"61.8k"') const modules = await analyzeSizes('node_modules/**/*', serverDir) expect(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"2286k"')