gaearon / react-hot-loader

Tweak React components in real time. (Deprecated: use Fast Refresh instead.)

Home Page:http://gaearon.github.io/react-hot-loader/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

After react-hot-loader/babel plugin compiled, some code missing

yujiangshui opened this issue · comments

Description

What you are reporting: BUG

Expected behavior

What you think should happen: The code should work as expected.

Actual behavior

What actually happens: After enabling react-hot-loader/babel plugin and compiling, some parts of code missing, and only in the production environment, caused a serious production level issue.

Environment

React Hot Loader version: ^4.12.15

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

  1. node -v: v10.15.3
  2. npm -v: 6.4.1

Then, specify:

  1. Operating system: macOS 10.14
  2. Browser and version: Chrome 78

Reproducible Demo

Demo here: https://github.com/yujiangshui/hot-loader-replace-issue. Please follow the instruction on README.md.

Documentation many times points on the specific on hot - export default hot(App).

  • no compose
  • no wrapping before
  • no wrapping after

And in production hot magically disappears, leaving only the "right argument", while is empty in your case.

@theKashey thank you for your reply. I have to say that I am not familiar with hot-loader before, and previously in our code use compose wrapper hot(module) (maybe its wrapper App usage looks like HOC?) and it works (so I thought it likes a function can work with compose).

But after added another HOC to the compose, guess what happened? Still works in development but after releasing crash in a production environment!!

You may be familiar with the features and think it reasonable, but I think there must be some improvements that can make hot-loader better? Maybe crash in the beginning or give a tip? or just close this issue.

BTW, I couldn't get your points in the last sentence:

in production hot leave only the "right argument", while it is empty in your case.

Actually, in my case, it looks like at least keep one HOC, and that's the reason why we didn't have any issues before, because we only had one HOC here.

image

Anyway, thank you.

The logic is quite simple, with 3 use cases for hot - https://github.com/gaearon/react-hot-loader/blob/master/src/babel.prod.js#L70
Something is not working for use cases we haven't predicted and test.

If you cant change your code to an expected version(export default hot(App)) - just disable babel plugin in production

Absolutely can understand, there are so many different use cases outside.

Just addressed this issue today, next Monday will upgrade to the recommended export default hot(App) way.

Thanks again, should I close this issue?

Not yet. Your case should be added to the tests, so keep it open until then