Repository navigation
[2.x] fix: load each extension's lazy chunks from its own build - #5085
Merged
Merged
Conversation
Webpack chunk ids are only unique within one build, but the export registry resolved chunks by id alone, and every build shared one JSONP array (`webpackChunkmodule_exports`). Two extensions with the same chunk id therefore loaded each other's file, or, once one had loaded, the other's import resolved with no request and failed with "r[e] is not a function". - flarum-webpack-config gives each build its own chunk loading global, `webpackChunk_<extension id>`, and passes the extension id to `flarum.reg.loadChunk()`. - The registry resolves chunks by namespace and id. Bundles built before this send no namespace; for them a colliding chunk is matched by the file name in the URL webpack built, then falls back to the first registered, as before. Fixes #5027
5 of 12 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5027
Changes proposed in this pull request:
Webpack chunk ids are only unique within one build, but the export registry looked chunks up by id alone and every build shared one JSONP array, so two extensions with the same chunk id loaded each other's file, or failed with
TypeError: r[e] is not a functiononce one of them had loaded. This gives each build its own chunk array, has each runtime tell the registry which extension is asking, and makes the registry resolve chunks by extension and id. Thanks to @datlechin for the analysis in the issue, which this follows.js-packages/webpack-config:output.chunkLoadingGlobalis nowwebpackChunk_<extension id>, and the__webpack_require__.loverride passes the extension id toflarum.reg.loadChunk().framework/core/js/src/common/ExportRegistry.ts: chunks are resolved bynamespace:chunkId;getChunk(),chunkUrl()andloadChunk()take the namespace as an optional last argument. Bundles built with an older flarum-webpack-config send none, so for them a colliding chunk is matched by the file name in the URL webpack built, then falls back to the first registered as before. The publicchunksmap keeps its old meaning.Reviewers should focus on:
fof/oauthboth using chunk170today are fixed straight away._.Screenshot
N/A, no user-facing change.
Necessity
Confirmed
yarn testinjs/).composer test). (No backend changes.)