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 — perf(javascript): read every parser hook node by id, so a build makes no ESTree object by alexander-akait · Pull Request #23256 · webpack/webpack

perf(javascript): read every parser hook node by id, so a build makes no ESTree object #23256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
alexander-akait merged 16 commits into main from perf/javascript-plugins-path-taps-rest
Nov 11, 2026

Uh oh!

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

Merged

perf(javascript): read every parser hook node by id, so a build makes no ESTree object #23256

Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
b0ee24b
perf(javascript): add path forms of the parser tap helpers
alexander-akait Nov 10, 2026
aa9cf2b
perf(javascript): read CommonJS and createRequire hook nodes by id
alexander-akait Nov 10, 2026
233cbf6
perf(javascript): read ESM, worker, URL and context hook nodes by id
alexander-akait Nov 10, 2026
d70a9a7
perf(javascript): read AMD, System, Node, HMR and provide hook nodes …
alexander-akait Nov 10, 2026
b1f8a08
perf(javascript): read define, import.meta and parser-own hook nodes …
alexander-akait Nov 10, 2026
ffababf
perf(javascript): read CommonJS export and context nodes by id
alexander-akait Nov 10, 2026
2c03787
perf(javascript): read import, URL and namespace check nodes by id
alexander-akait Nov 10, 2026
dfd3d0b
perf(javascript): walk patterns, labels, updates and dead branches by id
alexander-akait Nov 10, 2026
eb1b3cc
perf(javascript): read AMD, require.ensure and HMR accept nodes by id
alexander-akait Nov 10, 2026
56376f1
perf(javascript): read ESM, live export, import, context and worker n…
alexander-akait Nov 10, 2026
b1b3579
perf(javascript): read import guards, import().then and System.import…
alexander-akait Nov 10, 2026
560297a
perf(javascript): load getFunctionNode on first use
alexander-akait Nov 11, 2026
14d8951
refactor(javascript): type an import option key name instead of unknown
alexander-akait Nov 11, 2026
1e97fd1
fix(javascript): pick an AMD factory's mode detection by its reader
alexander-akait Nov 11, 2026
057ad05
test: cover the object-form parser APIs and drop dead ConstPlugin code
alexander-akait Nov 11, 2026
00c21ca
test: widen the burn gap in hotspots-ranked
alexander-akait Nov 11, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

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

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

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

Diff view
Diff view

There are no files selected for viewing

428 changes: 234 additions & 194 deletions 428 lib/define/DefinePlugin.js
Show comments
View file
Open in desktop

Large diffs are not rendered by default.

Oops, something went wrong.

Uh oh!

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

369 changes: 188 additions & 181 deletions 369 lib/dependencies/amd/AMDDefineDependencyParserPlugin.js
Show comments
View file
Open in desktop

Large diffs are not rendered by default.

Oops, something went wrong.

Uh oh!

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

86 changes: 49 additions & 37 deletions 86 lib/dependencies/amd/AMDPlugin.js
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

const {
approve,
evaluateToIdentifier,
evaluateToString,
toConstantDependency
evaluateToIdentifierByPath,
evaluateToStringByPath,
toConstantDependencyByPath
} = require("../../javascript/JavascriptParserHelpers");
const {
JAVASCRIPT_MODULE_TYPE_AUTO,
Expand Down Expand Up @@ -39,7 +39,7 @@ const UnsupportedDependency = require("./UnsupportedDependency");
* } from "../../../declarations/WebpackOptions"
*/
/** @import Compiler from "../../Compiler" */
/** @import Parser, { Range } from "../../javascript/JavascriptParser" */
/** @import Parser from "../../javascript/JavascriptParser" */
/** @import { GetMembers } from "../../javascript/BasicEvaluatedExpression" */

