fix: use __webpack_global__ in loader if available#940
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
4acf257 to
2502358
Compare
|
@pmmmwh Excuse me, could you please help review this PR? ❤️ |
|
Thanks for the PR! I think the proposed changes look correct. However, I think it would be best of we can also patch this for older Webpack versions where Would you be interested to look into that? |
After discussing with webpack team members, it was difficult to resolve this conflict in the old version of webpack, so this variable was introduced. As this case is uncommon, I recommend that users who encounter it simply upgrade to the latest version of webpack and react-refresh-webpack-plugin for full support. |
6b43535 to
fc3d14b
Compare
|
Tests have been updated. |
b0cd9b1 to
d8b6571
Compare
@pmmmwh Sorry, this time all tests should pass, you can continue to review and approve this PR. |
pmmmwh
left a comment
There was a problem hiding this comment.
One small change in the tests, but otherwise I think this looks good.
I'll probably want to think of ways such that we can minimise the evaluation of the conditional, but I don't think that's a blocker for merging this.
(Sorry for taking a bit longer, was on vacation.)
| @@ -1,5 +1,5 @@ | |||
| const { Template } = require('webpack'); | |||
| const getRefreshModuleRuntime = require('../../../loader/utils/getRefreshModuleRuntime'); | |||
| const { getRefreshModuleRuntime } = require('../../../loader/utils'); | |||
There was a problem hiding this comment.
Probably revert this change in imports?
a23d3bf to
9479280
Compare
|
Thanks for the merge, and looking forward to this being released in a future update❤️. |

Origin issue see webpack/webpack#20139.
In order to avoid the
__webpack_require__conflict, webpack added a stable runtime function variable__webpack_global__in webpack/webpack#20170.This PR changes the injected loader template to support this.