Skip to content
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

Merged
merged 2 commits into from
Jun 18, 2018

Conversation

realityking
Copy link
Contributor

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.

@lencioni
Copy link
Owner

Thanks for the pr! One small request, and a couple of linting errors to fix otherwise this looks good to me.

@realityking
Copy link
Contributor Author

Fixed the linting errors - my bad!

What's the small request?

Copy link
Owner

@lencioni lencioni left a 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,
Copy link
Owner

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?

Copy link
Contributor Author

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.

Copy link
Owner

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!

@lencioni lencioni merged commit 03dbb45 into lencioni:master Jun 18, 2018
@realityking realityking deleted the rollup branch June 18, 2018 15:30
lencioni added a commit to civiccc/react-waypoint that referenced this pull request Jun 18, 2018
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))
lencioni added a commit to airbnb/react-outside-click-handler that referenced this pull request Jun 18, 2018
- 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))
lencioni added a commit to react-dates/react-dates that referenced this pull request Jun 18, 2018
- 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))
lencioni added a commit to react-dates/react-dates that referenced this pull request Jun 18, 2018
- 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))
devs-cloud pushed a commit to devs-cloud/react-date that referenced this pull request Dec 27, 2019
- 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))
MarcoAntonioAG pushed a commit to MarcoAntonioAG/React-dates that referenced this pull request Mar 31, 2022
- 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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants