use custom plotly bundle to reduce file size#3364
use custom plotly bundle to reduce file size#3364mashehu wants to merge 1 commit intoMultiQC:mainfrom
Conversation
generated following instructions in https://github.com/plotly/plotly.js/blob/master/CUSTOM_BUNDLE.md and the command `npm run custom-bundle -- --traces bar,scatter,table,violin,heatmap,box`
|
ooh amazing! 🤩 That's a signifiant improvement, thank you for finding this! Any chance I can be cheeky and ask for a version of this PR against the |
|
Apologies, looks like I'm still including the plotly source in that branch - haven't yet gotten around to making it part of the build script. But it's the intention to do that with all / as many of the JS deps as possible. |
|
Claude says that it might be possible to include plotly as an npm dependency in the new build system, then do something like the following as an alternative to import Plotly from 'plotly.js/lib/core';
import Bar from 'plotly.js/lib/bar';
import Scatter from 'plotly.js/lib/scatter';
import Table from 'plotly.js/lib/table';
import Violin from 'plotly.js/lib/violin';
import Heatmap from 'plotly.js/lib/heatmap';
import Box from 'plotly.js/lib/box';
Plotly.register([Bar, Scatter, Table, Violin, Heatmap, Box]);
export default Plotly;
Not sure if this'd work or not, but if it does that feels nice and simple - no need to clone the Plotly repo as a dependency or anything, can just run |
|
From what i gathered, treeshaking is not working for plotly, that's why we need the bundling. |
This reduces the file size 3.4MB to 1.1MB (which is 0.3MB smaller than the pre-bundled plotlyjs-cartesion
The bundle file was generated following instructions in https://github.com/plotly/plotly.js/blob/master/CUSTOM_BUNDLE.md and the command
npm run custom-bundle -- --traces bar,scatter,table,violin,heatmap,box(this covers all plot types listed in https://docs.seqera.io/multiqc/development/plots (with linechart being a subtype of scatter in plotly)The jump to 3.12 shouldn't include any breaking changes for MultiQC: https://github.com/plotly/plotly.js/blob/master/CHANGELOG.md#300----2025-01-27