GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — fix: gap-fill entryOptions when an async block reuses an existing entrypoint by alexander-akait · Pull Request #21026 · webpack/webpack Conversation
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
🦋 Changeset detectedLatest commit: 36aadab The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
This PR is packaged and the instant preview is available (c073890). Install it locally:
npm i -D webpack@https://pkg.pr.new/webpack@c073890
yarn add -D webpack@https://pkg.pr.new/webpack@c073890
pnpm add -D webpack@https://pkg.pr.new/webpack@c073890 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This PR aims to eliminate “risky-refactor” TODOs by making async entrypoint option handling more complete and adding regression coverage in the worker configCases suite.
Changes:
entryOptions when an async block joins an existing named async entrypoint, and emit an error on conflicts.Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
lib/buildChunkGraph.js |
Adds entryOptions merge/conflict detection when reusing an existing async entrypoint. |
test/configCases/worker/entry-options-merge/index.js |
Runtime test that creates two workers targeting the same async entrypoint name. |
test/configCases/worker/entry-options-merge/worker.js |
Worker script used by the merge test. |
test/configCases/worker/entry-options-merge/webpack.config.js |
Plugin asserts merged entrypoint options/origins in compilation. |
test/configCases/worker/entry-options-merge/test.filter.js |
Skips the case when Node doesn’t support URL-based new Worker(...). |
test/configCases/worker/entry-options-merge/errors.js |
Asserts the merge case produces no compilation errors. |
test/configCases/worker/entry-options-merge-conflict/index.js |
Unreachable worker instantiations used to trigger compilation-time conflict detection. |
test/configCases/worker/entry-options-merge-conflict/worker.js |
Worker script used by the conflict case. |
test/configCases/worker/entry-options-merge-conflict/webpack.config.js |
Basic config for the conflict case. |
test/configCases/worker/entry-options-merge-conflict/test.filter.js |
Skips the case when Node doesn’t support URL-based new Worker(...). |
test/configCases/worker/entry-options-merge-conflict/errors.js |
Expects a specific “Conflicting entry option …” compilation error. |
.changeset/merge-async-entry-options.md |
Documents the behavior change as a patch release note. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| "use strict"; | ||
|
|
||
| const ModuleGraphConnection = require("./ModuleGraphConnection"); | ||
| const WebpackError = require("./WebpackError"); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Resolved — the require("./WebpackError") import was removed entirely. The revised implementation uses gap-fill semantics (copy only options the entrypoint hasn't set yet) and no longer constructs any error, so no WebpackError is needed here.
Generated by Claude Code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| --- | ||
| "webpack": patch | ||
| --- | ||
|
|
||
| Merge `entryOptions` when an async block joins an existing entrypoint. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Resolved — the PR title and description were updated to match the actual scope. The CommonJsExportRequireDependency (Object.defineProperty) and EnableLibraryPlugin (non-string library type) changes were reverted in an earlier commit; this PR now contains only the buildChunkGraph entryOptions gap-fill plus its test and changeset.
Generated by Claude Code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| entrypoint = /** @type {Entrypoint} */ (cgi.chunkGroup); | ||
| // TODO merge entryOptions | ||
| const existingOptions = entrypoint.options; | ||
| for (const key_ of Object.keys(entryOptions)) { | ||
| const key = | ||
| /** @type {keyof EntryOptions} */ | ||
| (key_); | ||
| if (entryOptions[key] === undefined) continue; | ||
| if (existingOptions[key] === entryOptions[key]) continue; | ||
| if ( | ||
| Array.isArray(existingOptions[key]) && | ||
| Array.isArray(entryOptions[key]) && | ||
| arrayEquals(existingOptions[key], entryOptions[key]) | ||
| ) { | ||
| continue; | ||
| } | ||
| if (existingOptions[key] === undefined) { | ||
| /** @type {EntryOptions[keyof EntryOptions]} */ | ||
| (existingOptions[key]) = entryOptions[key]; | ||
| } else { | ||
| compilation.errors.push( | ||
| new WebpackError( | ||
| `Conflicting entry option ${key} = ${existingOptions[key]} vs ${entryOptions[key]} for entrypoint ${entrypoint.name}` | ||
| ) | ||
| ); | ||
| } | ||
| } |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Good catch — this is the key reason the implementation was reworked. Syncing the derived cgi.runtime/chunkLoading/asyncChunks mid-build turned out to be unsafe: an entrypoint can be joined after its own modules were already traversed, and recomputing the fallback values against the joining block's parent (or mutating cgi.runtime) changed traversal results — in practice it sent web-worker into a hang.
So this PR deliberately scopes the change to gap-filling entrypoint.options only, and does not touch the ChunkGroupInfo traversal state. The merged options are recorded on the shared entrypoint but, for the structural keys, the values chosen when the entrypoint was first created remain authoritative for traversal. Making those take effect safely would need a larger redesign of how/when entrypoint structure is finalized, which is out of scope here.
Generated by Claude Code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| compilation.errors.push( | ||
| new WebpackError( | ||
| `Conflicting entry option ${key} = ${existingOptions[key]} vs ${entryOptions[key]} for entrypoint ${entrypoint.name}` | ||
| ) | ||
| ); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Resolved — the conflict WebpackError was removed altogether. Blocks that dedupe to one entrypoint (e.g. multiple workers pointing at the same module) legitimately carry differing options such as an auto-generated per-worker runtime, so treating a difference as a conflict produced false positives (it regressed the web-worker case). The path now only gap-fills missing options and never emits an error, so there's no longer an error needing module/loc attribution.
Generated by Claude Code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
The previous conflict-on-difference approach broke webpack's supported "multiple workers share one module" dedup: such workers legitimately carry distinct auto-generated runtimes, which were wrongly reported as `Conflicting entry option runtime` errors (the repo's own web-worker configCase regressed). Switch to gap-fill semantics: when a later async block joins an existing entrypoint, copy only the options the entrypoint has not set yet; never overwrite and never error, so the first block to create the entrypoint wins. Traversal state (cgi.*) is intentionally left untouched to avoid mutating an entrypoint mid-build. Drop the now-inapplicable conflict test; keep the gap-fill test that asserts a second block's `asyncChunks` lands on the shared entrypoint.
There was an error while loading. Please reload this page.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@ ## main #21026 +/- ## ========================================== - Coverage 91.59% 91.58% -0.01% ========================================== Files 573 573 Lines 59541 59569 +28 Branches 16077 16091 +14 ========================================== + Hits 54534 54558 +24 - Misses 5007 5011 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
CI's lint job type-checks config files; the inline assertion plugin's `compiler`/`compilation` params were implicitly `any`, and `entrypoint.options` is typed as the base `ChunkGroupOptions` (no `asyncChunks`). Annotate the plugin and read `asyncChunks` through an `EntryOptions` cast so `yarn lint` (tsc + tsconfig.types.test) passes.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const existingOptions = entrypoint.options; | ||
| for (const key_ of Object.keys(entryOptions)) { | ||
| const key = | ||
| /** @type {keyof EntryOptions} */ | ||
| (key_); | ||
| if (entryOptions[key] === undefined) continue; | ||
| if (existingOptions[key] !== undefined) continue; | ||
| /** @type {EntryOptions[keyof EntryOptions]} */ | ||
| (existingOptions[key]) = entryOptions[key]; | ||
| } |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Good catch — fixed in 5fbee11. The gap-fill now skips __proto__, constructor and prototype before assigning onto entrypoint.options, since entryOptions can come from the webpackEntryOptions magic comment in user source.
Note: __proto__/constructor were already incidentally skipped by the existingOptions[key] !== undefined read-guard (both resolve on the prototype chain), but prototype was genuinely writable (plain objects have no inherited prototype), so the explicit denylist is the real fix rather than relying on that coincidence. The entry-options-merge test now passes a second worker carrying prototype/constructor keys and asserts they are not copied onto the entrypoint options and the global prototype is untouched.
Generated by Claude Code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Back-filling `name` onto a reused entrypoint broke persistent caching: when an unnamed worker creates the entrypoint and a later named worker dedupes onto it via its module, copying `name` left it out of sync with `entrypoint.name` and made the worker module's code generation order-dependent, invalidating the cache pack (the web-worker case failed only under ConfigCacheTestCases). `name` is the entrypoint's identity, fixed at creation, so it must never be merged; other missing options are still gap-filled.
… gap-fill entryOptions can originate from the `webpackEntryOptions` magic comment in user source, so the gap-fill now skips `__proto__`, `constructor` and `prototype` before assigning onto `entrypoint.options`. The existing test passes a polluting second worker and asserts the keys are not copied and the global prototype is untouched.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Move the prototype-pollution guard out of buildChunkGraph and into the place where the `webpackEntryOptions` magic comment is consumed: copy only safe own keys (skip `__proto__`/`constructor`/`prototype`) instead of `Object.assign`. This protects every consumer of the resulting entryOptions (the entrypoint constructor and the gap-fill) at the untrusted-input boundary, so buildChunkGraph no longer needs key validation and keeps only its `name`-identity exclusion. The existing worker test still asserts the keys never reach entrypoint.options.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const existingOptions = entrypoint.options; | ||
| for (const key_ of Object.keys(entryOptions)) { | ||
| const key = | ||
| /** @type {keyof EntryOptions} */ | ||
| (key_); | ||
| if (key === "name") continue; | ||
| if (entryOptions[key] === undefined) continue; | ||
| if (existingOptions[key] !== undefined) continue; | ||
| /** @type {EntryOptions[keyof EntryOptions]} */ | ||
| (existingOptions[key]) = entryOptions[key]; | ||
| } |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Intentionally not duplicating this guard in buildChunkGraph. The sanitization is done once at the trust boundary where the untrusted webpackEntryOptions magic comment is consumed (WorkerPlugin, commit 8ad7622). By the time entryOptions reaches this gap-fill it has already been sanitized — the only producers of an async block's entryOptions are WorkerPlugin (now guarded) and LoaderPlugin (which builds entryOptions internally, not from user input). Keeping the check in one place avoids drift between two denylists and keeps buildChunkGraph free of input-validation concerns. The entry-options-merge test exercises the end-to-end path (prototype/constructor/__proto__ in a worker's magic comment never reach entrypoint.options).
Generated by Claude Code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const w2 = new Worker( | ||
| /* webpackEntryOptions: { name: "merged", runtime: "merged-rt", asyncChunks: false, prototype: { polluted: true }, constructor: { polluted: true } } */ | ||
| new URL("./worker.js", import.meta.url) | ||
| ); | ||
| expect({}.polluted).toBeUndefined(); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Done in 36aadab. The second worker's webpackEntryOptions now also includes a computed ["__proto__"]: { polluted: true } key, and the in-config plugin asserts the entrypoint options carry no __proto__/constructor/prototype own key, that Object.getPrototypeOf(options) === Object.prototype, and the runtime test asserts ({}).polluted stays undefined — so all three denylisted keys are exercised end-to-end.
Generated by Claude Code
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Add a computed `["__proto__"]` key to the second worker's webpackEntryOptions and assert the entrypoint options carry no `__proto__` own key and that their prototype is untouched, so the WorkerPlugin denylist is exercised for all three special keys.
Types CoverageCoverage after merging claude/risky-refactors-feature-gaps-QseM1 into main will be
Coverage Report
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.