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:
node -v
: v10.15.3npm -v
: 6.4.1
Then, specify:
- Operating system: macOS 10.14
- 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.
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