GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(javascript): drop a loop breaking the labeled block it ends after a join in one pass by alexander-akait · Pull Request #23515 · webpack/webpack

Conversation

@alexander-akait

@alexander-akait alexander-akait commented Nov 21, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Summary

The one-pass minifier left a loop that breaks the labeled block it ends, when a statement before it joined the loop's head. Only a second pass removed it.

Input One pass, before One pass, after (= second pass)
x:{g();for(;;)break x} x:for(g();;)break x; g();
x:{for(var i=g();;)break x}return[i,i] x:for(var i=g();;)break x;… var i=g();…

#23462 drops such a loop when its head runs nothing (breaksRunningNothing). Here the joined g() runs, so printsBrokenLoop has to print the head once. It only counted a break naming the loop's own label as leaving the loop. The pre-pass now records each loop that ends a labeled block (endingLoops), and breaksOwnLoop counts a break naming that block too. A let/const start stays out: printing it would lose the braces that keep its scope.

Code changes only for these shapes; no other snapshot of the JavaScript invariants, printer or parser suites moved, including #23509's generated corpus.

Not covered here: a label that drops, leaving an expression, still doesn't join the next statement's sequence in one pass (x:g();h() prints g();h(), then g(),h()). That happens on main too.

What kind of change does this PR introduce?

fix

Did you add tests for your changes?

Yes. test/fixtures/javascript/minify-drops-a-loop-breaking-the-labeled-block-it-ends/ gains a joined case and a var start, with its behavior check. A test in test/unitCases/javascript/printer.unittest.js asserts both print in one pass as a second pass does. It fails on main.

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

Use of AI

Claude Code found the cause, wrote the fix, the fixture cases and the test, and ran the checks, from the maintainer's note of the gap.


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed JavaScript minification that could incorrectly omit content from a loop when it ended a labeled block with a break.
    • Preserved variable declarations and values in affected loops.
    • Ensured repeated minification produces consistent output for this case.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@alexander-akait
fix(javascript): drop a loop breaking the labeled block it ends after…
0c88504
… a join in one pass

Claude-Session: https://claude.ai/code/session_013FhutRjRnaBAwgtK8Qe5bW
@changeset-bot

changeset-bot Bot commented Nov 21, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 0c88504

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the area: parser JavaScript parsing and dependency analysis (lib/javascript, lib/dependencies) label Nov 21, 2026
@github-actions

github-actions Bot commented Nov 21, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Reports for 0c88504, computed by this pull request's own code. Each section updates when its workflow finishes.


Preview package

This PR is packaged and the instant preview of its latest commit is available.

Install it locally:

  • npm
npm i -D webpack@https://pkg.pr.new/webpack@23515
  • yarn
yarn add -D webpack@https://pkg.pr.new/webpack@23515
  • pnpm
pnpm add -D webpack@https://pkg.pr.new/webpack@23515

From Preview package run #13866.


Generated code size

Comparing base (56faf8f) to head (0c88504). Merging this pull request will not change the code webpack generates.

What moved Tests Assets Gzip Raw Test edit
Changed, test untouched 0 0 — — —
Changed, test edited 0 0 — — —
New 0 0 — — —
Deleted 0 0 — — —
Unchanged — 10939 — — —

Read Changed, test untouched first: the test is byte-identical on both sides, so webpack generated the difference. Changed, test edited moved partly because the test did — Test edit is how many bytes the test gained, and a bundle that grew by less is not a regression. New and Deleted are whole files, not deltas — a new asset was created, not grown, so it reads gray (⚪ added) — and adding tests cannot bury a real change. Gzip decides, because that is what users download; raw is the tiebreak, and brotli and zstd are per asset below.

Sample apps

No sample app changed size.

