That’s exactly the point of this tool. It pinpoints you the possible errors that you may have encountered during the configuration of your build process.
So your use of .babelrc + uglify package does or doesn’t produce a production build?
My react apps are all showing as development builds in production, but I didn’t have a .babelrc file or anything else because I had assumed Meteor took care of a sensible default config for us.
It does. The .babelrc removes the PropTypes and ensures some speed optimizations. The modified uglifyjs ensures code mangling and dead code elimination.
This problem is caused by the fact that React uses if (process.env.NODE_ENV !== 'production') { ... } checks throughout its code, and Meteor’s standard-minifier-js package does not convert process.node.NODE_ENV references into the envify style of plain strings that React is expecting. So after minification, React expects process.env.NODE_ENV !== 'production' to become 'production' !== 'production'. For example, making the following change in Meteor’s packages/minifier-js/minifier.js file demonstrates the issue:
var uglify;
meteorJsMinify = function (source) {
var result = {};
uglify = uglify || Npm.require("uglify-js");
// NOTE: This is intended to demonstrate the issue; this is not a proper fix!
source = source.replace(/process\.env\.NODE_ENV/g, '"production"');
try {
result.code = uglify.minify(source, {
fromString: true,
compress: {
drop_debugger: false,
unused: false,
dead_code: false
}
}).code;
} catch (e) {
// Although Babel.minify can handle a wider variety of ECMAScript
// 2015+ syntax, it is substantially slower than UglifyJS, so we use
// it only as a fallback.
result.code = Babel.minify(source).code;
}
return result;
};
By adding that one source = source.replace ... line, we’re replacing process.env.NODE_ENV references with "production" before minification, which then shows the React dev tools plugin that we’re using a production build:
(running locally with --production)
All of the above being said however, a fix for this might not be best suited in the standard-minifier-js (or associated) package(s). As @benjamn mentioned here:
This sounds like a case where you’d want to use something other than standard-minifier-js. Assuming process.env.NODE_ENV is a constant is not a sound decision for a generic minifier to make.
Instead of opening a new issue, I just added my comments to that one (since it was already open and refers to the same issue, albeit in a different context).