Reduce bundle size: package with rollup; tidy dependencies #43
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.
Resolves: No issue but happy to raise on!
Overall change: No functional changes: reduce bundle size by bundling into a single file and trimming production / peer dependency lists
Code changes:
react-dom
andshell-js
aren't required to be installed by clients installing this package and so should be dev dependenciesdist
andesm
directories. This leads to large bundle sizes for clients. This PR changes thebuild
step to use Babel + Rollup to produce a single bundled file for each of CommonJS and ESM (inspired by theweb-vitals
build process: https://github.com/GoogleChrome/web-vitals/blob/main/rollup.config.js )Before:
After:
While this isn't a totally fair test (we're now doing some minification), I've tested this with the WebCore Presentation Layer bundler (which does minify everything) and the total contribution of
@bbc/web-vitals
to the production bundle is reduced by 8KB using this version compared to the latest release.None of this should be a breaking change — the browser compatibility list is the same as it was and the use of
exports
inpackage.json
means that people couldn't import the individual files indist/
oresm/
.