React-hot-loader: using hot makes react-hot-loader included in the bundle

Created on 6 Jul 2019  路  1Comment  路  Source: gaearon/react-hot-loader

If you are reporting a bug or having an issue setting up React Hot Loader, please fill in below. For feature requests, feel free to remove this template entirely.

Description

Hi , I'm straggling to make the bundle free of react-hot-loader code,
in Webpack config i only add react-hot-loader/babel in development and same for @hot-loader/react-dom , also i have theNODE_ENV set to production

if i added hot(module)(Com) i find react-hot-loader included in the bundle,
it would solve this by have two entries for prod and development but what if i have many components that are been lazy-loaded i have to add hot to get HMR working
what is the best way to deal with that

Expected behavior

react-hot-loader code not included if the NODE_ENV set production and babel plugin isn't included

Actual behavior

react-hot-loader included on the bundle because of using hot

Environment

React Hot Loader version:

Run these commands in the project folder and fill in their results:

  1. Node: v10.15.3:
  2. Npm 6.4.1:

Then, specify:

  1. Operating system:osx 10.14.5 Beta
  2. Browser and version:

Reproducible Demo

webpack resolve
image

babel config
image

webpack plugins
image

package.json scripts
image

Thanks

Most helpful comment

Long story short, but that's impossible, from a javascript prospective, to remove some module, not the code, from "production". hot(module) still should be something, or you will get _undefined is not a function_.

__Include__ RHL babel plugin in production - it will remove everything you _"don't want to have in prod"_

>All comments

Long story short, but that's impossible, from a javascript prospective, to remove some module, not the code, from "production". hot(module) still should be something, or you will get _undefined is not a function_.

__Include__ RHL babel plugin in production - it will remove everything you _"don't want to have in prod"_

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adesmet picture adesmet  路  4Comments

jljorgenson18 picture jljorgenson18  路  3Comments

JamesIves picture JamesIves  路  4Comments

mqklin picture mqklin  路  3Comments

Opty1712 picture Opty1712  路  4Comments