When you install React in a project and look at the library code. The main (CJS) entry point is a file with the following content:
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/react.production.min.js');
} else {
module.exports = require('./cjs/react.development.js');
}
Obviously, when we do react-scripts start we load the react.development.js. When we create a production build of our app with react-scripts build, the webpack could still use the react.development.js file and minify it itself.
I assume that NODE_ENV is still development when we run react-scripts build.
If we're using the react.development.js all the time, then what is the point of having these two separate files?
There are many other libraries (like React) using this approach but I cannot understand why are they doing it.