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

Strip "invariant" from production builds? #67

Closed
SkaterDad opened this issue Mar 9, 2019 · 3 comments
Closed

Strip "invariant" from production builds? #67

SkaterDad opened this issue Mar 9, 2019 · 3 comments

Comments

@SkaterDad
Copy link
Contributor

SkaterDad commented Mar 9, 2019

I was examining my application bundles after adding microstates, and noticed that invariant was adding nearly a KB, since it is used by funcadelic.

I see the value in having that during development, but for production builds it would be nice to remove/tree-shake it away.

I see the rollup file will already do replacements for process.env.NODE_ENV, so could the code be wrapped up inside an if (process.env.NODE_ENV !== 'production') { ... } block?

EDIT: I know this seems fiddly and trivial in the grand scheme, but I was a bit surprised by the actual size of adding microstates, since bundlephobia's figure does not include funcadelic.

@cowboyd
Copy link
Member

cowboyd commented Mar 10, 2019

This makes total sense. Sounds like you know the best way to proceed...

@cowboyd
Copy link
Member

cowboyd commented Mar 10, 2019

Sorry if that came off as brusque (I was on my phone) but basically yes, ++ would merge!

@SkaterDad
Copy link
Contributor Author

No worries! I finally remembered to circle back to this.

I'm curious why you do not currently produce any minified builds?

I did some research into what other libraries do with invariant, and a popular alternative is tiny-invariant, combined with babel-plugin-dev-expression to strip the string messages in production builds. I'll submit a PR shortly.

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

No branches or pull requests

2 participants