26 unchanged app(s)
App Gzip Gzip change Raw Raw change
library amd 1.38 KiB — 2.68 KiB —
library amd-require 1.38 KiB — 2.67 KiB —
library assign 1.38 KiB — 2.66 KiB —
library assign-properties 1.42 KiB — 2.80 KiB —
library commonjs 1.38 KiB — 2.66 KiB —
library commonjs-module 1.38 KiB — 2.67 KiB —
library commonjs-static 1.55 KiB — 3.54 KiB —
library commonjs2 1.38 KiB — 2.67 KiB —
library global 1.38 KiB — 2.66 KiB —
library jsonp 1.37 KiB — 2.66 KiB —
library module 1.21 KiB — 2.35 KiB —
library self 1.38 KiB — 2.66 KiB —
library system 1.41 KiB — 2.73 KiB —
library this 1.37 KiB — 2.66 KiB —
library umd 1.44 KiB — 2.85 KiB —
library umd2 1.44 KiB — 2.85 KiB —
library var 1.38 KiB — 2.67 KiB —
library window 1.38 KiB — 2.66 KiB —
node-ssr 96.36 KiB — 371.26 KiB —
node-ssr-esm 96.60 KiB — 371.83 KiB —
react-100 32.14 KiB — 150.41 KiB —
react-1k 73.31 KiB — 907.23 KiB —
react-1k-esm 72.51 KiB — 906.05 KiB —
react-5k 191.45 KiB — 4.08 MiB —
webworker 36.60 KiB — 94.98 KiB —
webworker-esm 35.67 KiB — 93.65 KiB —

No asset changed size.

No runtime gained or lost a runtime module.

Built test/configCases with the defaults a user gets, and the apps in test/sizeCoreReports (apps/): 2512 test(s), 10939 asset(s), 112 emitted nothing.

From Generated code size run #8501.


Types Coverage

Typed lines: 99.66% (206465 of 207178)

Kind Base Head Change
any 41 41 —
unknown 18 18 —
object 15 15 —
Function 0 0 —
untyped 0 0 —

any counts EXPECTED_ANY, a written any and JSDoc's * and ? for any type. unknown counts a written unknown; ThrownValue, the unknown a throw or a rejected promise hands on, is left out. object counts EXPECTED_OBJECT and Object, Function counts EXPECTED_FUNCTION. Untyped counts the any TypeScript infers where no type is written: a type argument a call leaves to inference that comes out any, whether a lib signature defaults it, as in const map = new Map() and Array(5), or a generic call infers it from an any argument; and const list = []. An identifier that only holds an any written in the project's files is not counted again, as the any row counts it where it is written; an any a lib signature returns, such as JSON.parse's, is counted in neither row.

This pull request adds or removes no escape hatch, any or untyped identifier.

33 file(s) in lib/, hot/, declarations/ and bin/ still have an escape hatch, `any` or untyped identifiers
File Typed lines any unknown object Function untyped
declarations/WebpackOptions.ts 100.00% 7
lib/Compilation.js 99.97% 5 2
lib/module/NormalModule.js 100.00% 4 1
lib/loaders/LoaderOptionsPlugin.js 100.00% 4
lib/serialization/ObjectMiddleware.js 100.00% 4
lib/util/SortableSet.js 100.00% 4
lib/hmr/HotModuleReplacement.runtime.js 100.00% 2 1
lib/module/NormalModuleFactory.js 100.00% 3
lib/stats/StatsFactory.js 100.00% 2 1
lib/Compiler.js 100.00% 2
lib/config/defineConfig.js 100.00% 2
lib/hmr/JavascriptHotModuleReplacement.runtime.js 100.00% 2
lib/index.js 100.00% 2
lib/javascript/syntax-printer.js 99.99% 2
lib/loaders/LoaderRunner.js 100.00% 2
lib/module/Module.js 100.00% 2
lib/module/Parser.js 100.00% 2
lib/node/nodeConsole.js 100.00% 2
lib/util/cleverMerge.js 100.00% 2
lib/config/cli.js 100.00% 1
lib/dll/DllReferencePlugin.js 100.00% 1
lib/graph/ModuleGraph.js 100.00% 1
lib/hmr/HotModuleReplacementPlugin.js 100.00% 1
lib/javascript/JavascriptParser.js 100.00% 1
lib/javascript/syntax-parser.js 100.00% 1
lib/logging/Logger.js 100.00% 1
lib/logging/createConsoleLogger.js 100.00% 1
lib/output/ManifestPlugin.js 100.00% 1
lib/serialization/types.js 100.00% 1
lib/stats/DefaultStatsFactoryPlugin.js 100.00% 1
lib/stats/StatsPrinter.js 100.00% 1
lib/util/makeSerializable.js 100.00% 1
lib/util/terminalColors.js 100.00% 1

From Types Coverage run #4534.


Module loading

How many files a fresh Node.js process loads (require or import) to do each thing below; a change from the pull request's base is marked 🔴 when it grew and 🟢 when it shrank. Every file is startup time, so fewer is better. webpack files are this package's own (lib/, hot/); node_modules files are its dependencies'.

