vite: actually split the renderer into its own chunk

The existing manualChunks rule had a bug: every renderer-related check
sat INSIDE `if(id.includes('node_modules'))`, but the renderer source
is consumed via filesystem alias to ../Nitro_Render_V3/packages/*/src
— it is not under node_modules. So the `Nitro_Render_V3` branch never
fired, and the entire renderer (~1MB+) ended up merged into the main
app chunk instead of its own nitro-renderer-*.js.

Move the renderer-path check BEFORE the node_modules guard and base
it on either the literal "Nitro_Render_V3" segment or the resolved
rendererRoot (whichever is in use). The node_modules branch still
handles the unlikely case that someone publishes the renderer as a
real npm package later.

Result expected on yarn build:
- one nitro-renderer-*.js chunk for renderer + pixi (pixi is aliased
  to rendererRoot/node_modules/pixi.js, so its id will include
  rendererRoot too)
- one vendor-*.js chunk for third-party deps from node_modules
- one src-*.js (or similar) chunk for the app

This makes the first paint of the app faster (browser can parallel-
download chunks) and lets the CDN cache the renderer between deploys
where only the client code changed.

No behavior change at runtime — just a different on-disk layout.
This commit is contained in:
simoleo89
2026-05-12 09:00:56 +00:00
parent 35b8493696
commit 45620cab15
+7 -1
View File
@@ -84,9 +84,15 @@ export default defineConfig({
assetFileNames: 'src/assets/[name]-[hash].[ext]', assetFileNames: 'src/assets/[name]-[hash].[ext]',
manualChunks: id => manualChunks: id =>
{ {
// Renderer source is consumed via filesystem alias
// (../Nitro_Render_V3/packages/*/src) so it is NOT
// under node_modules — needs its own branch before
// the node_modules check.
if(id.includes('Nitro_Render_V3') || id.includes(`${ rendererRoot }`)) return 'nitro-renderer';
if(id.includes('node_modules')) if(id.includes('node_modules'))
{ {
if(id.includes('@nitrots/nitro-renderer') || id.includes('renderer3') || id.includes('Nitro_Render_V3')) return 'nitro-renderer'; if(id.includes('@nitrots/nitro-renderer') || id.includes('renderer3')) return 'nitro-renderer';
return 'vendor'; return 'vendor';
} }