mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 00:02:25 +00:00
build: the initial-chunk guard covers Navara's whole dependency closure
Review of Task 0: - build/navaraDependencies.js reads the dependency closure of @navaramap/three and @navaramap/three-default-plugin from node_modules (dependencies and peers) and drops what the app's other bundled dependencies reach too (Cesium is served as a script, so draco3d, which only Cesium shares, stays engine-only), plus three and postprocessing: 88 packages today (the @navaramap/* packages, @takram/*, @react-three/ fiber, @sparkjsdev/spark, astronomy-engine, d3*, draco3d, n8ao, three-stdlib, …). The browser build's initialChunkGuard fails on a module from any of them in an initial chunk. Tested on a fixture tree. - check-main-chunk's budget measures the entry the page loads (the same chunk the composition check reads), falling back to phase 4's largest index-*.js only for a dist without a page. Build clean: no Navara-only module in the initial chunks; main chunk 2,869,565 bytes (gzip 889,041).
This commit is contained in:
1 parent
ae52695b15
commit
d483e5897e
8 files changed
+209
-11
No files matched your search
@@ -5,7 +5,11 @@
|
||||
// (what Rollup put in each chunk), and fails the build otherwise;
|
||||
// scripts/check-main-chunk.mjs checks the built files' text as well.
|
||||
|
||||
/** Module ids that only the Navara engine may load. */
|
||||
/**
|
||||
* Module ids that only the Navara engine may load, when no package list is
|
||||
* given (the browser build passes the full dependency closure,
|
||||
* navaraDependencies.js).
|
||||
*/
|
||||
export const ENGINE_ONLY_MODULES =
|
||||
/[\\/]node_modules[\\/](?:three|@navaramap[\\/][^\\/]+|postprocessing)[\\/]/;
|
||||
|
||||
@@ -32,21 +36,24 @@ export function initialChunkViolations(bundle, pattern = ENGINE_ONLY_MODULES) {
|
||||
}
|
||||
|
||||
/** The Rollup plugin: fails generateBundle when an initial chunk holds three or Navara. */
|
||||
export function initialChunkGuard({ log = console.log } = {}) {
|
||||
export function initialChunkGuard({
|
||||
log = console.log,
|
||||
pattern = ENGINE_ONLY_MODULES,
|
||||
} = {}) {
|
||||
return {
|
||||
name: 'gev-initial-chunk-guard',
|
||||
generateBundle(_options, bundle) {
|
||||
const violations = initialChunkViolations(bundle);
|
||||
const violations = initialChunkViolations(bundle, pattern);
|
||||
if (violations.length) {
|
||||
this.error(
|
||||
'three/Navara in the Cesium-mode initial chunks:\n' +
|
||||
'Navara-only modules in the Cesium-mode initial chunks:\n' +
|
||||
violations
|
||||
.map(({ chunk, module }) => ` ${chunk}: ${module}`)
|
||||
.join('\n'),
|
||||
);
|
||||
return;
|
||||
}
|
||||
log('[initial-chunks] no three or Navara modules in the initial chunks');
|
||||
log('[initial-chunks] no Navara-only modules in the initial chunks');
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user