Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8323220

Browse files
committed
perf(nuxt): tree shake island renderer
1 parent 260d468 commit 8323220

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/nuxt/src/app/components/nuxt-root.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,10 @@ import { useRoute, useRouter } from '../composables/router'
2424
import { PageRouteSymbol } from '../components/injections'
2525
import AppComponent from '#build/app-component.mjs'
2626
import ErrorComponent from '#build/error-component.mjs'
27+
// @ts-expect-error virtual file
28+
import { componentIslands } from '#build/nuxt.config.mjs'
2729
28-
const IslandRenderer = import.meta.server
30+
const IslandRenderer = import.meta.server && componentIslands
2931
? defineAsyncComponent(() => import('./island-renderer').then(r => r.default || r))
3032
: () => null
3133

test/bundle.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM
3232
const serverDir = join(rootDir, '.output/server')
3333

3434
const serverStats = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir)
35-
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot('"205k"')
35+
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot('"204k"')
3636

3737
const modules = await analyzeSizes('node_modules/**/*', serverDir)
3838
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"1335k"')
@@ -72,7 +72,7 @@ describe.skipIf(process.env.SKIP_BUNDLE_SIZE === 'true' || process.env.ECOSYSTEM
7272
const serverDir = join(rootDir, '.output-inline/server')
7373

7474
const serverStats = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir)
75-
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot('"524k"')
75+
expect.soft(roundToKilobytes(serverStats.totalBytes)).toMatchInlineSnapshot('"523k"')
7676

7777
const modules = await analyzeSizes('node_modules/**/*', serverDir)
7878
expect.soft(roundToKilobytes(modules.totalBytes)).toMatchInlineSnapshot('"78.0k"')

0 commit comments

Comments
 (0)