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

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

Closed
yujiangshui opened this issue Nov 1, 2019 · 5 comments · May be fixed by novalina26/anchor#1
Closed

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

yujiangshui opened this issue Nov 1, 2019 · 5 comments · May be fixed by novalina26/anchor#1

Comments

@yujiangshui
Copy link

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.

@theKashey
Copy link
Collaborator

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.

@yujiangshui
Copy link
Author

@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.

@theKashey
Copy link
Collaborator

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

@yujiangshui
Copy link
Author

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?

@theKashey
Copy link
Collaborator

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

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