Skip to content
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

Develpoment version of React/React-DOM used on production #244

Closed
fabiospampinato opened this issue Dec 9, 2018 · 2 comments
Closed

Develpoment version of React/React-DOM used on production #244

fabiospampinato opened this issue Dec 9, 2018 · 2 comments

Comments

@fabiospampinato
Copy link
Contributor

It looks like react expect process.env.NODE_ENV === 'production' in order to load the production version of the library. Since I saw the development version of react-dom getting loaded in a stack trace I've logged the actual value of process.env.NODE_ENV that react is getting:

screen shot 2018-12-09 at 18 01 25

And it's undefined, so I guess the webpack configuration generated by electron-webpack doesn't properly use:

new webpack.DefinePlugin ({
  'process.env.NODE_ENV': JSON.stringify ( 'production' )
})

Also if I set that manually into my custom webpack configuration nothing seems to change.

@develar I'd like to submit a PR for fixing this, any suggestion at where should I make the changes in the codebase?

@fabiospampinato
Copy link
Contributor Author

It looks like for this particular case it doesn't matter what 'process.env.NODE_ENV' is set to, since those dependencies are loaded as external dependencies.

It's probably still a good idea to set process.env.NODE_ENV === "production" though, as our apps' code may do something differently depending on this, and dead code elimination might help shave some bytes off the bundle.

It should also be mentioned somewhere in the docs that one would probably want to set process.env.NODE_ENV === "production" somewhere manually, or mess with external dependencies.

@fabiospampinato
Copy link
Contributor Author

fabiospampinato commented Dec 9, 2018

It looks like there's an explicit exception for vue

    if (this.isRenderer) {
      whiteListedModules.add("vue");
    }

I guess react, react-dom, and probably many others, should be whitelisted as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant