perf(build): cut npm run build RAM, time, and output size - #769
Open
SudoThijn wants to merge 1 commit into
Open
Conversation
Apply the openregister PR #108 build-performance fixes to opencatalogi: - Minify with esbuild (TerserPlugin.esbuildMinify, parallel:false, legalComments:'eof') instead of Terser. - Disable production source maps (a stray unconditional devtool='inline-source-map' was embedding base64 maps in every bundle). - Disable the in-memory build cache in production. - splitChunks vendor cacheGroup so node_modules is bundled once into a shared opencatalogi-vendor.js instead of duplicated across all 5 entries. - Emit js/opencatalogi-entrypoints.json and load it via the new ScriptManifestLoader so each entry pulls its split chunks in order, with a fallback to the legacy single-script name. - Fix a pre-existing build blocker: make the @nextcloud/dialogs alias exact (@nextcloud/dialogs$) so subpath imports like /style.css resolve via the package exports map. Result: build time 61.6s -> 13.6s, peak RAM 9.56GB -> 3.16GB, js/ output 162MB -> 23MB. Adds ScriptManifestLoaderTest covering all manifest fallback branches.
SudoThijn
requested review from
WilcoLouwerse,
bbrands02,
remko48 and
rjzondervan
as code owners
July 24, 2026 12:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ports the build-performance fixes from openregister PR #108 to opencatalogi.
Results
Clean production build (
npm run build), peak RAM sampled across the whole webpack process tree:js/output sizeWhat changed
webpack.config.jsTerserPlugin.esbuildMinify,parallel: false,legalComments: 'eof'). esbuild parallelises internally, so webpack-worker parallelism is disabled to avoid redundant Node processes.devtool = 'inline-source-map'unconditionally (a later override that beat theisDev ? … : …line), embedding base64 source maps into every bundle. Nowfalsein production — this accounts for most of the size drop.cache = falsein production — the in-memory cache is unused in a single-shot build and only added heap pressure.splitChunksvendor cacheGroup.node_moduleswas being bundled into all 5 entrypoints (each 54–92 MB). It now lands once in a sharedopencatalogi-vendor.js(18 MB), shrinking the per-entry chunks to KBs.js/opencatalogi-entrypoints.jsonmapping each entry to its ordered initial chunks (vendor → shared → entry).PHP (required so the shared vendor chunk loads before each entry)
lib/Service/ScriptManifestLoader.phpreads the manifest and enqueues each chunk viaUtil::addScript, falling back to the legacy single-script name when the manifest is absent.templates/index.php,templates/settings/admin.php, and the threelib/Dashboard/*Widget.phpfiles.tests/Unit/Service/ScriptManifestLoaderTest.phpcovering every manifest fallback branch (missing file, unknown entry, invalid JSON, non-array JSON, happy path).package.json— addsesbuildandterser-webpack-plugintodevDependencies.Drive-by fix
The committed config could not build locally at all: the
@nextcloud/dialogsalias lacked a$, making it a prefix alias that hijacked@nextcloud/dialogs/style.css→ a raw path bypassing the package'sexportsmap. Made it exact (@nextcloud/dialogs$), matching the other singleton aliases (vue$,pinia$,@nextcloud/vue$). The baseline numbers above were taken with this fix applied, so the comparison is apples-to-apples.Verification
npm run buildsucceeds; manifest andopencatalogi-vendor.jsemitted as expected.phpcs,phpstan,psalmclean on all changed PHP files.phpunit—ScriptManifestLoaderTest5/5 passing.Notes for reviewers
js/build output (including the manifest) is gitignored and produced fresh by CI.Duplicate key "euro"notice esbuild surfaces from a third-party dependency that Terser silently ignored.