What the process does webpack files node_modules files
require("webpack") 2 0
import "webpack" 2 0
JavaScript syntax 12 0
CSS syntax 12 0
HTML syntax 11 0
XML syntax 11 0
JavaScript minifier 13 0
CSS minifier 14 0
HTML minifier 19 0
XML minifier 14 0
JSON minifier 1 0
development build 422 103
production build 430 133
watch with HMR, one rebuild 446 110

From Module loading run #1778.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@coderabbitai

coderabbitai Bot commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The syntax printer records loops that end labeled blocks, with an exception for for loops whose initializer uses let or const. Broken-loop handling uses the recorded label when checking break targets. A fixture and regression test cover the behavior.

Changes: Labeled-block loop break handling

Layer / File(s) Summary
Record loops ending labeled blocks
lib/javascript/syntax-printer.js
The printer records eligible loops and their labels, and clears the mapping when print state resets.
Check labeled break targets
lib/javascript/syntax-printer.js, test/fixtures/javascript/minify-drops-a-loop-breaking-the-labeled-block-it-ends/index.js, test/unitCases/javascript/printer.unittest.js
breaksOwnLoop, varsAfterBreak, and printsBrokenLoop use the recorded label when checking break targets. The fixture adds labeled-block break cases, and the regression test checks generated output and repeated minification.

Possibly related PRs

  • webpack/webpack#23462: This PR also addresses dropping a loop that breaks the labeled block it ends and changes the same fixture path.
  • webpack/webpack#23131: This PR changes loop-removal decisions and break-label handling in the same code path.

Suggested labels: area: parser

Suggested reviewers: aryanraj45, bjohansebas

Change: Bug fix

Merge Risk: Minimal · up to 0c885

This change lets the minifier remove a loop that breaks the labeled block it ends in a single pass. It has a narrow scope and no concrete merge-blocking risk was found.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Title check Inconclusive The title uses the conventional-commit form fix(javascript): .... The type fix is allowed. The scope is javascript. The subject names the change: a loop that breaks the labeled block it ends is … Confirm the source branch name starts with the fix prefix, as the title requirement says the type must match the branch prefix. No branch name appears in the provided context. If the branch uses another prefix, rename the branch or change…
Passed Passed checks: 3 passed

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title uses the conventional-commit form fix(javascript): .... The type fix is allowed. The scope is javascript. The subject names the change: a loop that breaks the labeled block it ends is dropped in one pass after a join. The raw summary and objectives describe this same change in the minifier. The title does not match the branch prefix check, because no branch name was provided in the context, so that part cannot be verified.

Resolution

Confirm the source branch name starts with the fix prefix, as the title requirement says the type must match the branch prefix. No branch name appears in the provided context. If the branch uses another prefix, rename the branch or change the title type to match it.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ast-grep (0.51.1)

lib/javascript/syntax-printer.js

ast-grep timed out on this file

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

  • X
  • Mastodon
  • Reddit
  • LinkedIn
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: webpack/webpack
  • Branch: fix/minify-labeled-break-loop
  • File: .coderabbit.yaml
  • Commit: 0c88504
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a8f8625f-f5f2-41c3-b436-5835ffa0576f
Commits

Reviewing files that changed from the base of the PR and between 56faf8f and 0c88504.

Files ignored due to path filters: 1

  • test/unitCases/javascript/__snapshots__/invariants.unittest.js.snap is excluded by !**/*.snap, !test/**/__snapshots__/**
Files selected for processing: 3

  • lib/javascript/syntax-printer.js
  • test/fixtures/javascript/minify-drops-a-loop-breaking-the-labeled-block-it-ends/index.js
  • test/unitCases/javascript/printer.unittest.js

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@codspeed

codspeed Bot commented Nov 21, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning, 1 note

⚠️ 117 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

ℹ️ 39 benchmarks have no flamegraph

The flamegraph wasn't generated: most of the time was spent in runtime internals, which would leave nothing useful to analyze.

See affected benchmarks

✅ 351 untouched benchmarks


Comparing fix/minify-labeled-break-loop (0c88504) with main (56faf8f)

Open in CodSpeed
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@alexander-akait
alexander-akait merged commit 0d4f2f3 into main Nov 21, 2026
55 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@alexander-akait
alexander-akait deleted the fix/minify-labeled-break-loop branch November 21, 2026 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

area: parser JavaScript parsing and dependency analysis (lib/javascript, lib/dependencies)

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@alexander-akait
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.