diff --git a/src/content/api/normalmodulefactory-hooks.mdx b/src/content/api/normalmodulefactory-hooks.mdx index a10d6e437522..6adb4639ac42 100644 --- a/src/content/api/normalmodulefactory-hooks.mdx +++ b/src/content/api/normalmodulefactory-hooks.mdx @@ -67,6 +67,18 @@ Called before a request with scheme (URI) is resolved. - Callback Parameters: `resourceData` `resolveData` +## resolveInScheme + +`HookMap` + + + +Called to resolve a request made from inside a resource that itself has a scheme, when the request carries no scheme of its own — the relative case of [`resolveForScheme`](#resolveforscheme). The map is keyed by the scheme of the importing resource. Return `true` to report the request as resolved; anything else lets webpack fall back to its normal resolution. + +- Hook Parameters: `scheme` + +- Callback Parameters: `resourceData` `resolveData` + ## afterResolve `AsyncSeriesBailHook` @@ -103,6 +115,16 @@ Called after a `NormalModule` instance is created. - Callback Parameters: `module` `createData` `resolveData` +## prepareModuleType + +`HookMap` + + + +Called once for a module type before webpack needs that type's parser or generator, so a plugin can asynchronously load whatever its synchronous [`createParser`](#createparser) or [`createGenerator`](#creategenerator) tap then uses. A type nothing taps, or one already prepared, continues without waiting. + +- Hook Parameters: `type` + ## createParser `HookMap` diff --git a/src/content/api/parser.mdx b/src/content/api/parser.mdx index ca01f1adc4d2..daa8782e906d 100644 --- a/src/content/api/parser.mdx +++ b/src/content/api/parser.mdx @@ -151,6 +151,28 @@ Called when evaluating an identifier that is a defined variable. - Hook Parameters: `identifier` - Callback Parameters: `expression` +### evaluateNewExpression + +`SyncBailHook` + + + +Called when evaluating a `new` expression, keyed by the name of the constructor being called. + +- Hook Parameters: `identifier` +- Callback Parameters: `expression` + +### evaluateCallExpression + +`SyncBailHook` + + + +Called when evaluating a call whose callee is a plain identifier, keyed by that identifier's name. + +- Hook Parameters: `identifier` +- Callback Parameters: `expression` + ### evaluateCallExpressionMember `SyncBailHook` @@ -179,8 +201,19 @@ parser.hooks.evaluateCallExpressionMember.for("myFunc").tap( ); ``` +### isPure + +`SyncBailHook` + +Called to decide whether a node is free of side effects, keyed by the node's type. Returning `false` marks it impure, which keeps webpack from dropping it. + +- Hook Parameters: `type` +- Callback Parameters: `expression` `commentsStartPosition` + ### statement +`SyncBailHook`### statement + `SyncBailHook` General purpose hook that is called for every parsed statement in a code fragment. @@ -225,6 +258,17 @@ Called for every statement during the pre-walk, before any statement of the bloc - Callback Parameters: `statement` +### preStatementByType + +`SyncBailHook` + + + +The per-type form of [`preStatement`](#prestatement), keyed by the statement's node type. It runs only when no `preStatement` tap has already bailed. + +- Hook Parameters: `type` +- Callback Parameters: `statement` + ### blockPreStatement `SyncBailHook` @@ -233,6 +277,17 @@ Same as [`preStatement`](#prestatement), but for the block pre-walk, which only - Callback Parameters: `statement` +### blockPreStatementByType + +`SyncBailHook` + + + +The per-type form of [`blockPreStatement`](#blockprestatement), keyed by the declaration's node type, and run on the same terms as [`preStatementByType`](#prestatementbytype). + +- Hook Parameters: `type` +- Callback Parameters: `declaration` + ### unusedStatement `SyncBailHook` @@ -433,6 +488,17 @@ Called when parsing a variable declaration defined using `const` - Hook Parameters: `identifier` - Callback Parameters: `identifier` +### varDeclarationUsing + +`SyncBailHook` + + + +Called for a variable declared with `using` or `await using`, keyed by the declared name, alongside the [`let`](#vardeclarationlet), [`const`](#vardeclarationconst) and [`var`](#vardeclarationvar) forms. + +- Hook Parameters: `identifier` +- Callback Parameters: `declaration` + ### varDeclarationVar `HookMap` @@ -442,6 +508,15 @@ Called when parsing a variable declaration defined using `var` - Hook Parameters: `identifier` - Callback Parameters: `identifier` +### pattern + +`SyncBailHook` + +Called for each identifier a destructuring pattern binds, keyed by that name. + +- Hook Parameters: `identifier` +- Callback Parameters: `pattern` + ### canRename `SyncBailHook` @@ -494,6 +569,15 @@ parser.hooks.assign.for("a").tap("MyPlugin", (expression) => { }); ``` +### assignMemberChain + +`SyncBailHook` + +Called when a member chain is assigned to, keyed by the name the chain starts from. + +- Hook Parameters: `identifier` +- Callback Parameters: `expression` `members` + ### typeof `SyncBailHook` @@ -537,6 +621,24 @@ parser.hooks.callMemberChain .tap("MyPlugin", (expression, properties) => {}); ``` +### memberChainOfCallMemberChain + +`SyncBailHook` + +Called for a member chain read off the result of a call that was itself made on a member chain, keyed by the name the chain starts from. + +- Hook Parameters: `identifier` +- Callback Parameters: `expression` `calleeMembers` `callExpression` `members` `memberRanges` + +### callMemberChainOfCallMemberChain + +`SyncBailHook` + +The same as [`memberChainOfCallMemberChain`](#memberchainofcallmemberchain), for when that outer member chain is itself called. + +- Hook Parameters: `identifier` +- Callback Parameters: `expression` `calleeMembers` `callExpression` `members` `memberRanges` + ### new `SyncBailHook` @@ -567,6 +669,24 @@ const a = this; parser.hooks.expression.for("this").tap("MyPlugin", (expression) => {}); ``` +### expressionMemberChain + +`SyncBailHook` + +Called for a member chain read as an expression, keyed by the name the chain starts from. + +- Hook Parameters: `identifier` +- Callback Parameters: `expression` `members` `membersOptionals` `memberRanges` + +### unhandledExpressionMemberChain + +`SyncBailHook` + +Called for a member chain that [`expressionMemberChain`](#expressionmemberchain) left unhandled, keyed by the name the chain starts from. + +- Hook Parameters: `identifier` +- Callback Parameters: `expression` `members` + ### expressionConditionalOperator `SyncBailHook` @@ -657,6 +777,14 @@ Called with the test of a conditional expression to collect the guards it implie - Callback Parameters: `expression` +### finish + +`SyncBailHook` + +Called after the whole program has been walked, with the parsed AST and its comments. + +- Callback Parameters: `ast` `comments` + ### program `SyncBailHook`