From 9bce51f651aad297ef9eb6df832bfdaf1de05d84 Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期三, 22 四月 2026 14:27:54 +0800
Subject: [PATCH] 青岛推送

---
 node_modules/webpack/lib/NormalModuleFactory.js |   87 ++++++++++++++++++++++++++++++++++++-------
 1 files changed, 72 insertions(+), 15 deletions(-)

diff --git a/node_modules/webpack/lib/NormalModuleFactory.js b/node_modules/webpack/lib/NormalModuleFactory.js
index 3229a72..b5f7b89 100644
--- a/node_modules/webpack/lib/NormalModuleFactory.js
+++ b/node_modules/webpack/lib/NormalModuleFactory.js
@@ -20,6 +20,7 @@
 const ModuleGraph = require("./ModuleGraph");
 const { JAVASCRIPT_MODULE_TYPE_AUTO } = require("./ModuleTypeConstants");
 const NormalModule = require("./NormalModule");
+const { ImportPhaseUtils } = require("./dependencies/ImportPhase");
 const BasicEffectRulePlugin = require("./rules/BasicEffectRulePlugin");
 const BasicMatcherRulePlugin = require("./rules/BasicMatcherRulePlugin");
 const ObjectMatcherRulePlugin = require("./rules/ObjectMatcherRulePlugin");
@@ -38,6 +39,7 @@
 /** @typedef {import("enhanced-resolve").ResolveRequest} ResolveRequest */
 /** @typedef {import("../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptions */
 /** @typedef {import("../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
+/** @typedef {import("./Compilation").FileSystemDependencies} FileSystemDependencies */
 /** @typedef {import("./Generator")} Generator */
 /** @typedef {import("./ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */
 /** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */
@@ -51,37 +53,44 @@
 /** @typedef {import("./ResolverFactory")} ResolverFactory */
 /** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
 /** @typedef {import("./dependencies/ModuleDependency")} ModuleDependency */
+/** @typedef {import("./dependencies/ImportPhase").ImportPhaseType} ImportPhaseType */
+/** @typedef {import("./dependencies/ImportPhase").ImportPhaseName} ImportPhaseName */
 /** @typedef {import("./javascript/JavascriptParser").ImportAttributes} ImportAttributes */
 /** @typedef {import("./rules/RuleSetCompiler").RuleSetRules} RuleSetRules */
+/** @typedef {import("./rules/RuleSetCompiler").RuleSet} RuleSet */
 /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
 /** @typedef {import("./util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
 
 /**
+ * Defines the callback type used by this module.
  * @template T
  * @typedef {import("./Compiler").Callback<T>} Callback
  */
 
-/** @typedef {Pick<RuleSetRule, 'type' | 'sideEffects' | 'parser' | 'generator' | 'resolve' | 'layer' | 'extractSourceMap'>} ModuleSettings */
+/** @typedef {Pick<RuleSetRule, "type" | "sideEffects" | "parser" | "generator" | "resolve" | "layer" | "extractSourceMap">} ModuleSettings */
 /** @typedef {Partial<NormalModuleCreateData & { settings: ModuleSettings }>} CreateData */
 
 /**
+ * Defines the resolve data type used by this module.
  * @typedef {object} ResolveData
  * @property {ModuleFactoryCreateData["contextInfo"]} contextInfo
  * @property {ModuleFactoryCreateData["resolveOptions"]} resolveOptions
  * @property {string} context
  * @property {string} request
- * @property {ImportAttributes | undefined} attributes
+ * @property {ImportPhaseName=} phase
+ * @property {ImportAttributes=} attributes
  * @property {ModuleDependency[]} dependencies
  * @property {string} dependencyType
  * @property {CreateData} createData
- * @property {LazySet<string>} fileDependencies
- * @property {LazySet<string>} missingDependencies
- * @property {LazySet<string>} contextDependencies
+ * @property {FileSystemDependencies} fileDependencies
+ * @property {FileSystemDependencies} missingDependencies
+ * @property {FileSystemDependencies} contextDependencies
  * @property {Module=} ignoredModule
  * @property {boolean} cacheable allow to use the unsafe cache
  */
 
 /**
+ * Defines the resource data type used by this module.
  * @typedef {object} ResourceData
  * @property {string} resource
  * @property {string=} path
@@ -91,6 +100,7 @@
  */
 
 /**
+ * Defines the resource scheme data type used by this module.
  * @typedef {object} ResourceSchemeData
  * @property {string=} mimetype mime type of the resource
  * @property {string=} parameters additional parameters for the resource
@@ -101,9 +111,10 @@
 /** @typedef {ResourceData & { data: ResourceSchemeData & Partial<ResolveRequest> }} ResourceDataWithData */
 
 /**
+ * Defines the parsed loader request type used by this module.
  * @typedef {object} ParsedLoaderRequest
  * @property {string} loader loader
- * @property {string|undefined} options options
+ * @property {string | undefined} options options
  */
 
 /** @typedef {import("./ModuleTypeConstants").JAVASCRIPT_MODULE_TYPE_AUTO} JAVASCRIPT_MODULE_TYPE_AUTO */
