feat: adds the global variable __webpack_global__ for this compilation#20170
feat: adds the global variable __webpack_global__ for this compilation#20170alexander-akait merged 2 commits intowebpack:mainfrom
Conversation
dd8ccf0 to
5f67fe1
Compare
CodSpeed Performance ReportMerging #20170 will not alter performanceComparing Summary
|
|
@JSerFeng Can you look at this solution too, thanks? |
|
We Rspack, want to provide a global variable that can let user interop with current runtime, for example:
Once this is done, there should be no And this PR inject |
🦋 Changeset detectedLatest commit: 87c5630 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@JSerFeng We use the module factory parameter here because we want to provide a stable runtime variable, similar to Node.js, without needing any build-time intervention. As shown in the screenshot, When We’re not handling this problem in a very complex way for now, to be honest, the implementation of react-refresh is a bit of a hack. Now that this problem #20139 can be solved.
|
|
If loader and plugin wants to inject code to do something with current webpack runtime, f user code has already |
This comment was marked as resolved.
This comment was marked as resolved.
|
Replacing it at build time sounds like a good idea. It also reminded me of how __webpack_public_path__ = "https://example.com/public/path/";We can implement it by following the existing behavior of |
5a42aeb to
e93007f
Compare
e93007f to
7d4c502
Compare
|
Thanks |
|
This PR is packaged and the instant preview is available (5983843). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@5983843
yarn add -D webpack@https://pkg.pr.new/webpack@5983843
pnpm add -D webpack@https://pkg.pr.new/webpack@5983843 |

Summary
Fixes #20139
What kind of change does this PR introduce?
feat: provide a stable runtime function variable
__webpack_global__Did you add tests for your changes?
Yes
Does this PR introduce a breaking change?
No
If relevant, what needs to be documented once your changes are merged or what have you already documented?
update module-variables