Skip to content

docs: build modern and legacy bundles from one source with layers - #8401

Merged
alexander-akait merged 1 commit into
mainfrom
docs/differential-builds-with-layers
Sep 13, 2026
Merged

alexander-akait merged 1 commit into
mainfrom
docs/differential-builds-with-layers

Conversation

@alexander-akait

Copy link
Copy Markdown
Member

Summary

The shimming guide showed how to compile polyfills twice by tagging imports with a ?legacy query, but not the layer version of the same idea, where an entry's layer makes webpack walk the whole graph twice and Rule.issuerLayer picks the Babel targets and polyfills per copy — one compilation, two bundles, no browser sniffing in the page. Adds that section, and next to it the array-of-configurations form for when the modern build has to be emitted as real ECMAScript modules, since output.module and output.environment are compilation-wide and layers cannot vary them.

Also picks up the idea behind #8215: the entry page now documents the polyfill entry array, with the measured cost of importing all of core-js/stable (637 modules, 215 KB minified / 71 KB gzipped with core-js 3.50) and a pointer to useBuiltIns: 'usage' and to the shimming guide, so the example teaches the cost rather than only the syntax. Refs #8215.

Every configuration here was run against webpack 5.110.3 before being written down: the layer build emits each bundle carrying only its own layer's loader output with no shared modules across layers, and the array build emits export plus import() chunk loading for the modern compilation and a var library with script-tag chunk loading for the legacy one.

What kind of change does this PR introduce?

docs

Did you add tests for your changes?

n/a — documentation only.

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?

n/a — this PR is the documentation.

Use of AI

AI was used. Claude Code checked which options are per-entry and which are per-compilation against the webpack schema and sources, ran every configuration in this PR as a real build to confirm what it emits, measured the core-js figure quoted above, and drafted the sections; I reviewed and edited the result before pushing.


Generated by Claude Code

Adds the differential-serving recipe the shimming guide was missing: an entry
per layer so webpack walks the graph twice and issuerLayer picks the babel
targets and polyfills for each copy, plus the array-of-configurations form for
when the modern build has to be emitted as real ECMAScript modules.

Also documents the polyfill entry array on the entry page, with what importing
all of core-js/stable actually costs, and links both to the shimming guide.
@vercel

vercel Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
webpack-js-org Ready Ready Preview Sep 13, 2026 3:24pm UTC

Request Review

@alexander-akait
alexander-akait merged commit 8b85270 into main Sep 13, 2026
12 checks passed
@alexander-akait
alexander-akait deleted the docs/differential-builds-with-layers branch September 13, 2026 16:13

This branch was successfully deployed

1 active deployment
Preview — dbb433ed Deployed Sep 13, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant