Repository navigation
feat: public path fallbacks - #358
Conversation
1574556 to
b0e0d1d
Compare
dgaponov
left a comment
There was a problem hiding this comment.
The controller/plugin split and the MF runtime plugin are a big step up from the first version, and the late-failure attribution in installChunkFallback is the right call given webpack's in-flight chunk dedup. Three things remain, two of them blocking for the scenario this feature targets (a hung or blocked CDN). Inline below.
dgaponov
left a comment
There was a problem hiding this comment.
Concrete suggestions for the two blocking points from my previous review, as GitHub suggestion blocks so they can be applied in one batch:
- Runtime syntax level: six one-line rewrites in
fallback-controller.tsthat bring both serialized functions down to ES2017, plus an acorn-based test that fails if anything newer sneaks back in. This is option 1 from the earlier comment; if you prefer the esbuild-at-build-time route instead, ignore these and keep only the test idea. - JS chunk timeout:
compiler.options.output.chunkLoadTimeout ??= 15000inside the plugin'sapply(theconfigureOutputblock is not part of this diff, so it cannot carry a suggestion). - playwright replaced by
acornin devDependencies (lockfile needspnpm install).
Not included as a suggestion because it is more than a few lines: the CSS chunk timeout. mini-css-extract-plugin never times out on its own, so the controller needs to watch managed <link rel="stylesheet"> elements and dispatch error on them after the same 15 s; the existing retry path then handles CSS_CHUNK_LOAD_FAILED. Happy to send that as a follow-up patch if you want.
|
Follow-up on the runtime syntax level: on reflection the six hand-rewrites I suggested above are the wrong tool. They fix today's six lines, but nothing stops the next
import {writeFile} from 'node:fs/promises';
import {transformFile} from '@swc/core';
// fallback-controller.ts has no runtime imports, so a plain transform is enough.
const {code} = await transformFile('src/common/webpack/fallback-controller.ts', {
jsc: {parser: {syntax: 'typescript'}, target: 'es2017'},
module: {type: 'commonjs'},
sourceMaps: false,
});
const source = `(function () {\nvar exports = {};\n${code}\nreturn exports;\n})()`;
await writeFile(
'src/common/webpack/fallback-runtime-source.ts',
`// Generated by scripts/build-fallback-runtime.mjs. Do not edit.\nexport const fallbackRuntimeSource: string = ${JSON.stringify(source)};\n`,
);
import {fallbackRuntimeSource} from './fallback-runtime-source.js';
generate() {
return [
`var fallback = ${fallbackRuntimeSource};`,
`var controller = fallback.createFallbackController(${JSON.stringify(runtimeConfig)});`,
`fallback.installChunkFallback(${RuntimeGlobals.require}, controller);`,
].join('\n');
}
"build:runtime": "node scripts/build-fallback-runtime.mjs",
"build:compile": "pnpm run build:runtime && tsc -p tsconfig.production.json",
"pretest": "pnpm run build:runtime",
"pretypecheck": "pnpm run build:runtime",
"prepare": "husky && pnpm run build:runtime"What this gives:
|
dgaponov
left a comment
There was a problem hiding this comment.
All three points from the last round are addressed, and the stylesheet monitor plus the swc-built runtime came out cleaner than what I sketched. CI is green on both bundlers. Two non-blocking leftovers inline.
dgaponov
left a comment
There was a problem hiding this comment.
Suggestions for the two leftovers, verified locally on this branch (tsc --noEmit clean, eslint 0 errors, 47/47 tests in src/common/webpack green, both bundlers):
__webpack_require__.pspelling (fallback-controller.ts, 6 blocks + 2 test expectations): absolute URLs remain the key for matching and shared state, a smallformsmap remembers how each base was configured, andpath()writes that spelling./build/stays/build/,https://cdn/…/stays as is. Behaviour for chunk loading is unchanged, consumers reading__webpack_public_path__see what they saw before this PR.miniCssFcoverage (fallback-runtime.test.ts, 3 blocks): a real compile on webpack and rspack with a lazy CSS chunk, asserting the runtime contains.miniCssFandcreateStylesheetMonitor. No new dependencies:mini-css-extract-pluginandcss-loaderare already here.
Apply in file order; the controller blocks depend on each other (remember is introduced in the last one).
Co-authored-by: dgaponov <dagaponov@yandex-team.ru>
Co-authored-by: dgaponov <dagaponov@yandex-team.ru>
Co-authored-by: dgaponov <dagaponov@yandex-team.ru>
Co-authored-by: dgaponov <dagaponov@yandex-team.ru>
Co-authored-by: dgaponov <dagaponov@yandex-team.ru>
Co-authored-by: dgaponov <dagaponov@yandex-team.ru>
Co-authored-by: dgaponov <dagaponov@yandex-team.ru>
Co-authored-by: dgaponov <dagaponov@yandex-team.ru>
Co-authored-by: dgaponov <dagaponov@yandex-team.ru>
Co-authored-by: dgaponov <dagaponov@yandex-team.ru>
- add the remember() helper that the applied public-path suggestions call - drop the stale acorn test in fallback-controller.test.ts (superseded by fallback-runtime.test.ts, which checks the generated runtime source) - remove a stray brace left at the top of fallback-runtime.test.ts by the batch apply Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
No description provided.