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:
German Khokhlov committed 2026-10-16 19:30:23 +04:00
1 parent ae52695b15
commit d483e5897e
8 files changed
+209 -11

No files matched your search

+23 -3
View File
@@ -42,8 +42,28 @@ export function checkMainChunk(
};
}
/** gzip-9 size of the largest dist/assets/index-*.js, with its name. */
export function measureMainChunk(distDir) {
/**
* gzip-9 size of the main chunk, with its name: the entry the built page
* loads (`entry`, or found from dist/index.html or the Vite manifest), else
* (phase 4's rule, for a dist without a page) the largest
* dist/assets/index-*.js.
*/
export function measureMainChunk(distDir, { entry = null } = {}) {
let file = entry;
if (!file) {
try {
file = findEntry(distDir).entry;
} catch {
file = null;
}
}
if (file) {
const bytes = fs.readFileSync(path.join(distDir, file));
return {
name: path.basename(file),
gzipBytes: gzipSync(bytes, { level: 9 }).length,
};
}
const assets = path.join(distDir, 'assets');
const candidates = fs
.readdirSync(assets)
@@ -113,7 +133,7 @@ function main() {
const baselinePath = path.join(ROOT, 'scripts/main-chunk-baseline.json');
let budget = null;
if (fs.existsSync(baselinePath)) {
const measured = measureMainChunk(dist);
const measured = measureMainChunk(dist, { entry: composition.entry });
budget = {
...measured,
...checkMainChunk(
+4 -1
View File
@@ -1082,5 +1082,8 @@
"src/globe/navara/picking.test.mjs",
"src/data/selectionDispatcher.test.mjs",
"src/globe/navara/cascadedLightCopy.test.mjs",
"src/tooling/w1Feeds.test.mjs"
"src/tooling/w1Feeds.test.mjs",
"src/tooling/navaraDependencies.test.mjs",
"build/navaraDependencies.js",
"build/initialChunkGuard.js"
]