[sparkle] Add minification on sparkle cjs code #10263
Draft
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.
Description
This is compressing the generated cjs for sparkle, which is used in next server-side and front-worker.
In the end it reduces by about 10Mb the memory footprint of sparkle. The problem is that the sources of all modules are loaded in memory by node for debugging purpose, and I did not find a way to disable this.
Note that sparkle.cjs is embedding all dependencies, and some are huge :
elkjs - 1.61 MB (14.48%)
mermaid - 1.51 MB (13.62%)
highlight.js - 1.37 MB (12.36%)
cytoscape - 954.15 kB (8.60%)
app - 654.04 kB (5.90%)
lottie-web - 627.79 kB (5.66%)
katex - 604.82 kB (5.45%)
@emoji-mart/data - 410.63 kB (3.70%)
parse5 - 275.85 kB (2.49%)
lodash-es - 184.47 kB (1.66%)
emoji-mart - 162.72 kB (1.47%)
@tanstack/table-core - 138.71 kB (1.25%)
dagre-d3-es - 119.51 kB (1.08%)
micromark-core-commonmark - 118.89 kB (1.07%)
layout-base - 117.75 kB (1.06%)
Most of them are probably not needed on server side anyway.
Tests
Risk
Minimal - we're just minifying and removing source maps.
Deploy Plan
publish sparkle, update front