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

Production is broken after 4.8.5 #1283

Closed
chrisbutler opened this issue Jul 3, 2019 · 2 comments
Closed

Production is broken after 4.8.5 #1283

chrisbutler opened this issue Jul 3, 2019 · 2 comments

Comments

@chrisbutler
Copy link

chrisbutler commented Jul 3, 2019

Description

We have been using RHL with Recompose for a long time, but suddenly our production server cannot start (development is fine).

export default compose( hot(module), withSomeHOC, )(HotReloadedParent)

Upgrading past version 4.8.5 produces the following error when trying to run the code in production mode:

TypeError: b.apply is not a function at node_modules/recompose/dist/Recompose.cjs.js:810:18

Seemingly the signature of hot(module) has changed in production mode after the above stated version?

Expected behavior

It should continue to work as before. Production should ABSOLUTELY NEVER be affected by RHL

Actual behavior

Production build/deployment fails because of code error

Environment

React Hot Loader version: 4.8.5

@theKashey
Copy link
Collaborator

It should continue to work as before. Production should ABSOLUTELY NEVER be affected by RHL

So, this is exactly what's happening - it wipes itself from production to ABSOLUTELY NEVER affect your App.

export default compose( hot(module), withSomeHOC, )(HotReloadedParent)
// becomes
export default compose(, withSomeHOC, )(HotReloadedParent)

This is definitely a bug, as long as it shall not remove hot(module) - only hot(module)(something), and somewhere around 4.8 we added code for babel plugin to delete another form of hot, and that's ended as a false positive.

But, anyway, I would ask you to change the code - you have to remove magic module variable, or some production optimization would be disabled.

How to fix

  • if you are using webpack:
import {hot} from 'react-hot-loader/root';
....
export default hot(withSomeHOC(HotReloadedParent))
  • if you are using "not" webpack (and /root would complain):
export default hot(module)(withSomeHOC(HotReloadedParent))

@theKashey
Copy link
Collaborator

v4.12.2 is containing the fix for babel plugin. You might use your old code, but I still encourage you to update it.

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

2 participants