Skip to content

feat(vanilla): add bundled build strategy to reduce MultiCompiler fan-out - #54

Merged
Hug0-Drelon merged 5 commits into
masterfrom
feat/bundled-vanilla-strategy
Oct 16, 2026
Merged

Hug0-Drelon merged 5 commits into
masterfrom
feat/bundled-vanilla-strategy

Conversation

@Hug0-Drelon

@Hug0-Drelon Hug0-Drelon commented Oct 9, 2026 •

Copy link
Copy Markdown
Member

What?

Release v2.5.0: add an opt-in strategy: 'bundled' option to getVanillaConfig, bundled entry-key modes for consumer-facing output paths, and runWebpackConfigs for concurrency-limited builds.

Why?

The legacy per-file vanilla strategy creates one webpack config per source file per variant (4 × file count). webpack-cli runs these via MultiCompiler in parallel, which drove high peak memory and slow builds in Polylang Pro before glob fixes — and remains a bottleneck for any consumer with many vanilla assets.

Polylang-family plugins enqueue flat build URLs (js/build/settings.min.js). Bundled builds default to the same flat layout as per-file (entryKey: 'basename'), so consumers need not pass entryKey or maintain local webpack hacks.

How?

  • strategy: 'bundled' (default remains 'per-file'): emits up to 4 configs — JS min/unmin + CSS min/unmin — using multi-entry webpack configs. Invalid strategy values throw (no silent fallback to per-file).
  • entryKey (bundled only): 'basename' (default) for flat js/build/{name} paths, or 'relative' for nested outputs mirroring source paths. Duplicate basenames in one bundled config throw at config generation time.
  • createBundledJsConfig / createBundledCssConfig: collision-safe entry maps; splitChunks / runtimeChunk disabled so each entry stays one file; bundled CSS scopes CleanWebpackPlugin to the output directory.
  • CSS intermediates: min/unmin use distinct .min.work / .unmin.work files so bundled (and per-file) CSS min + unmin can run in parallel without racing on the same paths. Per-file CSS cleanup is scoped to the output directory instead of process.cwd().
  • Glob dedupe: stable deduplication when multiple patterns match the same file.
  • runWebpackConfigs(configs, { concurrency }): TypeError for non-array configs or invalid concurrency; fail-fast on first compilation error; Infinity concurrency still supported.

Versioning

  • Bump @wpsyntex/polylang-build-scripts to 2.5.0 (minor): new public APIs plus CSS intermediate filename and clean-scope changes that apply to all vanilla strategies (not only bundled).

Test plan

  • npm test (77 tests)
  • npm run lint
  • Integration: nested bundled outputs (entryKey: 'relative'), default flat JS/CSS, parallel bundled CSS min/unmin, no extra chunks with shared local imports
  • Consumer smoke test: Polylang Pro with strategy: 'bundled' only (~6 total configs instead of ~54)

…-out

Per-file vanilla configs spawn one webpack compiler per source file per
variant, causing webpack-cli MultiCompiler to run many parallel builds and
OOM on large projects. Add opt-in strategy: 'bundled' (4 configs) plus
runWebpackConfigs for concurrency-limited builds.
Add entryKey basename mode with collision checks, parallel-safe CSS intermediates, strategy validation, and runWebpackConfigs input guards.
Document naming table, collision behavior, CSS intermediates, and per-file clean scope change.
Flat build URLs match per-file and Polylang PHP enqueues; use entryKey relative for nested outputs.
@Hug0-Drelon Hug0-Drelon added the enhancement New feature or request label Oct 16, 2026
@Hug0-Drelon
Hug0-Drelon merged commit 766c0cb into master Oct 16, 2026
3 checks passed
@Hug0-Drelon
Hug0-Drelon deleted the feat/bundled-vanilla-strategy branch October 16, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant