-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use rollup to generate bundles for UMD, ESM and CJS #63
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Joezo / @jackdclark LGTM - One question about async/await
.
62cb4d3
to
c7f7cfa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only a few small things - everything else is perfect 👌
"contributors:generate": "all-contributors generate" | ||
"contributors:generate": "all-contributors generate", | ||
"build": "rollup -c", | ||
"prepublishOnly": "npm run build" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to run npm run build
in prepack
also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we add it in prepack
I believe it will run twice when we run npm publish
. Are we using npm pack
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think npm pack
might be an edge case and if people want to use it they could do npm run build
first?
Co-authored-by: Jack Clark <jack.clark@nearform.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-authored-by: Jack Clark
What does this PR do?
Generates bundles for UMD, ESM and CommonJS. This brings with it support for browsers >= IE11.
Whilst working on this we published a few version to
npm
with thetest
tag so that it could be tested. This codepen has been created which uses theUMD
build. We spun up a quick Create react app to test outESM
which worked great. The nextjs example app has also been updated locally to use the commonjs version.Our rollup config was heavily influenced by the one in redux.
Bundle size has slightly increased but we now have increased browser support and our module is now tree shakeable, meaning potentially reduced size for end users.
Important
We now use Promises to write this library as transpiling from async/await is usually avoided in libraries as it's expensive. We opted instead to use untranspiled Promises and then inform the user they should provide an environment that includes Promises.
Related issues
Resolves #11
Checklist