From 86a719b3bc697afef98f475a4dc207b618b99e8b Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 29 Jul 2026 16:35:27 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20one=20chunk=20=F0=9F=98=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nuxt.config.ts | 26 +++++++++++++------------- test/unit/bundle.spec.ts | 5 ++--- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/nuxt.config.ts b/nuxt.config.ts index 7a2f97db..8a4272fe 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -267,19 +267,19 @@ export default defineNuxtConfig({ modulePreload: { polyfill: false, }, - rollupOptions: { - output: { - // Merge modules shared between the entry and lazy chunks into a - // single chunk (excluding /admin js) - advancedChunks: { - groups: [ - { - name: 'shared', - minShareCount: 2, - test: (id: string) => - !/[\\/](?:app[\\/](?:components|pages)[\\/]admin|shared[\\/](?:lex|cms)|node_modules[\\/](?:@formkit|@atproto|@atcute|multiformats|gsap|mediabunny|modern-screenshot))[\\/]/.test(id), - }, - ], + }, + $client: { + build: { + rollupOptions: { + output: { + codeSplitting: { + groups: [ + { + name: 'shared', + tags: ['$initial'], + }, + ], + }, }, }, }, diff --git a/test/unit/bundle.spec.ts b/test/unit/bundle.spec.ts index 6d60a04b..b14b2f46 100644 --- a/test/unit/bundle.spec.ts +++ b/test/unit/bundle.spec.ts @@ -55,7 +55,7 @@ describe('project sizes', () => { expect .soft(roundToKilobytes(stats.client.totalBytes)) - .toMatchInlineSnapshot(`"288k"`) + .toMatchInlineSnapshot(`"284k"`) expect.soft(stats.client.files.map(f => f.replace(/\..*\.js/, '.js')).sort()) .toMatchInlineSnapshot(` [ @@ -88,7 +88,6 @@ describe('project sizes', () => { "_nuxt/ProseUl.js", "_nuxt/SocialPost.js", "_nuxt/entry.js", - "_nuxt/shared.js", ] `) }) @@ -97,7 +96,7 @@ describe('project sizes', () => { stats.server = await analyzeSizes(['**/*.mjs', '!node_modules'], serverDir) expect .soft(roundToKilobytes(stats.server.totalBytes, 10)) - .toMatchInlineSnapshot(`"2970k"`) + .toMatchInlineSnapshot(`"2980k"`) const modules = await analyzeSizes('node_modules/**/*', serverDir) expect -- 2.51.2