diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2026-05-18 23:10:59 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2026-05-18 23:41:44 +0800 |
| commit | fc87c009806dcc98867f6b58efe29b042aa01dee (patch) | |
| tree | 8f59b3f4a5b66e9dfef2d40c8d318e258a521228 /node_modules/webpack/lib/dependencies/ContextDependency.js | |
| parent | 3336b2356ee6152d9c6ae59bd9b87ccbc0958407 (diff) | |
node: updatemain
Diffstat (limited to 'node_modules/webpack/lib/dependencies/ContextDependency.js')
| -rw-r--r-- | node_modules/webpack/lib/dependencies/ContextDependency.js | 173 |
1 files changed, 0 insertions, 173 deletions
diff --git a/node_modules/webpack/lib/dependencies/ContextDependency.js b/node_modules/webpack/lib/dependencies/ContextDependency.js deleted file mode 100644 index fb12467d..00000000 --- a/node_modules/webpack/lib/dependencies/ContextDependency.js +++ /dev/null @@ -1,173 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -const Dependency = require("../Dependency"); -const DependencyTemplate = require("../DependencyTemplate"); -const makeSerializable = require("../util/makeSerializable"); -const memoize = require("../util/memoize"); - -/** @typedef {import("../ContextModule").ContextOptions} ContextOptions */ -/** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */ -/** @typedef {import("../ModuleGraph")} ModuleGraph */ -/** @typedef {import("../WebpackError")} WebpackError */ -/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ -/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ - -const getCriticalDependencyWarning = memoize(() => - require("./CriticalDependencyWarning") -); - -/** @typedef {ContextOptions & { request: string }} ContextDependencyOptions */ - -/** - * @param {RegExp | null | undefined} r regexp - * @returns {string} stringified regexp - */ -const regExpToString = r => (r ? String(r) : ""); - -class ContextDependency extends Dependency { - /** - * @param {ContextDependencyOptions} options options for the context module - * @param {string=} context request context - */ - constructor(options, context) { - super(); - - this.options = options; - this.userRequest = this.options && this.options.request; - /** @type {false | undefined | string} */ - this.critical = false; - this.hadGlobalOrStickyRegExp = false; - - if ( - this.options && - (this.options.regExp.global || this.options.regExp.sticky) - ) { - this.options = { ...this.options, regExp: null }; - this.hadGlobalOrStickyRegExp = true; - } - - this.request = undefined; - this.range = undefined; - this.valueRange = undefined; - /** @type {boolean | string | undefined} */ - this.inShorthand = undefined; - // TODO refactor this - this.replaces = undefined; - this._requestContext = context; - } - - /** - * @returns {string | undefined} a request context - */ - getContext() { - return this._requestContext; - } - - get category() { - return "commonjs"; - } - - /** - * @returns {boolean | TRANSITIVE} true, when changes to the referenced module could affect the referencing module; TRANSITIVE, when changes to the referenced module could affect referencing modules of the referencing module - */ - couldAffectReferencingModule() { - return true; - } - - /** - * @returns {string | null} an identifier to merge equal requests - */ - getResourceIdentifier() { - return ( - `context${this._requestContext || ""}|ctx request${ - this.options.request - } ${this.options.recursive} ` + - `${regExpToString(this.options.regExp)} ${regExpToString( - this.options.include - )} ${regExpToString(this.options.exclude)} ` + - `${this.options.mode} ${this.options.chunkName} ` + - `${JSON.stringify(this.options.groupOptions)}` - ); - } - - /** - * Returns warnings - * @param {ModuleGraph} moduleGraph module graph - * @returns {WebpackError[] | null | undefined} warnings - */ - getWarnings(moduleGraph) { - let warnings = super.getWarnings(moduleGraph); - - if (this.critical) { - if (!warnings) warnings = []; - const CriticalDependencyWarning = getCriticalDependencyWarning(); - warnings.push(new CriticalDependencyWarning(this.critical)); - } - - if (this.hadGlobalOrStickyRegExp) { - if (!warnings) warnings = []; - const CriticalDependencyWarning = getCriticalDependencyWarning(); - warnings.push( - new CriticalDependencyWarning( - "Contexts can't use RegExps with the 'g' or 'y' flags." - ) - ); - } - - return warnings; - } - - /** - * @param {ObjectSerializerContext} context context - */ - serialize(context) { - const { write } = context; - - write(this.options); - write(this.userRequest); - write(this.critical); - write(this.hadGlobalOrStickyRegExp); - write(this.request); - write(this._requestContext); - write(this.range); - write(this.valueRange); - write(this.prepend); - write(this.replaces); - - super.serialize(context); - } - - /** - * @param {ObjectDeserializerContext} context context - */ - deserialize(context) { - const { read } = context; - - this.options = read(); - this.userRequest = read(); - this.critical = read(); - this.hadGlobalOrStickyRegExp = read(); - this.request = read(); - this._requestContext = read(); - this.range = read(); - this.valueRange = read(); - this.prepend = read(); - this.replaces = read(); - - super.deserialize(context); - } -} - -makeSerializable( - ContextDependency, - "webpack/lib/dependencies/ContextDependency" -); - -ContextDependency.Template = DependencyTemplate; - -module.exports = ContextDependency; |
