Files
twenty/packages/twenty-website/scripts/check-visual-bundle.mjs
T
Abdullah. 569d887d1e [Website] Cut over to the rebuilt site (#21825)
Renaming the package so any further PRs directed to the website are
targeted to the reworked code instead of diverging. Once merged, I will
start preparing this for deployment to dev to test before releasing to
prod. Any improvements will also be applied to this package.

I avoided making significant changes to API routes so nothing breaks,
but will test it thoroughly today to confirm. That said, everything is
ported - double checked.

Big diff PR, impossible to review, but last one! No more rebuilds.
2026-06-19 10:22:46 +02:00

49 lines
1.5 KiB
JavaScript

import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
// The three chunk must never enter the initial bundle: rigs reach the heavy
// zones only through next/dynamic. This reads the production build manifest
// and fails if any initial chunk contains the three marker.
const packageRoot = path.join(
path.dirname(fileURLToPath(import.meta.url)),
'..',
);
const manifestPath = path.join(packageRoot, '.next', 'build-manifest.json');
if (!fs.existsSync(manifestPath)) {
console.error(
'check-visual-bundle: run `next build` first (.next/build-manifest.json missing).',
);
process.exit(1);
}
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
const initialChunks = new Set([
...(manifest.rootMainFiles ?? []),
...Object.values(manifest.pages ?? {}).flat(),
]);
const offending = [];
for (const chunk of initialChunks) {
if (!chunk.endsWith('.js')) continue;
const chunkPath = path.join(packageRoot, '.next', chunk);
if (!fs.existsSync(chunkPath)) continue;
const content = fs.readFileSync(chunkPath, 'utf8');
if (content.includes('WebGLRenderer') || content.includes('three.module')) {
offending.push(chunk);
}
}
if (offending.length > 0) {
console.error(
'check-visual-bundle: FAILED — three reached the initial bundle:',
);
for (const chunk of offending) console.error(` ${chunk}`);
process.exit(1);
}
console.log(
`check-visual-bundle: OK (${initialChunks.size} initial chunks, three absent)`,
);