-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Framework: Use warn module in place of react/lib/warn #787
Conversation
@@ -5,9 +5,11 @@ var config = require( 'config' ); | |||
|
|||
function warn() { | |||
if ( config( 'env' ) !== 'production' ) { |
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.
can config change over the life of the app? we could make warn a noop and then override it if we're not in prod
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.
can config change over the life of the app? we could make warn a noop and then override it if we're not in prod
Sure, makes sense, and could shave a few cycles in production. What do you think about 726ccf7?
👍 |
|
||
function warn() { | ||
if ( config( 'env' ) !== 'production' ) { |
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.
We can use also process.env.NODE_ENV !== 'production'
and the block should be removed during compilation.
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.
We can use also
process.env.NODE_ENV !== 'production'
It's my understanding that we're not to use NODE_ENV
and instead rely on the value specified in config
, which is equal to the current environment's CALYPSO_ENV
environment variable specified in the Dockerfile for each environment's build.
the block should be removed during compilation.
I'm not sure the uglifier is that smart. A common approach to achieve this is to use something like Webpack's DefinePlugin
to replace occurrences of a text with false
, which the uglifier would be smart enough to remove.
// 1. Variable comparison
var env = 'production';
if ( env !== 'production' ) {
// Could be, but probably not removed by uglifier
}
// 2. Use `DefinePlugin` to replace `__DEV__` with `false`
if ( false ) {
// Definitely removed by uglifier
}
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.
NODE_ENV
is set in during the build process and will replaced by 'production' !== 'production'
, which will be removed by uglifier.
726ccf7
to
90b7cbb
Compare
Framework: Use warn module in place of react/lib/warn
@umurkontaci @lamosty - Indeed, I had overlooked that we're already specifying a |
@aduth 👍 I'm sorry, I didn't notice that. |
Related: #786, #776
This pull request seeks to replace existing usage of the
react/lib/warn
module with our own existingwarn
module. This is a prerequisite for upgrading to React 0.14. Facebook has moved library modules to a separate package, which they warn against using.https://github.com/facebook/fbjs
Testing instructions:
Ensure that no references remain for
react/lib/warn
./cc @blowery 11943-gh-calypso-pre-oss