@@ -137,6 +148,7 @@
 const LEADING_DOT_EXTENSION_REGEX = /^[^.]/;
 
 /**
+ * Returns ident.
  * @param {LoaderItem} data data
  * @returns {string} ident
  */
@@ -157,6 +169,7 @@
 };
 
 /**
+ * Stringify loaders and resource.
  * @param {LoaderItem[]} loaders loaders
  * @param {string} resource resource
  * @returns {string} stringified loaders and resource
@@ -170,6 +183,7 @@
 };
 
 /**
+ * Checks whether it needs calls.
  * @param {number} times times
  * @param {(err?: null | Error) => void} callback callback
  * @returns {(err?: null | Error) => void} callback
@@ -185,6 +199,7 @@
 };
 
 /**
+ * Merges global options.
  * @template T
  * @template O
  * @param {T} globalOptions global options
@@ -194,6 +209,7 @@
  */
 const mergeGlobalOptions = (globalOptions, type, localOptions) => {
 	const parts = type.split("/");
+	/** @type {undefined | T} */
 	let result;
 	let current = "";
 	for (const part of parts) {
@@ -214,6 +230,7 @@
 
 // TODO webpack 6 remove
 /**
+ * Deprecation changed hook message.
  * @template {import("tapable").Hook<EXPECTED_ANY, EXPECTED_ANY>} T
  * @param {string} name name
  * @param {T} hook hook
@@ -243,6 +260,7 @@
 	new BasicMatcherRulePlugin("issuer"),
 	new BasicMatcherRulePlugin("compiler"),
 	new BasicMatcherRulePlugin("issuerLayer"),
+	new BasicMatcherRulePlugin("phase"),
 	new ObjectMatcherRulePlugin("assert", "attributes", (value) => {
 		if (value) {
 			return (
@@ -296,16 +314,14 @@
 
 /** @typedef {import("./css/CssParser")} CssParser */
 /** @typedef {import("../declarations/WebpackOptions").CssParserOptions} CssParserOptions */
-/** @typedef {import("../declarations/WebpackOptions").CssAutoParserOptions} CssAutoParserOptions */
-/** @typedef {import("../declarations/WebpackOptions").CssGlobalParserOptions} CssGlobalParserOptions */
 /** @typedef {import("../declarations/WebpackOptions").CssModuleParserOptions} CssModuleParserOptions */
 /** @typedef {import("./css/CssGenerator")} CssGenerator */
 /** @typedef {import("../declarations/WebpackOptions").CssGeneratorOptions} CssGeneratorOptions */
-/** @typedef {import("../declarations/WebpackOptions").CssGlobalGeneratorOptions} CssGlobalGeneratorOptions */
 /** @typedef {import("../declarations/WebpackOptions").CssModuleGeneratorOptions} CssModuleGeneratorOptions */
-/** @typedef {import("../declarations/WebpackOptions").CssAutoGeneratorOptions} CssAutoGeneratorOptions */
 
+/* eslint-disable jsdoc/type-formatting */
 /**
+ * Defines the shared type used by this module.
  * @typedef {[
  * [JAVASCRIPT_MODULE_TYPE_AUTO, JavascriptParser, JavascriptParserOptions, JavascriptGenerator, EmptyGeneratorOptions],
  * [JAVASCRIPT_MODULE_TYPE_DYNAMIC, JavascriptParser, JavascriptParserOptions, JavascriptGenerator, EmptyGeneratorOptions],
@@ -319,20 +335,23 @@
  * [WEBASSEMBLY_MODULE_TYPE_ASYNC, AsyncWebAssemblyParser, EmptyParserOptions, Generator, EmptyParserOptions],
  * [WEBASSEMBLY_MODULE_TYPE_SYNC, WebAssemblyParser, EmptyParserOptions, Generator, EmptyParserOptions],
  * [CSS_MODULE_TYPE, CssParser, CssParserOptions, CssGenerator, CssGeneratorOptions],
- * [CSS_MODULE_TYPE_AUTO, CssParser, CssAutoParserOptions, CssGenerator, CssAutoGeneratorOptions],
+ * [CSS_MODULE_TYPE_AUTO, CssParser, CssModuleParserOptions, CssGenerator, CssModuleGeneratorOptions],
  * [CSS_MODULE_TYPE_MODULE, CssParser, CssModuleParserOptions, CssGenerator, CssModuleGeneratorOptions],
- * [CSS_MODULE_TYPE_GLOBAL, CssParser, CssGlobalParserOptions, CssGenerator, CssGlobalGeneratorOptions],
+ * [CSS_MODULE_TYPE_GLOBAL, CssParser, CssModuleParserOptions, CssGenerator, CssModuleGeneratorOptions],
  * [string, Parser, ParserOptions, Generator, GeneratorOptions],
  * ]} ParsersAndGeneratorsByTypes
  */
+/* eslint-enable jsdoc/type-formatting */
 
 /**
+ * Defines the extract tuple elements type used by this module.
  * @template {unknown[]} T
  * @template {number[]} I
  * @typedef {{ [K in keyof I]: K extends keyof I ? I[K] extends keyof T ? T[I[K]] : never : never }} ExtractTupleElements
  */
 
 /**
+ * Represents the normal module factory runtime component.
  * @template {unknown[]} T
  * @template {number[]} A
  * @template [R=void]
@@ -341,6 +360,7 @@
 
 class NormalModuleFactory extends ModuleFactory {
 	/**
+	 * Creates an instance of NormalModuleFactory.
 	 * @param {object} param params
 	 * @param {string=} param.context context
 	 * @param {InputFileSystem} param.fs file system
@@ -394,7 +414,9 @@
 				() => new SyncBailHook(["createData", "resolveData"])
 			)
 		});
+		/** @type {ResolverFactory} */
 		this.resolverFactory = resolverFactory;
+		/** @type {RuleSet} */
 		this.ruleSet = ruleSetCompiler.compile([
 			{
 				rules: /** @type {RuleSetRules} */ (options.defaultRules)
@@ -403,7 +425,9 @@
 				rules: /** @type {RuleSetRules} */ (options.rules)
 			}
 		]);
+		/** @type {string} */
 		this.context = context || "";
+		/** @type {InputFileSystem} */
 		this.fs = fs;
 		this._globalParserOptions = options.parser;
 		this._globalGeneratorOptions = options.generator;
@@ -515,6 +539,7 @@
 					dependencies,
 					dependencyType,
 					request,
+					phase,
 					attributes,
 					resolveOptions,
 					fileDependencies,
@@ -665,7 +690,9 @@
 					const useLoadersPre = [];
 
 					// handle .webpack[] suffix
+					/** @type {string} */
 					let resource;
+					/** @type {RegExpExecArray | null} */
 					let match;
 					if (
 						matchResourceData &&
@@ -680,12 +707,14 @@
 					} else {
 						settings.type = JAVASCRIPT_MODULE_TYPE_AUTO;
 						const resourceDataForRules = matchResourceData || resourceData;
+
 						const result = this.ruleSet.exec({
 							resource: resourceDataForRules.path,
 							realResource: resourceData.path,
 							resourceQuery: resourceDataForRules.query,
 							resourceFragment: resourceDataForRules.fragment,
 							scheme,
+							phase,
 							attributes,
 							mimetype: matchResourceData
 								? ""
@@ -853,10 +882,11 @@
 				);
 
 				/**
+				 * Processes the provided string.
 				 * @param {string} context context
 				 */
 				const defaultResolve = (context) => {
-					if (/^($|\?)/.test(unresolvedResource)) {
+					if (/^(?:$|\?)/.test(unresolvedResource)) {
 						resourceData = {
 							...cacheParseResource(unresolvedResource),
 							resource: unresolvedResource,
@@ -957,6 +987,7 @@
 	}
 
 	/**
+	 * Processes the provided data.
 	 * @param {ModuleFactoryCreateData} data data object
 	 * @param {ModuleFactoryCallback} callback callback
 	 * @returns {void}
@@ -970,10 +1001,23 @@
 		const attributes =
 			/** @type {ModuleDependency & { attributes: ImportAttributes }} */
 			(dependency).attributes;
+		const phase =
+			typeof (
+				/** @type {ModuleDependency & { phase?: ImportPhaseType }} */
+				(dependency).phase
+			) === "number"
+				? ImportPhaseUtils.stringify(
+						/** @type {ModuleDependency & { phase?: ImportPhaseType }} */
+						(dependency).phase
+					)
+				: "evaluation";
 		const dependencyType = dependency.category || "";
 		const contextInfo = data.contextInfo;
+		/** @type {FileSystemDependencies} */
 		const fileDependencies = new LazySet();
+		/** @type {FileSystemDependencies} */
 		const missingDependencies = new LazySet();
+		/** @type {FileSystemDependencies} */
 		const contextDependencies = new LazySet();
 		/** @type {ResolveData} */
 		const resolveData = {
@@ -981,6 +1025,7 @@
 			resolveOptions,
 			context,
 			request,
+			phase,
 			attributes,
 			dependencies,
 			dependencyType,
@@ -1051,6 +1096,7 @@
 	}
 
 	/**
+	 * Processes the provided context info.
 	 * @param {ModuleFactoryCreateDataContextInfo} contextInfo context info
 	 * @param {string} context context
 	 * @param {string} unresolvedResource unresolved resource
@@ -1123,6 +1169,7 @@
 	}
 
 	/**
+	 * Resolve resource error hints.
 	 * @param {Error} error error
 	 * @param {ModuleFactoryCreateDataContextInfo} contextInfo context info
 	 * @param {string} context context
@@ -1188,7 +1235,7 @@
 							(err, resolvedResource) => {
 								if (!err && resolvedResource) {
 									let hint = "";
-									const match = /(\.[^.]+)(\?|$)/.exec(unresolvedResource);
+									const match = /\.[^.]+(?:\?|$)/.exec(unresolvedResource);
 									if (match) {
 										const fixedRequest = unresolvedResource.replace(
 											/(\.[^.]+)(\?|$)/,
@@ -1248,6 +1295,7 @@
 	}
 
 	/**
+	 * Resolves request array.
 	 * @param {ModuleFactoryCreateDataContextInfo} contextInfo context info
 	 * @param {string} context context
 	 * @param {LoaderItem[]} array array
@@ -1269,6 +1317,7 @@
 		asyncLib.map(
 			array,
 			/**
+			 * Handles the callback logic for this hook.
 			 * @param {LoaderItem} item item
 			 * @param {Callback<LoaderItem>} callback callback
 			 */
@@ -1338,12 +1387,16 @@
 				);
 			},
 			(err, value) => {
-				callback(err, /** @type {(LoaderItem)[]} */ (value));
+				callback(
+					/** @type {Error | null} */ (err),
+					/** @type {(LoaderItem)[]} */ (value)
+				);
 			}
 		);
 	}
 
 	/**
+	 * Returns parser.
 	 * @param {string} type type
 	 * @param {ParserOptions} parserOptions parser options
 	 * @returns {Parser} parser
@@ -1367,6 +1420,7 @@
 	}
 
 	/**
+	 * Creates a parser from the provided type.
 	 * @param {string} type type
 	 * @param {ParserOptions} parserOptions parser options
 	 * @returns {Parser} parser
@@ -1386,6 +1440,7 @@
 	}
 
 	/**
+	 * Returns generator.
 	 * @param {string} type type of generator
 	 * @param {GeneratorOptions} generatorOptions generator options
 	 * @returns {Generator} generator
@@ -1409,6 +1464,7 @@
 	}
 
 	/**
+	 * Creates a generator.
 	 * @param {string} type type of generator
 	 * @param {GeneratorOptions} generatorOptions generator options
 	 * @returns {Generator} generator
@@ -1430,6 +1486,7 @@
 	}
 
 	/**
+	 * Returns the resolver.
 	 * @param {Parameters<ResolverFactory["get"]>[0]} type type of resolver
 	 * @param {Parameters<ResolverFactory["get"]>[1]=} resolveOptions options
 	 * @returns {ReturnType<ResolverFactory["get"]>} the resolver

--
Gitblit v1.9.3