Adds `process.env.NODE_ENV` polyfill #2279

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
5 participants
@dsibiski
Contributor

dsibiski commented Aug 10, 2015

There are many libraries that use NODE_ENV to check whether the code is running in
"production" mode or not. This allows those library authors to not have to add conditionals
for React Native.

One such library is Redux: reduxjs/react-redux#40

Thanks to @brentvatne for providing the solution via this tweet (via his phone in the airport 馃槈): https://twitter.com/notbrent/status/630440250951749632

/cc @vjeux @gaearon @zpao @amasad

Adds `process.env.NODE_ENV` polyfill
There are many libraries that use `NODE_ENV` to check whether the code is running in
"production" mode or not. This allows those library authors to not have to add conditionals
for React Native.
@vjeux

This comment has been minimized.

Show comment
Hide comment
Contributor

vjeux commented Aug 10, 2015

@vjeux vjeux self-assigned this Aug 10, 2015

@facebook-github-bot

This comment has been minimized.

Show comment
Hide comment
@vjeux

This comment has been minimized.

Show comment
Hide comment
@vjeux

vjeux Aug 10, 2015

Contributor

While looking into it, turns out that we don't currently remove if (__DEV__) { } blocks from the minified version. I'm working on fixing it as well.

Contributor

vjeux commented Aug 10, 2015

While looking into it, turns out that we don't currently remove if (__DEV__) { } blocks from the minified version. I'm working on fixing it as well.

@gaearon

This comment has been minimized.

Show comment
Hide comment
@gaearon

gaearon Aug 10, 2015

Member

@dsibiski Thank you!

Member

gaearon commented Aug 10, 2015

@dsibiski Thank you!

@vjeux

This comment has been minimized.

Show comment
Hide comment
@vjeux

vjeux Aug 10, 2015

Contributor

Pull request opened on UglifyJS: mishoo/UglifyJS2#767

Contributor

vjeux commented Aug 10, 2015

Pull request opened on UglifyJS: mishoo/UglifyJS2#767

@amasad

This comment has been minimized.

Show comment
Hide comment
@amasad

amasad Sep 8, 2015

Contributor

we also now inline __DEV__ and NODE_ENV checks so that the minifier can safely remove them:

plugins = plugins.concat(['node-env-inline', 'dunderscore-dev-inline']);

Contributor

amasad commented Sep 8, 2015

we also now inline __DEV__ and NODE_ENV checks so that the minifier can safely remove them:

plugins = plugins.concat(['node-env-inline', 'dunderscore-dev-inline']);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment