-
Notifications
You must be signed in to change notification settings - Fork 2
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 one CommonJS module with more efficent code & ship ESM version #8
Conversation
Thanks for the pr! One small request, and a couple of linting errors to fix otherwise this looks good to me. |
Fixed the linting errors - my bad! What's the small request? |
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.
Oh sorry am on phone and didn't realize my comment hadn't posted.
rollup.config.js
Outdated
], | ||
plugins: [ | ||
babel({ | ||
babelrc: false, |
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 I would prefer to continue using the babelrc file. Can you update this PR please?
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.
That's unfortunately not easily possible. jest and rollup need a slightly different config, rollup's needs to preserve the modules as ESMs while jest needs them transformed to CommonJS.
It might be possible to get jest working with ESM using something like @std/esm but this seems much easier.
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.
Ah, I see. Thanks for the explanation!
None of the changes affect how consolidated-events is used in react-waypoint. Changelog: - Now built with rollup ([#8](lencioni/consolidated-events#8)) - Deprecated `removeEventListener` export removed ([#13](lencioni/consolidated-events#13)) - Passive event listener test is now removed after being added ([#11](lencioni/consolidated-events#11)) - Reduced bundle size impact by replacing a class with a function ([#12](lencioni/consolidated-events#12))
- Now built with rollup ([#8](lencioni/consolidated-events#8)) - Deprecated `removeEventListener` export removed ([#13](lencioni/consolidated-events#13)) - Passive event listener test is now removed after being added ([#11](lencioni/consolidated-events#11)) - Reduced bundle size impact by replacing a class with a function ([#12](lencioni/consolidated-events#12))
- Now built with rollup ([#8](lencioni/consolidated-events#8)) - Deprecated `removeEventListener` export removed ([#13](lencioni/consolidated-events#13)) - Passive event listener test is now removed after being added ([#11](lencioni/consolidated-events#11)) - Reduced bundle size impact by replacing a class with a function ([#12](lencioni/consolidated-events#12))
- Now built with rollup ([#8](lencioni/consolidated-events#8)) - Deprecated `removeEventListener` export removed ([#13](lencioni/consolidated-events#13)) - Passive event listener test is now removed after being added ([#11](lencioni/consolidated-events#11)) - Reduced bundle size impact by replacing a class with a function ([#12](lencioni/consolidated-events#12))
- Now built with rollup ([#8](lencioni/consolidated-events#8)) - Deprecated `removeEventListener` export removed ([#13](lencioni/consolidated-events#13)) - Passive event listener test is now removed after being added ([#11](lencioni/consolidated-events#11)) - Reduced bundle size impact by replacing a class with a function ([#12](lencioni/consolidated-events#12))
- Now built with rollup ([#8](lencioni/consolidated-events#8)) - Deprecated `removeEventListener` export removed ([#13](lencioni/consolidated-events#13)) - Passive event listener test is now removed after being added ([#11](lencioni/consolidated-events#11)) - Reduced bundle size impact by replacing a class with a function ([#12](lencioni/consolidated-events#12))
This reduces bundle size and startup when working with, for example, webpack, where every module is loaded individually. It also removes all the
_interopRequireDefault
functions.I've also added an ESM version of the module to the package. Since consolidated-events uses named export, this is compatible with bundlers like Webpack even when the requiring app/library uses CommonJS.