Add JS-CATCH-FALLBACK-01 rule and update npm packages
Add PHP-ALIAS-01 rule: prohibit field aliasing in serialization 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
0
node_modules/webpack/lib/dependencies/AMDDefineDependency.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/AMDDefineDependency.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/AMDDefineDependencyParserPlugin.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/AMDDefineDependencyParserPlugin.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/AMDPlugin.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/AMDPlugin.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/AMDRequireArrayDependency.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/AMDRequireArrayDependency.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/AMDRequireContextDependency.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/AMDRequireContextDependency.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/AMDRequireDependenciesBlock.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/AMDRequireDependenciesBlock.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/AMDRequireDependency.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/AMDRequireDependency.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/AMDRequireItemDependency.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/AMDRequireItemDependency.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/AMDRuntimeModules.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/AMDRuntimeModules.js
generated
vendored
Executable file → Normal file
34
node_modules/webpack/lib/dependencies/CachedConstDependency.js
generated
vendored
Executable file → Normal file
34
node_modules/webpack/lib/dependencies/CachedConstDependency.js
generated
vendored
Executable file → Normal file
@@ -22,15 +22,22 @@ const NullDependency = require("./NullDependency");
|
||||
class CachedConstDependency extends NullDependency {
|
||||
/**
|
||||
* @param {string} expression expression
|
||||
* @param {Range} range range
|
||||
* @param {Range | null} range range
|
||||
* @param {string} identifier identifier
|
||||
* @param {number=} place place where we inject the expression
|
||||
*/
|
||||
constructor(expression, range, identifier) {
|
||||
constructor(
|
||||
expression,
|
||||
range,
|
||||
identifier,
|
||||
place = CachedConstDependency.PLACE_MODULE
|
||||
) {
|
||||
super();
|
||||
|
||||
this.expression = expression;
|
||||
this.range = range;
|
||||
this.identifier = identifier;
|
||||
this.place = place;
|
||||
this._hashUpdate = undefined;
|
||||
}
|
||||
|
||||
@@ -38,7 +45,7 @@ class CachedConstDependency extends NullDependency {
|
||||
* @returns {string} hash update
|
||||
*/
|
||||
_createHashUpdate() {
|
||||
return `${this.identifier}${this.range}${this.expression}`;
|
||||
return `${this.place}${this.identifier}${this.range}${this.expression}`;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,6 +70,7 @@ class CachedConstDependency extends NullDependency {
|
||||
write(this.expression);
|
||||
write(this.range);
|
||||
write(this.identifier);
|
||||
write(this.place);
|
||||
|
||||
super.serialize(context);
|
||||
}
|
||||
@@ -76,11 +84,15 @@ class CachedConstDependency extends NullDependency {
|
||||
this.expression = read();
|
||||
this.range = read();
|
||||
this.identifier = read();
|
||||
this.place = read();
|
||||
|
||||
super.deserialize(context);
|
||||
}
|
||||
}
|
||||
|
||||
CachedConstDependency.PLACE_MODULE = 10;
|
||||
CachedConstDependency.PLACE_CHUNK = 20;
|
||||
|
||||
makeSerializable(
|
||||
CachedConstDependency,
|
||||
"webpack/lib/dependencies/CachedConstDependency"
|
||||
@@ -95,25 +107,27 @@ CachedConstDependency.Template = class CachedConstDependencyTemplate extends (
|
||||
* @param {DependencyTemplateContext} templateContext the context object
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(dependency, source, { initFragments }) {
|
||||
apply(dependency, source, { initFragments, chunkInitFragments }) {
|
||||
const dep = /** @type {CachedConstDependency} */ (dependency);
|
||||
|
||||
initFragments.push(
|
||||
(dep.place === CachedConstDependency.PLACE_MODULE
|
||||
? initFragments
|
||||
: chunkInitFragments
|
||||
).push(
|
||||
new InitFragment(
|
||||
`var ${dep.identifier} = ${dep.expression};\n`,
|
||||
InitFragment.STAGE_CONSTANTS,
|
||||
0,
|
||||
// For a chunk we inject expression after imports
|
||||
dep.place === CachedConstDependency.PLACE_MODULE ? 0 : 10,
|
||||
`const ${dep.identifier}`
|
||||
)
|
||||
);
|
||||
|
||||
if (typeof dep.range === "number") {
|
||||
source.insert(dep.range, dep.identifier);
|
||||
|
||||
return;
|
||||
} else if (dep.range !== null) {
|
||||
source.replace(dep.range[0], dep.range[1] - 1, dep.identifier);
|
||||
}
|
||||
|
||||
source.replace(dep.range[0], dep.range[1] - 1, dep.identifier);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
0
node_modules/webpack/lib/dependencies/CommonJsDependencyHelpers.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/CommonJsDependencyHelpers.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/CommonJsExportRequireDependency.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/CommonJsExportRequireDependency.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/CommonJsExportsDependency.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/CommonJsExportsDependency.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/CommonJsExportsParserPlugin.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/CommonJsExportsParserPlugin.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/CommonJsFullRequireDependency.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/CommonJsFullRequireDependency.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/CommonJsImportsParserPlugin.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/CommonJsImportsParserPlugin.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/CommonJsPlugin.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/CommonJsPlugin.js
generated
vendored
Executable file → Normal file
2
node_modules/webpack/lib/dependencies/CommonJsRequireContextDependency.js
generated
vendored
Executable file → Normal file
2
node_modules/webpack/lib/dependencies/CommonJsRequireContextDependency.js
generated
vendored
Executable file → Normal file
@@ -19,7 +19,7 @@ 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 {boolean | string} inShorthand true or name
|
||||
* @param {string=} context context
|
||||
*/
|
||||
constructor(options, range, valueRange, inShorthand, context) {
|
||||
|
||||
0
node_modules/webpack/lib/dependencies/CommonJsRequireDependency.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/CommonJsRequireDependency.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/CommonJsSelfReferenceDependency.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/CommonJsSelfReferenceDependency.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/ConstDependency.js
generated
vendored
Executable file → Normal file
0
node_modules/webpack/lib/dependencies/ConstDependency.js
generated
vendored
Executable file → Normal file
4
node_modules/webpack/lib/dependencies/ContextDependencyHelpers.js
generated
vendored
4
node_modules/webpack/lib/dependencies/ContextDependencyHelpers.js
generated
vendored
@@ -42,14 +42,14 @@ const splitContextFromPrefix = (prefix) => {
|
||||
};
|
||||
|
||||
/** @typedef {Partial<Omit<ContextDependencyOptions, "resource">>} PartialContextDependencyOptions */
|
||||
/** @typedef {{ new(options: ContextDependencyOptions, range: Range, valueRange: Range, ...args: any[]): ContextDependency }} ContextDependencyConstructor */
|
||||
/** @typedef {{ new(options: ContextDependencyOptions, range: Range, valueRange: Range, ...args: EXPECTED_ANY[]): ContextDependency }} ContextDependencyConstructor */
|
||||
|
||||
/**
|
||||
* @param {ContextDependencyConstructor} 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 {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
|
||||
|
||||
4
node_modules/webpack/lib/dependencies/ContextDependencyTemplateAsRequireCall.js
generated
vendored
4
node_modules/webpack/lib/dependencies/ContextDependencyTemplateAsRequireCall.js
generated
vendored
@@ -12,7 +12,9 @@ const ContextDependency = require("./ContextDependency");
|
||||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||
|
||||
class ContextDependencyTemplateAsRequireCall extends ContextDependency.Template {
|
||||
class ContextDependencyTemplateAsRequireCall
|
||||
extends ContextDependency.Template
|
||||
{
|
||||
/**
|
||||
* @param {Dependency} dependency the dependency for which the template should be applied
|
||||
* @param {ReplaceSource} source the current replace source which can be modified
|
||||
|
||||
344
node_modules/webpack/lib/dependencies/CssIcssExportDependency.js
generated
vendored
344
node_modules/webpack/lib/dependencies/CssIcssExportDependency.js
generated
vendored
@@ -5,11 +5,14 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const { CSS_TYPE, JAVASCRIPT_TYPE } = require("../ModuleSourceTypeConstants");
|
||||
const WebpackError = require("../WebpackError");
|
||||
const { cssExportConvention } = require("../util/conventions");
|
||||
const createHash = require("../util/createHash");
|
||||
const { makePathsRelative } = require("../util/identifier");
|
||||
const makeSerializable = require("../util/makeSerializable");
|
||||
const memoize = require("../util/memoize");
|
||||
const nonNumericOnlyHash = require("../util/nonNumericOnlyHash");
|
||||
const CssIcssImportDependency = require("./CssIcssImportDependency");
|
||||
const NullDependency = require("./NullDependency");
|
||||
|
||||
@@ -20,6 +23,7 @@ const getCssParser = memoize(() => require("../css/CssParser"));
|
||||
/** @typedef {import("../../declarations/WebpackOptions").CssGeneratorLocalIdentName} CssGeneratorLocalIdentName */
|
||||
/** @typedef {import("../CssModule")} CssModule */
|
||||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
|
||||
/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
|
||||
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
||||
/** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
|
||||
@@ -28,6 +32,7 @@ const getCssParser = memoize(() => require("../css/CssParser"));
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
||||
/** @typedef {import("../util/Hash")} Hash */
|
||||
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
||||
/** @typedef {import("../css/CssParser").Range} Range */
|
||||
@@ -43,7 +48,7 @@ const getLocalIdent = (local, module, chunkGraph, runtimeTemplate) => {
|
||||
const generator = /** @type {CssGenerator} */ (module.generator);
|
||||
const localIdentName =
|
||||
/** @type {CssGeneratorLocalIdentName} */
|
||||
(generator.localIdentName);
|
||||
(generator.options.localIdentName);
|
||||
const relativeResourcePath = makePathsRelative(
|
||||
/** @type {string} */
|
||||
(module.context),
|
||||
@@ -51,38 +56,92 @@ const getLocalIdent = (local, module, chunkGraph, runtimeTemplate) => {
|
||||
(module.getResource()),
|
||||
runtimeTemplate.compilation.compiler.root
|
||||
);
|
||||
const { hashFunction, hashDigest, hashDigestLength, hashSalt, uniqueName } =
|
||||
runtimeTemplate.outputOptions;
|
||||
const hash = createHash(hashFunction);
|
||||
const { uniqueName } = runtimeTemplate.outputOptions;
|
||||
|
||||
if (hashSalt) {
|
||||
hash.update(hashSalt);
|
||||
}
|
||||
let localIdentHash = "";
|
||||
|
||||
hash.update(relativeResourcePath);
|
||||
if (/\[(fullhash|hash)\]/.test(localIdentName)) {
|
||||
const hashSalt = generator.options.localIdentHashSalt;
|
||||
const hashDigest =
|
||||
/** @type {string} */
|
||||
(generator.options.localIdentHashDigest);
|
||||
const hashDigestLength = generator.options.localIdentHashDigestLength;
|
||||
const { hashFunction } = runtimeTemplate.outputOptions;
|
||||
|
||||
if (!/\[local\]/.test(localIdentName)) {
|
||||
const hash = createHash(hashFunction);
|
||||
|
||||
if (hashSalt) {
|
||||
hash.update(hashSalt);
|
||||
}
|
||||
|
||||
if (uniqueName) {
|
||||
hash.update(uniqueName);
|
||||
}
|
||||
|
||||
hash.update(relativeResourcePath);
|
||||
hash.update(local);
|
||||
|
||||
localIdentHash = hash.digest(hashDigest).slice(0, hashDigestLength);
|
||||
}
|
||||
|
||||
const localIdentHash = hash.digest(hashDigest).slice(0, hashDigestLength);
|
||||
let contentHash = "";
|
||||
|
||||
return runtimeTemplate.compilation
|
||||
.getPath(localIdentName, {
|
||||
filename: relativeResourcePath,
|
||||
hash: localIdentHash,
|
||||
contentHash: localIdentHash,
|
||||
chunkGraph,
|
||||
module
|
||||
})
|
||||
.replace(/\[local\]/g, local)
|
||||
.replace(/\[uniqueName\]/g, /** @type {string} */ (uniqueName))
|
||||
.replace(/^((-?[0-9])|--)/, "_$1");
|
||||
if (/\[contenthash\]/.test(localIdentName)) {
|
||||
const hash = createHash(runtimeTemplate.outputOptions.hashFunction);
|
||||
const source = module.originalSource();
|
||||
|
||||
if (source) {
|
||||
hash.update(source.buffer());
|
||||
}
|
||||
|
||||
if (module.error) {
|
||||
hash.update(module.error.toString());
|
||||
}
|
||||
|
||||
const fullContentHash = hash.digest(
|
||||
runtimeTemplate.outputOptions.hashDigest
|
||||
);
|
||||
|
||||
contentHash = nonNumericOnlyHash(
|
||||
fullContentHash,
|
||||
runtimeTemplate.outputOptions.hashDigestLength
|
||||
);
|
||||
}
|
||||
|
||||
let localIdent = runtimeTemplate.compilation.getPath(localIdentName, {
|
||||
prepareId: (id) => {
|
||||
if (typeof id !== "string") return id;
|
||||
|
||||
return id
|
||||
.replace(/^([.-]|[^a-zA-Z0-9_-])+/, "")
|
||||
.replace(/[^a-zA-Z0-9_-]+/g, "_");
|
||||
},
|
||||
filename: relativeResourcePath,
|
||||
hash: localIdentHash,
|
||||
contentHash,
|
||||
chunkGraph,
|
||||
module
|
||||
});
|
||||
|
||||
if (/\[local\]/.test(localIdentName)) {
|
||||
localIdent = localIdent.replace(/\[local\]/g, local);
|
||||
}
|
||||
|
||||
if (/\[uniqueName\]/.test(localIdentName)) {
|
||||
localIdent = localIdent.replace(
|
||||
/\[uniqueName\]/g,
|
||||
/** @type {string} */ (uniqueName)
|
||||
);
|
||||
}
|
||||
|
||||
// Protect the first character from unsupported values
|
||||
return localIdent.replace(/^((-?[0-9])|--)/, "_$1");
|
||||
};
|
||||
// 0 - replace, 1 - append, 2 - once
|
||||
/** @typedef {0 | 1 | 2} ExportMode */
|
||||
// 0 - none, 1 - name, 1 - value
|
||||
/** @typedef {0 | 1 | 2} InterpolationMode */
|
||||
|
||||
// 0 - replace, 1 - replace, 2 - append, 2 - once
|
||||
/** @typedef {0 | 1 | 2 | 3 | 4} ExportMode */
|
||||
// 0 - normal, 1 - custom css variable, 2 - grid custom ident
|
||||
/** @typedef {0 | 1 | 2} ExportType */
|
||||
|
||||
class CssIcssExportDependency extends NullDependency {
|
||||
/**
|
||||
@@ -90,20 +149,27 @@ class CssIcssExportDependency extends NullDependency {
|
||||
*
|
||||
* :export { LOCAL_NAME: EXPORT_NAME }
|
||||
* @param {string} name export name
|
||||
* @param {string} value export value or true when we need interpolate name as a value
|
||||
* @param {string=} reexport reexport name
|
||||
* @param {string | [string, string, boolean]} value export value or true when we need interpolate name as a value
|
||||
* @param {Range=} range range
|
||||
* @param {boolean=} interpolate true when value need to be interpolated, otherwise false
|
||||
* @param {ExportMode=} exportMode export mode
|
||||
* @param {ExportType=} exportType export type
|
||||
*/
|
||||
constructor(name, value, reexport, range) {
|
||||
constructor(
|
||||
name,
|
||||
value,
|
||||
range,
|
||||
interpolate = false,
|
||||
exportMode = CssIcssExportDependency.EXPORT_MODE.REPLACE,
|
||||
exportType = CssIcssExportDependency.EXPORT_TYPE.NORMAL
|
||||
) {
|
||||
super();
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.reexport = reexport;
|
||||
this.range = range;
|
||||
/** @type {undefined | InterpolationMode} */
|
||||
this.interpolationMode = undefined;
|
||||
/** @type {ExportMode} */
|
||||
this.exportMode = CssIcssExportDependency.EXPORT_MODE.REPLACE;
|
||||
this.interpolate = interpolate;
|
||||
this.exportMode = exportMode;
|
||||
this.exportType = exportType;
|
||||
this._hashUpdate = undefined;
|
||||
}
|
||||
|
||||
@@ -124,21 +190,52 @@ class CssIcssExportDependency extends NullDependency {
|
||||
return this._conventionNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns list of exports referenced by this dependency
|
||||
* @param {ModuleGraph} moduleGraph module graph
|
||||
* @param {RuntimeSpec} runtime the runtime for which the module is analysed
|
||||
* @returns {ReferencedExports} referenced exports
|
||||
*/
|
||||
getReferencedExports(moduleGraph, runtime) {
|
||||
if (
|
||||
this.exportMode === CssIcssExportDependency.EXPORT_MODE.SELF_REFERENCE
|
||||
) {
|
||||
return [
|
||||
{
|
||||
name: [this.name],
|
||||
canMangle: true
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
return super.getReferencedExports(moduleGraph, runtime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the exported names
|
||||
* @param {ModuleGraph} moduleGraph module graph
|
||||
* @returns {ExportsSpec | undefined} export names
|
||||
*/
|
||||
getExports(moduleGraph) {
|
||||
if (
|
||||
this.exportMode === CssIcssExportDependency.EXPORT_MODE.NONE ||
|
||||
this.exportMode === CssIcssExportDependency.EXPORT_MODE.SELF_REFERENCE
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
const module = /** @type {CssModule} */ (moduleGraph.getParentModule(this));
|
||||
const generator = /** @type {CssGenerator} */ (module.generator);
|
||||
const names = this.getExportsConventionNames(
|
||||
this.name,
|
||||
/** @type {CssGeneratorExportsConvention} */
|
||||
(generator.convention)
|
||||
(generator.options.exportsConvention)
|
||||
);
|
||||
return {
|
||||
exports: names.map((name) => ({
|
||||
exports: [
|
||||
...names,
|
||||
...(Array.isArray(this.value) ? [this.value[1]] : [])
|
||||
].map((name) => ({
|
||||
name,
|
||||
canMangle: true
|
||||
})),
|
||||
@@ -146,6 +243,34 @@ class CssIcssExportDependency extends NullDependency {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns warnings
|
||||
* @param {ModuleGraph} moduleGraph module graph
|
||||
* @returns {WebpackError[] | null | undefined} warnings
|
||||
*/
|
||||
getWarnings(moduleGraph) {
|
||||
if (
|
||||
this.exportMode === CssIcssExportDependency.EXPORT_MODE.SELF_REFERENCE &&
|
||||
!Array.isArray(this.value)
|
||||
) {
|
||||
const module = moduleGraph.getParentModule(this);
|
||||
|
||||
if (
|
||||
module &&
|
||||
!moduleGraph.getExportsInfo(module).isExportProvided(this.value)
|
||||
) {
|
||||
const error = new WebpackError(
|
||||
`Self-referencing name "${this.value}" not found`
|
||||
);
|
||||
error.module = module;
|
||||
|
||||
return [error];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the hash
|
||||
* @param {Hash} hash hash to be updated
|
||||
@@ -161,9 +286,9 @@ class CssIcssExportDependency extends NullDependency {
|
||||
const names = this.getExportsConventionNames(
|
||||
this.name,
|
||||
/** @type {CssGeneratorExportsConvention} */
|
||||
(generator.convention)
|
||||
(generator.options.exportsConvention)
|
||||
);
|
||||
this._hashUpdate = `exportsConvention|${JSON.stringify(names)}|localIdentName|${JSON.stringify(generator.localIdentName)}`;
|
||||
this._hashUpdate = `exportsConvention|${JSON.stringify(names)}|localIdentName|${JSON.stringify(generator.options.localIdentName)}`;
|
||||
}
|
||||
hash.update(this._hashUpdate);
|
||||
}
|
||||
@@ -175,10 +300,10 @@ class CssIcssExportDependency extends NullDependency {
|
||||
const { write } = context;
|
||||
write(this.name);
|
||||
write(this.value);
|
||||
write(this.reexport);
|
||||
write(this.range);
|
||||
write(this.interpolationMode);
|
||||
write(this.interpolate);
|
||||
write(this.exportMode);
|
||||
write(this.exportType);
|
||||
super.serialize(context);
|
||||
}
|
||||
|
||||
@@ -189,10 +314,10 @@ class CssIcssExportDependency extends NullDependency {
|
||||
const { read } = context;
|
||||
this.name = read();
|
||||
this.value = read();
|
||||
this.reexport = read();
|
||||
this.range = read();
|
||||
this.interpolationMode = read();
|
||||
this.interpolate = read();
|
||||
this.exportMode = read();
|
||||
this.exportType = read();
|
||||
super.deserialize(context);
|
||||
}
|
||||
}
|
||||
@@ -222,17 +347,21 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
||||
nestedDep instanceof CssIcssExportDependency &&
|
||||
symbol === nestedDep.name
|
||||
) {
|
||||
if (nestedDep.reexport) {
|
||||
return this.findReference(nestedDep.reexport, {
|
||||
if (Array.isArray(nestedDep.value)) {
|
||||
return this.findReference(nestedDep.value[1], {
|
||||
...templateContext,
|
||||
module
|
||||
});
|
||||
}
|
||||
|
||||
return CssIcssExportDependency.Template.getIdentifier(nestedDep, {
|
||||
...templateContext,
|
||||
module
|
||||
});
|
||||
return CssIcssExportDependency.Template.getIdentifier(
|
||||
nestedDep.value,
|
||||
nestedDep,
|
||||
{
|
||||
...templateContext,
|
||||
module
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -240,45 +369,30 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} value value to identifier
|
||||
* @param {Dependency} dependency the dependency for which the template should be applied
|
||||
* @param {DependencyTemplateContext} templateContext the context object
|
||||
* @returns {string} identifier
|
||||
*/
|
||||
static getIdentifier(dependency, templateContext) {
|
||||
static getIdentifier(value, dependency, templateContext) {
|
||||
const dep = /** @type {CssIcssExportDependency} */ (dependency);
|
||||
|
||||
if (
|
||||
dep.interpolationMode ===
|
||||
CssIcssExportDependency.INTERPOLATION_MODE.NAME ||
|
||||
dep.interpolationMode === CssIcssExportDependency.INTERPOLATION_MODE.VALUE
|
||||
) {
|
||||
const { module: m, moduleGraph, runtime } = templateContext;
|
||||
if (dep.interpolate) {
|
||||
const { module: m } = templateContext;
|
||||
const module = /** @type {CssModule} */ (m);
|
||||
const generator = /** @type {CssGenerator} */ (module.generator);
|
||||
const names = dep.getExportsConventionNames(
|
||||
dep.interpolationMode ===
|
||||
CssIcssExportDependency.INTERPOLATION_MODE.NAME
|
||||
? dep.name
|
||||
: dep.value,
|
||||
const local = cssExportConvention(
|
||||
value,
|
||||
/** @type {CssGeneratorExportsConvention} */
|
||||
(generator.convention)
|
||||
);
|
||||
const usedNames =
|
||||
/** @type {string[]} */
|
||||
(
|
||||
names
|
||||
.map((name) =>
|
||||
moduleGraph.getExportInfo(module, name).getUsedName(name, runtime)
|
||||
)
|
||||
.filter(Boolean)
|
||||
);
|
||||
const local = usedNames.length === 0 ? names[0] : usedNames[0];
|
||||
(generator.options.exportsConvention)
|
||||
)[0];
|
||||
const prefix =
|
||||
/** @type {CssIcssExportDependency & { prefix: string }} */
|
||||
(dependency).prefix;
|
||||
dep.exportType === CssIcssExportDependency.EXPORT_TYPE.CUSTOM_VARIABLE
|
||||
? "--"
|
||||
: "";
|
||||
|
||||
return (
|
||||
(prefix || "") +
|
||||
prefix +
|
||||
getCssParser().escapeIdentifier(
|
||||
getLocalIdent(
|
||||
local,
|
||||
@@ -302,7 +416,7 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
||||
*/
|
||||
apply(dependency, source, templateContext) {
|
||||
const dep = /** @type {CssIcssExportDependency} */ (dependency);
|
||||
if (!dep.range && templateContext.type !== "javascript") return;
|
||||
if (!dep.range && templateContext.type !== JAVASCRIPT_TYPE) return;
|
||||
const { cssData } = templateContext;
|
||||
const { module: m, moduleGraph, runtime } = templateContext;
|
||||
const module = /** @type {CssModule} */ (m);
|
||||
@@ -310,7 +424,7 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
||||
const names = dep.getExportsConventionNames(
|
||||
dep.name,
|
||||
/** @type {CssGeneratorExportsConvention} */
|
||||
(generator.convention)
|
||||
(generator.options.exportsConvention)
|
||||
);
|
||||
const usedNames =
|
||||
/** @type {string[]} */
|
||||
@@ -323,42 +437,63 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
||||
);
|
||||
|
||||
const allNames = new Set([...usedNames, ...names]);
|
||||
const isReference = Array.isArray(dep.value);
|
||||
|
||||
/** @type {string} */
|
||||
let value;
|
||||
|
||||
if (dep.reexport) {
|
||||
if (isReference && dep.value[2] === true) {
|
||||
const resolved = CssIcssExportDependencyTemplate.findReference(
|
||||
dep.reexport,
|
||||
dep.value[1],
|
||||
templateContext
|
||||
);
|
||||
|
||||
if (resolved) {
|
||||
dep.value = resolved;
|
||||
}
|
||||
// Fallback to the original name if not found
|
||||
value = resolved || dep.value[0];
|
||||
} else {
|
||||
value = isReference ? dep.value[1] : /** @type {string} */ (dep.value);
|
||||
}
|
||||
|
||||
if (typeof dep.interpolationMode !== "undefined") {
|
||||
if (dep.interpolate) {
|
||||
value = CssIcssExportDependencyTemplate.getIdentifier(
|
||||
value,
|
||||
dep,
|
||||
templateContext
|
||||
);
|
||||
} else {
|
||||
value = dep.value;
|
||||
}
|
||||
|
||||
if (templateContext.type === "javascript") {
|
||||
if (
|
||||
dep.exportType ===
|
||||
CssIcssExportDependency.EXPORT_TYPE.GRID_CUSTOM_IDENTIFIER
|
||||
) {
|
||||
value += `-${dep.name}`;
|
||||
}
|
||||
|
||||
if (
|
||||
templateContext.type === JAVASCRIPT_TYPE &&
|
||||
dep.exportMode !== CssIcssExportDependency.EXPORT_MODE.NONE
|
||||
) {
|
||||
for (const used of allNames) {
|
||||
if (dep.exportMode === 2) {
|
||||
if (dep.exportMode === CssIcssExportDependency.EXPORT_MODE.ONCE) {
|
||||
const newValue = getCssParser().unescapeIdentifier(value);
|
||||
if (isReference) {
|
||||
cssData.exports.set(dep.value[1], newValue);
|
||||
}
|
||||
if (cssData.exports.has(used)) return;
|
||||
cssData.exports.set(
|
||||
used,
|
||||
`${getCssParser().unescapeIdentifier(value)}`
|
||||
);
|
||||
cssData.exports.set(used, newValue);
|
||||
} else {
|
||||
const originalValue =
|
||||
dep.exportMode === 0 ? undefined : cssData.exports.get(used);
|
||||
const newValue = getCssParser().unescapeIdentifier(value);
|
||||
dep.exportMode === CssIcssExportDependency.EXPORT_MODE.REPLACE
|
||||
? undefined
|
||||
: cssData.exports.get(used);
|
||||
|
||||
const newValue =
|
||||
dep.exportMode ===
|
||||
CssIcssExportDependency.EXPORT_MODE.SELF_REFERENCE
|
||||
? cssData.exports.get(
|
||||
isReference ? dep.value[0] : /** @type {string} */ (dep.value)
|
||||
) || value
|
||||
: getCssParser().unescapeIdentifier(value);
|
||||
|
||||
cssData.exports.set(
|
||||
used,
|
||||
@@ -368,26 +503,29 @@ CssIcssExportDependency.Template = class CssIcssExportDependencyTemplate extends
|
||||
}
|
||||
} else if (
|
||||
dep.range &&
|
||||
templateContext.type === "css" &&
|
||||
dep.exportMode !== 1
|
||||
templateContext.type === CSS_TYPE &&
|
||||
dep.exportMode !== CssIcssExportDependency.EXPORT_MODE.APPEND &&
|
||||
dep.exportMode !== CssIcssExportDependency.EXPORT_MODE.SELF_REFERENCE
|
||||
) {
|
||||
source.replace(dep.range[0], dep.range[1] - 1, value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/** @type {Record<"REPLACE" | "APPEND" | "ONCE", ExportMode>} */
|
||||
/** @type {Record<"NONE" | "REPLACE" | "APPEND" | "ONCE" | "SELF_REFERENCE", ExportMode>} */
|
||||
CssIcssExportDependency.EXPORT_MODE = {
|
||||
REPLACE: 0,
|
||||
APPEND: 1,
|
||||
ONCE: 2
|
||||
NONE: 0,
|
||||
REPLACE: 1,
|
||||
APPEND: 2,
|
||||
ONCE: 3,
|
||||
SELF_REFERENCE: 4
|
||||
};
|
||||
|
||||
/** @type {Record<"NONE" | "NAME" | "VALUE", InterpolationMode>} */
|
||||
CssIcssExportDependency.INTERPOLATION_MODE = {
|
||||
NONE: 0,
|
||||
NAME: 1,
|
||||
VALUE: 2
|
||||
/** @type {Record<"NORMAL" | "CUSTOM_VARIABLE" | "GRID_CUSTOM_IDENTIFIER", ExportType>} */
|
||||
CssIcssExportDependency.EXPORT_TYPE = {
|
||||
NORMAL: 0,
|
||||
CUSTOM_VARIABLE: 1,
|
||||
GRID_CUSTOM_IDENTIFIER: 2
|
||||
};
|
||||
|
||||
makeSerializable(
|
||||
|
||||
124
node_modules/webpack/lib/dependencies/CssIcssFromIdentifierDependency.js
generated
vendored
124
node_modules/webpack/lib/dependencies/CssIcssFromIdentifierDependency.js
generated
vendored
@@ -1,124 +0,0 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Alexander Akait @alexander-akait
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const { cssExportConvention } = require("../util/conventions");
|
||||
const makeSerializable = require("../util/makeSerializable");
|
||||
const CssIcssExportDependency = require("./CssIcssExportDependency");
|
||||
const CssIcssImportDependency = require("./CssIcssImportDependency");
|
||||
const ModuleDependency = require("./ModuleDependency");
|
||||
|
||||
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
||||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../Module")} Module */
|
||||
/** @typedef {import("../CssModule")} CssModule */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").CssGeneratorExportsConvention} CssGeneratorExportsConvention */
|
||||
/** @typedef {import("../css/CssGenerator")} CssGenerator */
|
||||
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
|
||||
class CssIcssFromIdentifierDependency extends CssIcssImportDependency {
|
||||
/**
|
||||
* @param {string} request request request path which needs resolving
|
||||
* @param {"local" | "global"} mode mode of the parsed CSS
|
||||
* @param {Range} range the range of dependency
|
||||
* @param {string} name import class name
|
||||
* @param {string} exportName export class name
|
||||
* @param {string=} prefix prefix
|
||||
*/
|
||||
constructor(request, mode, range, name, exportName, prefix) {
|
||||
super(request, range, mode, name);
|
||||
this.exportName = exportName;
|
||||
this.value = name;
|
||||
this.prefix = prefix;
|
||||
this.interpolationMode = CssIcssExportDependency.INTERPOLATION_MODE.VALUE;
|
||||
this.exportMode = CssIcssExportDependency.EXPORT_MODE.APPEND;
|
||||
}
|
||||
|
||||
get type() {
|
||||
return "css from identifier";
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string | null} an identifier to merge equal requests
|
||||
*/
|
||||
getResourceIdentifier() {
|
||||
return `${super.getResourceIdentifier()}|exportName${this.exportName}|prefix${this.prefix}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name export name
|
||||
* @param {CssGeneratorExportsConvention} convention convention of the export name
|
||||
* @returns {string[]} convention results
|
||||
*/
|
||||
getExportsConventionNames(name, convention) {
|
||||
return cssExportConvention(name, convention);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ObjectSerializerContext} context context
|
||||
*/
|
||||
serialize(context) {
|
||||
const { write } = context;
|
||||
write(this.exportName);
|
||||
write(this.prefix);
|
||||
write(this.interpolationMode);
|
||||
write(this.exportMode);
|
||||
super.serialize(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ObjectDeserializerContext} context context
|
||||
*/
|
||||
deserialize(context) {
|
||||
const { read } = context;
|
||||
this.exportName = read();
|
||||
this.prefix = read();
|
||||
this.interpolationMode = read();
|
||||
this.exportMode = read();
|
||||
super.deserialize(context);
|
||||
}
|
||||
}
|
||||
|
||||
CssIcssFromIdentifierDependency.Template = class CssIcssFromIdentifierDependencyTemplate extends (
|
||||
ModuleDependency.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, templateContext) {
|
||||
const { moduleGraph } = templateContext;
|
||||
const dep = /** @type {CssIcssFromIdentifierDependency} */ (dependency);
|
||||
const module =
|
||||
/** @type {CssModule} */
|
||||
(moduleGraph.getModule(dep));
|
||||
|
||||
if (!moduleGraph.getExportsInfo(module).isExportProvided(dep.name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const template = new CssIcssExportDependency.Template();
|
||||
const originalName = dep.name;
|
||||
dep.name = dep.exportName;
|
||||
template.apply(dep, source, { ...templateContext, module });
|
||||
dep.name = originalName;
|
||||
}
|
||||
};
|
||||
|
||||
makeSerializable(
|
||||
CssIcssFromIdentifierDependency,
|
||||
"webpack/lib/dependencies/CssIcssFromIdentifierDependency"
|
||||
);
|
||||
|
||||
module.exports = CssIcssFromIdentifierDependency;
|
||||
48
node_modules/webpack/lib/dependencies/CssIcssGlobalIdentifierDependency.js
generated
vendored
48
node_modules/webpack/lib/dependencies/CssIcssGlobalIdentifierDependency.js
generated
vendored
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Alexander Akait @alexander-akait
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const makeSerializable = require("../util/makeSerializable");
|
||||
const CssIcssExportDependency = require("./CssIcssExportDependency");
|
||||
|
||||
/** @typedef {import("../css/CssParser").Range} Range */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
|
||||
|
||||
class CssIcssGlobalIdentifierDependency extends CssIcssExportDependency {
|
||||
/**
|
||||
* @param {string} name export identifier name
|
||||
* @param {string} value identifier value
|
||||
* @param {string | undefined} reexport reexport name
|
||||
* @param {Range} range the range of dependency
|
||||
*/
|
||||
constructor(name, value, reexport, range) {
|
||||
super(name, value, reexport, range);
|
||||
this.exportMode = CssIcssExportDependency.EXPORT_MODE.APPEND;
|
||||
}
|
||||
|
||||
get type() {
|
||||
return "css global identifier";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the exported names
|
||||
* @param {ModuleGraph} moduleGraph module graph
|
||||
* @returns {ExportsSpec | undefined} export names
|
||||
*/
|
||||
getExports(moduleGraph) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
CssIcssGlobalIdentifierDependency.Template = CssIcssExportDependency.Template;
|
||||
|
||||
makeSerializable(
|
||||
CssIcssGlobalIdentifierDependency,
|
||||
"webpack/lib/dependencies/CssIcssGlobalDependency"
|
||||
);
|
||||
|
||||
module.exports = CssIcssGlobalIdentifierDependency;
|
||||
65
node_modules/webpack/lib/dependencies/CssIcssImportDependency.js
generated
vendored
65
node_modules/webpack/lib/dependencies/CssIcssImportDependency.js
generated
vendored
@@ -6,13 +6,16 @@
|
||||
"use strict";
|
||||
|
||||
const WebpackError = require("../WebpackError");
|
||||
const { cssExportConvention } = require("../util/conventions");
|
||||
const makeSerializable = require("../util/makeSerializable");
|
||||
const memoize = require("../util/memoize");
|
||||
const CssImportDependency = require("./CssImportDependency");
|
||||
|
||||
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
||||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../Module")} Module */
|
||||
/** @typedef {import("../CssModule")} CssModule */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
@@ -20,20 +23,41 @@ const CssImportDependency = require("./CssImportDependency");
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
||||
/** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").CssGeneratorExportsConvention} CssGeneratorExportsConvention */
|
||||
/** @typedef {import("./CssIcssExportDependency").ExportMode} ExportMode */
|
||||
/** @typedef {import("./CssIcssExportDependency").ExportType} ExportType */
|
||||
|
||||
const getCssIcssExportDependency = memoize(() =>
|
||||
require("./CssIcssExportDependency")
|
||||
);
|
||||
|
||||
class CssIcssImportDependency extends CssImportDependency {
|
||||
/**
|
||||
* Example of dependency:
|
||||
*
|
||||
* :import('./style.css') { IMPORTED_NAME: v-primary }
|
||||
* :import('./style.css') { value: name }
|
||||
* @param {string} request request request path which needs resolving
|
||||
* @param {Range} range the range of dependency
|
||||
* @param {"local" | "global"} mode mode of the parsed CSS
|
||||
* @param {string} name importName name
|
||||
* @param {string} name name
|
||||
* @param {string=} exportName export value
|
||||
* @param {ExportMode=} exportMode export mode
|
||||
* @param {ExportType=} exportType export type
|
||||
*/
|
||||
constructor(request, range, mode, name) {
|
||||
constructor(
|
||||
request,
|
||||
range,
|
||||
mode,
|
||||
name,
|
||||
exportName = undefined,
|
||||
exportMode = getCssIcssExportDependency().EXPORT_MODE.NONE,
|
||||
exportType = getCssIcssExportDependency().EXPORT_TYPE.NORMAL
|
||||
) {
|
||||
super(request, range, mode);
|
||||
this.name = name;
|
||||
this.value = exportName;
|
||||
this.interpolate = true;
|
||||
this.exportMode = exportMode;
|
||||
this.exportType = exportType;
|
||||
}
|
||||
|
||||
get type() {
|
||||
@@ -47,6 +71,15 @@ class CssIcssImportDependency extends CssImportDependency {
|
||||
return `${super.getResourceIdentifier()}|mode${this.mode}|name${this.name}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name export name
|
||||
* @param {CssGeneratorExportsConvention} convention convention of the export name
|
||||
* @returns {string[]} convention results
|
||||
*/
|
||||
getExportsConventionNames(name, convention) {
|
||||
return cssExportConvention(name, convention);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns list of exports referenced by this dependency
|
||||
* @param {ModuleGraph} moduleGraph module graph
|
||||
@@ -91,6 +124,10 @@ class CssIcssImportDependency extends CssImportDependency {
|
||||
serialize(context) {
|
||||
const { write } = context;
|
||||
write(this.name);
|
||||
write(this.value);
|
||||
write(this.interpolate);
|
||||
write(this.exportMode);
|
||||
write(this.exportType);
|
||||
super.serialize(context);
|
||||
}
|
||||
|
||||
@@ -100,6 +137,10 @@ class CssIcssImportDependency extends CssImportDependency {
|
||||
deserialize(context) {
|
||||
const { read } = context;
|
||||
this.name = read();
|
||||
this.value = read();
|
||||
this.interpolate = read();
|
||||
this.exportMode = read();
|
||||
this.exportType = read();
|
||||
super.deserialize(context);
|
||||
}
|
||||
}
|
||||
@@ -114,7 +155,23 @@ CssIcssImportDependency.Template = class CssIcssImportDependencyTemplate extends
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(dependency, source, templateContext) {
|
||||
// We remove everything in CSS parser
|
||||
const dep = /** @type {CssIcssImportDependency} */ (dependency);
|
||||
|
||||
if (dep.value) {
|
||||
const { moduleGraph } = templateContext;
|
||||
const module =
|
||||
/** @type {CssModule} */
|
||||
(moduleGraph.getModule(dep));
|
||||
const CssIcssExportDependency = getCssIcssExportDependency();
|
||||
const template = new CssIcssExportDependency.Template();
|
||||
const originalName = dep.name;
|
||||
const originalExportName = dep.value;
|
||||
dep.value = originalName;
|
||||
dep.name = originalExportName;
|
||||
template.apply(dep, source, { ...templateContext, module });
|
||||
dep.name = originalName;
|
||||
dep.value = originalExportName;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
61
node_modules/webpack/lib/dependencies/CssIcssLocalIdentifierDependency.js
generated
vendored
61
node_modules/webpack/lib/dependencies/CssIcssLocalIdentifierDependency.js
generated
vendored
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Ivan Kopeykin @vankop
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const makeSerializable = require("../util/makeSerializable");
|
||||
const CssIcssExportDependency = require("./CssIcssExportDependency");
|
||||
|
||||
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
||||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../css/CssParser").Range} Range */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
||||
|
||||
class CssIcssLocalIdentifierDependency extends CssIcssExportDependency {
|
||||
/**
|
||||
* @param {string} name name
|
||||
* @param {Range} range range
|
||||
* @param {string=} prefix prefix
|
||||
*/
|
||||
constructor(name, range, prefix = "") {
|
||||
super(name, name, undefined, range);
|
||||
this.prefix = prefix;
|
||||
this.interpolationMode = CssIcssExportDependency.INTERPOLATION_MODE.VALUE;
|
||||
this.exportMode = CssIcssExportDependency.EXPORT_MODE.ONCE;
|
||||
}
|
||||
|
||||
get type() {
|
||||
return "css local identifier";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ObjectSerializerContext} context context
|
||||
*/
|
||||
serialize(context) {
|
||||
const { write } = context;
|
||||
write(this.prefix);
|
||||
super.serialize(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ObjectDeserializerContext} context context
|
||||
*/
|
||||
deserialize(context) {
|
||||
const { read } = context;
|
||||
this.prefix = read();
|
||||
super.deserialize(context);
|
||||
}
|
||||
}
|
||||
|
||||
CssIcssLocalIdentifierDependency.Template = CssIcssExportDependency.Template;
|
||||
|
||||
makeSerializable(
|
||||
CssIcssLocalIdentifierDependency,
|
||||
"webpack/lib/dependencies/CssLocalIdentifierDependency"
|
||||
);
|
||||
|
||||
module.exports = CssIcssLocalIdentifierDependency;
|
||||
190
node_modules/webpack/lib/dependencies/CssIcssSelfLocalIdentifierDependency.js
generated
vendored
190
node_modules/webpack/lib/dependencies/CssIcssSelfLocalIdentifierDependency.js
generated
vendored
@@ -1,190 +0,0 @@
|
||||
/*
|
||||
MIT License http://www.opensource.org/licenses/mit-license.php
|
||||
Author Ivan Kopeykin @vankop
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const Dependency = require("../Dependency");
|
||||
const WebpackError = require("../WebpackError");
|
||||
const makeSerializable = require("../util/makeSerializable");
|
||||
const CssIcssExportDependency = require("./CssIcssExportDependency");
|
||||
const CssLocalIdentifierDependency = require("./CssIcssLocalIdentifierDependency");
|
||||
|
||||
/** @typedef {import("../../declarations/WebpackOptions").CssGeneratorExportsConvention} CssGeneratorExportsConvention */
|
||||
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
||||
/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
|
||||
/** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
|
||||
/** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../css/CssParser").Range} Range */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
||||
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
/** @typedef {import("../CssModule")} CssModule */
|
||||
/** @typedef {import("../css/CssGenerator")} CssGenerator */
|
||||
|
||||
class CssIcssSelfLocalIdentifierDependency extends CssLocalIdentifierDependency {
|
||||
/**
|
||||
* @param {string} name name
|
||||
* @param {string | undefined} referencedExport referenced export name
|
||||
* @param {Range} range range
|
||||
* @param {string=} prefix prefix
|
||||
* @param {Set<string>=} declaredSet set of declared names (will only be active when in declared set)
|
||||
* @param {string=} reexport reexport name
|
||||
*/
|
||||
constructor(
|
||||
name,
|
||||
referencedExport,
|
||||
range,
|
||||
prefix = "",
|
||||
declaredSet = undefined,
|
||||
reexport = undefined
|
||||
) {
|
||||
super(name, range, prefix);
|
||||
this.declaredSet = declaredSet;
|
||||
this.referencedExport = referencedExport;
|
||||
this.reexport = reexport;
|
||||
this.interpolationMode = referencedExport
|
||||
? CssIcssExportDependency.INTERPOLATION_MODE.NONE
|
||||
: CssIcssExportDependency.INTERPOLATION_MODE.VALUE;
|
||||
this.exportMode = referencedExport
|
||||
? CssIcssExportDependency.EXPORT_MODE.APPEND
|
||||
: CssIcssExportDependency.EXPORT_MODE.ONCE;
|
||||
}
|
||||
|
||||
get type() {
|
||||
return "css self local identifier";
|
||||
}
|
||||
|
||||
get category() {
|
||||
return "self";
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string | null} an identifier to merge equal requests
|
||||
*/
|
||||
getResourceIdentifier() {
|
||||
return "self";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the exported names
|
||||
* @param {ModuleGraph} moduleGraph module graph
|
||||
* @returns {ExportsSpec | undefined} export names
|
||||
*/
|
||||
getExports(moduleGraph) {
|
||||
if (
|
||||
(this.declaredSet && !this.declaredSet.has(this.name)) ||
|
||||
this.referencedExport
|
||||
) {
|
||||
return;
|
||||
}
|
||||
return super.getExports(moduleGraph);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns list of exports referenced by this dependency
|
||||
* @param {ModuleGraph} moduleGraph module graph
|
||||
* @param {RuntimeSpec} runtime the runtime for which the module is analysed
|
||||
* @returns {ReferencedExports} referenced exports
|
||||
*/
|
||||
getReferencedExports(moduleGraph, runtime) {
|
||||
if (this.declaredSet && !this.declaredSet.has(this.name)) {
|
||||
return Dependency.NO_EXPORTS_REFERENCED;
|
||||
}
|
||||
return [
|
||||
{
|
||||
name: [this.referencedExport || this.name],
|
||||
canMangle: true
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns warnings
|
||||
* @param {ModuleGraph} moduleGraph module graph
|
||||
* @returns {WebpackError[] | null | undefined} warnings
|
||||
*/
|
||||
getWarnings(moduleGraph) {
|
||||
if (this.referencedExport && !this.reexport) {
|
||||
const module = moduleGraph.getModule(this);
|
||||
|
||||
if (
|
||||
module &&
|
||||
!moduleGraph
|
||||
.getExportsInfo(module)
|
||||
.isExportProvided(this.referencedExport)
|
||||
) {
|
||||
const error = new WebpackError(
|
||||
`Self-referencing name "${this.referencedExport}" not found`
|
||||
);
|
||||
error.module = module;
|
||||
|
||||
return [error];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ObjectSerializerContext} context context
|
||||
*/
|
||||
serialize(context) {
|
||||
const { write } = context;
|
||||
write(this.declaredSet);
|
||||
write(this.referencedExport);
|
||||
super.serialize(context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ObjectDeserializerContext} context context
|
||||
*/
|
||||
deserialize(context) {
|
||||
const { read } = context;
|
||||
this.declaredSet = read();
|
||||
this.referencedExport = read();
|
||||
super.deserialize(context);
|
||||
}
|
||||
}
|
||||
|
||||
CssIcssSelfLocalIdentifierDependency.Template = class CssSelfLocalIdentifierDependencyTemplate extends (
|
||||
CssLocalIdentifierDependency.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, templateContext) {
|
||||
const dep =
|
||||
/** @type {CssIcssSelfLocalIdentifierDependency} */
|
||||
(dependency);
|
||||
if (dep.declaredSet && !dep.declaredSet.has(dep.name)) return;
|
||||
if (dep.referencedExport) {
|
||||
const { module: m, moduleGraph, cssData } = templateContext;
|
||||
const module = /** @type {CssModule} */ (m);
|
||||
|
||||
if (
|
||||
!dep.reexport &&
|
||||
!moduleGraph
|
||||
.getExportsInfo(module)
|
||||
.isExportProvided(dep.referencedExport)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
dep.value = cssData.exports.get(dep.referencedExport) || "";
|
||||
}
|
||||
super.apply(dependency, source, templateContext);
|
||||
}
|
||||
};
|
||||
|
||||
makeSerializable(
|
||||
CssIcssSelfLocalIdentifierDependency,
|
||||
"webpack/lib/dependencies/CssIcssSelfLocalIdentifierDependency"
|
||||
);
|
||||
|
||||
module.exports = CssIcssSelfLocalIdentifierDependency;
|
||||
8
node_modules/webpack/lib/dependencies/CssIcssSymbolDependency.js
generated
vendored
8
node_modules/webpack/lib/dependencies/CssIcssSymbolDependency.js
generated
vendored
@@ -5,6 +5,7 @@
|
||||
|
||||
"use strict";
|
||||
|
||||
const { CSS_TYPE } = require("../ModuleSourceTypeConstants");
|
||||
const makeSerializable = require("../util/makeSerializable");
|
||||
const CssIcssExportDependency = require("./CssIcssExportDependency");
|
||||
const NullDependency = require("./NullDependency");
|
||||
@@ -42,10 +43,6 @@ class CssIcssSymbolDependency extends NullDependency {
|
||||
return "css symbol identifier";
|
||||
}
|
||||
|
||||
get category() {
|
||||
return "self";
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the hash
|
||||
* @param {Hash} hash hash to be updated
|
||||
@@ -106,7 +103,7 @@ CssIcssSymbolDependency.Template = class CssIcssSymbolDependencyTemplate extends
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(dependency, source, templateContext) {
|
||||
if (templateContext.type === "css") {
|
||||
if (templateContext.type === CSS_TYPE) {
|
||||
const dep = /** @type {CssIcssSymbolDependency} */ (dependency);
|
||||
/** @type {string | undefined} */
|
||||
const value = dep.isReference
|
||||
@@ -117,7 +114,6 @@ CssIcssSymbolDependency.Template = class CssIcssSymbolDependencyTemplate extends
|
||||
: dep.symbol;
|
||||
|
||||
if (!value) {
|
||||
// TODO generate warning
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
3
node_modules/webpack/lib/dependencies/CssImportDependency.js
generated
vendored
3
node_modules/webpack/lib/dependencies/CssImportDependency.js
generated
vendored
@@ -10,7 +10,7 @@ const ModuleDependency = require("./ModuleDependency");
|
||||
|
||||
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
||||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../css/CssParser").Range} Range */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
||||
@@ -105,6 +105,7 @@ CssImportDependency.Template = class CssImportDependencyTemplate extends (
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(dependency, source, templateContext) {
|
||||
if (templateContext.type === "javascript") return;
|
||||
const dep = /** @type {CssImportDependency} */ (dependency);
|
||||
|
||||
source.replace(dep.range[0], dep.range[1] - 1, "");
|
||||
|
||||
5
node_modules/webpack/lib/dependencies/CssUrlDependency.js
generated
vendored
5
node_modules/webpack/lib/dependencies/CssUrlDependency.js
generated
vendored
@@ -13,7 +13,7 @@ const ModuleDependency = require("./ModuleDependency");
|
||||
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
||||
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
||||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../Module")} Module */
|
||||
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
@@ -118,8 +118,9 @@ CssUrlDependency.Template = class CssUrlDependencyTemplate extends (
|
||||
apply(
|
||||
dependency,
|
||||
source,
|
||||
{ moduleGraph, runtimeTemplate, codeGenerationResults }
|
||||
{ type, moduleGraph, runtimeTemplate, codeGenerationResults }
|
||||
) {
|
||||
if (type === "javascript") return;
|
||||
const dep = /** @type {CssUrlDependency} */ (dependency);
|
||||
const module = /** @type {Module} */ (moduleGraph.getModule(dep));
|
||||
|
||||
|
||||
14
node_modules/webpack/lib/dependencies/DynamicExports.js
generated
vendored
14
node_modules/webpack/lib/dependencies/DynamicExports.js
generated
vendored
@@ -6,13 +6,13 @@
|
||||
"use strict";
|
||||
|
||||
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
||||
/** @typedef {import("../Parser").ParserState} ParserState */
|
||||
/** @typedef {import("../javascript/JavascriptParser").JavascriptParserState} JavascriptParserState */
|
||||
|
||||
/** @type {WeakMap<ParserState, boolean>} */
|
||||
/** @type {WeakMap<JavascriptParserState, boolean>} */
|
||||
const parserStateExportsState = new WeakMap();
|
||||
|
||||
/**
|
||||
* @param {ParserState} parserState parser state
|
||||
* @param {JavascriptParserState} parserState parser state
|
||||
* @returns {void}
|
||||
*/
|
||||
module.exports.bailout = (parserState) => {
|
||||
@@ -26,7 +26,7 @@ module.exports.bailout = (parserState) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {ParserState} parserState parser state
|
||||
* @param {JavascriptParserState} parserState parser state
|
||||
* @returns {void}
|
||||
*/
|
||||
module.exports.enable = (parserState) => {
|
||||
@@ -41,7 +41,7 @@ module.exports.enable = (parserState) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {ParserState} parserState parser state
|
||||
* @param {JavascriptParserState} parserState parser state
|
||||
* @returns {boolean} true, when enabled
|
||||
*/
|
||||
module.exports.isEnabled = (parserState) => {
|
||||
@@ -50,7 +50,7 @@ module.exports.isEnabled = (parserState) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {ParserState} parserState parser state
|
||||
* @param {JavascriptParserState} parserState parser state
|
||||
* @returns {void}
|
||||
*/
|
||||
module.exports.setDynamic = (parserState) => {
|
||||
@@ -61,7 +61,7 @@ module.exports.setDynamic = (parserState) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {ParserState} parserState parser state
|
||||
* @param {JavascriptParserState} parserState parser state
|
||||
* @returns {void}
|
||||
*/
|
||||
module.exports.setFlagged = (parserState) => {
|
||||
|
||||
11
node_modules/webpack/lib/dependencies/ExternalModuleDependency.js
generated
vendored
11
node_modules/webpack/lib/dependencies/ExternalModuleDependency.js
generated
vendored
@@ -13,17 +13,19 @@ const ExternalModuleInitFragment = require("./ExternalModuleInitFragment");
|
||||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {import("../dependencies/ExternalModuleInitFragment").ArrayImportSpecifiers} ArrayImportSpecifiers */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
||||
|
||||
class ExternalModuleDependency extends CachedConstDependency {
|
||||
/**
|
||||
* @param {string} module module
|
||||
* @param {{ name: string, value: string }[]} importSpecifiers import specifiers
|
||||
* @param {ArrayImportSpecifiers} importSpecifiers import specifiers
|
||||
* @param {string | undefined} defaultImport default import
|
||||
* @param {string} expression expression
|
||||
* @param {Range} range range
|
||||
* @param {Range | null} range range
|
||||
* @param {string} identifier identifier
|
||||
* @param {number=} place place where we inject the expression
|
||||
*/
|
||||
constructor(
|
||||
module,
|
||||
@@ -31,9 +33,10 @@ class ExternalModuleDependency extends CachedConstDependency {
|
||||
defaultImport,
|
||||
expression,
|
||||
range,
|
||||
identifier
|
||||
identifier,
|
||||
place = CachedConstDependency.PLACE_MODULE
|
||||
) {
|
||||
super(expression, range, identifier);
|
||||
super(expression, range, identifier, place);
|
||||
|
||||
this.importedModule = module;
|
||||
this.specifiers = importSpecifiers;
|
||||
|
||||
3
node_modules/webpack/lib/dependencies/ExternalModuleInitFragment.js
generated
vendored
3
node_modules/webpack/lib/dependencies/ExternalModuleInitFragment.js
generated
vendored
@@ -12,6 +12,7 @@ const makeSerializable = require("../util/makeSerializable");
|
||||
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
||||
/** @typedef {{ name: string, value?: string }[]} ArrayImportSpecifiers */
|
||||
/** @typedef {Map<string, Set<string>>} ImportSpecifiers */
|
||||
|
||||
/**
|
||||
@@ -20,7 +21,7 @@ const makeSerializable = require("../util/makeSerializable");
|
||||
class ExternalModuleInitFragment extends InitFragment {
|
||||
/**
|
||||
* @param {string} importedModule imported module
|
||||
* @param {{ name: string, value?: string }[] | ImportSpecifiers} specifiers import specifiers
|
||||
* @param {ArrayImportSpecifiers | ImportSpecifiers} specifiers import specifiers
|
||||
* @param {string=} defaultImport default import
|
||||
*/
|
||||
constructor(importedModule, specifiers, defaultImport) {
|
||||
|
||||
3
node_modules/webpack/lib/dependencies/ExternalModuleInitFragmentDependency.js
generated
vendored
3
node_modules/webpack/lib/dependencies/ExternalModuleInitFragmentDependency.js
generated
vendored
@@ -14,13 +14,14 @@ const NullDependency = require("./NullDependency");
|
||||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {import("../dependencies/ExternalModuleInitFragment").ArrayImportSpecifiers} ArrayImportSpecifiers */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
||||
|
||||
class ExternalModuleInitFragmentDependency extends NullDependency {
|
||||
/**
|
||||
* @param {string} module module
|
||||
* @param {{ name: string, value: string }[]} importSpecifiers import specifiers
|
||||
* @param {ArrayImportSpecifiers} importSpecifiers import specifiers
|
||||
* @param {string | undefined} defaultImport default import
|
||||
*/
|
||||
constructor(module, importSpecifiers, defaultImport) {
|
||||
|
||||
5
node_modules/webpack/lib/dependencies/HarmonyExportDependencyParserPlugin.js
generated
vendored
5
node_modules/webpack/lib/dependencies/HarmonyExportDependencyParserPlugin.js
generated
vendored
@@ -123,7 +123,7 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
||||
})
|
||||
.join(""),
|
||||
node.type.endsWith("Declaration") &&
|
||||
/** @type {FunctionDeclaration | ClassDeclaration} */ (node).id
|
||||
/** @type {FunctionDeclaration | ClassDeclaration} */ (node).id
|
||||
? /** @type {FunctionDeclaration | ClassDeclaration} */
|
||||
(node).id.name
|
||||
: isFunctionDeclaration
|
||||
@@ -224,7 +224,8 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
||||
const dep = new HarmonyExportImportedSpecifierDependency(
|
||||
/** @type {string} */
|
||||
(source),
|
||||
parser.state.lastHarmonyImportOrder,
|
||||
/** @type {number} */
|
||||
(parser.state.lastHarmonyImportOrder),
|
||||
id ? [id] : [],
|
||||
name,
|
||||
harmonyNamedExports,
|
||||
|
||||
10
node_modules/webpack/lib/dependencies/HarmonyExportImportedSpecifierDependency.js
generated
vendored
10
node_modules/webpack/lib/dependencies/HarmonyExportImportedSpecifierDependency.js
generated
vendored
@@ -60,7 +60,7 @@ const processExportInfo = require("./processExportInfo");
|
||||
/** @typedef {import("./HarmonyImportDependency").ExportPresenceMode} ExportPresenceMode */
|
||||
/** @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 */
|
||||
/** @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 */
|
||||
|
||||
const { ExportPresenceModes } = HarmonyImportDependency;
|
||||
|
||||
@@ -1251,9 +1251,11 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
||||
}
|
||||
|
||||
content += "__WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = ";
|
||||
content += runtimeTemplate.supportsArrowFunction()
|
||||
? `() => ${importVar}[__WEBPACK_IMPORT_KEY__]`
|
||||
: `function(key) { return ${importVar}[key]; }.bind(0, __WEBPACK_IMPORT_KEY__)`;
|
||||
content +=
|
||||
runtimeTemplate.supportsArrowFunction() &&
|
||||
runtimeTemplate.supportsConst()
|
||||
? `() => ${importVar}[__WEBPACK_IMPORT_KEY__]`
|
||||
: `function(key) { return ${importVar}[key]; }.bind(0, __WEBPACK_IMPORT_KEY__)`;
|
||||
|
||||
runtimeRequirements.add(RuntimeGlobals.exports);
|
||||
runtimeRequirements.add(RuntimeGlobals.definePropertyGetters);
|
||||
|
||||
8
node_modules/webpack/lib/dependencies/HarmonyExports.js
generated
vendored
8
node_modules/webpack/lib/dependencies/HarmonyExports.js
generated
vendored
@@ -9,13 +9,13 @@ const RuntimeGlobals = require("../RuntimeGlobals");
|
||||
|
||||
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
||||
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
||||
/** @typedef {import("../Parser").ParserState} ParserState */
|
||||
/** @typedef {import("../javascript/JavascriptParser").JavascriptParserState} JavascriptParserState */
|
||||
|
||||
/** @type {WeakMap<ParserState, boolean>} */
|
||||
/** @type {WeakMap<JavascriptParserState, boolean>} */
|
||||
const parserStateExportsState = new WeakMap();
|
||||
|
||||
/**
|
||||
* @param {ParserState} parserState parser state
|
||||
* @param {JavascriptParserState} parserState parser state
|
||||
* @param {boolean} isStrictHarmony strict harmony mode should be enabled
|
||||
* @returns {void}
|
||||
*/
|
||||
@@ -37,7 +37,7 @@ module.exports.enable = (parserState, isStrictHarmony) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {ParserState} parserState parser state
|
||||
* @param {JavascriptParserState} parserState parser state
|
||||
* @returns {boolean} true, when enabled
|
||||
*/
|
||||
module.exports.isEnabled = (parserState) => {
|
||||
|
||||
11
node_modules/webpack/lib/dependencies/HarmonyImportDependency.js
generated
vendored
11
node_modules/webpack/lib/dependencies/HarmonyImportDependency.js
generated
vendored
@@ -12,7 +12,7 @@ const InitFragment = require("../InitFragment");
|
||||
const Template = require("../Template");
|
||||
const AwaitDependenciesInitFragment = require("../async-modules/AwaitDependenciesInitFragment");
|
||||
const { filterRuntime, mergeRuntime } = require("../util/runtime");
|
||||
const { ImportPhaseUtils } = require("./ImportPhase");
|
||||
const { ImportPhase, ImportPhaseUtils } = require("./ImportPhase");
|
||||
const ModuleDependency = require("./ModuleDependency");
|
||||
|
||||
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
||||
@@ -62,10 +62,15 @@ class HarmonyImportDependency extends ModuleDependency {
|
||||
/**
|
||||
* @param {string} request request string
|
||||
* @param {number} sourceOrder source order
|
||||
* @param {ImportPhaseType} phase import phase
|
||||
* @param {ImportPhaseType=} phase import phase
|
||||
* @param {ImportAttributes=} attributes import attributes
|
||||
*/
|
||||
constructor(request, sourceOrder, phase, attributes) {
|
||||
constructor(
|
||||
request,
|
||||
sourceOrder,
|
||||
phase = ImportPhase.Evaluation,
|
||||
attributes = undefined
|
||||
) {
|
||||
super(request, sourceOrder);
|
||||
this.phase = phase;
|
||||
this.attributes = attributes;
|
||||
|
||||
2
node_modules/webpack/lib/dependencies/ImportMetaContextDependencyParserPlugin.js
generated
vendored
2
node_modules/webpack/lib/dependencies/ImportMetaContextDependencyParserPlugin.js
generated
vendored
@@ -25,7 +25,7 @@ const ImportMetaContextDependency = require("./ImportMetaContextDependency");
|
||||
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
||||
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
|
||||
|
||||
/** @typedef {Pick<ContextModuleOptions, 'mode' | 'recursive' | 'regExp' | 'include' | 'exclude' | 'chunkName'> & { groupOptions: RawChunkGroupOptions, exports?: RawReferencedExports }} ImportMetaContextOptions */
|
||||
/** @typedef {Pick<ContextModuleOptions, "mode" | "recursive" | "regExp" | "include" | "exclude" | "chunkName"> & { groupOptions: RawChunkGroupOptions, exports?: RawReferencedExports }} ImportMetaContextOptions */
|
||||
|
||||
/**
|
||||
* @param {Property} prop property
|
||||
|
||||
57
node_modules/webpack/lib/dependencies/ImportMetaPlugin.js
generated
vendored
57
node_modules/webpack/lib/dependencies/ImportMetaPlugin.js
generated
vendored
@@ -8,6 +8,7 @@
|
||||
const { pathToFileURL } = require("url");
|
||||
const { SyncBailHook } = require("tapable");
|
||||
const Compilation = require("../Compilation");
|
||||
const DefinePlugin = require("../DefinePlugin");
|
||||
const ModuleDependencyWarning = require("../ModuleDependencyWarning");
|
||||
const {
|
||||
JAVASCRIPT_MODULE_TYPE_AUTO,
|
||||
@@ -43,6 +44,31 @@ const getCriticalDependencyWarning = memoize(() =>
|
||||
|
||||
const PLUGIN_NAME = "ImportMetaPlugin";
|
||||
|
||||
/**
|
||||
* Collect import.meta.env definitions from DefinePlugin and build JSON string
|
||||
* @param {Compilation} compilation the compilation
|
||||
* @returns {string} env object as JSON string
|
||||
*/
|
||||
const collectImportMetaEnvDefinitions = (compilation) => {
|
||||
const definePluginHooks = DefinePlugin.getCompilationHooks(compilation);
|
||||
const definitions = definePluginHooks.definitions.call({});
|
||||
if (!definitions) {
|
||||
return "{}";
|
||||
}
|
||||
|
||||
/** @type {string[]} */
|
||||
const pairs = [];
|
||||
for (const key of Object.keys(definitions)) {
|
||||
if (key.startsWith("import.meta.env.")) {
|
||||
const envKey = key.slice("import.meta.env.".length);
|
||||
const value = definitions[key];
|
||||
pairs.push(`${JSON.stringify(envKey)}:${value}`);
|
||||
}
|
||||
}
|
||||
|
||||
return `{${pairs.join(",")}}`;
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {object} ImportMetaPluginHooks
|
||||
* @property {SyncBailHook<[DestructuringAssignmentProperty], string | void>} propertyInDestructuring
|
||||
@@ -294,6 +320,37 @@ class ImportMetaPlugin {
|
||||
.for("import.meta.main")
|
||||
.tap(PLUGIN_NAME, evaluateToString("boolean"));
|
||||
|
||||
// import.meta.env
|
||||
parser.hooks.typeof
|
||||
.for("import.meta.env")
|
||||
.tap(
|
||||
PLUGIN_NAME,
|
||||
toConstantDependency(parser, JSON.stringify("object"))
|
||||
);
|
||||
parser.hooks.expression
|
||||
.for("import.meta.env")
|
||||
.tap(PLUGIN_NAME, (expr) => {
|
||||
const envCode = collectImportMetaEnvDefinitions(compilation);
|
||||
const dep = new ConstDependency(
|
||||
envCode,
|
||||
/** @type {Range} */ (expr.range)
|
||||
);
|
||||
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
return true;
|
||||
});
|
||||
parser.hooks.evaluateTypeof
|
||||
.for("import.meta.env")
|
||||
.tap(PLUGIN_NAME, evaluateToString("object"));
|
||||
parser.hooks.evaluateIdentifier
|
||||
.for("import.meta.env")
|
||||
.tap(PLUGIN_NAME, (expr) =>
|
||||
new BasicEvaluatedExpression()
|
||||
.setTruthy()
|
||||
.setSideEffects(false)
|
||||
.setRange(/** @type {Range} */ (expr.range))
|
||||
);
|
||||
|
||||
// Unknown properties
|
||||
parser.hooks.unhandledExpressionMemberChain
|
||||
.for("import.meta")
|
||||
|
||||
4
node_modules/webpack/lib/dependencies/ImportParserPlugin.js
generated
vendored
4
node_modules/webpack/lib/dependencies/ImportParserPlugin.js
generated
vendored
@@ -29,7 +29,7 @@ const ImportWeakDependency = require("./ImportWeakDependency");
|
||||
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
||||
/** @typedef {import("../javascript/JavascriptParser").ImportExpression} ImportExpression */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {import("../javascript/JavascriptParser").ParserState} ParserState */
|
||||
/** @typedef {import("../javascript/JavascriptParser").JavascriptParserState} JavascriptParserState */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Members} Members */
|
||||
/** @typedef {import("../javascript/JavascriptParser").MembersOptionals} MembersOptionals */
|
||||
/** @typedef {import("../javascript/JavascriptParser").ArrowFunctionExpression} ArrowFunctionExpression */
|
||||
@@ -41,7 +41,7 @@ const ImportWeakDependency = require("./ImportWeakDependency");
|
||||
/** @typedef {{ references: RawReferencedExports, expression: ImportExpression }} ImportSettings */
|
||||
/** @typedef {WeakMap<ImportExpression, RawReferencedExports>} State */
|
||||
|
||||
/** @type {WeakMap<ParserState, State>} */
|
||||
/** @type {WeakMap<JavascriptParserState, State>} */
|
||||
const parserStateMap = new WeakMap();
|
||||
const dynamicImportTag = Symbol("import()");
|
||||
|
||||
|
||||
6
node_modules/webpack/lib/dependencies/LocalModulesHelpers.js
generated
vendored
6
node_modules/webpack/lib/dependencies/LocalModulesHelpers.js
generated
vendored
@@ -7,7 +7,7 @@
|
||||
|
||||
const LocalModule = require("./LocalModule");
|
||||
|
||||
/** @typedef {import("../javascript/JavascriptParser").ParserState} ParserState */
|
||||
/** @typedef {import("../javascript/JavascriptParser").JavascriptParserState} JavascriptParserState */
|
||||
|
||||
/**
|
||||
* @param {string} parent parent module
|
||||
@@ -34,7 +34,7 @@ const lookup = (parent, mod) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {ParserState} state parser state
|
||||
* @param {JavascriptParserState} state parser state
|
||||
* @param {string} name name
|
||||
* @returns {LocalModule} local module
|
||||
*/
|
||||
@@ -48,7 +48,7 @@ module.exports.addLocalModule = (state, name) => {
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {ParserState} state parser state
|
||||
* @param {JavascriptParserState} state parser state
|
||||
* @param {string} name name
|
||||
* @param {string=} namedModule named module
|
||||
* @returns {LocalModule | null} local module or null
|
||||
|
||||
4
node_modules/webpack/lib/dependencies/WorkerPlugin.js
generated
vendored
4
node_modules/webpack/lib/dependencies/WorkerPlugin.js
generated
vendored
@@ -41,9 +41,9 @@ const WorkerDependency = require("./WorkerDependency");
|
||||
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
||||
/** @typedef {import("../Entrypoint").EntryOptions} EntryOptions */
|
||||
/** @typedef {import("../NormalModule")} NormalModule */
|
||||
/** @typedef {import("../Parser").ParserState} ParserState */
|
||||
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
||||
/** @typedef {import("../javascript/JavascriptParser")} Parser */
|
||||
/** @typedef {import("../javascript/JavascriptParser").JavascriptParserState} JavascriptParserState */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {import("./HarmonyImportDependencyParserPlugin").HarmonySettings} HarmonySettings */
|
||||
|
||||
@@ -62,7 +62,7 @@ const DEFAULT_SYNTAX = [
|
||||
"Worker from worker_threads"
|
||||
];
|
||||
|
||||
/** @type {WeakMap<ParserState, number>} */
|
||||
/** @type {WeakMap<JavascriptParserState, number>} */
|
||||
const workerIndexMap = new WeakMap();
|
||||
|
||||
const PLUGIN_NAME = "WorkerPlugin";
|
||||
|
||||
2
node_modules/webpack/lib/dependencies/getFunctionExpression.js
generated
vendored
2
node_modules/webpack/lib/dependencies/getFunctionExpression.js
generated
vendored
@@ -12,7 +12,7 @@
|
||||
|
||||
/**
|
||||
* @param {Expression | SpreadElement} expr expressions
|
||||
* @returns {{fn: FunctionExpression | ArrowFunctionExpression, expressions: (Expression | SpreadElement)[], needThis: boolean | undefined } | undefined} function expression with additional information
|
||||
* @returns {{ fn: FunctionExpression | ArrowFunctionExpression, expressions: (Expression | SpreadElement)[], needThis: boolean | undefined } | undefined} function expression with additional information
|
||||
*/
|
||||
module.exports = (expr) => {
|
||||
// <FunctionExpression>
|
||||
|
||||
Reference in New Issue
Block a user