react
react copied to clipboard
P5-wrapper size
Linked to this I think, not an issue with the wrapper.
https://github.com/processing/p5.js/issues/1734#issuecomment-390380630
Originally posted by @subodhpareek18 in https://github.com/P5-wrapper/react/issues/26#issuecomment-451716657
I reviewed the above issue in P5 proper, and still have some questions:
- is p5-wrapper using the minified version of the p5 library as a dependency?
- if so, is it also including p5-sound as a dependency?
- this library has a problem, in that it includes the unminified P5 library (see issue link)
- if 1 & 2 are true, then can't p5-wrapper be split into (a) p5-wrapper; (b) p5-sound-wrapper, such that including (a) doesn't bloat the dependency if (b) isn't included as well?
@yevdyko can you take a look into this, maybe the imported values should be updated.
Thanks @JeffML for the topic. If it's something we can change or brings benefits, we will! Appreciate it.
@jamesrweb sure thing, I will check the bundle sizes to see if it can apply to us, and thanks for pointing that out @JeffML
@yevdyko any updates here?
I looked into this issue and the outcome is:
p5does use the minified version by default in the current version at least (didn't check others)- The minified version is 1,029.38 kB by default and 260.21 kB when gzipped
- We could reduce upfront load by using
React.lazyand more aggressive code-splitting in thevitebuild but in my testing this only saved less than 0.5% of the current bundle size and that took quite a bit of configuring to do. Not sure if it is worth the future administration for such little gain. I will consider it.
So to answer the original questions from @JeffML:
- Yes, by default from
p5themselves, in the upstream dependency. - Not unless you import it yourself and there is also a
p5/lib/addons/p5.sound.minfile available for import also FYI. - No since we rely on the upstream
p5dependency and since they usep5/lib/p5.minby default as the main entrypoint, we are already using the minified version. We don't use sound or other plugins and so optimization routes for us are either further code-splitting of the internal components (but these are already extremely small) or applying fixes upstream which depends on thep5maintainers.
Anyway, closing this issue for now. Thanks for raising the issue, it was interesting to look into 😄.
@jamesrweb Moreover, after releasing a new version of the package in #325, where p5 moved to a peer dependency, this becomes irrelevant to the package itself. Which seems like the right solution to me.