const PLUGIN_NAME = "AMDPlugin";
Expand Down Expand Up @@ -154,29 +154,33 @@ class AMDPlugin {
parser.hooks.expression
.for(optionExpr)
.tap(
PLUGIN_NAME,
toConstantDependency(parser, RuntimeGlobals.amdOptions, [
{ name: PLUGIN_NAME, path: true },
toConstantDependencyByPath(parser, RuntimeGlobals.amdOptions, [
RuntimeGlobals.amdOptions
])
);
parser.hooks.evaluateIdentifier
.for(optionExpr)
.tap(PLUGIN_NAME, (expr) =>
evaluateToIdentifier(
.tap(
{ name: PLUGIN_NAME, path: true },
evaluateToIdentifierByPath(
optionExpr,
rootName,
getMembers,
true
)(expr)
)
);
parser.hooks.evaluateTypeof
.for(optionExpr)
.tap(PLUGIN_NAME, evaluateToString("object"));
.tap(
{ name: PLUGIN_NAME, path: true },
evaluateToStringByPath("object")
);
parser.hooks.typeof
.for(optionExpr)
.tap(
PLUGIN_NAME,
toConstantDependency(parser, JSON.stringify("object"))
{ name: PLUGIN_NAME, path: true },
toConstantDependencyByPath(parser, JSON.stringify("object"))
);
};

Expand All @@ -193,45 +197,53 @@ class AMDPlugin {
() => []
);

parser.hooks.expression.for("define").tap(PLUGIN_NAME, (expr) => {
const dep = new ConstDependency(
RuntimeGlobals.amdDefine,
/** @type {Range} */ (expr.range),
[RuntimeGlobals.amdDefine]
parser.hooks.expression
.for("define")
.tap(
{ name: PLUGIN_NAME, path: true },
toConstantDependencyByPath(parser, RuntimeGlobals.amdDefine, [
RuntimeGlobals.amdDefine
])
);
dep.loc = parser.getLocation(expr);
parser.state.module.addPresentationalDependency(dep);
return true;
});
parser.hooks.typeof
.for("define")
.tap(
PLUGIN_NAME,
toConstantDependency(parser, JSON.stringify("function"))
{ name: PLUGIN_NAME, path: true },
toConstantDependencyByPath(parser, JSON.stringify("function"))
);
parser.hooks.evaluateTypeof
.for("define")
.tap(PLUGIN_NAME, evaluateToString("function"));
parser.hooks.canRename.for("define").tap(PLUGIN_NAME, approve);
parser.hooks.rename.for("define").tap(PLUGIN_NAME, (expr) => {
const dep = new ConstDependency(
RuntimeGlobals.amdDefine,
/** @type {Range} */ (expr.range),
[RuntimeGlobals.amdDefine]
.tap(
{ name: PLUGIN_NAME, path: true },
evaluateToStringByPath("function")
);
dep.loc = parser.getLocation(expr);
parser.state.module.addPresentationalDependency(dep);
return false;
});
parser.hooks.canRename
.for("define")
.tap({ name: PLUGIN_NAME, path: true }, approve);
parser.hooks.rename
.for("define")
.tap({ name: PLUGIN_NAME, path: true }, (path, node) => {
const dep = new ConstDependency(
RuntimeGlobals.amdDefine,
path.range(node),
[RuntimeGlobals.amdDefine]
);
dep.loc = parser.getLocation(parser.nodeOfPath(path, node));
parser.state.module.addPresentationalDependency(dep);
return false;
});
parser.hooks.typeof
.for("require")
.tap(
PLUGIN_NAME,
toConstantDependency(parser, JSON.stringify("function"))
{ name: PLUGIN_NAME, path: true },
toConstantDependencyByPath(parser, JSON.stringify("function"))
);
parser.hooks.evaluateTypeof
.for("require")
.tap(PLUGIN_NAME, evaluateToString("function"));
.tap(
{ name: PLUGIN_NAME, path: true },
evaluateToStringByPath("function")
);
};

normalModuleFactory.hooks.parser
Expand Down
Loading
Oops, something went wrong.

Uh oh!

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

Loading
Oops, something went wrong.

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.
You are visitor 01402792 — 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.