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 dev-expression Babel plugin #124

Merged
merged 1 commit into from
Nov 2, 2015

Conversation

taion
Copy link
Contributor

@taion taion commented Nov 2, 2015

This drops the size of History.min.js from 27,016 B to 25,851 B.

@mjackson
Copy link
Member

mjackson commented Nov 2, 2015

So we can already take advantage of this plugin without any code modifications? We're not currently using __DEV__ anywhere. What code is it removing?

@taion
Copy link
Contributor Author

taion commented Nov 2, 2015

It's these two: https://github.com/4Catalyzer/babel-plugin-dev-expression#invariant, https://github.com/4Catalyzer/babel-plugin-dev-expression#warning

For a production build, this strips out calls to warning and removes the error messages for invariant.

Though https://github.com/rackt/history/blob/v1.13.0/package.json#L13 means that these will also happen for our un-minified UMD bundle, which I'm not sure if you want.

@taion
Copy link
Contributor Author

taion commented Nov 2, 2015

And I have absolutely no idea why this isn't broadly used in the React ecosystem outside of Facebook's own modules. It's a free win for package size if you're using warning and invariant. You'd think the people who pulled out warning and invariant from fbjs would have noticed that there was this great Babel plugin that goes with them.

@agundermann
Copy link
Contributor

👍 Thanks for this @taion . Finally a real solution for remix-run/react-router#556

ryanflorence added a commit that referenced this pull request Nov 2, 2015
Use dev-expression Babel plugin
@ryanflorence ryanflorence merged commit b451277 into remix-run:master Nov 2, 2015
@taion taion deleted the dev-expression branch November 2, 2015 23:13
@mjackson
Copy link
Member

mjackson commented Nov 2, 2015

cc @BerkeleyTrue who maintains the warning package

@taion
Copy link
Contributor Author

taion commented Nov 2, 2015

I think this is the last missing piece of the warning/invariant trinity - the Babel plugin that Facebook use to strip everything out for production builds. Not a massive space savings by any means, but it's "free", more or less.

@BerkeleyTrue
Copy link

Yes?

@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants