GeezerVison is showing github.com — refactor(javascript): let each parser helper take an ESTree node or a path by alexander-akait · Pull Request #23574 · webpack/webpack
Conversation
alexander-akait
commented
Nov 26, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
Every helper in lib/javascript/JavascriptParserHelpers.js had a *ByPath copy for { path: true } taps. The two copies differed only in where they read the range and location. Now each helper reads either form. A number as the second argument means a path and a node id; otherwise the argument is an ESTree node.
// before
parser.hooks.evaluateTypeof.for("define").tap({ name, path: true }, evaluateToStringByPath("function"));
// after: the same helper serves object taps and path taps
parser.hooks.evaluateTypeof.for("define").tap({ name, path: true }, evaluateToString("function"));
- Removes
evaluateToBooleanByPath, evaluateToIdentifierByPath, evaluateToNumberByPath, evaluateToStringByPath, expressionIsUnsupportedByPath, toConstantDependencyByPath and getArgumentsRangeByPath, and switches their 20 callers in lib/ to the plain names.
- No hook passes a plain number argument, so the
typeof node === "number" check can't mistake an object tap for a path tap.
- Net: 21 files, +193 / −344.
Note: I didn't measure performance. The only per-call cost added is one typeof check.
What kind of change does this PR introduce?
refactor
Did you add tests for your changes?
No new tests. Existing cases cover both forms: test/configCases/parsing/object-tap-helpers covers object taps, and the configCases of the plugins that switched names cover path taps (1748 cases pass locally).
Does this PR introduce a breaking change?
No. The removed *ByPath helpers were experimental and never released, and the plain helpers keep their behavior for object taps.
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 wrote the refactor, renamed the callers, resolved the rebase conflict and ran yarn lint and the targeted configCases, at the requester's direction.
Generated by Claude Code
Summary by CodeRabbit
- Refactor
- Standardized how JavaScript expressions are handled across webpack’s module formats and built-in features.
- Existing parsing results and behavior are preserved; no user-facing changes are expected.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Walkthrough
-
The parser helper module now supports expression taps and reader/node taps through shared helpers, replacing separate *ByPath exports. Parser plugins across definitions, module systems, import-meta, HMR, URL, worker, and Node handling now use the unified APIs.
Changes: Parser helper unification
| Layer / File(s) |
Summary |
Shared helper contract lib/javascript/JavascriptParserHelpers.js |
Parser helpers now resolve ranges and locations from expression nodes or reader/node pairs. The separate path-specific exports are removed. |
Definitions and built-in identifiers lib/define/DefinePlugin.js, lib/javascript/APIPlugin.js, lib/javascript/ConstPlugin.js, lib/javascript/WebpackIsIncludedPlugin.js, lib/node/NodeStuffPlugin.js |
These plugins now use the unified evaluation and constant-dependency helpers. |
Module-system parser hooks lib/dependencies/amd/*, lib/dependencies/commonjs/*, lib/dependencies/esm/CreateRequireParserPlugin.js, lib/dependencies/system/SystemPlugin.js |
AMD, CommonJS, create-require, and System hooks now use the unified helpers. Their registered values and messages remain unchanged. |
Import-meta, context, and HMR hooks lib/dependencies/context/*, lib/dependencies/import-meta/ImportMetaPlugin.js, lib/hmr/HotModuleReplacementPlugin.js |
These hooks now use the unified identifier, evaluation, and constant-dependency helpers. |
URL and worker argument ranges lib/dependencies/url/URLParserPlugin.js, lib/dependencies/worker/WorkerAndWorkletPlugin.js |
URL and worker parsing now obtains argument ranges through getArgumentsRange. |
Possibly related PRs
- webpack/webpack#23256: Adds the path-specific helper forms that this change folds into the unified helpers.
- webpack/webpack#23251: Converts parser plugins to path-based taps that the unified helpers now support.
Suggested labels: area: parser, area: watch, area: runtime
Suggested reviewers: hai-x, bjohansebas
Change: Refactor
Merge Risk: Minimal · up to 3a611
-
This refactor merges the path-aware parser helpers into the shared ones and updates their internal callers without changing the values or messages they register. No user-facing behavior change is expected, and existing config-case coverage exercises the changed plugins. Merge-readiness risk is minimal.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Description Check |
 |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
 |
The title uses the conventional-commit form with type refactor and scope javascript. The change removes the seven *ByPath helpers and makes each parser helper accept either an ESTree node or a path ta… |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
Full details: Title check
-
Explanation
The title uses the conventional-commit form with type refactor and scope javascript. The change removes the seven *ByPath helpers and makes each parser helper accept either an ESTree node or a path tap, which matches the title. The title is not vague and describes the main change. The title is an author-provided conventional-commit title, and the requirement is type(scope): subject with type from the allowed list and matching the branch prefix. The branch name was not provided, so the branch-prefix match cannot be verified.
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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
-
Recent review info
-
Run configuration
-
Commits
-
Reviewing files that changed from the base of the PR and between a89102d and 3a6115d.
Files selected for processing: 21
-
lib/define/DefinePlugin.js
lib/dependencies/amd/AMDPlugin.js
lib/dependencies/amd/RequireJsStuffPlugin.js
lib/dependencies/commonjs/CommonJsExportsParserPlugin.js
lib/dependencies/commonjs/CommonJsImportsParserPlugin.js
lib/dependencies/commonjs/CommonJsPlugin.js
lib/dependencies/commonjs/RequireEnsurePlugin.js
lib/dependencies/commonjs/RequireIncludeDependencyParserPlugin.js
lib/dependencies/context/ImportMetaContextDependencyParserPlugin.js
lib/dependencies/context/ImportMetaGlobDependencyParserPlugin.js
lib/dependencies/esm/CreateRequireParserPlugin.js
lib/dependencies/import-meta/ImportMetaPlugin.js
lib/dependencies/system/SystemPlugin.js
lib/dependencies/url/URLParserPlugin.js
lib/dependencies/worker/WorkerAndWorkletPlugin.js
lib/hmr/HotModuleReplacementPlugin.js
lib/javascript/APIPlugin.js
lib/javascript/ConstPlugin.js
lib/javascript/JavascriptParserHelpers.js
lib/javascript/WebpackIsIncludedPlugin.js
lib/node/NodeStuffPlugin.js
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Reports for 3a6115d, 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 i -D webpack@https://pkg.pr.new/webpack@23574
yarn add -D webpack@https://pkg.pr.new/webpack@23574
pnpm add -D webpack@https://pkg.pr.new/webpack@23574
From Preview package run #14092.
Generated code size
Comparing base (a89102d) to head (3a6115d). Merging this pull request changes the size of 1 asset(s) whose tests it leaves untouched.
| What moved |
Tests |
Assets |
Gzip |
Raw |
Test edit |
| Changed, test untouched |
1 |
1 |
🟢 ↓ -3 B |
— |
— |
| Changed, test edited |
0 |
0 |
— |
— |
— |
| New |
0 |
0 |
— |
— |
— |
| Deleted |
0 |
0 |
— |
— |
— |
| Unchanged |
— |
11078 |
— |
— |
— |
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.37 KiB |
— |
2.64 KiB |
— |
library amd-require |
1.37 KiB |
— |
2.63 KiB |
— |
library assign |
1.37 KiB |
— |
2.63 KiB |
— |
library assign-properties |
1.41 KiB |
— |
2.75 KiB |
— |
library commonjs |
1.37 KiB |
— |
2.62 KiB |
— |
library commonjs-module |
1.37 KiB |
— |
2.63 KiB |
— |
library commonjs-static |
1.54 KiB |
— |
3.50 KiB |
— |
library commonjs2 |
1.37 KiB |
— |
2.63 KiB |
— |
library global |
1.37 KiB |
— |
2.62 KiB |
— |
library jsonp |
1.37 KiB |
— |
2.62 KiB |
— |
library module |
1.20 KiB |
— |
2.30 KiB |
— |
library self |
1.37 KiB |
— |
2.62 KiB |
— |
library system |
1.40 KiB |
— |
2.69 KiB |
— |
library this |
1.37 KiB |
— |
2.62 KiB |
— |
library umd |
1.43 KiB |
— |
2.82 KiB |
— |
library umd2 |
1.43 KiB |
— |
2.82 KiB |
— |
library var |
1.37 KiB |
— |
2.63 KiB |
— |
library window |
1.37 KiB |
— |
2.62 KiB |
— |
node-ssr |
96.21 KiB |
— |
370.39 KiB |
— |
node-ssr-esm |
96.56 KiB |
— |
370.95 KiB |
— |
react-100 |
32.83 KiB |
— |
151.45 KiB |
— |
react-1k |
73.38 KiB |
— |
897.75 KiB |
— |
react-1k-esm |
72.87 KiB |
— |
896.58 KiB |
— |
react-5k |
188.96 KiB |
— |
4.02 MiB |
— |
webworker |
36.75 KiB |
— |
95.18 KiB |
— |
webworker-esm |
35.89 KiB |
— |
93.90 KiB |
— |
1 asset(s) changed size, test untouched
|
Asset |
Before |
After |
Change |
Gzip (9) |
Brotli (11) |
Zstd (19) |
| 🟢 ↓ |
side-effects/issue-13063 vendors.js.LICENSE.txt |
2.11 KiB |
2.11 KiB |
0 B (—) |
-3 B (-0.67%) |
-2 B (-0.53%) |
-2 B (-0.45%) |
No runtime gained or lost a runtime module.
Built test/configCases with the defaults a user gets, and the apps in test/sizeCoreReports (apps/): 2527 test(s), 11079 asset(s), 112 emitted nothing.
From Generated code size run #8727.
Types Coverage
Typed lines: 99.66% (213082 of 213799)
| Kind |
Base |
Head |
Change |
any |
41 |
41 |
— |
unknown |
20 |
20 |
— |
object |
13 |
13 |
— |
Function |
0 |
0 |
— |
| untyped |
1 |
1 |
— |
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.
34 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/javascript/syntax-printer.js |
99.99% |
|
1 |
2 |
|
|
lib/module/NormalModuleFactory.js |
100.00% |
|
3 |
|
|
|
lib/stats/StatsFactory.js |
100.00% |
2 |
|
1 |
|
|
lib/Compiler.js |
99.89% |
2 |
|
|
|
|
lib/config/defineConfig.js |
100.00% |
2 |
|
|
|
|
lib/hmr/JavascriptHotModuleReplacement.runtime.js |
100.00% |
|
|
2 |
|
|
lib/index.js |
100.00% |
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/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/SourceProcessor.js |
100.00% |
|
|
|
|
1 |
lib/util/makeSerializable.js |
100.00% |
|
|
1 |
|
|
lib/util/terminalColors.js |
100.00% |
|
1 |
|
|
|
lib/worker/Worker.js |
100.00% |
|
1 |
|
|
|
From Types Coverage run #4714.
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 |
131 |
| watch with HMR, one rebuild |
446 |
110 |
From Module loading run #1958.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Merging this PR will improve performance by 20.69%
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
ℹ️ 12 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
⚡ 1 improved benchmark
✅ 350 untouched benchmarks
Performance Changes
Tip Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing refactor/parser-helpers-estree-or-path (3a6115d) with main (a89102d)
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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)
area: runtime
Emitted runtime and chunk loading across targets (lib/runtime, lib/web, lib/node, lib/esm)
area: watch
Watching, HMR, lazy compilation (lib/hmr, hot/)
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.
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.
|