refactor: udate acorn

refactor: update acorn
This commit is contained in:
Alexander Akait 2024-10-31 20:07:50 +03:00 committed by GitHub
commit 6a6f14fc04
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 333 additions and 192 deletions

4
declarations.d.ts vendored
View File

@ -414,10 +414,6 @@ type RecursiveArrayOrRecord<T> =
| Array<RecursiveArrayOrRecord<T>>
| T;
declare module "acorn-import-attributes" {
export function importAttributesOrAssertions(BaseParser: typeof import("acorn").Parser): typeof import("acorn").Parser;
}
declare module "loader-runner" {
export function getContext(resource: string) : string;
export function runLoaders(options: any, callback: (err: Error | null, result: any) => void): void;

View File

@ -5,6 +5,7 @@
"use strict";
const { getImportAttributes } = require("../javascript/JavascriptParser");
const InnerGraph = require("../optimize/InnerGraph");
const ConstDependency = require("./ConstDependency");
const HarmonyExportExpressionDependency = require("./HarmonyExportExpressionDependency");
@ -13,8 +14,7 @@ const HarmonyExportImportedSpecifierDependency = require("./HarmonyExportImporte
const HarmonyExportSpecifierDependency = require("./HarmonyExportSpecifierDependency");
const { ExportPresenceModes } = require("./HarmonyImportDependency");
const {
harmonySpecifierTag,
getAttributes
harmonySpecifierTag
} = require("./HarmonyImportDependencyParserPlugin");
const HarmonyImportSideEffectDependency = require("./HarmonyImportSideEffectDependency");
@ -78,7 +78,7 @@ module.exports = class HarmonyExportDependencyParserPlugin {
const sideEffectDep = new HarmonyImportSideEffectDependency(
/** @type {string} */ (source),
parser.state.lastHarmonyImportOrder,
getAttributes(statement)
getImportAttributes(statement)
);
sideEffectDep.loc = Object.create(
/** @type {DependencyLocation} */ (statement.loc)

View File

@ -6,6 +6,7 @@
"use strict";
const HotModuleReplacementPlugin = require("../HotModuleReplacementPlugin");
const { getImportAttributes } = require("../javascript/JavascriptParser");
const InnerGraph = require("../optimize/InnerGraph");
const ConstDependency = require("./ConstDependency");
const HarmonyAcceptDependency = require("./HarmonyAcceptDependency");
@ -16,11 +17,7 @@ const { ExportPresenceModes } = require("./HarmonyImportDependency");
const HarmonyImportSideEffectDependency = require("./HarmonyImportSideEffectDependency");
const HarmonyImportSpecifierDependency = require("./HarmonyImportSpecifierDependency");
/** @typedef {import("estree").ExportAllDeclaration} ExportAllDeclaration */
/** @typedef {import("estree").ExportNamedDeclaration} ExportNamedDeclaration */
/** @typedef {import("estree").Identifier} Identifier */
/** @typedef {import("estree").ImportDeclaration} ImportDeclaration */
/** @typedef {import("estree").ImportExpression} ImportExpression */
/** @typedef {import("estree").Literal} Literal */
/** @typedef {import("estree").MemberExpression} MemberExpression */
/** @typedef {import("estree").ObjectExpression} ObjectExpression */
@ -30,7 +27,11 @@ const HarmonyImportSpecifierDependency = require("./HarmonyImportSpecifierDepend
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("../javascript/JavascriptParser").DestructuringAssignmentProperty} DestructuringAssignmentProperty */
/** @typedef {import("../javascript/JavascriptParser").ExportAllDeclaration} ExportAllDeclaration */
/** @typedef {import("../javascript/JavascriptParser").ExportNamedDeclaration} ExportNamedDeclaration */
/** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */
/** @typedef {import("../javascript/JavascriptParser").ImportDeclaration} ImportDeclaration */
/** @typedef {import("../javascript/JavascriptParser").ImportExpression} ImportExpression */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/** @typedef {import("../optimize/InnerGraph").InnerGraph} InnerGraph */
/** @typedef {import("../optimize/InnerGraph").TopLevelSymbol} TopLevelSymbol */
@ -48,73 +49,6 @@ const harmonySpecifierTag = Symbol("harmony import");
* @property {Record<string, any> | undefined} assertions
*/
/**
* @param {ImportDeclaration | ExportNamedDeclaration | ExportAllDeclaration | (ImportExpression & { arguments?: ObjectExpression[] })} node node with assertions
* @returns {ImportAttributes | undefined} import attributes
*/
function getAttributes(node) {
if (
node.type === "ImportExpression" &&
node.arguments &&
node.arguments[0] &&
node.arguments[0].type === "ObjectExpression" &&
node.arguments[0].properties[0] &&
node.arguments[0].properties[0].type === "Property" &&
node.arguments[0].properties[0].value.type === "ObjectExpression" &&
node.arguments[0].properties[0].value.properties
) {
const properties =
/** @type {Property[]} */
(node.arguments[0].properties[0].value.properties);
const result = /** @type {ImportAttributes} */ ({});
for (const property of properties) {
const key =
/** @type {string} */
(
property.key.type === "Identifier"
? property.key.name
: /** @type {Literal} */ (property.key).value
);
result[key] =
/** @type {string} */
(/** @type {Literal} */ (property.value).value);
}
const key =
node.arguments[0].properties[0].key.type === "Identifier"
? node.arguments[0].properties[0].key.name
: /** @type {Literal} */ (node.arguments[0].properties[0].key).value;
if (key === "assert") {
result._isLegacyAssert = true;
}
return result;
}
// TODO remove cast when @types/estree has been updated to import assertions
const isImportAssertion =
/** @type {{ assertions?: ImportAttributeNode[] }} */ (node).assertions !==
undefined;
const attributes = isImportAssertion
? /** @type {{ assertions?: ImportAttributeNode[] }} */ (node).assertions
: /** @type {{ attributes?: ImportAttributeNode[] }} */ (node).attributes;
if (attributes === undefined) {
return;
}
const result = /** @type {ImportAttributes} */ ({});
for (const attribute of attributes) {
const key =
/** @type {string} */
(
attribute.key.type === "Identifier"
? attribute.key.name
: attribute.key.value
);
result[key] = /** @type {string} */ (attribute.value.value);
}
if (isImportAssertion) {
result._isLegacyAssert = true;
}
return result;
}
module.exports = class HarmonyImportDependencyParserPlugin {
/**
* @param {JavascriptParserOptions} options options
@ -184,7 +118,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
clearDep.loc = /** @type {DependencyLocation} */ (statement.loc);
parser.state.module.addPresentationalDependency(clearDep);
parser.unsetAsiPosition(/** @type {Range} */ (statement.range)[1]);
const attributes = getAttributes(statement);
const attributes = getImportAttributes(statement);
const sideEffectDep = new HarmonyImportSideEffectDependency(
/** @type {string} */ (source),
parser.state.lastHarmonyImportOrder,
@ -204,7 +138,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
source,
ids,
sourceOrder: parser.state.lastHarmonyImportOrder,
assertions: getAttributes(statement)
assertions: getImportAttributes(statement)
});
return true;
}
@ -434,6 +368,3 @@ module.exports = class HarmonyImportDependencyParserPlugin {
};
module.exports.harmonySpecifierTag = harmonySpecifierTag;
// TODO remove it in webpack@6 in favor getAttributes
module.exports.getAssertions = getAttributes;
module.exports.getAttributes = getAttributes;

View File

@ -8,20 +8,20 @@
const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
const CommentCompilationWarning = require("../CommentCompilationWarning");
const UnsupportedFeatureWarning = require("../UnsupportedFeatureWarning");
const { getImportAttributes } = require("../javascript/JavascriptParser");
const ContextDependencyHelpers = require("./ContextDependencyHelpers");
const { getAttributes } = require("./HarmonyImportDependencyParserPlugin");
const ImportContextDependency = require("./ImportContextDependency");
const ImportDependency = require("./ImportDependency");
const ImportEagerDependency = require("./ImportEagerDependency");
const ImportWeakDependency = require("./ImportWeakDependency");
/** @typedef {import("estree").ImportExpression} ImportExpression */
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
/** @typedef {import("../ChunkGroup").RawChunkGroupOptions} RawChunkGroupOptions */
/** @typedef {import("../ContextModule").ContextMode} ContextMode */
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
/** @typedef {import("../Module").BuildMeta} BuildMeta */
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("../javascript/JavascriptParser").ImportExpression} ImportExpression */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
class ImportParserPlugin {
@ -260,7 +260,7 @@ class ImportParserPlugin {
}
if (param.isString()) {
const attributes = getAttributes(expr);
const attributes = getImportAttributes(expr);
if (mode === "eager") {
const dep = new ImportEagerDependency(
@ -323,7 +323,7 @@ class ImportParserPlugin {
typePrefix: "import()",
category: "esm",
referencedExports: exports,
attributes: getAttributes(expr)
attributes: getImportAttributes(expr)
},
parser
);

View File

@ -125,7 +125,8 @@ class SystemPlugin {
/** @type {import("estree").Literal} */
(expr.arguments[0]),
loc: expr.loc,
range: expr.range
range: expr.range,
options: null
});
});
};

View File

@ -5,8 +5,7 @@
"use strict";
const { Parser: AcornParser } = require("acorn");
const { importAttributesOrAssertions } = require("acorn-import-attributes");
const { Parser: AcornParser, tokTypes } = require("acorn");
const { SyncBailHook, HookMap } = require("tapable");
const vm = require("vm");
const Parser = require("../Parser");
@ -27,11 +26,9 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
/** @typedef {import("estree").CallExpression} CallExpression */
/** @typedef {import("estree").BaseCallExpression} BaseCallExpression */
/** @typedef {import("estree").StaticBlock} StaticBlock */
/** @typedef {import("estree").ImportExpression} ImportExpression */
/** @typedef {import("estree").ClassDeclaration} ClassDeclaration */
/** @typedef {import("estree").ForStatement} ForStatement */
/** @typedef {import("estree").SwitchStatement} SwitchStatement */
/** @typedef {import("estree").ExportNamedDeclaration} ExportNamedDeclaration */
/** @typedef {import("estree").ClassExpression} ClassExpression */
/** @typedef {import("estree").Comment} Comment */
/** @typedef {import("estree").ConditionalExpression} ConditionalExpression */
@ -71,7 +68,6 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
/** @typedef {import("estree").WithStatement} WithStatement */
/** @typedef {import("estree").ThrowStatement} ThrowStatement */
/** @typedef {import("estree").MethodDefinition} MethodDefinition */
/** @typedef {import("estree").ModuleDeclaration} ModuleDeclaration */
/** @typedef {import("estree").NewExpression} NewExpression */
/** @typedef {import("estree").SpreadElement} SpreadElement */
/** @typedef {import("estree").FunctionExpression} FunctionExpression */
@ -85,9 +81,7 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
/** @typedef {import("estree").Program} Program */
/** @typedef {import("estree").Directive} Directive */
/** @typedef {import("estree").Statement} Statement */
/** @typedef {import("estree").ImportDeclaration} ImportDeclaration */
/** @typedef {import("estree").ExportDefaultDeclaration} ExportDefaultDeclaration */
/** @typedef {import("estree").ExportAllDeclaration} ExportAllDeclaration */
/** @typedef {import("estree").Super} Super */
/** @typedef {import("estree").TaggedTemplateExpression} TaggedTemplateExpression */
/** @typedef {import("estree").TemplateLiteral} TemplateLiteral */
@ -105,7 +99,13 @@ const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
/** @typedef {function(string, Identifier): void} OnIdent */
/** @typedef {StatementPathItem[]} StatementPath */
/** @typedef {Record<string, string> & { _isLegacyAssert?: boolean }} ImportAttributes */
// TODO remove cast when @types/estree has been updated to import assertions
/** @typedef {import("estree").BaseNode & { type: "ImportAttribute", key: Identifier | Literal, value: Literal }} ImportAttribute */
/** @typedef {import("estree").ImportDeclaration & { attributes?: Array<ImportAttribute> }} ImportDeclaration */
/** @typedef {import("estree").ExportNamedDeclaration & { attributes?: Array<ImportAttribute> }} ExportNamedDeclaration */
/** @typedef {import("estree").ExportAllDeclaration & { attributes?: Array<ImportAttribute> }} ExportAllDeclaration */
/** @typedef {import("estree").ImportExpression & { options?: Expression | null }} ImportExpression */
/** @typedef {ImportDeclaration | ExportNamedDeclaration | ExportDefaultDeclaration | ExportAllDeclaration} ModuleDeclaration */
/** @type {string[]} */
const EMPTY_ARRAY = [];
@ -113,9 +113,146 @@ const ALLOWED_MEMBER_TYPES_CALL_EXPRESSION = 0b01;
const ALLOWED_MEMBER_TYPES_EXPRESSION = 0b10;
const ALLOWED_MEMBER_TYPES_ALL = 0b11;
// Syntax: https://developer.mozilla.org/en/SpiderMonkey/Parser_API
const LEGACY_ASSERT_ATTRIBUTES = Symbol("assert");
const parser = AcornParser.extend(importAttributesOrAssertions);
/**
* @param {any} Parser parser
* @returns {typeof AcornParser} extender acorn parser
*/
const importAssertions = Parser =>
/** @type {typeof AcornParser} */ (
/** @type {unknown} */ (
class extends Parser {
parseWithClause() {
const nodes = [];
const isAssertLegacy = this.value === "assert";
if (isAssertLegacy) {
if (!this.eat(tokTypes.name)) {
return nodes;
}
} else if (!this.eat(tokTypes._with)) {
return nodes;
}
this.expect(tokTypes.braceL);
const attributeKeys = {};
let first = true;
while (!this.eat(tokTypes.braceR)) {
if (!first) {
this.expect(tokTypes.comma);
if (this.afterTrailingComma(tokTypes.braceR)) {
break;
}
} else {
first = false;
}
const attr = this.parseImportAttribute();
const keyName =
attr.key.type === "Identifier" ? attr.key.name : attr.key.value;
if (Object.prototype.hasOwnProperty.call(attributeKeys, keyName)) {
this.raiseRecoverable(
attr.key.start,
`Duplicate attribute key '${keyName}'`
);
}
attributeKeys[keyName] = true;
nodes.push(attr);
}
if (isAssertLegacy) {
nodes[LEGACY_ASSERT_ATTRIBUTES] = true;
}
return nodes;
}
}
)
);
// Syntax: https://developer.mozilla.org/en/SpiderMonkey/Parser_API
const parser = AcornParser.extend(importAssertions);
/** @typedef {Record<string, string> & { _isLegacyAssert?: boolean }} ImportAttributes */
/**
* @param {ImportDeclaration | ExportNamedDeclaration | ExportAllDeclaration | ImportExpression} node node with assertions
* @returns {ImportAttributes | undefined} import attributes
*/
const getImportAttributes = node => {
if (node.type === "ImportExpression") {
if (
node.options &&
node.options.type === "ObjectExpression" &&
node.options.properties[0] &&
node.options.properties[0].type === "Property" &&
node.options.properties[0].key.type === "Identifier" &&
(node.options.properties[0].key.name === "with" ||
node.options.properties[0].key.name === "assert") &&
node.options.properties[0].value.type === "ObjectExpression" &&
node.options.properties[0].value.properties.length > 0
) {
const properties =
/** @type {Property[]} */
(node.options.properties[0].value.properties);
const result = /** @type {ImportAttributes} */ ({});
for (const property of properties) {
const key =
/** @type {string} */
(
property.key.type === "Identifier"
? property.key.name
: /** @type {Literal} */ (property.key).value
);
result[key] =
/** @type {string} */
(/** @type {Literal} */ (property.value).value);
}
const key =
node.options.properties[0].key.type === "Identifier"
? node.options.properties[0].key.name
: /** @type {Literal} */ (node.options.properties[0].key).value;
if (key === "assert") {
result._isLegacyAssert = true;
}
return result;
}
return;
}
if (node.attributes === undefined || node.attributes.length === 0) {
return;
}
const result = /** @type {ImportAttributes} */ ({});
for (const attribute of node.attributes) {
const key =
/** @type {string} */
(
attribute.key.type === "Identifier"
? attribute.key.name
: attribute.key.value
);
result[key] = /** @type {string} */ (attribute.value.value);
}
if (node.attributes[LEGACY_ASSERT_ATTRIBUTES]) {
result._isLegacyAssert = true;
}
return result;
};
class VariableInfo {
/**
@ -4866,3 +5003,4 @@ module.exports.ALLOWED_MEMBER_TYPES_EXPRESSION =
ALLOWED_MEMBER_TYPES_EXPRESSION;
module.exports.ALLOWED_MEMBER_TYPES_CALL_EXPRESSION =
ALLOWED_MEMBER_TYPES_CALL_EXPRESSION;
module.exports.getImportAttributes = getImportAttributes;

View File

@ -9,8 +9,7 @@
"@webassemblyjs/ast": "^1.12.1",
"@webassemblyjs/wasm-edit": "^1.12.1",
"@webassemblyjs/wasm-parser": "^1.12.1",
"acorn": "^8.7.1",
"acorn-import-attributes": "^1.9.5",
"acorn": "^8.14.0",
"browserslist": "^4.24.0",
"chrome-trace-event": "^1.0.2",
"enhanced-resolve": "^5.17.1",

239
types.d.ts vendored
View File

@ -14,6 +14,7 @@ import {
AssignmentPattern,
AssignmentProperty,
AwaitExpression,
BaseNode,
BigIntLiteral,
BinaryExpression,
BlockStatement,
@ -30,9 +31,9 @@ import {
Directive,
DoWhileStatement,
EmptyStatement,
ExportAllDeclaration,
ExportAllDeclaration as ExportAllDeclarationImport,
ExportDefaultDeclaration,
ExportNamedDeclaration,
ExportNamedDeclaration as ExportNamedDeclarationImport,
ExportSpecifier,
ExpressionStatement,
ForInStatement,
@ -42,9 +43,9 @@ import {
FunctionExpression,
Identifier,
IfStatement,
ImportDeclaration,
ImportDeclaration as ImportDeclarationImport,
ImportDefaultSpecifier,
ImportExpression,
ImportExpression as ImportExpressionImport,
ImportNamespaceSpecifier,
ImportSpecifier,
LabeledStatement,
@ -561,6 +562,10 @@ declare abstract class BasicEvaluatedExpression {
getMemberRanges?: () => [number, number][];
expression?:
| Program
| ImportDeclarationImport
| ExportNamedDeclarationImport
| ExportAllDeclarationImport
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
| ArrowFunctionExpression
@ -574,7 +579,6 @@ declare abstract class BasicEvaluatedExpression {
| ConditionalExpression
| FunctionExpression
| Identifier
| ImportExpression
| SimpleLiteral
| RegExpLiteral
| BigIntLiteral
@ -612,10 +616,7 @@ declare abstract class BasicEvaluatedExpression {
| ForStatement
| ForInStatement
| ForOfStatement
| ImportDeclaration
| ExportNamedDeclaration
| ExportDefaultDeclaration
| ExportAllDeclaration
| MethodDefinition
| PropertyDefinition
| VariableDeclarator
@ -784,6 +785,10 @@ declare abstract class BasicEvaluatedExpression {
setExpression(
expression?:
| Program
| ImportDeclarationImport
| ExportNamedDeclarationImport
| ExportAllDeclarationImport
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
| ArrowFunctionExpression
@ -797,7 +802,6 @@ declare abstract class BasicEvaluatedExpression {
| ConditionalExpression
| FunctionExpression
| Identifier
| ImportExpression
| SimpleLiteral
| RegExpLiteral
| BigIntLiteral
@ -835,10 +839,7 @@ declare abstract class BasicEvaluatedExpression {
| ForStatement
| ForInStatement
| ForOfStatement
| ImportDeclaration
| ExportNamedDeclaration
| ExportDefaultDeclaration
| ExportAllDeclaration
| MethodDefinition
| PropertyDefinition
| VariableDeclarator
@ -4366,6 +4367,9 @@ declare interface ExperimentsNormalizedExtra {
*/
lazyCompilation?: false | LazyCompilationOptions;
}
type ExportAllDeclarationJavascriptParser = ExportAllDeclarationImport & {
attributes?: ImportAttribute[];
};
declare abstract class ExportInfo {
name: string;
@ -4463,6 +4467,9 @@ declare abstract class ExportInfo {
| "not provided";
getRenameInfo(): string;
}
type ExportNamedDeclarationJavascriptParser = ExportNamedDeclarationImport & {
attributes?: ImportAttribute[];
};
declare interface ExportSpec {
/**
* the name of the export
@ -4614,6 +4621,7 @@ declare interface ExposesObject {
[index: string]: string | ExposesConfig | string[];
}
type Expression =
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
| ArrowFunctionExpression
@ -4627,7 +4635,6 @@ type Expression =
| ConditionalExpression
| FunctionExpression
| Identifier
| ImportExpression
| SimpleLiteral
| RegExpLiteral
| BigIntLiteral
@ -5307,6 +5314,7 @@ declare interface HMRJavascriptParserHooks {
hotAcceptCallback: SyncBailHook<
[
(
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
| ArrowFunctionExpression
@ -5320,7 +5328,6 @@ declare interface HMRJavascriptParserHooks {
| ConditionalExpression
| FunctionExpression
| Identifier
| ImportExpression
| SimpleLiteral
| RegExpLiteral
| BigIntLiteral
@ -5602,11 +5609,50 @@ type IgnorePluginOptions =
*/
checkResource: (resource: string, context: string) => boolean;
};
type ImportAttribute = BaseNode & {
type: "ImportAttribute";
key: Identifier | SimpleLiteral | RegExpLiteral | BigIntLiteral;
value: Literal;
};
type ImportAttributes = Record<string, string> & {};
type ImportDeclarationJavascriptParser = ImportDeclarationImport & {
attributes?: ImportAttribute[];
};
declare interface ImportDependencyMeta {
attributes?: ImportAttributes;
externalType?: "import" | "module";
}
type ImportExpressionJavascriptParser = ImportExpressionImport & {
options?:
| null
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
| ArrowFunctionExpression
| AssignmentExpression
| AwaitExpression
| BinaryExpression
| SimpleCallExpression
| NewExpression
| ChainExpression
| ClassExpression
| ConditionalExpression
| FunctionExpression
| Identifier
| SimpleLiteral
| RegExpLiteral
| BigIntLiteral
| LogicalExpression
| MemberExpression
| MetaProperty
| ObjectExpression
| SequenceExpression
| TaggedTemplateExpression
| TemplateLiteral
| ThisExpression
| UpdateExpression
| YieldExpression;
};
declare interface ImportModuleOptions {
/**
* the target layer
@ -5846,6 +5892,7 @@ declare class JavascriptParser extends Parser {
evaluate: HookMap<
SyncBailHook<
[
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
| ArrowFunctionExpression
@ -5859,7 +5906,6 @@ declare class JavascriptParser extends Parser {
| ConditionalExpression
| FunctionExpression
| Identifier
| ImportExpression
| SimpleLiteral
| RegExpLiteral
| BigIntLiteral
@ -5910,6 +5956,7 @@ declare class JavascriptParser extends Parser {
SyncBailHook<
[
(
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
| ArrowFunctionExpression
@ -5923,7 +5970,6 @@ declare class JavascriptParser extends Parser {
| ConditionalExpression
| FunctionExpression
| Identifier
| ImportExpression
| SimpleLiteral
| RegExpLiteral
| BigIntLiteral
@ -5949,6 +5995,9 @@ declare class JavascriptParser extends Parser {
>;
preStatement: SyncBailHook<
[
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| FunctionDeclaration
| VariableDeclaration
| ClassDeclaration
@ -5971,15 +6020,15 @@ declare class JavascriptParser extends Parser {
| ForStatement
| ForInStatement
| ForOfStatement
| ImportDeclaration
| ExportNamedDeclaration
| ExportDefaultDeclaration
| ExportAllDeclaration
],
boolean | void
>;
blockPreStatement: SyncBailHook<
[
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| FunctionDeclaration
| VariableDeclaration
| ClassDeclaration
@ -6002,15 +6051,15 @@ declare class JavascriptParser extends Parser {
| ForStatement
| ForInStatement
| ForOfStatement
| ImportDeclaration
| ExportNamedDeclaration
| ExportDefaultDeclaration
| ExportAllDeclaration
],
boolean | void
>;
statement: SyncBailHook<
[
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| FunctionDeclaration
| VariableDeclaration
| ClassDeclaration
@ -6033,10 +6082,7 @@ declare class JavascriptParser extends Parser {
| ForStatement
| ForInStatement
| ForOfStatement
| ImportDeclaration
| ExportNamedDeclaration
| ExportDefaultDeclaration
| ExportAllDeclaration
],
boolean | void
>;
@ -6061,25 +6107,34 @@ declare class JavascriptParser extends Parser {
boolean | void
>;
label: HookMap<SyncBailHook<[LabeledStatement], boolean | void>>;
import: SyncBailHook<[ImportDeclaration, ImportSource], boolean | void>;
import: SyncBailHook<
[ImportDeclarationJavascriptParser, ImportSource],
boolean | void
>;
importSpecifier: SyncBailHook<
[ImportDeclaration, ImportSource, null | string, string],
[ImportDeclarationJavascriptParser, ImportSource, null | string, string],
boolean | void
>;
export: SyncBailHook<
[ExportNamedDeclaration | ExportDefaultDeclaration],
[ExportNamedDeclarationJavascriptParser | ExportDefaultDeclaration],
boolean | void
>;
exportImport: SyncBailHook<
[ExportNamedDeclaration | ExportAllDeclaration, ImportSource],
[
(
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
),
ImportSource
],
boolean | void
>;
exportDeclaration: SyncBailHook<
[
(
| ExportNamedDeclaration
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| ExportDefaultDeclaration
| ExportAllDeclaration
),
Declaration
],
@ -6092,9 +6147,9 @@ declare class JavascriptParser extends Parser {
exportSpecifier: SyncBailHook<
[
(
| ExportNamedDeclaration
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| ExportDefaultDeclaration
| ExportAllDeclaration
),
string,
string,
@ -6104,7 +6159,10 @@ declare class JavascriptParser extends Parser {
>;
exportImportSpecifier: SyncBailHook<
[
ExportNamedDeclaration | ExportAllDeclaration,
(
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
),
ImportSource,
null | string,
null | string,
@ -6129,9 +6187,13 @@ declare class JavascriptParser extends Parser {
SyncBailHook<[AssignmentExpression, string[]], boolean | void>
>;
typeof: HookMap<SyncBailHook<[Expression], boolean | void>>;
importCall: SyncBailHook<[ImportExpression], boolean | void>;
importCall: SyncBailHook<
[ImportExpressionJavascriptParser],
boolean | void
>;
topLevelAwait: SyncBailHook<
[
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
| ArrowFunctionExpression
@ -6145,7 +6207,6 @@ declare class JavascriptParser extends Parser {
| ConditionalExpression
| FunctionExpression
| Identifier
| ImportExpression
| SimpleLiteral
| RegExpLiteral
| BigIntLiteral
@ -6219,6 +6280,10 @@ declare class JavascriptParser extends Parser {
semicolons?: Set<number>;
statementPath?: StatementPathItem[];
prevStatement?:
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
| ArrowFunctionExpression
@ -6232,7 +6297,6 @@ declare class JavascriptParser extends Parser {
| ConditionalExpression
| FunctionExpression
| Identifier
| ImportExpression
| SimpleLiteral
| RegExpLiteral
| BigIntLiteral
@ -6268,10 +6332,7 @@ declare class JavascriptParser extends Parser {
| ForStatement
| ForInStatement
| ForOfStatement
| ImportDeclaration
| ExportNamedDeclaration
| ExportDefaultDeclaration
| ExportAllDeclaration;
| ExportDefaultDeclaration;
destructuringAssignmentProperties?: WeakMap<
Expression,
Set<DestructuringAssignmentProperty>
@ -6283,6 +6344,7 @@ declare class JavascriptParser extends Parser {
): undefined | Set<DestructuringAssignmentProperty>;
getRenameIdentifier(
expr:
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
| ArrowFunctionExpression
@ -6296,7 +6358,6 @@ declare class JavascriptParser extends Parser {
| ConditionalExpression
| FunctionExpression
| Identifier
| ImportExpression
| SimpleLiteral
| RegExpLiteral
| BigIntLiteral
@ -6319,6 +6380,9 @@ declare class JavascriptParser extends Parser {
*/
preWalkStatements(
statements: (
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| FunctionDeclaration
| VariableDeclaration
| ClassDeclaration
@ -6341,10 +6405,7 @@ declare class JavascriptParser extends Parser {
| ForStatement
| ForInStatement
| ForOfStatement
| ImportDeclaration
| ExportNamedDeclaration
| ExportDefaultDeclaration
| ExportAllDeclaration
)[]
): void;
@ -6353,6 +6414,9 @@ declare class JavascriptParser extends Parser {
*/
blockPreWalkStatements(
statements: (
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| FunctionDeclaration
| VariableDeclaration
| ClassDeclaration
@ -6375,10 +6439,7 @@ declare class JavascriptParser extends Parser {
| ForStatement
| ForInStatement
| ForOfStatement
| ImportDeclaration
| ExportNamedDeclaration
| ExportDefaultDeclaration
| ExportAllDeclaration
)[]
): void;
@ -6387,6 +6448,9 @@ declare class JavascriptParser extends Parser {
*/
walkStatements(
statements: (
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| FunctionDeclaration
| VariableDeclaration
| ClassDeclaration
@ -6409,10 +6473,7 @@ declare class JavascriptParser extends Parser {
| ForStatement
| ForInStatement
| ForOfStatement
| ImportDeclaration
| ExportNamedDeclaration
| ExportDefaultDeclaration
| ExportAllDeclaration
)[]
): void;
@ -6421,6 +6482,9 @@ declare class JavascriptParser extends Parser {
*/
preWalkStatement(
statement:
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| FunctionDeclaration
| VariableDeclaration
| ClassDeclaration
@ -6443,13 +6507,13 @@ declare class JavascriptParser extends Parser {
| ForStatement
| ForInStatement
| ForOfStatement
| ImportDeclaration
| ExportNamedDeclaration
| ExportDefaultDeclaration
| ExportAllDeclaration
): void;
blockPreWalkStatement(
statement:
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| FunctionDeclaration
| VariableDeclaration
| ClassDeclaration
@ -6472,13 +6536,13 @@ declare class JavascriptParser extends Parser {
| ForStatement
| ForInStatement
| ForOfStatement
| ImportDeclaration
| ExportNamedDeclaration
| ExportDefaultDeclaration
| ExportAllDeclaration
): void;
walkStatement(
statement:
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| FunctionDeclaration
| VariableDeclaration
| ClassDeclaration
@ -6501,10 +6565,7 @@ declare class JavascriptParser extends Parser {
| ForStatement
| ForInStatement
| ForOfStatement
| ImportDeclaration
| ExportNamedDeclaration
| ExportDefaultDeclaration
| ExportAllDeclaration
): void;
/**
@ -6543,16 +6604,24 @@ declare class JavascriptParser extends Parser {
walkFunctionDeclaration(statement: FunctionDeclaration): void;
blockPreWalkExpressionStatement(statement: ExpressionStatement): void;
preWalkAssignmentExpression(expression: AssignmentExpression): void;
blockPreWalkImportDeclaration(statement: ImportDeclaration): void;
blockPreWalkImportDeclaration(
statement: ImportDeclarationJavascriptParser
): void;
enterDeclaration(
declaration: Declaration,
onIdent: (arg0: string, arg1: Identifier) => void
): void;
blockPreWalkExportNamedDeclaration(statement: ExportNamedDeclaration): void;
walkExportNamedDeclaration(statement: ExportNamedDeclaration): void;
blockPreWalkExportNamedDeclaration(
statement: ExportNamedDeclarationJavascriptParser
): void;
walkExportNamedDeclaration(
statement: ExportNamedDeclarationJavascriptParser
): void;
blockPreWalkExportDefaultDeclaration(statement?: any): void;
walkExportDefaultDeclaration(statement: ExportDefaultDeclaration): void;
blockPreWalkExportAllDeclaration(statement: ExportAllDeclaration): void;
blockPreWalkExportAllDeclaration(
statement: ExportAllDeclarationJavascriptParser
): void;
preWalkVariableDeclaration(statement: VariableDeclaration): void;
blockPreWalkVariableDeclaration(statement: VariableDeclaration): void;
preWalkVariableDeclarator(declarator: VariableDeclarator): void;
@ -6571,6 +6640,7 @@ declare class JavascriptParser extends Parser {
walkExpressions(
expressions: (
| null
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
| ArrowFunctionExpression
@ -6584,7 +6654,6 @@ declare class JavascriptParser extends Parser {
| ConditionalExpression
| FunctionExpression
| Identifier
| ImportExpression
| SimpleLiteral
| RegExpLiteral
| BigIntLiteral
@ -6625,7 +6694,7 @@ declare class JavascriptParser extends Parser {
walkTaggedTemplateExpression(expression: TaggedTemplateExpression): void;
walkClassExpression(expression: ClassExpression): void;
walkChainExpression(expression: ChainExpression): void;
walkImportExpression(expression: ImportExpression): void;
walkImportExpression(expression: ImportExpressionJavascriptParser): void;
walkCallExpression(expression: CallExpression): void;
walkMemberExpression(expression: MemberExpression): void;
walkMemberExpressionWithExpressionName(
@ -6641,6 +6710,7 @@ declare class JavascriptParser extends Parser {
callHooksForExpression<T, R>(
hookMap: HookMap<SyncBailHook<T, R>>,
expr:
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
| ArrowFunctionExpression
@ -6654,7 +6724,6 @@ declare class JavascriptParser extends Parser {
| ConditionalExpression
| FunctionExpression
| Identifier
| ImportExpression
| SimpleLiteral
| RegExpLiteral
| BigIntLiteral
@ -6674,6 +6743,7 @@ declare class JavascriptParser extends Parser {
callHooksForExpressionWithFallback<T, R>(
hookMap: HookMap<SyncBailHook<T, R>>,
expr:
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
| ArrowFunctionExpression
@ -6687,7 +6757,6 @@ declare class JavascriptParser extends Parser {
| ConditionalExpression
| FunctionExpression
| Identifier
| ImportExpression
| SimpleLiteral
| RegExpLiteral
| BigIntLiteral
@ -6754,6 +6823,9 @@ declare class JavascriptParser extends Parser {
inBlockScope(fn: () => void): void;
detectMode(
statements: (
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| FunctionDeclaration
| VariableDeclaration
| ClassDeclaration
@ -6776,10 +6848,7 @@ declare class JavascriptParser extends Parser {
| ForStatement
| ForInStatement
| ForOfStatement
| ImportDeclaration
| ExportNamedDeclaration
| ExportDefaultDeclaration
| ExportAllDeclaration
| Directive
)[]
): void;
@ -6829,6 +6898,7 @@ declare class JavascriptParser extends Parser {
): void;
evaluateExpression(
expression:
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
| ArrowFunctionExpression
@ -6842,7 +6912,6 @@ declare class JavascriptParser extends Parser {
| ConditionalExpression
| FunctionExpression
| Identifier
| ImportExpression
| SimpleLiteral
| RegExpLiteral
| BigIntLiteral
@ -6871,6 +6940,7 @@ declare class JavascriptParser extends Parser {
expr:
| undefined
| null
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
| ArrowFunctionExpression
@ -6884,7 +6954,6 @@ declare class JavascriptParser extends Parser {
| ConditionalExpression
| FunctionExpression
| Identifier
| ImportExpression
| SimpleLiteral
| RegExpLiteral
| BigIntLiteral
@ -6923,6 +6992,7 @@ declare class JavascriptParser extends Parser {
};
extractMemberExpressionChain(
expression:
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
| ArrowFunctionExpression
@ -6936,7 +7006,6 @@ declare class JavascriptParser extends Parser {
| ConditionalExpression
| FunctionExpression
| Identifier
| ImportExpression
| SimpleLiteral
| RegExpLiteral
| BigIntLiteral
@ -6954,6 +7023,7 @@ declare class JavascriptParser extends Parser {
): {
members: string[];
object:
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
| ArrowFunctionExpression
@ -6967,7 +7037,6 @@ declare class JavascriptParser extends Parser {
| ConditionalExpression
| FunctionExpression
| Identifier
| ImportExpression
| SimpleLiteral
| RegExpLiteral
| BigIntLiteral
@ -6990,6 +7059,7 @@ declare class JavascriptParser extends Parser {
): undefined | { name: string; info: string | VariableInfo };
getMemberExpressionInfo(
expression:
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
| ArrowFunctionExpression
@ -7003,7 +7073,6 @@ declare class JavascriptParser extends Parser {
| ConditionalExpression
| FunctionExpression
| Identifier
| ImportExpression
| SimpleLiteral
| RegExpLiteral
| BigIntLiteral
@ -7032,6 +7101,13 @@ declare class JavascriptParser extends Parser {
static ALLOWED_MEMBER_TYPES_ALL: 3;
static ALLOWED_MEMBER_TYPES_EXPRESSION: 2;
static ALLOWED_MEMBER_TYPES_CALL_EXPRESSION: 1;
static getImportAttributes: (
node:
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| ImportExpressionJavascriptParser
) => undefined | ImportAttributes;
}
/**
@ -8029,6 +8105,7 @@ declare interface LimitChunkCountPluginOptions {
*/
maxChunks: number;
}
type Literal = SimpleLiteral | RegExpLiteral | BigIntLiteral;
declare interface LoadScriptCompilationHooks {
createScript: SyncWaterfallHook<[string, Chunk]>;
}
@ -14369,6 +14446,10 @@ type Statement =
| ForInStatement
| ForOfStatement;
type StatementPathItem =
| ImportDeclarationJavascriptParser
| ExportNamedDeclarationJavascriptParser
| ExportAllDeclarationJavascriptParser
| ImportExpressionImport
| UnaryExpression
| ArrayExpression
| ArrowFunctionExpression
@ -14382,7 +14463,6 @@ type StatementPathItem =
| ConditionalExpression
| FunctionExpression
| Identifier
| ImportExpression
| SimpleLiteral
| RegExpLiteral
| BigIntLiteral
@ -14418,10 +14498,7 @@ type StatementPathItem =
| ForStatement
| ForInStatement
| ForOfStatement
| ImportDeclaration
| ExportNamedDeclaration
| ExportDefaultDeclaration
| ExportAllDeclaration;
| ExportDefaultDeclaration;
declare class Stats {
constructor(compilation: Compilation);
compilation: Compilation;

View File

@ -1482,11 +1482,6 @@ abbrev@1.0.x:
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.0.9.tgz#91b4792588a7738c25f35dd6f63752a2f8776135"
integrity sha512-LEyx4aLEC3x6T0UguF6YILf+ntvmOaWsVfENmIW0E9H09vKlLDGelMjjSm0jkDHALj8A8quZ/HapKNigzwge+Q==
acorn-import-attributes@^1.9.5:
version "1.9.5"
resolved "https://registry.yarnpkg.com/acorn-import-attributes/-/acorn-import-attributes-1.9.5.tgz#7eb1557b1ba05ef18b5ed0ec67591bfab04688ef"
integrity sha512-n02Vykv5uA3eHGM/Z2dQrcD56kL8TyDb2p1+0P83PClMnC/nc+anbQRhIOWnSq4Ke/KvDPrY3C9hDtC/A3eHnQ==
acorn-jsx@^5.3.2:
version "5.3.2"
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937"
@ -1497,10 +1492,10 @@ acorn@^7.1.1:
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa"
integrity sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==
acorn@^8.12.0, acorn@^8.7.1, acorn@^8.8.2:
version "8.12.1"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.12.1.tgz#71616bdccbe25e27a54439e0046e89ca76df2248"
integrity sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==
acorn@^8.12.0, acorn@^8.14.0, acorn@^8.8.2:
version "8.14.0"
resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.14.0.tgz#063e2c70cac5fb4f6467f0b11152e04c682795b0"
integrity sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==
aggregate-error@^3.0.0:
version "3.1.0"
@ -5035,8 +5030,7 @@ prelude-ls@~1.1.2:
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
integrity sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==
"prettier-2@npm:prettier@^2", prettier@^2.0.5:
name prettier-2
"prettier-2@npm:prettier@^2":
version "2.8.8"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==
@ -5048,6 +5042,11 @@ prettier-linter-helpers@^1.0.0:
dependencies:
fast-diff "^1.1.2"
prettier@^2.0.5:
version "2.8.8"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==
prettier@^3.2.1:
version "3.3.3"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.3.3.tgz#30c54fe0be0d8d12e6ae61dbb10109ea00d53105"