Update npm packages (73 packages including @jqhtml 2.3.36)
Update npm registry domain from privatenpm.hanson.xyz to npm.internal.hanson.xyz 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
4
node_modules/webpack/lib/dependencies/AMDDefineDependency.js
generated
vendored
4
node_modules/webpack/lib/dependencies/AMDDefineDependency.js
generated
vendored
@@ -10,6 +10,7 @@ const makeSerializable = require("../util/makeSerializable");
|
||||
const NullDependency = require("./NullDependency");
|
||||
|
||||
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
||||
/** @typedef {import("./LocalModule")} LocalModule */
|
||||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
@@ -120,6 +121,7 @@ class AMDDefineDependency extends NullDependency {
|
||||
this.functionRange = functionRange;
|
||||
this.objectRange = objectRange;
|
||||
this.namedModule = namedModule;
|
||||
/** @type {LocalModule | null} */
|
||||
this.localModule = null;
|
||||
}
|
||||
|
||||
@@ -182,7 +184,7 @@ AMDDefineDependency.Template = class AMDDefineDependencyTemplate extends (
|
||||
|
||||
/**
|
||||
* @param {AMDDefineDependency} dependency dependency
|
||||
* @returns {string} variable name
|
||||
* @returns {string | false | null} variable name
|
||||
*/
|
||||
localModuleVar(dependency) {
|
||||
return (
|
||||
|
||||
6
node_modules/webpack/lib/dependencies/AMDDefineDependencyParserPlugin.js
generated
vendored
6
node_modules/webpack/lib/dependencies/AMDDefineDependencyParserPlugin.js
generated
vendored
@@ -26,11 +26,13 @@ const { addLocalModule, getLocalModule } = require("./LocalModulesHelpers");
|
||||
/** @typedef {import("estree").ObjectExpression} ObjectExpression */
|
||||
/** @typedef {import("estree").SpreadElement} SpreadElement */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
||||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
||||
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
|
||||
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
||||
/** @typedef {import("../javascript/JavascriptParser").ExportedVariableInfo} ExportedVariableInfo */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {import("./LocalModule")} LocalModule */
|
||||
|
||||
/**
|
||||
* @param {Expression | SpreadElement} expr expression
|
||||
@@ -123,7 +125,9 @@ class AMDDefineDependencyParserPlugin {
|
||||
const deps = [];
|
||||
const array = /** @type {string[]} */ (param.array);
|
||||
for (const [idx, request] of array.entries()) {
|
||||
/** @type {string | LocalModuleDependency | AMDRequireItemDependency} */
|
||||
let dep;
|
||||
/** @type {undefined | null | LocalModule} */
|
||||
let localModule;
|
||||
if (request === "require") {
|
||||
identifiers[idx] = request;
|
||||
@@ -174,7 +178,9 @@ class AMDDefineDependencyParserPlugin {
|
||||
|
||||
return true;
|
||||
} else if (param.isString()) {
|
||||
/** @type {Dependency} */
|
||||
let dep;
|
||||
/** @type {undefined | null | LocalModule} */
|
||||
let localModule;
|
||||
|
||||
if (param.string === "require") {
|
||||
|
||||
2
node_modules/webpack/lib/dependencies/AMDPlugin.js
generated
vendored
2
node_modules/webpack/lib/dependencies/AMDPlugin.js
generated
vendored
@@ -58,7 +58,7 @@ class AMDPlugin {
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(compiler) {
|
||||
const amdOptions = this.amdOptions;
|
||||
const { amdOptions } = this;
|
||||
compiler.hooks.compilation.tap(
|
||||
PLUGIN_NAME,
|
||||
(compilation, { contextModuleFactory, normalModuleFactory }) => {
|
||||
|
||||
8
node_modules/webpack/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js
generated
vendored
8
node_modules/webpack/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js
generated
vendored
@@ -25,10 +25,12 @@ const getFunctionExpression = require("./getFunctionExpression");
|
||||
/** @typedef {import("estree").SourceLocation} SourceLocation */
|
||||
/** @typedef {import("estree").SpreadElement} SpreadElement */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
||||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
||||
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
|
||||
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {import("./LocalModule")} LocalModule */
|
||||
|
||||
const PLUGIN_NAME = "AMDRequireDependenciesBlockParserPlugin";
|
||||
|
||||
@@ -102,8 +104,10 @@ class AMDRequireDependenciesBlockParserPlugin {
|
||||
} else if (param.isConstArray()) {
|
||||
/** @type {(string | LocalModuleDependency | AMDRequireItemDependency)[]} */
|
||||
const deps = [];
|
||||
for (const request of /** @type {EXPECTED_ANY[]} */ (param.array)) {
|
||||
for (const request of /** @type {string[]} */ (param.array)) {
|
||||
/** @type {string | LocalModuleDependency | AMDRequireItemDependency} */
|
||||
let dep;
|
||||
/** @type {undefined | null | LocalModule} */
|
||||
let localModule;
|
||||
if (request === "require") {
|
||||
dep = RuntimeGlobals.require;
|
||||
@@ -152,7 +156,9 @@ class AMDRequireDependenciesBlockParserPlugin {
|
||||
}
|
||||
return true;
|
||||
} else if (param.isString()) {
|
||||
/** @type {Dependency} */
|
||||
let dep;
|
||||
/** @type {LocalModule | null | undefined} */
|
||||
let localModule;
|
||||
if (param.string === "require") {
|
||||
dep = new ConstDependency(
|
||||
|
||||
1
node_modules/webpack/lib/dependencies/CachedConstDependency.js
generated
vendored
1
node_modules/webpack/lib/dependencies/CachedConstDependency.js
generated
vendored
@@ -38,6 +38,7 @@ class CachedConstDependency extends NullDependency {
|
||||
this.range = range;
|
||||
this.identifier = identifier;
|
||||
this.place = place;
|
||||
/** @type {undefined | string} */
|
||||
this._hashUpdate = undefined;
|
||||
}
|
||||
|
||||
|
||||
2
node_modules/webpack/lib/dependencies/CommonJsDependencyHelpers.js
generated
vendored
2
node_modules/webpack/lib/dependencies/CommonJsDependencyHelpers.js
generated
vendored
@@ -22,7 +22,9 @@ module.exports.handleDependencyBase = (
|
||||
module,
|
||||
runtimeRequirements
|
||||
) => {
|
||||
/** @type {string} */
|
||||
let base;
|
||||
/** @type {string} */
|
||||
let type;
|
||||
switch (depBase) {
|
||||
case "exports":
|
||||
|
||||
1
node_modules/webpack/lib/dependencies/CommonJsExportRequireDependency.js
generated
vendored
1
node_modules/webpack/lib/dependencies/CommonJsExportRequireDependency.js
generated
vendored
@@ -57,6 +57,7 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
||||
this.names = names;
|
||||
this.ids = ids;
|
||||
this.resultUsed = resultUsed;
|
||||
/** @type {undefined | boolean} */
|
||||
this.asiSafe = undefined;
|
||||
}
|
||||
|
||||
|
||||
2
node_modules/webpack/lib/dependencies/CommonJsFullRequireDependency.js
generated
vendored
2
node_modules/webpack/lib/dependencies/CommonJsFullRequireDependency.js
generated
vendored
@@ -41,7 +41,9 @@ class CommonJsFullRequireDependency extends ModuleDependency {
|
||||
this.range = range;
|
||||
this.names = names;
|
||||
this.idRanges = idRanges;
|
||||
/** @type {boolean} */
|
||||
this.call = false;
|
||||
/** @type {undefined | boolean} */
|
||||
this.asiSafe = undefined;
|
||||
}
|
||||
|
||||
|
||||
3
node_modules/webpack/lib/dependencies/CommonJsImportsParserPlugin.js
generated
vendored
3
node_modules/webpack/lib/dependencies/CommonJsImportsParserPlugin.js
generated
vendored
@@ -40,6 +40,7 @@ const RequireResolveHeaderDependency = require("./RequireResolveHeaderDependency
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Members} Members */
|
||||
/** @typedef {import("../javascript/JavascriptParser").CalleeMembers} CalleeMembers */
|
||||
/** @typedef {import("./LocalModule")} LocalModule */
|
||||
|
||||
/**
|
||||
* @typedef {object} CommonJsImportSettings
|
||||
@@ -299,6 +300,7 @@ class CommonJsImportsParserPlugin {
|
||||
}
|
||||
|
||||
if (expr.arguments.length !== 1) return;
|
||||
/** @type {null | LocalModule} */
|
||||
let localModule;
|
||||
const param = parser.evaluateExpression(expr.arguments[0]);
|
||||
if (param.isConditional()) {
|
||||
@@ -586,6 +588,7 @@ class CommonJsImportsParserPlugin {
|
||||
moduleName = ["module", "node:module"];
|
||||
specifierName = "createRequire";
|
||||
} else {
|
||||
/** @type {undefined | string} */
|
||||
let moduleName;
|
||||
const match = /^(.*) from (.*)$/.exec(options.createRequire);
|
||||
if (match) {
|
||||
|
||||
4
node_modules/webpack/lib/dependencies/CommonJsRequireContextDependency.js
generated
vendored
4
node_modules/webpack/lib/dependencies/CommonJsRequireContextDependency.js
generated
vendored
@@ -18,8 +18,8 @@ class CommonJsRequireContextDependency extends ContextDependency {
|
||||
/**
|
||||
* @param {ContextDependencyOptions} options options for the context module
|
||||
* @param {Range} range location in source code
|
||||
* @param {Range | undefined} valueRange location of the require call
|
||||
* @param {boolean | string} inShorthand true or name
|
||||
* @param {Range=} valueRange location of the require call
|
||||
* @param {boolean | string=} inShorthand true or name
|
||||
* @param {string=} context context
|
||||
*/
|
||||
constructor(options, range, valueRange, inShorthand, context) {
|
||||
|
||||
1
node_modules/webpack/lib/dependencies/CommonJsSelfReferenceDependency.js
generated
vendored
1
node_modules/webpack/lib/dependencies/CommonJsSelfReferenceDependency.js
generated
vendored
@@ -118,6 +118,7 @@ CommonJsSelfReferenceDependency.Template = class CommonJsSelfReferenceDependency
|
||||
);
|
||||
}
|
||||
|
||||
/** @type {string} */
|
||||
let base;
|
||||
switch (dep.base) {
|
||||
case "exports":
|
||||
|
||||
1
node_modules/webpack/lib/dependencies/ConstDependency.js
generated
vendored
1
node_modules/webpack/lib/dependencies/ConstDependency.js
generated
vendored
@@ -33,6 +33,7 @@ class ConstDependency extends NullDependency {
|
||||
this.runtimeRequirements = runtimeRequirements
|
||||
? new Set(runtimeRequirements)
|
||||
: null;
|
||||
/** @type {undefined | string} */
|
||||
this._hashUpdate = undefined;
|
||||
}
|
||||
|
||||
|
||||
15
node_modules/webpack/lib/dependencies/ContextDependencyHelpers.js
generated
vendored
15
node_modules/webpack/lib/dependencies/ContextDependencyHelpers.js
generated
vendored
@@ -26,7 +26,7 @@ const quoteMeta = (str) => str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&");
|
||||
|
||||
/**
|
||||
* @param {string} prefix prefix
|
||||
* @returns {{prefix: string, context: string}} result
|
||||
* @returns {{ prefix: string, context: string }} result
|
||||
*/
|
||||
const splitContextFromPrefix = (prefix) => {
|
||||
const idx = prefix.lastIndexOf("/");
|
||||
@@ -42,17 +42,23 @@ const splitContextFromPrefix = (prefix) => {
|
||||
};
|
||||
|
||||
/** @typedef {Partial<Omit<ContextDependencyOptions, "resource">>} PartialContextDependencyOptions */
|
||||
/** @typedef {{ new(options: ContextDependencyOptions, range: Range, valueRange: Range, ...args: EXPECTED_ANY[]): ContextDependency }} ContextDependencyConstructor */
|
||||
/** @typedef {{ new (options: ContextDependencyOptions, range: Range, valueRange: Range, ...args: EXPECTED_ANY[]): ContextDependency }} ContextDependencyConstructor */
|
||||
|
||||
/**
|
||||
* @param {ContextDependencyConstructor} Dep the Dependency class
|
||||
* @template T
|
||||
* @typedef {T extends new (options: ContextDependencyOptions, range: Range, valueRange: Range, ...remains: infer R) => EXPECTED_ANY ? R : []} GetAdditionalDepArgs
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template {ContextDependencyConstructor} T
|
||||
* @param {T} Dep the Dependency class
|
||||
* @param {Range} range source range
|
||||
* @param {BasicEvaluatedExpression} param context param
|
||||
* @param {Expression} expr expr
|
||||
* @param {Pick<JavascriptParserOptions, `${"expr" | "wrapped"}Context${"Critical" | "Recursive" | "RegExp"}` | "exprContextRequest">} options options for context creation
|
||||
* @param {PartialContextDependencyOptions} contextOptions options for the ContextModule
|
||||
* @param {JavascriptParser} parser the parser
|
||||
* @param {...EXPECTED_ANY} depArgs depArgs
|
||||
* @param {GetAdditionalDepArgs<T>} depArgs depArgs
|
||||
* @returns {ContextDependency} the created Dependency
|
||||
*/
|
||||
module.exports.create = (
|
||||
@@ -216,6 +222,7 @@ module.exports.create = (
|
||||
...depArgs
|
||||
);
|
||||
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||
/** @type {Replaces} */
|
||||
const replaces = [];
|
||||
if (prefixRange) {
|
||||
replaces.push({
|
||||
|
||||
1
node_modules/webpack/lib/dependencies/ContextElementDependency.js
generated
vendored
1
node_modules/webpack/lib/dependencies/ContextElementDependency.js
generated
vendored
@@ -82,6 +82,7 @@ class ContextElementDependency extends ModuleDependency {
|
||||
*/
|
||||
getReferencedExports(moduleGraph, runtime) {
|
||||
if (!this.referencedExports) return Dependency.EXPORTS_OBJECT_REFERENCED;
|
||||
/** @type {ReferencedExports} */
|
||||
const refs = [];
|
||||
for (const referencedExport of this.referencedExports) {
|
||||
if (
|
||||
|
||||
1
node_modules/webpack/lib/dependencies/CriticalDependencyWarning.js
generated
vendored
1
node_modules/webpack/lib/dependencies/CriticalDependencyWarning.js
generated
vendored
@@ -15,6 +15,7 @@ class CriticalDependencyWarning extends WebpackError {
|
||||
constructor(message) {
|
||||
super();
|
||||
|
||||
/** @type {string} */
|
||||
this.name = "CriticalDependencyWarning";
|
||||
this.message = `Critical dependency: ${message}`;
|
||||
}
|
||||
|
||||
11
node_modules/webpack/lib/dependencies/CssIcssExportDependency.js
generated
vendored
11
node_modules/webpack/lib/dependencies/CssIcssExportDependency.js
generated
vendored
@@ -37,6 +37,8 @@ const getCssParser = memoize(() => require("../css/CssParser"));
|
||||
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
||||
/** @typedef {import("../css/CssParser").Range} Range */
|
||||
|
||||
/** @typedef {(name: string) => string} ExportsConventionFn */
|
||||
|
||||
/**
|
||||
* @param {string} local css local
|
||||
* @param {CssModule} module module
|
||||
@@ -60,7 +62,7 @@ const getLocalIdent = (local, module, chunkGraph, runtimeTemplate) => {
|
||||
|
||||
let localIdentHash = "";
|
||||
|
||||
if (/\[(fullhash|hash)\]/.test(localIdentName)) {
|
||||
if (/\[(?:fullhash|hash)\]/.test(localIdentName)) {
|
||||
const hashSalt = generator.options.localIdentHashSalt;
|
||||
const hashDigest =
|
||||
/** @type {string} */
|
||||
@@ -113,8 +115,8 @@ const getLocalIdent = (local, module, chunkGraph, runtimeTemplate) => {
|
||||
if (typeof id !== "string") return id;
|
||||
|
||||
return id
|
||||
.replace(/^([.-]|[^a-zA-Z0-9_-])+/, "")
|
||||
.replace(/[^a-zA-Z0-9_-]+/g, "_");
|
||||
.replace(/^([.-]|[^a-z0-9_-])+/i, "")
|
||||
.replace(/[^a-z0-9_-]+/gi, "_");
|
||||
},
|
||||
filename: relativeResourcePath,
|
||||
hash: localIdentHash,
|
||||
@@ -135,7 +137,7 @@ const getLocalIdent = (local, module, chunkGraph, runtimeTemplate) => {
|
||||
}
|
||||
|
||||
// Protect the first character from unsupported values
|
||||
return localIdent.replace(/^((-?[0-9])|--)/, "_$1");
|
||||
return localIdent.replace(/^((-?\d)|--)/, "_$1");
|
||||
};
|
||||
|
||||
// 0 - replace, 1 - replace, 2 - append, 2 - once
|
||||
@@ -170,6 +172,7 @@ class CssIcssExportDependency extends NullDependency {
|
||||
this.interpolate = interpolate;
|
||||
this.exportMode = exportMode;
|
||||
this.exportType = exportType;
|
||||
/** @type {undefined | string} */
|
||||
this._hashUpdate = undefined;
|
||||
}
|
||||
|
||||
|
||||
1
node_modules/webpack/lib/dependencies/CssIcssSymbolDependency.js
generated
vendored
1
node_modules/webpack/lib/dependencies/CssIcssSymbolDependency.js
generated
vendored
@@ -36,6 +36,7 @@ class CssIcssSymbolDependency extends NullDependency {
|
||||
this.symbol = symbol;
|
||||
this.range = range;
|
||||
this.isReference = isReference;
|
||||
/** @type {undefined | string} */
|
||||
this._hashUpdate = undefined;
|
||||
}
|
||||
|
||||
|
||||
5
node_modules/webpack/lib/dependencies/CssUrlDependency.js
generated
vendored
5
node_modules/webpack/lib/dependencies/CssUrlDependency.js
generated
vendored
@@ -16,6 +16,7 @@ const ModuleDependency = require("./ModuleDependency");
|
||||
/** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../Module")} Module */
|
||||
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
||||
/** @typedef {import("../Module").CodeGenerationResultData} CodeGenerationResultData */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
||||
@@ -173,9 +174,7 @@ CssUrlDependency.Template = class CssUrlDependencyTemplate extends (
|
||||
return "data:,";
|
||||
}
|
||||
const codeGen = codeGenerationResults.get(module, runtime);
|
||||
const data =
|
||||
/** @type {NonNullable<CodeGenerationResult["data"]>} */
|
||||
(codeGen.data);
|
||||
const data = codeGen.data;
|
||||
if (!data) return "data:,";
|
||||
const url = data.get("url");
|
||||
if (!url || !url["css-url"]) return "data:,";
|
||||
|
||||
5
node_modules/webpack/lib/dependencies/ExternalModuleInitFragment.js
generated
vendored
5
node_modules/webpack/lib/dependencies/ExternalModuleInitFragment.js
generated
vendored
@@ -13,7 +13,8 @@ const makeSerializable = require("../util/makeSerializable");
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
||||
/** @typedef {{ name: string, value?: string }[]} ArrayImportSpecifiers */
|
||||
/** @typedef {Map<string, Set<string>>} ImportSpecifiers */
|
||||
/** @typedef {Set<string>} ImportSpecifier */
|
||||
/** @typedef {Map<string, ImportSpecifier>} ImportSpecifiers */
|
||||
|
||||
/**
|
||||
* @extends {InitFragment<GenerateContext>}
|
||||
@@ -38,6 +39,7 @@ class ExternalModuleInitFragment extends InitFragment {
|
||||
for (const { name, value } of specifiers) {
|
||||
let specifiers = this.specifiers.get(name);
|
||||
if (!specifiers) {
|
||||
/** @type {ImportSpecifier} */
|
||||
specifiers = new Set();
|
||||
this.specifiers.set(name, specifiers);
|
||||
}
|
||||
@@ -77,6 +79,7 @@ class ExternalModuleInitFragment extends InitFragment {
|
||||
* @returns {string | Source | undefined} the source code that will be included as initialization code
|
||||
*/
|
||||
getContent({ runtimeRequirements }) {
|
||||
/** @type {string[]} */
|
||||
const namedImports = [];
|
||||
|
||||
for (const [name, specifiers] of this.specifiers) {
|
||||
|
||||
9
node_modules/webpack/lib/dependencies/ExternalModuleInitFragmentDependency.js
generated
vendored
9
node_modules/webpack/lib/dependencies/ExternalModuleInitFragmentDependency.js
generated
vendored
@@ -31,15 +31,6 @@ class ExternalModuleInitFragmentDependency extends NullDependency {
|
||||
this.default = defaultImport;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string} hash update
|
||||
*/
|
||||
_createHashUpdate() {
|
||||
return `${this.importedModule}${JSON.stringify(this.specifiers)}${
|
||||
this.default || "null"
|
||||
}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ObjectSerializerContext} context context
|
||||
*/
|
||||
|
||||
3
node_modules/webpack/lib/dependencies/HarmonyAcceptDependency.js
generated
vendored
3
node_modules/webpack/lib/dependencies/HarmonyAcceptDependency.js
generated
vendored
@@ -114,8 +114,11 @@ HarmonyAcceptDependency.Template = class HarmonyAcceptDependencyTemplate extends
|
||||
* @returns {HarmonyImportDependency[]} array of related harmony import dependencies
|
||||
*/
|
||||
const getHarmonyImportDependencies = (dependency) => {
|
||||
/** @type {HarmonyImportDependency[]} */
|
||||
const result = [];
|
||||
/** @type {HarmonyImportDependency | null} */
|
||||
let deferDependency = null;
|
||||
/** @type {HarmonyImportDependency | null} */
|
||||
let noDeferredDependency = null;
|
||||
|
||||
for (const d of module.dependencies) {
|
||||
|
||||
4
node_modules/webpack/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js
generated
vendored
4
node_modules/webpack/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js
generated
vendored
@@ -6,6 +6,7 @@
|
||||
"use strict";
|
||||
|
||||
const makeSerializable = require("../util/makeSerializable");
|
||||
const { ExportPresenceModes } = require("./HarmonyImportDependency");
|
||||
const HarmonyImportSpecifierDependency = require("./HarmonyImportSpecifierDependency");
|
||||
const { ImportPhase } = require("./ImportPhase");
|
||||
|
||||
@@ -44,7 +45,7 @@ class HarmonyEvaluatedImportSpecifierDependency extends HarmonyImportSpecifierDe
|
||||
ids,
|
||||
name,
|
||||
range,
|
||||
false,
|
||||
ExportPresenceModes.NONE,
|
||||
ImportPhase.Evaluation,
|
||||
attributes,
|
||||
[]
|
||||
@@ -103,6 +104,7 @@ HarmonyEvaluatedImportSpecifierDependency.Template = class HarmonyEvaluatedImpor
|
||||
);
|
||||
const ids = dep.getIds(moduleGraph);
|
||||
|
||||
/** @type {boolean | undefined | null} */
|
||||
let value;
|
||||
|
||||
const exportsType =
|
||||
|
||||
4
node_modules/webpack/lib/dependencies/HarmonyExportExpressionDependency.js
generated
vendored
4
node_modules/webpack/lib/dependencies/HarmonyExportExpressionDependency.js
generated
vendored
@@ -21,6 +21,7 @@ const NullDependency = require("./NullDependency");
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
||||
/** @typedef {import("./HarmonyExportInitFragment").ExportMap} ExportMap */
|
||||
|
||||
class HarmonyExportExpressionDependency extends NullDependency {
|
||||
/**
|
||||
@@ -120,6 +121,7 @@ HarmonyExportExpressionDependency.Template = class HarmonyExportDependencyTempla
|
||||
const { declarationId } = dep;
|
||||
const exportsName = module.exportsArgument;
|
||||
if (declarationId) {
|
||||
/** @type {string} */
|
||||
let name;
|
||||
if (typeof declarationId === "string") {
|
||||
name = declarationId;
|
||||
@@ -139,6 +141,7 @@ HarmonyExportExpressionDependency.Template = class HarmonyExportDependencyTempla
|
||||
.getExportsInfo(module)
|
||||
.getUsedName("default", runtime);
|
||||
if (used) {
|
||||
/** @type {ExportMap} */
|
||||
const map = new Map();
|
||||
map.set(used, `/* export default binding */ ${name}`);
|
||||
initFragments.push(new HarmonyExportInitFragment(exportsName, map));
|
||||
@@ -164,6 +167,7 @@ HarmonyExportExpressionDependency.Template = class HarmonyExportDependencyTempla
|
||||
.getUsedName("default", runtime);
|
||||
if (used) {
|
||||
runtimeRequirements.add(RuntimeGlobals.exports);
|
||||
/** @type {ExportMap} */
|
||||
const map = new Map();
|
||||
map.set(used, name);
|
||||
initFragments.push(new HarmonyExportInitFragment(exportsName, map));
|
||||
|
||||
9
node_modules/webpack/lib/dependencies/HarmonyExportImportedSpecifierDependency.js
generated
vendored
9
node_modules/webpack/lib/dependencies/HarmonyExportImportedSpecifierDependency.js
generated
vendored
@@ -58,6 +58,7 @@ const processExportInfo = require("./processExportInfo");
|
||||
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
/** @typedef {import("./HarmonyImportDependency").Ids} Ids */
|
||||
/** @typedef {import("./HarmonyImportDependency").ExportPresenceMode} ExportPresenceMode */
|
||||
/** @typedef {import("./HarmonyExportInitFragment").ExportMap} ExportMap */
|
||||
/** @typedef {import("../dependencies/ImportPhase").ImportPhaseType} ImportPhaseType */
|
||||
|
||||
/** @typedef {"missing" | "unused" | "empty-star" | "reexport-dynamic-default" | "reexport-named-default" | "reexport-namespace-object" | "reexport-fake-namespace-object" | "reexport-undefined" | "normal-reexport" | "dynamic-reexport"} ExportModeType */
|
||||
@@ -264,6 +265,7 @@ const getMode = (moduleGraph, dep, runtimeKey) => {
|
||||
|
||||
// reexporting with a fixed name
|
||||
if (name) {
|
||||
/** @type {ExportMode} */
|
||||
let mode;
|
||||
const exportInfo = exportsInfo.getReadOnlyExportInfo(name);
|
||||
|
||||
@@ -464,7 +466,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
||||
* @param {RuntimeSpec} runtime the runtime
|
||||
* @param {ExportsInfo} exportsInfo exports info about the current module (optional)
|
||||
* @param {Module} importedModule the imported module (optional)
|
||||
* @returns {{exports?: Exports, checked?: Checked, ignoredExports: IgnoredExports, hidden?: Hidden}} information
|
||||
* @returns {{ exports?: Exports, checked?: Checked, ignoredExports: IgnoredExports, hidden?: Hidden }} information
|
||||
*/
|
||||
getStarReexports(
|
||||
moduleGraph,
|
||||
@@ -480,8 +482,10 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
||||
const noExtraImports =
|
||||
exportsInfo.otherExportsInfo.getUsed(runtime) === UsageState.Unused;
|
||||
|
||||
/** @type {IgnoredExports} */
|
||||
const ignoredExports = new Set(["default", ...this.activeExports]);
|
||||
|
||||
/** @type {Hidden | undefined} */
|
||||
let hiddenExports;
|
||||
const otherStarExports =
|
||||
this._discoverActiveExportsFromOtherStarExports(moduleGraph);
|
||||
@@ -1300,6 +1304,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
||||
runtimeRequirements.add(RuntimeGlobals.exports);
|
||||
runtimeRequirements.add(RuntimeGlobals.definePropertyGetters);
|
||||
|
||||
/** @type {ExportMap} */
|
||||
const map = new Map();
|
||||
map.set(key, `/* ${comment} */ ${returnValue}`);
|
||||
|
||||
@@ -1325,6 +1330,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
||||
runtimeRequirements.add(RuntimeGlobals.definePropertyGetters);
|
||||
runtimeRequirements.add(RuntimeGlobals.createFakeNamespaceObject);
|
||||
|
||||
/** @type {ExportMap} */
|
||||
const map = new Map();
|
||||
map.set(
|
||||
key,
|
||||
@@ -1365,6 +1371,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
||||
runtimeRequirements.add(RuntimeGlobals.definePropertyGetters);
|
||||
runtimeRequirements.add(RuntimeGlobals.makeDeferredNamespaceObject);
|
||||
|
||||
/** @type {ExportMap} */
|
||||
const map = new Map();
|
||||
const moduleId = JSON.stringify(chunkGraph.getModuleId(module));
|
||||
const mode = getMakeDeferredNamespaceModeFromExportsType(exportsType);
|
||||
|
||||
20
node_modules/webpack/lib/dependencies/HarmonyExportInitFragment.js
generated
vendored
20
node_modules/webpack/lib/dependencies/HarmonyExportInitFragment.js
generated
vendored
@@ -12,6 +12,7 @@ const { propertyName } = require("../util/propertyName");
|
||||
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
||||
/** @typedef {import("../ExportsInfo").UsedName} UsedName */
|
||||
|
||||
/**
|
||||
* @param {Iterable<string>} iterable iterable strings
|
||||
@@ -33,7 +34,12 @@ const joinIterableWithComma = (iterable) => {
|
||||
return str;
|
||||
};
|
||||
|
||||
/** @typedef {Map<UsedName, string>} ExportMap */
|
||||
/** @typedef {Set<string>} UnusedExports */
|
||||
|
||||
/** @type {ExportMap} */
|
||||
const EMPTY_MAP = new Map();
|
||||
/** @type {UnusedExports} */
|
||||
const EMPTY_SET = new Set();
|
||||
|
||||
/**
|
||||
@@ -42,8 +48,8 @@ const EMPTY_SET = new Set();
|
||||
class HarmonyExportInitFragment extends InitFragment {
|
||||
/**
|
||||
* @param {string} exportsArgument the exports identifier
|
||||
* @param {Map<string, string>} exportMap mapping from used name to exposed variable name
|
||||
* @param {Set<string>} unusedExports list of unused export names
|
||||
* @param {ExportMap} exportMap mapping from used name to exposed variable name
|
||||
* @param {UnusedExports} unusedExports list of unused export names
|
||||
*/
|
||||
constructor(
|
||||
exportsArgument,
|
||||
@@ -51,8 +57,11 @@ class HarmonyExportInitFragment extends InitFragment {
|
||||
unusedExports = EMPTY_SET
|
||||
) {
|
||||
super(undefined, InitFragment.STAGE_HARMONY_EXPORTS, 1, "harmony-exports");
|
||||
/** @type {string} */
|
||||
this.exportsArgument = exportsArgument;
|
||||
/** @type {ExportMap} */
|
||||
this.exportMap = exportMap;
|
||||
/** @type {UnusedExports} */
|
||||
this.unusedExports = unusedExports;
|
||||
}
|
||||
|
||||
@@ -61,8 +70,10 @@ class HarmonyExportInitFragment extends InitFragment {
|
||||
* @returns {HarmonyExportInitFragment} merged fragment
|
||||
*/
|
||||
mergeAll(fragments) {
|
||||
/** @type {undefined | ExportMap} */
|
||||
let exportMap;
|
||||
let exportMapOwned = false;
|
||||
/** @type {undefined | UnusedExports} */
|
||||
let unusedExports;
|
||||
let unusedExportsOwned = false;
|
||||
|
||||
@@ -108,6 +119,7 @@ class HarmonyExportInitFragment extends InitFragment {
|
||||
* @returns {HarmonyExportInitFragment} merged result
|
||||
*/
|
||||
merge(other) {
|
||||
/** @type {ExportMap} */
|
||||
let exportMap;
|
||||
if (this.exportMap.size === 0) {
|
||||
exportMap = other.exportMap;
|
||||
@@ -119,6 +131,7 @@ class HarmonyExportInitFragment extends InitFragment {
|
||||
if (!exportMap.has(key)) exportMap.set(key, value);
|
||||
}
|
||||
}
|
||||
/** @type {UnusedExports} */
|
||||
let unusedExports;
|
||||
if (this.unusedExports.size === 0) {
|
||||
unusedExports = other.unusedExports;
|
||||
@@ -153,6 +166,7 @@ class HarmonyExportInitFragment extends InitFragment {
|
||||
: this.unusedExports.size > 0
|
||||
? `/* unused harmony export ${first(this.unusedExports)} */\n`
|
||||
: "";
|
||||
/** @type {string[]} */
|
||||
const definitions = [];
|
||||
const orderedExportMap = [...this.exportMap].sort(([a], [b]) =>
|
||||
a < b ? -1 : 1
|
||||
@@ -160,7 +174,7 @@ class HarmonyExportInitFragment extends InitFragment {
|
||||
for (const [key, value] of orderedExportMap) {
|
||||
definitions.push(
|
||||
`\n/* harmony export */ ${propertyName(
|
||||
key
|
||||
/** @type {string} */ (key)
|
||||
)}: ${runtimeTemplate.returningFunction(value)}`
|
||||
);
|
||||
}
|
||||
|
||||
4
node_modules/webpack/lib/dependencies/HarmonyExportSpecifierDependency.js
generated
vendored
4
node_modules/webpack/lib/dependencies/HarmonyExportSpecifierDependency.js
generated
vendored
@@ -17,6 +17,8 @@ const NullDependency = require("./NullDependency");
|
||||
/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
||||
/** @typedef {import("./HarmonyExportInitFragment").UnusedExports} UnusedExports */
|
||||
/** @typedef {import("./HarmonyExportInitFragment").ExportMap} ExportMap */
|
||||
|
||||
class HarmonyExportSpecifierDependency extends NullDependency {
|
||||
/**
|
||||
@@ -104,6 +106,7 @@ HarmonyExportSpecifierDependency.Template = class HarmonyExportSpecifierDependen
|
||||
.getExportsInfo(module)
|
||||
.getUsedName(dep.name, runtime);
|
||||
if (!used) {
|
||||
/** @type {UnusedExports} */
|
||||
const set = new Set();
|
||||
set.add(dep.name || "namespace");
|
||||
initFragments.push(
|
||||
@@ -112,6 +115,7 @@ HarmonyExportSpecifierDependency.Template = class HarmonyExportSpecifierDependen
|
||||
return;
|
||||
}
|
||||
|
||||
/** @type {ExportMap} */
|
||||
const map = new Map();
|
||||
map.set(used, `/* binding */ ${dep.id}`);
|
||||
initFragments.push(
|
||||
|
||||
2
node_modules/webpack/lib/dependencies/HarmonyImportDependency.js
generated
vendored
2
node_modules/webpack/lib/dependencies/HarmonyImportDependency.js
generated
vendored
@@ -29,7 +29,7 @@ const ModuleDependency = require("./ModuleDependency");
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
||||
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
|
||||
/** @typedef {0 | 1 | 2 | 3 | false} ExportPresenceMode */
|
||||
/** @typedef {0 | 1 | 2 | 3} ExportPresenceMode */
|
||||
|
||||
const ExportPresenceModes = {
|
||||
NONE: /** @type {ExportPresenceMode} */ (0),
|
||||
|
||||
274
node_modules/webpack/lib/dependencies/HarmonyImportDependencyParserPlugin.js
generated
vendored
274
node_modules/webpack/lib/dependencies/HarmonyImportDependencyParserPlugin.js
generated
vendored
@@ -12,6 +12,7 @@ const {
|
||||
getImportAttributes
|
||||
} = require("../javascript/JavascriptParser");
|
||||
const InnerGraph = require("../optimize/InnerGraph");
|
||||
const AppendOnlyStackedSet = require("../util/AppendOnlyStackedSet");
|
||||
const ConstDependency = require("./ConstDependency");
|
||||
const HarmonyAcceptDependency = require("./HarmonyAcceptDependency");
|
||||
const HarmonyAcceptImportDependency = require("./HarmonyAcceptImportDependency");
|
||||
@@ -36,9 +37,18 @@ const { ImportPhaseUtils, createGetImportPhase } = require("./ImportPhase");
|
||||
/** @typedef {import("../javascript/JavascriptParser").Members} Members */
|
||||
/** @typedef {import("../javascript/JavascriptParser").MembersOptionals} MembersOptionals */
|
||||
/** @typedef {import("./HarmonyImportDependency").Ids} Ids */
|
||||
/** @typedef {import("./HarmonyImportDependency").ExportPresenceMode} ExportPresenceMode */
|
||||
/** @typedef {import("./ImportPhase").ImportPhaseType} ImportPhaseType */
|
||||
|
||||
/**
|
||||
* @typedef {object} HarmonySpecifierGuards
|
||||
* @property {AppendOnlyStackedSet<string> | undefined} guards
|
||||
*/
|
||||
|
||||
/** @typedef {Map<string, Set<string>>} Guards Map of import root to guarded member keys */
|
||||
|
||||
const harmonySpecifierTag = Symbol("harmony import");
|
||||
const harmonySpecifierGuardTag = Symbol("harmony import guard");
|
||||
|
||||
/**
|
||||
* @typedef {object} HarmonySettings
|
||||
@@ -53,12 +63,25 @@ const harmonySpecifierTag = Symbol("harmony import");
|
||||
|
||||
const PLUGIN_NAME = "HarmonyImportDependencyParserPlugin";
|
||||
|
||||
/** @type {(members: Members) => string} */
|
||||
const getMembersKey = (members) => members.join(".");
|
||||
|
||||
/**
|
||||
* Strip the root binding name if needed
|
||||
* @param {HarmonySettings} settings settings
|
||||
* @param {Ids} ids ids
|
||||
* @returns {Ids} ids for presence check
|
||||
*/
|
||||
const getIdsForPresence = (settings, ids) =>
|
||||
settings.ids.length ? ids.slice(1) : ids;
|
||||
|
||||
module.exports = class HarmonyImportDependencyParserPlugin {
|
||||
/**
|
||||
* @param {JavascriptParserOptions} options options
|
||||
*/
|
||||
constructor(options) {
|
||||
this.options = options;
|
||||
/** @type {ExportPresenceMode} */
|
||||
this.exportPresenceMode =
|
||||
options.importExportsPresence !== undefined
|
||||
? ExportPresenceModes.fromUserOption(options.importExportsPresence)
|
||||
@@ -70,13 +93,30 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
||||
this.strictThisContextOnImports = options.strictThisContextOnImports;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {JavascriptParser} parser the parser
|
||||
* @param {Ids} ids ids
|
||||
* @returns {ExportPresenceMode} exportPresenceMode
|
||||
*/
|
||||
getExportPresenceMode(parser, ids) {
|
||||
const harmonySettings = /** @type {HarmonySettings=} */ (
|
||||
parser.currentTagData
|
||||
);
|
||||
if (!harmonySettings) return this.exportPresenceMode;
|
||||
|
||||
const data = /** @type {HarmonySpecifierGuards=} */ (
|
||||
parser.getTagData(harmonySettings.name, harmonySpecifierGuardTag)
|
||||
);
|
||||
return data && data.guards && data.guards.has(getMembersKey(ids))
|
||||
? ExportPresenceModes.NONE
|
||||
: this.exportPresenceMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {JavascriptParser} parser the parser
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(parser) {
|
||||
const { exportPresenceMode } = this;
|
||||
|
||||
const getImportPhase = createGetImportPhase(this.options.deferImport);
|
||||
|
||||
/**
|
||||
@@ -228,6 +268,7 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
||||
.for(harmonySpecifierTag)
|
||||
.tap(PLUGIN_NAME, (expr) => {
|
||||
const settings = /** @type {HarmonySettings} */ (parser.currentTagData);
|
||||
|
||||
const dep = new HarmonyImportSpecifierDependency(
|
||||
settings.source,
|
||||
settings.sourceOrder,
|
||||
@@ -235,7 +276,10 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
||||
settings.name,
|
||||
/** @type {Range} */
|
||||
(expr.range),
|
||||
exportPresenceMode,
|
||||
this.getExportPresenceMode(
|
||||
parser,
|
||||
getIdsForPresence(settings, settings.ids)
|
||||
),
|
||||
settings.phase,
|
||||
settings.attributes,
|
||||
[]
|
||||
@@ -285,7 +329,10 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
||||
settings.name,
|
||||
/** @type {Range} */
|
||||
(expr.range),
|
||||
exportPresenceMode,
|
||||
this.getExportPresenceMode(
|
||||
parser,
|
||||
getIdsForPresence(settings, ids)
|
||||
),
|
||||
settings.phase,
|
||||
settings.attributes,
|
||||
ranges
|
||||
@@ -335,7 +382,10 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
||||
ids,
|
||||
settings.name,
|
||||
/** @type {Range} */ (expr.range),
|
||||
exportPresenceMode,
|
||||
this.getExportPresenceMode(
|
||||
parser,
|
||||
getIdsForPresence(settings, ids)
|
||||
),
|
||||
settings.phase,
|
||||
settings.attributes,
|
||||
ranges
|
||||
@@ -402,7 +452,221 @@ module.exports = class HarmonyImportDependencyParserPlugin {
|
||||
parser.state.module.addDependency(dep);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* @param {Expression} expression expression
|
||||
* @returns {{ root: string, members: Members } | undefined} info
|
||||
*/
|
||||
const getHarmonyImportInfo = (expression) => {
|
||||
const nameInfo = parser.getNameForExpression(expression);
|
||||
if (!nameInfo) return;
|
||||
|
||||
const rootInfo = nameInfo.rootInfo;
|
||||
const root =
|
||||
typeof rootInfo === "string"
|
||||
? rootInfo
|
||||
: rootInfo instanceof VariableInfo
|
||||
? rootInfo.name
|
||||
: undefined;
|
||||
if (!root) return;
|
||||
if (!parser.getTagData(root, harmonySpecifierTag)) return;
|
||||
return { root, members: nameInfo.getMembers() };
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Guards} guards guards
|
||||
* @param {string} root root name
|
||||
* @param {Members} members members
|
||||
*/
|
||||
const addToGuards = (guards, root, members) => {
|
||||
const membersKey = getMembersKey(members);
|
||||
const guardedMembers = guards.get(root);
|
||||
if (guardedMembers) {
|
||||
guardedMembers.add(membersKey);
|
||||
return;
|
||||
}
|
||||
|
||||
guards.set(
|
||||
root,
|
||||
// Adding `foo.bar` implies guarding `foo` as well
|
||||
membersKey === "" ? new Set([""]) : new Set([membersKey, ""])
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Expression} expression expression
|
||||
* @param {Guards} guards guards
|
||||
* @param {boolean} needTruthy need to be truthy
|
||||
*/
|
||||
const collect = (expression, guards, needTruthy) => {
|
||||
// !foo
|
||||
if (
|
||||
expression.type === "UnaryExpression" &&
|
||||
expression.operator === "!"
|
||||
) {
|
||||
collect(expression.argument, guards, !needTruthy);
|
||||
return;
|
||||
} else if (expression.type === "LogicalExpression" && needTruthy) {
|
||||
// foo && bar
|
||||
if (expression.operator === "&&") {
|
||||
collect(expression.left, guards, true);
|
||||
collect(expression.right, guards, true);
|
||||
}
|
||||
// falsy || foo
|
||||
else if (expression.operator === "||") {
|
||||
const leftEvaluation = parser.evaluateExpression(expression.left);
|
||||
const leftBool = leftEvaluation.asBool();
|
||||
if (leftBool === false) {
|
||||
collect(expression.right, guards, true);
|
||||
}
|
||||
}
|
||||
// nullish ?? foo
|
||||
else if (expression.operator === "??") {
|
||||
const leftEvaluation = parser.evaluateExpression(expression.left);
|
||||
const leftNullish = leftEvaluation.asNullish();
|
||||
if (leftNullish === true) {
|
||||
collect(expression.right, guards, true);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!needTruthy) return;
|
||||
|
||||
/**
|
||||
* @param {Expression} targetExpression expression
|
||||
* @returns {boolean} is added
|
||||
*/
|
||||
const addGuardForExpression = (targetExpression) => {
|
||||
const info = getHarmonyImportInfo(targetExpression);
|
||||
if (!info) return false;
|
||||
addToGuards(guards, info.root, info.members);
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Expression} left left expression
|
||||
* @param {Expression} right right expression
|
||||
* @param {(evaluation: ReturnType<JavascriptParser["evaluateExpression"]>) => boolean} matcher matcher
|
||||
* @returns {boolean} is added
|
||||
*/
|
||||
const addGuardForNullishCompare = (left, right, matcher) => {
|
||||
const leftEval = parser.evaluateExpression(left);
|
||||
if (leftEval && matcher(leftEval)) {
|
||||
return addGuardForExpression(right);
|
||||
}
|
||||
const rightEval = parser.evaluateExpression(right);
|
||||
if (rightEval && matcher(rightEval)) {
|
||||
return addGuardForExpression(/** @type {Expression} */ (left));
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
if (expression.type === "BinaryExpression") {
|
||||
// "bar" in foo
|
||||
if (expression.operator === "in") {
|
||||
const leftEvaluation = parser.evaluateExpression(expression.left);
|
||||
if (leftEvaluation.couldHaveSideEffects()) return;
|
||||
const propertyName = leftEvaluation.asString();
|
||||
if (!propertyName) return;
|
||||
parser.evaluateExpression(expression.right);
|
||||
const info = getHarmonyImportInfo(expression.right);
|
||||
if (!info) return;
|
||||
|
||||
if (info.members.length) {
|
||||
for (const member of info.members) {
|
||||
addToGuards(guards, info.root, [member]);
|
||||
}
|
||||
}
|
||||
addToGuards(guards, info.root, [...info.members, propertyName]);
|
||||
return;
|
||||
}
|
||||
// foo !== undefined
|
||||
else if (
|
||||
expression.operator === "!==" &&
|
||||
addGuardForNullishCompare(
|
||||
/** @type {Expression} */ (expression.left),
|
||||
expression.right,
|
||||
(evaluation) => evaluation.isUndefined()
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
// foo != undefined
|
||||
// foo != null
|
||||
else if (
|
||||
expression.operator === "!=" &&
|
||||
addGuardForNullishCompare(
|
||||
/** @type {Expression} */ (expression.left),
|
||||
expression.right,
|
||||
(evaluation) => Boolean(evaluation.asNullish())
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
addGuardForExpression(expression);
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Guards} guards guards
|
||||
* @param {() => void} walk walk callback
|
||||
* @returns {void}
|
||||
*/
|
||||
const withGuards = (guards, walk) => {
|
||||
const applyGuards = () => {
|
||||
/** @type {(() => void)[]} */
|
||||
const restoreFns = [];
|
||||
|
||||
for (const [rootName, members] of guards) {
|
||||
const previous = parser.getVariableInfo(rootName);
|
||||
const exist = /** @type {HarmonySpecifierGuards=} */ (
|
||||
parser.getTagData(rootName, harmonySpecifierGuardTag)
|
||||
);
|
||||
|
||||
const mergedGuards =
|
||||
exist && exist.guards
|
||||
? exist.guards.createChild()
|
||||
: new AppendOnlyStackedSet();
|
||||
|
||||
for (const memberKey of members) mergedGuards.add(memberKey);
|
||||
parser.tagVariable(rootName, harmonySpecifierGuardTag, {
|
||||
guards: mergedGuards
|
||||
});
|
||||
restoreFns.push(() => {
|
||||
parser.setVariable(rootName, previous);
|
||||
});
|
||||
}
|
||||
|
||||
return () => {
|
||||
for (const restore of restoreFns) {
|
||||
restore();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
const restore = applyGuards();
|
||||
try {
|
||||
walk();
|
||||
} finally {
|
||||
restore();
|
||||
}
|
||||
};
|
||||
|
||||
if (this.exportPresenceMode !== ExportPresenceModes.NONE) {
|
||||
parser.hooks.collectGuards.tap(PLUGIN_NAME, (expression) => {
|
||||
if (parser.scope.isAsmJs) return;
|
||||
/** @type {Guards} */
|
||||
const guards = new Map();
|
||||
collect(expression, guards, true);
|
||||
|
||||
if (guards.size === 0) return;
|
||||
return (walk) => {
|
||||
withGuards(guards, walk);
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.harmonySpecifierGuardTag = harmonySpecifierGuardTag;
|
||||
module.exports.harmonySpecifierTag = harmonySpecifierTag;
|
||||
|
||||
25
node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js
generated
vendored
25
node_modules/webpack/lib/dependencies/HarmonyImportSpecifierDependency.js
generated
vendored
@@ -6,6 +6,7 @@
|
||||
"use strict";
|
||||
|
||||
const Dependency = require("../Dependency");
|
||||
const InitFragment = require("../InitFragment");
|
||||
const Template = require("../Template");
|
||||
const {
|
||||
getDependencyUsedByExportsCondition
|
||||
@@ -72,10 +73,15 @@ class HarmonyImportSpecifierDependency extends HarmonyImportDependency {
|
||||
this.range = range;
|
||||
this.idRanges = idRanges;
|
||||
this.exportPresenceMode = exportPresenceMode;
|
||||
/** @type {undefined | boolean} */
|
||||
this.namespaceObjectAsContext = false;
|
||||
/** @type {undefined | boolean} */
|
||||
this.call = undefined;
|
||||
/** @type {undefined | boolean} */
|
||||
this.directImport = undefined;
|
||||
/** @type {undefined | boolean | string} */
|
||||
this.shorthand = undefined;
|
||||
/** @type {undefined | boolean} */
|
||||
this.asiSafe = undefined;
|
||||
/** @type {UsedByExports | undefined} */
|
||||
this.usedByExports = undefined;
|
||||
@@ -336,10 +342,22 @@ HarmonyImportSpecifierDependency.Template = class HarmonyImportSpecifierDependen
|
||||
*/
|
||||
apply(dependency, source, templateContext) {
|
||||
const dep = /** @type {HarmonyImportSpecifierDependency} */ (dependency);
|
||||
const { moduleGraph, runtime } = templateContext;
|
||||
const { moduleGraph, runtime, initFragments } = templateContext;
|
||||
const connection = moduleGraph.getConnection(dep);
|
||||
// Skip rendering depending when dependency is conditional
|
||||
if (connection && !connection.isTargetActive(runtime)) return;
|
||||
|
||||
// Only render declaration for import specifier when the dependency is conditional
|
||||
if (connection && !connection.isTargetActive(runtime)) {
|
||||
initFragments.push(
|
||||
new InitFragment(
|
||||
`/* unused harmony import specifier */ var ${dep.name};\n`,
|
||||
InitFragment.STAGE_HARMONY_IMPORTS,
|
||||
0,
|
||||
`unused import specifier ${dep.name}`
|
||||
)
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const ids = dep.getIds(moduleGraph);
|
||||
const {
|
||||
@@ -431,6 +449,7 @@ HarmonyImportSpecifierDependency.Template = class HarmonyImportSpecifierDependen
|
||||
const { moduleGraph, module, runtime, concatenationScope } =
|
||||
templateContext;
|
||||
const connection = moduleGraph.getConnection(dep);
|
||||
/** @type {string} */
|
||||
let exportExpr;
|
||||
if (
|
||||
connection &&
|
||||
|
||||
1
node_modules/webpack/lib/dependencies/ImportDependency.js
generated
vendored
1
node_modules/webpack/lib/dependencies/ImportDependency.js
generated
vendored
@@ -67,6 +67,7 @@ class ImportDependency extends ModuleDependency {
|
||||
*/
|
||||
getReferencedExports(moduleGraph, runtime) {
|
||||
if (!this.referencedExports) return Dependency.EXPORTS_OBJECT_REFERENCED;
|
||||
/** @type {ReferencedExports} */
|
||||
const refs = [];
|
||||
for (const referencedExport of this.referencedExports) {
|
||||
if (referencedExport[0] === "default") {
|
||||
|
||||
1
node_modules/webpack/lib/dependencies/ImportMetaContextDependencyParserPlugin.js
generated
vendored
1
node_modules/webpack/lib/dependencies/ImportMetaContextDependencyParserPlugin.js
generated
vendored
@@ -84,6 +84,7 @@ module.exports = class ImportMetaContextDependencyParserPlugin {
|
||||
);
|
||||
if (!requestExpr.isString()) return;
|
||||
const request = /** @type {string} */ (requestExpr.string);
|
||||
/** @type {WebpackError[]} */
|
||||
const errors = [];
|
||||
let regExp = /^\.\/.*$/;
|
||||
let recursive = true;
|
||||
|
||||
64
node_modules/webpack/lib/dependencies/ImportMetaPlugin.js
generated
vendored
64
node_modules/webpack/lib/dependencies/ImportMetaPlugin.js
generated
vendored
@@ -28,6 +28,7 @@ const propertyAccess = require("../util/propertyAccess");
|
||||
const ConstDependency = require("./ConstDependency");
|
||||
|
||||
/** @typedef {import("estree").MemberExpression} MemberExpression */
|
||||
/** @typedef {import("estree").Identifier} Identifier */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
||||
@@ -44,18 +45,24 @@ const getCriticalDependencyWarning = memoize(() =>
|
||||
|
||||
const PLUGIN_NAME = "ImportMetaPlugin";
|
||||
|
||||
/** @type {WeakMap<Compilation, { stringify: string, env: Record<string, string> }>} */
|
||||
const compilationMetaEnvMap = new WeakMap();
|
||||
|
||||
/**
|
||||
* Collect import.meta.env definitions from DefinePlugin and build JSON string
|
||||
* @param {Compilation} compilation the compilation
|
||||
* @returns {string} env object as JSON string
|
||||
* @returns {{ stringify: string, env: Record<string, string> }} env object as JSON string
|
||||
*/
|
||||
const collectImportMetaEnvDefinitions = (compilation) => {
|
||||
const definePluginHooks = DefinePlugin.getCompilationHooks(compilation);
|
||||
const definitions = definePluginHooks.definitions.call({});
|
||||
if (!definitions) {
|
||||
return "{}";
|
||||
const cached = compilationMetaEnvMap.get(compilation);
|
||||
if (cached) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
const definePluginHooks = DefinePlugin.getCompilationHooks(compilation);
|
||||
const definitions = definePluginHooks.definitions.call({});
|
||||
/** @type {Record<string, string>} */
|
||||
const env = {};
|
||||
/** @type {string[]} */
|
||||
const pairs = [];
|
||||
for (const key of Object.keys(definitions)) {
|
||||
@@ -63,10 +70,12 @@ const collectImportMetaEnvDefinitions = (compilation) => {
|
||||
const envKey = key.slice("import.meta.env.".length);
|
||||
const value = definitions[key];
|
||||
pairs.push(`${JSON.stringify(envKey)}:${value}`);
|
||||
env[envKey] = /** @type {string} */ (value);
|
||||
}
|
||||
}
|
||||
|
||||
return `{${pairs.join(",")}}`;
|
||||
const result = { stringify: `{${pairs.join(",")}}`, env };
|
||||
compilationMetaEnvMap.set(compilation, result);
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -148,10 +157,15 @@ class ImportMetaPlugin {
|
||||
* @param {Members} members members
|
||||
* @returns {string} error message
|
||||
*/
|
||||
const importMetaUnknownProperty = (members) =>
|
||||
`${Template.toNormalComment(
|
||||
const importMetaUnknownProperty = (members) => {
|
||||
if (importMeta === "preserve-unknown") {
|
||||
return `import.meta${propertyAccess(members, 0)}`;
|
||||
}
|
||||
return `${Template.toNormalComment(
|
||||
`unsupported import.meta.${members.join(".")}`
|
||||
)} undefined${propertyAccess(members, 1)}`;
|
||||
};
|
||||
|
||||
parser.hooks.typeof
|
||||
.for("import.meta")
|
||||
.tap(
|
||||
@@ -223,6 +237,9 @@ class ImportMetaPlugin {
|
||||
RuntimeGlobals.module
|
||||
);
|
||||
break;
|
||||
case "env":
|
||||
str += `env: ${collectImportMetaEnvDefinitions(compilation).stringify},`;
|
||||
break;
|
||||
default:
|
||||
str += `[${JSON.stringify(
|
||||
prop.id
|
||||
@@ -327,12 +344,31 @@ class ImportMetaPlugin {
|
||||
PLUGIN_NAME,
|
||||
toConstantDependency(parser, JSON.stringify("object"))
|
||||
);
|
||||
parser.hooks.expressionMemberChain
|
||||
.for("import.meta")
|
||||
.tap(PLUGIN_NAME, (expr, members) => {
|
||||
if (members[0] === "env" && members[1]) {
|
||||
const name = members[1];
|
||||
const { env } = collectImportMetaEnvDefinitions(compilation);
|
||||
if (!Object.prototype.hasOwnProperty.call(env, name)) {
|
||||
const dep = new ConstDependency(
|
||||
"undefined",
|
||||
/** @type {Range} */ (expr.range)
|
||||
);
|
||||
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
parser.hooks.expression
|
||||
.for("import.meta.env")
|
||||
.tap(PLUGIN_NAME, (expr) => {
|
||||
const envCode = collectImportMetaEnvDefinitions(compilation);
|
||||
const { stringify } =
|
||||
collectImportMetaEnvDefinitions(compilation);
|
||||
|
||||
const dep = new ConstDependency(
|
||||
envCode,
|
||||
stringify,
|
||||
/** @type {Range} */ (expr.range)
|
||||
);
|
||||
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||
@@ -355,6 +391,11 @@ class ImportMetaPlugin {
|
||||
parser.hooks.unhandledExpressionMemberChain
|
||||
.for("import.meta")
|
||||
.tap(PLUGIN_NAME, (expr, members) => {
|
||||
// unknown import.meta properties should be determined at runtime
|
||||
if (importMeta === "preserve-unknown") {
|
||||
return true;
|
||||
}
|
||||
|
||||
// keep import.meta.env unknown property
|
||||
// don't evaluate import.meta.env.UNKNOWN_PROPERTY -> undefined.UNKNOWN_PROPERTY
|
||||
// `dirname` and `filename` logic in NodeStuffPlugin
|
||||
@@ -373,6 +414,7 @@ class ImportMetaPlugin {
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
return true;
|
||||
});
|
||||
|
||||
parser.hooks.evaluate
|
||||
.for("MemberExpression")
|
||||
.tap(PLUGIN_NAME, (expression) => {
|
||||
|
||||
19
node_modules/webpack/lib/dependencies/ImportParserPlugin.js
generated
vendored
19
node_modules/webpack/lib/dependencies/ImportParserPlugin.js
generated
vendored
@@ -17,7 +17,7 @@ const ContextDependencyHelpers = require("./ContextDependencyHelpers");
|
||||
const ImportContextDependency = require("./ImportContextDependency");
|
||||
const ImportDependency = require("./ImportDependency");
|
||||
const ImportEagerDependency = require("./ImportEagerDependency");
|
||||
const { ImportPhaseUtils, createGetImportPhase } = require("./ImportPhase");
|
||||
const { createGetImportPhase } = require("./ImportPhase");
|
||||
const ImportWeakDependency = require("./ImportWeakDependency");
|
||||
|
||||
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
||||
@@ -262,11 +262,14 @@ class ImportParserPlugin {
|
||||
parser.hooks.importCall.tap(PLUGIN_NAME, (expr, importThen) => {
|
||||
const param = parser.evaluateExpression(expr.source);
|
||||
|
||||
/** @type {null | string} */
|
||||
let chunkName = null;
|
||||
let mode = /** @type {ContextMode} */ (this.options.dynamicImportMode);
|
||||
/** @type {null | RegExp} */
|
||||
let include = null;
|
||||
/** @type {null | RegExp} */
|
||||
let exclude = null;
|
||||
/** @type {RawReferencedExports | null} */
|
||||
/** @type {null | RawReferencedExports} */
|
||||
let exports = null;
|
||||
/** @type {RawChunkGroupOptions} */
|
||||
const groupOptions = {};
|
||||
@@ -557,15 +560,6 @@ class ImportParserPlugin {
|
||||
mode = "async-weak";
|
||||
}
|
||||
|
||||
if (ImportPhaseUtils.isDefer(phase)) {
|
||||
parser.state.module.addWarning(
|
||||
new UnsupportedFeatureWarning(
|
||||
"import.defer() is not yet supported for ContextModule (the import path is a dynamic expression).",
|
||||
/** @type {DependencyLocation} */ (expr.loc)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const dep = ContextDependencyHelpers.create(
|
||||
ImportContextDependency,
|
||||
/** @type {Range} */ (expr.range),
|
||||
@@ -586,7 +580,8 @@ class ImportParserPlugin {
|
||||
typePrefix: "import()",
|
||||
category: "esm",
|
||||
referencedExports: exports,
|
||||
attributes: getImportAttributes(expr)
|
||||
attributes: getImportAttributes(expr),
|
||||
phase
|
||||
},
|
||||
parser
|
||||
);
|
||||
|
||||
3
node_modules/webpack/lib/dependencies/LoaderPlugin.js
generated
vendored
3
node_modules/webpack/lib/dependencies/LoaderPlugin.js
generated
vendored
@@ -10,6 +10,7 @@ const LazySet = require("../util/LazySet");
|
||||
const LoaderDependency = require("./LoaderDependency");
|
||||
const LoaderImportDependency = require("./LoaderImportDependency");
|
||||
|
||||
/** @typedef {import("webpack-sources").RawSourceMap} RawSourceMap */
|
||||
/** @typedef {import("../Compilation").DependencyConstructor} DependencyConstructor */
|
||||
/** @typedef {import("../Compilation").ExecuteModuleExports} ExecuteModuleExports */
|
||||
/** @typedef {import("../Compilation").ExecuteModuleResult} ExecuteModuleResult */
|
||||
@@ -116,7 +117,9 @@ class LoaderPlugin {
|
||||
)
|
||||
);
|
||||
}
|
||||
/** @type {null | RawSourceMap} */
|
||||
let map;
|
||||
/** @type {string | Buffer | undefined} */
|
||||
let source;
|
||||
if (moduleSource.sourceAndMap) {
|
||||
const sourceAndMap = moduleSource.sourceAndMap();
|
||||
|
||||
1
node_modules/webpack/lib/dependencies/ModuleDecoratorDependency.js
generated
vendored
1
node_modules/webpack/lib/dependencies/ModuleDecoratorDependency.js
generated
vendored
@@ -30,6 +30,7 @@ class ModuleDecoratorDependency extends NullDependency {
|
||||
super();
|
||||
this.decorator = decorator;
|
||||
this.allowExportsAccess = allowExportsAccess;
|
||||
/** @type {undefined | string} */
|
||||
this._hashUpdate = undefined;
|
||||
}
|
||||
|
||||
|
||||
1
node_modules/webpack/lib/dependencies/ModuleDependency.js
generated
vendored
1
node_modules/webpack/lib/dependencies/ModuleDependency.js
generated
vendored
@@ -27,6 +27,7 @@ class ModuleDependency extends Dependency {
|
||||
this.sourceOrder = sourceOrder;
|
||||
/** @type {Range | undefined} */
|
||||
this.range = undefined;
|
||||
/** @type {undefined | string} */
|
||||
this._context = undefined;
|
||||
}
|
||||
|
||||
|
||||
87
node_modules/webpack/lib/dependencies/ModuleInitFragmentDependency.js
generated
vendored
Executable file
87
node_modules/webpack/lib/dependencies/ModuleInitFragmentDependency.js
generated
vendored
Executable file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Natsu @xiaoxiaojx
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const InitFragment = require("../InitFragment");
|
||||
const makeSerializable = require("../util/makeSerializable");
|
||||
const NullDependency = require("./NullDependency");
|
||||
|
||||
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
||||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||
/**
|
||||
* A dependency that adds an init fragment to the module
|
||||
*/
|
||||
class ModuleInitFragmentDependency extends NullDependency {
|
||||
/**
|
||||
* @param {string} initCode the initialization code
|
||||
* @param {string[]} runtimeRequirements runtime requirements
|
||||
* @param {string=} key unique key to avoid emitting the same initialization code twice
|
||||
*/
|
||||
constructor(initCode, runtimeRequirements, key) {
|
||||
super();
|
||||
this.initCode = initCode;
|
||||
this.runtimeRequirements = runtimeRequirements;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ObjectSerializerContext} context context
|
||||
*/
|
||||
serialize(context) {
|
||||
const { write } = context;
|
||||
write(this.initCode);
|
||||
write(this.runtimeRequirements);
|
||||
write(this.key);
|
||||
super.serialize(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ObjectDeserializerContext} context context
|
||||
*/
|
||||
deserialize(context) {
|
||||
const { read } = context;
|
||||
this.initCode = read();
|
||||
this.runtimeRequirements = read();
|
||||
this.key = read();
|
||||
super.deserialize(context);
|
||||
}
|
||||
}
|
||||
|
||||
makeSerializable(
|
||||
ModuleInitFragmentDependency,
|
||||
"webpack/lib/dependencies/ModuleInitFragmentDependency"
|
||||
);
|
||||
|
||||
ModuleInitFragmentDependency.Template = class ModuleInitFragmentDependencyTemplate extends (
|
||||
NullDependency.Template
|
||||
) {
|
||||
/**
|
||||
* @param {Dependency} dependency the dependency for which the template should be applied
|
||||
* @param {ReplaceSource} source the current replace source which can be modified
|
||||
* @param {DependencyTemplateContext} templateContext the context object
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(dependency, source, { initFragments, runtimeRequirements }) {
|
||||
const dep = /** @type {ModuleInitFragmentDependency} */ (dependency);
|
||||
for (const req of dep.runtimeRequirements) {
|
||||
runtimeRequirements.add(req);
|
||||
}
|
||||
initFragments.push(
|
||||
new InitFragment(
|
||||
dep.initCode,
|
||||
InitFragment.STAGE_CONSTANTS,
|
||||
0,
|
||||
dep.key,
|
||||
undefined
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = ModuleInitFragmentDependency;
|
||||
1
node_modules/webpack/lib/dependencies/ProvidedDependency.js
generated
vendored
1
node_modules/webpack/lib/dependencies/ProvidedDependency.js
generated
vendored
@@ -44,6 +44,7 @@ class ProvidedDependency extends ModuleDependency {
|
||||
this.identifier = identifier;
|
||||
this.ids = ids;
|
||||
this.range = range;
|
||||
/** @type {undefined | string} */
|
||||
this._hashUpdate = undefined;
|
||||
}
|
||||
|
||||
|
||||
1
node_modules/webpack/lib/dependencies/RequireContextPlugin.js
generated
vendored
1
node_modules/webpack/lib/dependencies/RequireContextPlugin.js
generated
vendored
@@ -86,6 +86,7 @@ class RequireContextPlugin {
|
||||
)
|
||||
).options;
|
||||
|
||||
/** @type {{ context: string, request: string }[]} */
|
||||
let newItems;
|
||||
if (!finalResolveOptions.fullySpecified) {
|
||||
newItems = [];
|
||||
|
||||
2
node_modules/webpack/lib/dependencies/RequireEnsureDependenciesBlock.js
generated
vendored
2
node_modules/webpack/lib/dependencies/RequireEnsureDependenciesBlock.js
generated
vendored
@@ -13,7 +13,7 @@ const makeSerializable = require("../util/makeSerializable");
|
||||
|
||||
class RequireEnsureDependenciesBlock extends AsyncDependenciesBlock {
|
||||
/**
|
||||
* @param {GroupOptions | null} chunkName chunk name
|
||||
* @param {GroupOptions | string | null} chunkName chunk name
|
||||
* @param {(DependencyLocation | null)=} loc location info
|
||||
*/
|
||||
constructor(chunkName, loc) {
|
||||
|
||||
9
node_modules/webpack/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js
generated
vendored
9
node_modules/webpack/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js
generated
vendored
@@ -10,11 +10,14 @@ const RequireEnsureDependency = require("./RequireEnsureDependency");
|
||||
const RequireEnsureItemDependency = require("./RequireEnsureItemDependency");
|
||||
const getFunctionExpression = require("./getFunctionExpression");
|
||||
|
||||
/** @typedef {import("estree").Expression} Expression */
|
||||
/** @typedef {import("estree").SpreadElement} SpreadElement */
|
||||
/** @typedef {import("../AsyncDependenciesBlock").GroupOptions} GroupOptions */
|
||||
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
||||
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
|
||||
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {import("./getFunctionExpression").FunctionExpressionResult} FunctionExpressionResult */
|
||||
|
||||
const PLUGIN_NAME = "RequireEnsureDependenciesBlockParserPlugin";
|
||||
|
||||
@@ -27,8 +30,10 @@ module.exports = class RequireEnsureDependenciesBlockParserPlugin {
|
||||
parser.hooks.call.for("require.ensure").tap(PLUGIN_NAME, (expr) => {
|
||||
/** @type {string | GroupOptions | null} */
|
||||
let chunkName = null;
|
||||
let errorExpressionArg = null;
|
||||
let errorExpression = null;
|
||||
/** @type {undefined | Expression | SpreadElement} */
|
||||
let errorExpressionArg;
|
||||
/** @type {undefined | FunctionExpressionResult} */
|
||||
let errorExpression;
|
||||
switch (expr.arguments.length) {
|
||||
case 4: {
|
||||
const chunkNameExpr = parser.evaluateExpression(expr.arguments[3]);
|
||||
|
||||
1
node_modules/webpack/lib/dependencies/RuntimeRequirementsDependency.js
generated
vendored
1
node_modules/webpack/lib/dependencies/RuntimeRequirementsDependency.js
generated
vendored
@@ -24,6 +24,7 @@ class RuntimeRequirementsDependency extends NullDependency {
|
||||
constructor(runtimeRequirements) {
|
||||
super();
|
||||
this.runtimeRequirements = new Set(runtimeRequirements);
|
||||
/** @type {undefined | string} */
|
||||
this._hashUpdate = undefined;
|
||||
}
|
||||
|
||||
|
||||
12
node_modules/webpack/lib/dependencies/WorkerDependency.js
generated
vendored
12
node_modules/webpack/lib/dependencies/WorkerDependency.js
generated
vendored
@@ -23,20 +23,26 @@ const ModuleDependency = require("./ModuleDependency");
|
||||
/** @typedef {import("../util/Hash")} Hash */
|
||||
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
|
||||
/**
|
||||
* @typedef {object} WorkerDependencyOptions
|
||||
* @property {string=} publicPath public path for the worker
|
||||
* @property {boolean=} needNewUrl true when need generate `new URL(...)`, otherwise false
|
||||
*/
|
||||
|
||||
class WorkerDependency extends ModuleDependency {
|
||||
/**
|
||||
* @param {string} request request
|
||||
* @param {Range} range range
|
||||
* @param {object} workerDependencyOptions options
|
||||
* @param {string=} workerDependencyOptions.publicPath public path for the worker
|
||||
* @param {boolean=} workerDependencyOptions.needNewUrl need generate `new URL(...)`
|
||||
* @param {WorkerDependencyOptions} workerDependencyOptions options
|
||||
*/
|
||||
constructor(request, range, workerDependencyOptions) {
|
||||
super(request);
|
||||
this.range = range;
|
||||
// If options are updated, don't forget to update the hash and serialization functions
|
||||
/** @type {WorkerDependencyOptions} */
|
||||
this.options = workerDependencyOptions;
|
||||
/** Cache the hash */
|
||||
/** @type {undefined | string} */
|
||||
this._hashUpdate = undefined;
|
||||
}
|
||||
|
||||
|
||||
1
node_modules/webpack/lib/dependencies/WorkerPlugin.js
generated
vendored
1
node_modules/webpack/lib/dependencies/WorkerPlugin.js
generated
vendored
@@ -387,6 +387,7 @@ class WorkerPlugin {
|
||||
|
||||
const block = new AsyncDependenciesBlock({
|
||||
name: entryOptions.name,
|
||||
circular: false,
|
||||
entryOptions: {
|
||||
chunkLoading: this._chunkLoading,
|
||||
wasmLoading: this._wasmLoading,
|
||||
|
||||
4
node_modules/webpack/lib/dependencies/getFunctionExpression.js
generated
vendored
4
node_modules/webpack/lib/dependencies/getFunctionExpression.js
generated
vendored
@@ -10,9 +10,11 @@
|
||||
/** @typedef {import("estree").FunctionExpression} FunctionExpression */
|
||||
/** @typedef {import("estree").SpreadElement} SpreadElement */
|
||||
|
||||
/** @typedef {{ fn: FunctionExpression | ArrowFunctionExpression, expressions: (Expression | SpreadElement)[], needThis: boolean | undefined }} FunctionExpressionResult */
|
||||
|
||||
/**
|
||||
* @param {Expression | SpreadElement} expr expressions
|
||||
* @returns {{ fn: FunctionExpression | ArrowFunctionExpression, expressions: (Expression | SpreadElement)[], needThis: boolean | undefined } | undefined} function expression with additional information
|
||||
* @returns {FunctionExpressionResult | undefined} function expression with additional information
|
||||
*/
|
||||
module.exports = (expr) => {
|
||||
// <FunctionExpression>
|
||||
|
||||
Reference in New Issue
Block a user