refactor(build): Don't use closure-calculate-chunks

Rewrite the getChunkOptions function to not use
closure-calculate-chunks, but instead just chunk the input files
(more or less) by subdirectory: first chunk is core/, second is
blocks/, etc.

This does make a material change to blockly_compressed.js,
because we end up feeding several empty modules that contain
only typescript interface declarations and which tsc
compiles to "export {};" in the input to Closure Compiler
(closure-calculate-chunks is smart enough to notice that
no other module depends on these), which results in ~1.7KiB of
superflous

    var module$build$src$core$interfaces$i_ast_node_location_svg={};

declarations.  This can be avoided by filtering such empty modules
out but that has been left for a future commit.

This adds the glob NPM package as a dev dependency, but gulp
and several other existing dev dependencies already depend on
it.

Build time is sped up by about a factor of 3x, due to removal
of the buildDeps step that was really slow:

$ time npm run build

before:
real    0m24.410s
user    0m16.010s
sys     0m1.140s

after:
real    0m8.397s
user    0m11.976s
sys     0m0.694s
This commit is contained in:
Christopher Allen
2023-09-08 18:08:32 +01:00
parent 9390796e83
commit fc18cbdad8
3 changed files with 348 additions and 658 deletions

View File

@@ -76,12 +76,12 @@
"@wdio/selenium-standalone-service": "^8.0.2",
"async-done": "^2.0.0",
"chai": "^4.2.0",
"closure-calculate-chunks": "^3.0.2",
"concurrently": "^8.0.1",
"eslint": "^8.4.1",
"eslint-config-google": "^0.14.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-jsdoc": "^46.2.6",
"glob": "^10.3.4",
"google-closure-compiler": "^20230802.0.0",
"google-closure-deps": "^20230502.0.0",
"gulp": "^4.0.2",