What is the thought process behind the root index.js in the React build code?


(Nathan Buchar) #1

My team is currently creating some open source packages and we’re following a similar pattern to React and we came across this file. It’s the primary package file and it switches to the development build or the production build based on the NODE_ENV.

I also found the commit but it’s not very telling. The file has only had one commit, no conversation, and yet it’s the primary entrypoint into React (and other React packages).

I’m just wondering, what is the thought process for using a switch like this? Couldn’t one just point directly to the development files and if the end user chose to minify their code, then the React code would also be minified? At the moment there’s currently a debate about whether we need a switch file like this in our repo and I’m wondering what others think the advantages are to having a file like this that maybe we don’t see.

You can find the most recently published code for React on npm here.

Thanks :slight_smile: