Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

webpack

Package Overview
Dependencies
Maintainers
4
Versions
868
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack - npm Package Compare versions

Comparing version
5.102.1
to
5.103.0
+56
lib/css/CssMergeStyleSheetsRuntimeModule.js
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Natsu @xiaoxiaojx
*/
"use strict";
const RuntimeGlobals = require("../RuntimeGlobals");
const RuntimeModule = require("../RuntimeModule");
const Template = require("../Template");
/** @typedef {import("../Chunk")} Chunk */
class CssMergeStyleSheetsRuntimeModule extends RuntimeModule {
constructor() {
super("css merge stylesheets");
}
/**
* @returns {string | null} runtime code
*/
generate() {
const { runtimeTemplate } = /** @type {import("../Compilation")} */ (
this.compilation
);
return Template.asString([
`${RuntimeGlobals.cssMergeStyleSheets} = ${runtimeTemplate.basicFunction(
"sheets",
[
"var sheetsArray = Array.isArray(sheets) ? sheets : [sheets];",
"var cssTexts = [];",
"for (var i = 0; i < sheetsArray.length; i++) {",
Template.indent([
"var s = sheetsArray[i];",
"if (!s) continue;",
"if (typeof s === 'string') {",
Template.indent("cssTexts.push(s);"),
"} else if (s.cssRules) {",
Template.indent([
"var rules = s.cssRules;",
"for (var j = 0; j < rules.length; j++) {",
Template.indent("cssTexts.push(rules[j].cssText);"),
"}"
]),
"}"
]),
"}",
"return cssTexts.join('');"
]
)};`
]);
}
}
module.exports = CssMergeStyleSheetsRuntimeModule;
/*
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;
/*
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;
/*
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;
/*
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;
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Alexander Akait @alexander-akait
*/
"use strict";
const DependencyTemplate = require("../DependencyTemplate");
const makeSerializable = require("../util/makeSerializable");
const ExternalModuleInitFragment = require("./ExternalModuleInitFragment");
const NullDependency = require("./NullDependency");
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
/** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/** @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 {string | undefined} defaultImport default import
*/
constructor(module, importSpecifiers, defaultImport) {
super();
this.importedModule = module;
this.specifiers = importSpecifiers;
this.default = defaultImport;
}
/**
* @returns {string} hash update
*/
_createHashUpdate() {
return `${this.importedModule}${JSON.stringify(this.specifiers)}${
this.default || "null"
}`;
}
/**
* @param {ObjectSerializerContext} context context
*/
serialize(context) {
const { write } = context;
write(this.importedModule);
write(this.specifiers);
write(this.default);
}
/**
* @param {ObjectDeserializerContext} context context
*/
deserialize(context) {
const { read } = context;
this.importedModule = read();
this.specifiers = read();
this.default = read();
}
}
makeSerializable(
ExternalModuleInitFragmentDependency,
"webpack/lib/dependencies/ExternalModuleConstDependency"
);
ExternalModuleInitFragmentDependency.Template = class ExternalModuleConstDependencyTemplate extends (
DependencyTemplate
) {
/**
* @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 {ExternalModuleInitFragmentDependency} */
(dependency);
const { chunkInitFragments, runtimeTemplate } = templateContext;
chunkInitFragments.push(
new ExternalModuleInitFragment(
`${runtimeTemplate.supportNodePrefixForCoreModules() ? "node:" : ""}${
dep.importedModule
}`,
dep.specifiers,
dep.default
)
);
}
};
module.exports = ExternalModuleInitFragmentDependency;
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Haijie Xie @hai-x
*/
"use strict";
const memoize = require("../util/memoize");
const getCommentCompilationWarning = memoize(() =>
require("../CommentCompilationWarning")
);
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("../javascript/JavascriptParser").ExportAllDeclaration} ExportAllDeclaration */
/** @typedef {import("../javascript/JavascriptParser").ExportNamedDeclaration} ExportNamedDeclaration */
/** @typedef {import("../javascript/JavascriptParser").ImportDeclaration} ImportDeclaration */
/** @typedef {import("../javascript/JavascriptParser").ImportExpression} ImportExpression */
/** @typedef {typeof ImportPhase.Evaluation | typeof ImportPhase.Defer | typeof ImportPhase.Source} ImportPhaseType */
const ImportPhase = Object.freeze({
Evaluation: 0b00,
Defer: 0b01,
Source: 0b10
});
/**
* @typedef {object} ImportPhaseUtils
* @property {(phase: ImportPhaseType) => boolean} isDefer true if phase is defer
* @property {(phase: ImportPhaseType) => boolean} isSource true if phase is source
*/
/** @type {ImportPhaseUtils} */
const ImportPhaseUtils = {
isDefer(phase) {
return phase === ImportPhase.Defer;
},
isSource(phase) {
return phase === ImportPhase.Source;
}
};
/**
* @typedef {() => Record<string, EXPECTED_ANY> | null} GetCommentOptions
*/
/**
* @callback GetImportPhase
* @param {JavascriptParser} parser parser
* @param {ExportNamedDeclaration | ExportAllDeclaration | ImportDeclaration | ImportExpression} node node
* @param {GetCommentOptions=} getCommentOptions optional function that returns the comment options object.
* @returns {ImportPhaseType} import phase
*/
/**
* @param {boolean=} enableImportPhase enable import phase detection
* @returns {GetImportPhase} evaluates the import phase for ast node
*/
function createGetImportPhase(enableImportPhase) {
return (parser, node, getCommentOptions) => {
if (!enableImportPhase) return ImportPhase.Evaluation;
// We now only support `defer import`
const phaseBySyntax =
"phase" in node && node.phase === "defer"
? ImportPhase.Defer
: ImportPhase.Evaluation;
if (!node.range) {
return phaseBySyntax;
}
getCommentOptions =
getCommentOptions ||
(() => {
if (!node.range) return null;
const { options, errors } = parser.parseCommentOptions(node.range);
if (errors) {
for (const e of errors) {
const { comment } = e;
if (!comment.loc) continue;
const CommentCompilationWarning = getCommentCompilationWarning();
parser.state.module.addWarning(
new CommentCompilationWarning(
`Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
comment.loc
)
);
}
}
return options;
});
const options = getCommentOptions();
if (!options || !options.webpackDefer) return phaseBySyntax;
const { webpackDefer } = options;
if (typeof webpackDefer === "boolean") {
return webpackDefer ? ImportPhase.Defer : phaseBySyntax;
} else if (node.loc) {
const CommentCompilationWarning = getCommentCompilationWarning();
parser.state.module.addWarning(
new CommentCompilationWarning(
"webpackDefer magic comment expected a boolean value.",
node.loc
)
);
}
return phaseBySyntax;
};
}
module.exports = {
ImportPhase,
ImportPhaseUtils,
createGetImportPhase
};
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Natsu @xiaoxiaojx
*/
"use strict";
const FileSystemInfo = require("./FileSystemInfo");
const createSchemaValidation = require("./util/create-schema-validation");
const { join } = require("./util/fs");
/** @typedef {import("../declarations/WebpackOptions").DotenvPluginOptions} DotenvPluginOptions */
/** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./CacheFacade").ItemCacheFacade} ItemCacheFacade */
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
/** @typedef {import("./FileSystemInfo").Snapshot} Snapshot */
/** @typedef {Exclude<DotenvPluginOptions["prefix"], string | undefined>} Prefix */
/** @typedef {Record<string, string>} Env */
/** @type {DotenvPluginOptions} */
const DEFAULT_OPTIONS = {
prefix: "WEBPACK_",
template: [".env", ".env.local", ".env.[mode]", ".env.[mode].local"]
};
// Regex for parsing .env files
// ported from https://github.com/motdotla/dotenv/blob/master/lib/main.js#L32
const LINE =
/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
const PLUGIN_NAME = "DotenvPlugin";
const validate = createSchemaValidation(
undefined,
() => {
const { definitions } = require("../schemas/WebpackOptions.json");
return {
definitions,
oneOf: [{ $ref: "#/definitions/DotenvPluginOptions" }]
};
},
{
name: "Dotenv Plugin",
baseDataPath: "options"
}
);
/**
* Parse .env file content
* ported from https://github.com/motdotla/dotenv/blob/master/lib/main.js#L49
* @param {string | Buffer} src the source content to parse
* @returns {Env} parsed environment variables object
*/
function parse(src) {
const obj = /** @type {Env} */ ({});
// Convert buffer to string
let lines = src.toString();
// Convert line breaks to same format
lines = lines.replace(/\r\n?/gm, "\n");
let match;
while ((match = LINE.exec(lines)) !== null) {
const key = match[1];
// Default undefined or null to empty string
let value = match[2] || "";
// Remove whitespace
value = value.trim();
// Check if double quoted
const maybeQuote = value[0];
// Remove surrounding quotes
value = value.replace(/^(['"`])([\s\S]*)\1$/gm, "$2");
// Expand newlines if double quoted
if (maybeQuote === '"') {
value = value.replace(/\\n/g, "\n");
value = value.replace(/\\r/g, "\r");
}
// Add to object
obj[key] = value;
}
return obj;
}
/**
* Resolve escape sequences
* ported from https://github.com/motdotla/dotenv-expand
* @param {string} value value to resolve
* @returns {string} resolved value
*/
function _resolveEscapeSequences(value) {
return value.replace(/\\\$/g, "$");
}
/**
* Expand environment variable value
* ported from https://github.com/motdotla/dotenv-expand
* @param {string} value value to expand
* @param {Record<string, string | undefined>} processEnv process.env object
* @param {Env} runningParsed running parsed object
* @returns {string} expanded value
*/
function expandValue(value, processEnv, runningParsed) {
const env = { ...runningParsed, ...processEnv }; // process.env wins
const regex = /(?<!\\)\$\{([^{}]+)\}|(?<!\\)\$([A-Za-z_][A-Za-z0-9_]*)/g;
let result = value;
let match;
const seen = new Set(); // self-referential checker
while ((match = regex.exec(result)) !== null) {
seen.add(result);
const [template, bracedExpression, unbracedExpression] = match;
const expression = bracedExpression || unbracedExpression;
// match the operators `:+`, `+`, `:-`, and `-`
const opRegex = /(:\+|\+|:-|-)/;
// find first match
const opMatch = expression.match(opRegex);
const splitter = opMatch ? opMatch[0] : null;
const r = expression.split(/** @type {string} */ (splitter));
// const r = splitter ? expression.split(splitter) : [expression];
let defaultValue;
let value;
const key = r.shift();
if ([":+", "+"].includes(splitter || "")) {
defaultValue = env[key || ""] ? r.join(splitter || "") : "";
value = null;
} else {
defaultValue = r.join(splitter || "");
value = env[key || ""];
}
if (value) {
// self-referential check
result = seen.has(value)
? result.replace(template, defaultValue)
: result.replace(template, value);
} else {
result = result.replace(template, defaultValue);
}
// if the result equaled what was in process.env and runningParsed then stop expanding
if (result === runningParsed[key || ""]) {
break;
}
regex.lastIndex = 0; // reset regex search position to re-evaluate after each replacement
}
return result;
}
/**
* Expand environment variables in parsed object
* ported from https://github.com/motdotla/dotenv-expand
* @param {{ parsed: Env, processEnv: Record<string, string | undefined> }} options expand options
* @returns {{ parsed: Env }} expanded options
*/
function expand(options) {
// for use with progressive expansion
const runningParsed = /** @type {Env} */ ({});
const processEnv = options.processEnv;
// dotenv.config() ran before this so the assumption is process.env has already been set
for (const key in options.parsed) {
let value = options.parsed[key];
// short-circuit scenario: process.env was already set prior to the file value
value =
processEnv[key] && processEnv[key] !== value
? /** @type {string} */ (processEnv[key])
: expandValue(value, processEnv, runningParsed);
const resolvedValue = _resolveEscapeSequences(value);
options.parsed[key] = resolvedValue;
// for use with progressive expansion
runningParsed[key] = resolvedValue;
}
// Part of `dotenv-expand` code, but we don't need it because of we don't modify `process.env`
// for (const processKey in options.parsed) {
// if (processEnv) {
// processEnv[processKey] = options.parsed[processKey];
// }
// }
return options;
}
/**
* Format environment variables as DefinePlugin definitions
* @param {Env} env environment variables
* @returns {Record<string, string>} formatted definitions
*/
const envToDefinitions = (env) => {
const definitions = /** @type {Record<string, string>} */ ({});
for (const [key, value] of Object.entries(env)) {
const defValue = JSON.stringify(value);
definitions[`process.env.${key}`] = defValue;
definitions[`import.meta.env.${key}`] = defValue;
}
return definitions;
};
class DotenvPlugin {
/**
* @param {DotenvPluginOptions=} options options object
*/
constructor(options = {}) {
validate(options);
this.options = { ...DEFAULT_OPTIONS, ...options };
}
/**
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply(compiler) {
const definePlugin = new compiler.webpack.DefinePlugin({});
const prefixes = Array.isArray(this.options.prefix)
? this.options.prefix
: [this.options.prefix || "WEBPACK_"];
/** @type {string | false} */
const dir =
typeof this.options.dir === "string"
? this.options.dir
: typeof this.options.dir === "undefined"
? compiler.context
: this.options.dir;
/** @type {undefined | Snapshot} */
let snapshot;
const cache = compiler.getCache(PLUGIN_NAME);
const identifier = JSON.stringify(this.options.template);
const itemCache = cache.getItemCache(identifier, null);
compiler.hooks.beforeCompile.tapPromise(PLUGIN_NAME, async () => {
const { parsed, snapshot: newSnapshot } = dir
? await this._loadEnv(compiler, itemCache, dir)
: { parsed: {} };
const env = this._getEnv(prefixes, parsed);
definePlugin.definitions = envToDefinitions(env || {});
snapshot = newSnapshot;
});
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
if (snapshot) {
compilation.fileDependencies.addAll(snapshot.getFileIterable());
compilation.missingDependencies.addAll(snapshot.getMissingIterable());
}
});
definePlugin.apply(compiler);
}
/**
* Get list of env files to load based on mode and template
* Similar to Vite's getEnvFilesForMode
* @private
* @param {InputFileSystem} inputFileSystem the input file system
* @param {string | false} dir the directory containing .env files
* @param {string | undefined} mode the mode (e.g., 'production', 'development')
* @returns {string[]} array of file paths to load
*/
_getEnvFilesForMode(inputFileSystem, dir, mode) {
if (!dir) {
return [];
}
const { template } = /** @type {DotenvPluginOptions} */ (this.options);
const templates = template || [];
return templates
.map((pattern) => pattern.replace(/\[mode\]/g, mode || "development"))
.map((file) => join(inputFileSystem, dir, file));
}
/**
* Get parsed env variables from `.env` files
* @private
* @param {InputFileSystem} fs input file system
* @param {string} dir dir to load `.env` files
* @param {string} mode mode
* @returns {Promise<{parsed: Env, fileDependencies: string[], missingDependencies: string[]}>} parsed env variables and dependencies
*/
async _getParsed(fs, dir, mode) {
/** @type {string[]} */
const fileDependencies = [];
/** @type {string[]} */
const missingDependencies = [];
// Get env files to load
const envFiles = this._getEnvFilesForMode(fs, dir, mode);
// Read all files
const contents = await Promise.all(
envFiles.map((filePath) =>
this._loadFile(fs, filePath).then(
(content) => {
fileDependencies.push(filePath);
return content;
},
() => {
// File doesn't exist, add to missingDependencies (this is normal)
missingDependencies.push(filePath);
return "";
}
)
)
);
// Parse all files and merge (later files override earlier ones)
// Similar to Vite's implementation
const parsed = /** @type {Env} */ ({});
for (const content of contents) {
if (!content) continue;
const entries = parse(content);
for (const key in entries) {
parsed[key] = entries[key];
}
}
return { parsed, fileDependencies, missingDependencies };
}
/**
* @private
* @param {Compiler} compiler compiler
* @param {ItemCacheFacade} itemCache item cache facade
* @param {string} dir directory to read
* @returns {Promise<{ parsed: Env, snapshot: Snapshot }>} parsed result and snapshot
*/
async _loadEnv(compiler, itemCache, dir) {
const fs = /** @type {InputFileSystem} */ (compiler.inputFileSystem);
const fileSystemInfo = new FileSystemInfo(fs, {
unmanagedPaths: compiler.unmanagedPaths,
managedPaths: compiler.managedPaths,
immutablePaths: compiler.immutablePaths,
hashFunction: compiler.options.output.hashFunction
});
const result = await itemCache.getPromise();
if (result) {
const isSnapshotValid = await new Promise((resolve, reject) => {
fileSystemInfo.checkSnapshotValid(result.snapshot, (error, isValid) => {
if (error) {
reject(error);
return;
}
resolve(isValid);
});
});
if (isSnapshotValid) {
return { parsed: result.parsed, snapshot: result.snapshot };
}
}
const { parsed, fileDependencies, missingDependencies } =
await this._getParsed(
fs,
dir,
/** @type {string} */
(compiler.options.mode)
);
const startTime = Date.now();
const newSnapshot = await new Promise((resolve, reject) => {
fileSystemInfo.createSnapshot(
startTime,
fileDependencies,
null,
missingDependencies,
// `.env` files are build dependencies
compiler.options.snapshot.buildDependencies,
(err, snapshot) => {
if (err) return reject(err);
resolve(snapshot);
}
);
});
await itemCache.storePromise({ parsed, snapshot: newSnapshot });
return { parsed, snapshot: newSnapshot };
}
/**
* Generate env variables
* @private
* @param {Prefix} prefixes expose only environment variables that start with these prefixes
* @param {Env} parsed parsed env variables
* @returns {Env} env variables
*/
_getEnv(prefixes, parsed) {
// Always expand environment variables (like Vite does)
// Make a copy of process.env so that dotenv-expand doesn't modify global process.env
const processEnv = { ...process.env };
expand({ parsed, processEnv });
const env = /** @type {Env} */ ({});
// Get all keys from parser and process.env
const keys = [...Object.keys(parsed), ...Object.keys(process.env)];
// Prioritize actual env variables from `process.env`, fallback to parsed
for (const key of keys) {
if (prefixes.some((prefix) => key.startsWith(prefix))) {
env[key] = process.env[key] ? process.env[key] : parsed[key];
}
}
return env;
}
/**
* Load a file with proper path resolution
* @private
* @param {InputFileSystem} fs the input file system
* @param {string} file the file to load
* @returns {Promise<string>} the content of the file
*/
_loadFile(fs, file) {
return new Promise((resolve, reject) => {
fs.readFile(file, (err, content) => {
if (err) reject(err);
else resolve(/** @type {Buffer} */ (content).toString() || "");
});
});
}
}
module.exports = DotenvPlugin;
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Haijie Xie @hai-x
*/
"use strict";
const { RawSource } = require("webpack-sources");
const Compilation = require("./Compilation");
const HotUpdateChunk = require("./HotUpdateChunk");
const createSchemaValidation = require("./util/create-schema-validation");
/** @typedef {import("./Compiler")} Compiler */
/** @typedef {import("./Chunk")} Chunk */
/** @typedef {import("./Chunk").ChunkName} ChunkName */
/** @typedef {import("./Chunk").ChunkId} ChunkId */
/** @typedef {import("./Compilation").Asset} Asset */
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
/** @typedef {import("../declarations/plugins/ManifestPlugin").ManifestPluginOptions} ManifestPluginOptions */
/** @typedef {import("../declarations/plugins/ManifestPlugin").ManifestObject} ManifestObject */
/** @typedef {import("../declarations/plugins/ManifestPlugin").ManifestEntrypoint} ManifestEntrypoint */
/** @typedef {import("../declarations/plugins/ManifestPlugin").ManifestItem} ManifestItem */
const PLUGIN_NAME = "ManifestPlugin";
const validate = createSchemaValidation(
require("../schemas/plugins/ManifestPlugin.check"),
() => require("../schemas/plugins/ManifestPlugin.json"),
{
name: "ManifestPlugin",
baseDataPath: "options"
}
);
/**
* @param {string} filename filename
* @returns {string} extname
*/
const extname = (filename) => {
const replaced = filename.replace(/\?.*/, "");
const split = replaced.split(".");
const last = split.pop();
if (!last) return "";
return last && /^(gz|br|map)$/i.test(last) ? `${split.pop()}.${last}` : last;
};
class ManifestPlugin {
/**
* @param {ManifestPluginOptions} options options
*/
constructor(options) {
validate(options);
/** @type {ManifestPluginOptions & Required<Omit<ManifestPluginOptions, "filter" | "generate">>} */
this.options = {
filename: "manifest.json",
prefix: "[publicpath]",
entrypoints: true,
serialize: (manifest) => JSON.stringify(manifest, null, 2),
...options
};
}
/**
* Apply the plugin
* @param {Compiler} compiler the compiler instance
* @returns {void}
*/
apply(compiler) {
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
compilation.hooks.processAssets.tap(
{
name: PLUGIN_NAME,
stage: Compilation.PROCESS_ASSETS_STAGE_SUMMARIZE
},
() => {
const hashDigestLength = compilation.outputOptions.hashDigestLength;
const publicPath = compilation.getPath(
compilation.outputOptions.publicPath
);
/**
* @param {string | string[]} value value
* @returns {RegExp} regexp to remove hash
*/
const createHashRegExp = (value) =>
new RegExp(
`(?:\\.${Array.isArray(value) ? `(${value.join("|")})` : value})(?=\\.)`,
"gi"
);
/**
* @param {string} name name
* @param {AssetInfo | null} info asset info
* @returns {string} hash removed name
*/
const removeHash = (name, info) => {
// Handles hashes that match configured `hashDigestLength`
// i.e. index.XXXX.html -> index.html (html-webpack-plugin)
if (hashDigestLength <= 0) return name;
const reg = createHashRegExp(`[a-f0-9]{${hashDigestLength},32}`);
return name.replace(reg, "");
};
/**
* @param {Chunk} chunk chunk
* @returns {ChunkName | ChunkId} chunk name or chunk id
*/
const getName = (chunk) => {
if (chunk.name) return chunk.name;
return chunk.id;
};
/** @type {ManifestObject} */
let manifest = {};
if (this.options.entrypoints) {
/** @type {ManifestObject["entrypoints"]} */
const entrypoints = {};
for (const [name, entrypoint] of compilation.entrypoints) {
const imports = [];
for (const chunk of entrypoint.chunks) {
for (const file of chunk.files) {
const name = getName(chunk);
imports.push(name ? `${name}.${extname(file)}` : file);
}
}
/** @type {ManifestEntrypoint} */
const item = { imports };
const parents = entrypoint
.getParents()
.map((item) => /** @type {string} */ (item.name));
if (parents.length > 0) {
item.parents = parents;
}
entrypoints[name] = item;
}
manifest.entrypoints = entrypoints;
}
/** @type {ManifestObject["assets"]} */
const assets = {};
/** @type {Set<string>} */
const added = new Set();
/**
* @param {string} file file
* @param {string=} usedName usedName
* @returns {void}
*/
const handleFile = (file, usedName) => {
if (added.has(file)) return;
added.add(file);
const asset = compilation.getAsset(file);
if (!asset) return;
const sourceFilename = asset.info.sourceFilename;
const name =
usedName ||
sourceFilename ||
// Fallback for unofficial plugins, just remove hash from filename
removeHash(file, asset.info);
const prefix = this.options.prefix.replace(
/\[publicpath\]/gi,
() => (publicPath === "auto" ? "/" : publicPath)
);
/** @type {ManifestItem} */
const item = { file: prefix + file };
if (sourceFilename) {
item.src = sourceFilename;
}
if (this.options.filter) {
const needKeep = this.options.filter(item);
if (!needKeep) {
return;
}
}
assets[name] = item;
};
for (const chunk of compilation.chunks) {
if (chunk instanceof HotUpdateChunk) continue;
for (const auxiliaryFile of chunk.auxiliaryFiles) {
handleFile(auxiliaryFile);
}
const name = getName(chunk);
for (const file of chunk.files) {
handleFile(file, name ? `${name}.${extname(file)}` : file);
}
}
for (const asset of compilation.getAssets()) {
if (asset.info.hotModuleReplacement) {
continue;
}
handleFile(asset.name);
}
manifest.assets = assets;
if (this.options.generate) {
manifest = this.options.generate(manifest);
}
compilation.emitAsset(
this.options.filename,
new RawSource(this.options.serialize(manifest)),
{ manifest: true }
);
}
);
});
}
}
module.exports = ManifestPlugin;
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Alexander Akait @alexander-akait
*/
"use strict";
//#region runtime code: json-parse-even-better-errors, parseJsonError
module.exports = "test";
//#endregion
/*
* This file was automatically generated.
* DO NOT MODIFY BY HAND.
* Run `yarn fix:special` to update
*/
declare const check: (options: import("../../declarations/plugins/ManifestPlugin").ManifestPluginOptions) => boolean;
export = check;
/*
* This file was automatically generated.
* DO NOT MODIFY BY HAND.
* Run `yarn fix:special` to update
*/
const r=/^(?:[A-Za-z]:[\\/]|\\\\|\/)/;function e(t,{instancePath:i="",parentData:n,parentDataProperty:o,rootData:s=t}={}){if(!t||"object"!=typeof t||Array.isArray(t))return e.errors=[{params:{type:"object"}}],!1;{const i=0;for(const r in t)if("entrypoints"!==r&&"filename"!==r&&"filter"!==r&&"generate"!==r&&"prefix"!==r&&"serialize"!==r)return e.errors=[{params:{additionalProperty:r}}],!1;if(0===i){if(void 0!==t.entrypoints){const r=0;if("boolean"!=typeof t.entrypoints)return e.errors=[{params:{type:"boolean"}}],!1;var a=0===r}else a=!0;if(a){if(void 0!==t.filename){let i=t.filename;const n=0;if(0===n){if("string"!=typeof i)return e.errors=[{params:{type:"string"}}],!1;if(i.includes("!")||!1!==r.test(i))return e.errors=[{params:{}}],!1;if(i.length<1)return e.errors=[{params:{}}],!1}a=0===n}else a=!0;if(a){if(void 0!==t.filter){const r=0;if(!(t.filter instanceof Function))return e.errors=[{params:{}}],!1;a=0===r}else a=!0;if(a){if(void 0!==t.generate){const r=0;if(!(t.generate instanceof Function))return e.errors=[{params:{}}],!1;a=0===r}else a=!0;if(a){if(void 0!==t.prefix){const r=0;if("string"!=typeof t.prefix)return e.errors=[{params:{type:"string"}}],!1;a=0===r}else a=!0;if(a)if(void 0!==t.serialize){const r=0;if(!(t.serialize instanceof Function))return e.errors=[{params:{}}],!1;a=0===r}else a=!0}}}}}}return e.errors=null,!0}module.exports=e,module.exports.default=e;
{
"definitions": {
"ManifestEntrypoint": {
"description": "Describes a manifest entrypoint.",
"type": "object",
"additionalProperties": false,
"properties": {
"imports": {
"description": "Contains the names of entrypoints.",
"type": "array",
"items": {
"description": "The name of file.",
"type": "string",
"minLength": 1
}
},
"parents": {
"description": "Contains the names of parent entrypoints.",
"type": "array",
"items": {
"description": "The entrypoint name.",
"type": "string",
"minLength": 1
}
}
},
"required": ["imports"]
},
"ManifestItem": {
"description": "Describes a manifest asset that links the emitted path to the producing asset.",
"type": "object",
"additionalProperties": false,
"properties": {
"file": {
"description": "The path absolute URL (this indicates that the path is absolute from the server's root directory) to file.",
"type": "string"
},
"src": {
"description": "The source path relative to the context.",
"type": "string"
}
},
"required": ["file"]
},
"ManifestObject": {
"description": "The manifest object.",
"type": "object",
"additionalProperties": true,
"properties": {
"assets": {
"description": "Contains the names of assets.",
"type": "object",
"tsType": "Record<string, ManifestItem>"
},
"entrypoints": {
"description": "Contains the names of entrypoints.",
"type": "object",
"tsType": "Record<string, ManifestEntrypoint>"
}
},
"required": ["assets", "entrypoints"]
}
},
"title": "ManifestPluginOptions",
"type": "object",
"additionalProperties": false,
"properties": {
"entrypoints": {
"description": "Enables/disables generation of the entrypoints manifest section.",
"type": "boolean"
},
"filename": {
"description": "Specifies the filename of the output file on disk. By default the plugin will emit `manifest.json` inside the 'output.path' directory.",
"type": "string",
"absolutePath": false,
"minLength": 1
},
"filter": {
"description": "Allows filtering the files which make up the manifest.",
"instanceof": "Function",
"tsType": "(item: ManifestItem) => boolean"
},
"generate": {
"description": "A function that receives the manifest object, modifies it, and returns the modified manifest.",
"instanceof": "Function",
"tsType": "(manifest: ManifestObject) => ManifestObject"
},
"prefix": {
"description": "Specifies a path prefix for all keys in the manifest.",
"type": "string"
},
"serialize": {
"description": "A function that receives the manifest object and returns the manifest string.",
"instanceof": "Function",
"tsType": "(manifest: ManifestObject) => string"
}
}
}
+1
-1

@@ -69,3 +69,3 @@ /*

runtimeRequirements.add(RuntimeGlobals.module);
sourceContent = `${RuntimeGlobals.module}.exports = ${RuntimeGlobals.toBinary}(${JSON.stringify(
sourceContent = `${module.moduleArgument}.exports = ${RuntimeGlobals.toBinary}(${JSON.stringify(
encodedSource

@@ -72,0 +72,0 @@ )});`;

@@ -383,3 +383,2 @@ /*

return {
// eslint-disable-next-line object-shorthand
assetPath: /** @type {string} */ (assetPath),

@@ -618,3 +617,3 @@ assetInfo: { sourceFilename, ...assetInfo }

return new RawSource(`${RuntimeGlobals.module}.exports = ${content};`);
return new RawSource(`${module.moduleArgument}.exports = ${content};`);
} else if (type === "css-url") {

@@ -621,0 +620,0 @@ return null;

@@ -68,3 +68,3 @@ /*

runtimeRequirements.add(RuntimeGlobals.module);
sourceContent = `${RuntimeGlobals.module}.exports = ${JSON.stringify(
sourceContent = `${module.moduleArgument}.exports = ${JSON.stringify(
encodedSource

@@ -71,0 +71,0 @@ )};`;

@@ -150,3 +150,2 @@ /*

});
return true;
});

@@ -156,4 +155,5 @@ parser.hooks.pattern

.tap(PLUGIN_NAME, (pattern) => {
const newName = "__nested_webpack_exports__";
parser.tagVariable(pattern.name, nestedWebpackIdentifierTag, {
name: "__nested_webpack_exports__",
name: newName,
declaration: {

@@ -167,2 +167,24 @@ updated: false,

});
// Update single `var __webpack_require__ = {};` and `var __webpack_exports__ = {};` without expression
parser.hooks.declarator.tap(PLUGIN_NAME, (declarator) => {
if (
declarator.id.type === "Identifier" &&
(declarator.id.name === RuntimeGlobals.exports ||
declarator.id.name === RuntimeGlobals.require)
) {
const { name, declaration } =
/** @type {CompatibilitySettings} */ (
parser.getTagData(
declarator.id.name,
nestedWebpackIdentifierTag
)
);
if (!declaration.updated) {
const dep = new ConstDependency(name, declaration.range);
dep.loc = declaration.loc;
parser.state.module.addPresentationalDependency(dep);
declaration.updated = true;
}
}
});
parser.hooks.expression

@@ -218,1 +240,2 @@ .for(nestedWebpackIdentifierTag)

module.exports = CompatibilityPlugin;
module.exports.nestedWebpackIdentifierTag = nestedWebpackIdentifierTag;

@@ -116,14 +116,2 @@ /*

/**
* @param {string} symbol identifier of the export in source code
* @returns {boolean} registered success
*/
registerUsedName(symbol) {
if (this.usedNames.has(symbol)) {
return false;
}
this.usedNames.add(symbol);
return true;
}
/**
* @param {Module} module the referenced module

@@ -193,5 +181,2 @@ * @param {Partial<ModuleReferenceOptions>} options options

/** @type {WeakMap<Chunk, Set<string>>} */
ConcatenationScope.chunkUsedNames = new WeakMap();
module.exports = ConcatenationScope;

@@ -357,2 +357,7 @@ /*

}),
importMetaDirnameAndFilename:
nodeProperty &&
rawChecker({
node: [22, 16]
}),
require: nodeProperty

@@ -359,0 +364,0 @@ };

@@ -205,2 +205,3 @@ /*

* & { recordsOutputPath: NonNullable<WebpackOptionsNormalized["recordsOutputPath"]>
* & { dotenv: NonNullable<WebpackOptionsNormalized["dotenv"]> }
* }} WebpackOptionsNormalizedWithDefaults

@@ -414,3 +415,6 @@ */

targetProperties,
buildHttp: Boolean(options.experiments.buildHttp)
buildHttp: Boolean(options.experiments.buildHttp),
outputModule:
/** @type {NonNullable<WebpackOptionsNormalized["output"]["module"]>} */
(options.output.module)
});

@@ -518,2 +522,3 @@

D(experiments, "backCompat", !experiments.futureDefaults);
// TODO do we need sync web assembly in webpack@6?
D(experiments, "syncWebAssembly", false);

@@ -1048,2 +1053,31 @@ D(experiments, "asyncWebAssembly", experiments.futureDefaults);

});
// For CSS modules, i.e. `.class { composes: className from "./style.css" }`
// We inherit for such constructions
rules.push({
dependency: /css-import-local-module/,
type: CSS_MODULE_TYPE_MODULE,
resolve
});
rules.push({
dependency: /css-import-global-module/,
type: CSS_MODULE_TYPE_GLOBAL,
resolve
});
rules.push(
{
with: { type: "css" },
parser: {
exportType: "css-style-sheet"
},
resolve
},
{
assert: { type: "css" },
parser: {
exportType: "css-style-sheet"
},
resolve
}
);
}

@@ -1065,7 +1099,9 @@ rules.push(

with: { type: JSON_MODULE_TYPE },
type: JSON_MODULE_TYPE
type: JSON_MODULE_TYPE,
parser: { namedExports: false }
},
{
assert: { type: JSON_MODULE_TYPE },
type: JSON_MODULE_TYPE
type: JSON_MODULE_TYPE,
parser: { namedExports: false }
},

@@ -1230,2 +1266,9 @@ {

environment,
"importMetaDirnameAndFilename",
() =>
// No optimistic, because it is new
tp && /** @type {boolean | undefined} */ (tp.importMetaDirnameAndFilename)
);
F(
environment,
"templateLiteral",

@@ -1310,2 +1353,4 @@ () =>

if (tp.globalThis) return "globalThis";
// For universal target (i.e. code can be run in browser/node/worker etc.)
if (tp.web === null && tp.node === null && tp.module) return "globalThis";
}

@@ -1413,3 +1458,2 @@ return "self";

(tp.nodeBuiltins === null || tp.fetchWasm === null) &&
asyncWebAssembly &&
output.module &&

@@ -1538,2 +1582,3 @@ environment.dynamicImport

* @param {boolean} options.buildHttp buildHttp experiment enabled
* @param {boolean} options.outputModule is output type is module
* @returns {void}

@@ -1543,4 +1588,11 @@ */

externalsPresets,
{ targetProperties, buildHttp }
{ targetProperties, buildHttp, outputModule }
) => {
/**
* @param {keyof TargetProperties} key a key
* @returns {boolean} true when target is universal, otherwise false
*/
const isUniversal = (key) =>
Boolean(outputModule && targetProperties && targetProperties[key] === null);
D(

@@ -1550,3 +1602,7 @@ externalsPresets,

/** @type {boolean | undefined} */
(!buildHttp && targetProperties && targetProperties.web)
(
!buildHttp &&
targetProperties &&
(targetProperties.web || isUniversal("node"))
)
);

@@ -1557,3 +1613,3 @@ D(

/** @type {boolean | undefined} */
(targetProperties && targetProperties.node)
(targetProperties && (targetProperties.node || isUniversal("node")))
);

@@ -1564,3 +1620,3 @@ D(

/** @type {boolean | undefined} */
(targetProperties && targetProperties.nwjs)
(targetProperties && (targetProperties.nwjs || isUniversal("nwjs")))
);

@@ -1571,3 +1627,3 @@ D(

/** @type {boolean | undefined} */
(targetProperties && targetProperties.electron)
((targetProperties && targetProperties.electron) || isUniversal("electron"))
);

@@ -1581,3 +1637,3 @@ D(

targetProperties.electron &&
targetProperties.electronMain
(targetProperties.electronMain || isUniversal("electronMain"))
)

@@ -1592,3 +1648,3 @@ );

targetProperties.electron &&
targetProperties.electronPreload
(targetProperties.electronPreload || isUniversal("electronPreload"))
)

@@ -1603,3 +1659,3 @@ );

targetProperties.electron &&
targetProperties.electronRenderer
(targetProperties.electronRenderer || isUniversal("electronRenderer"))
)

@@ -1649,3 +1705,3 @@ );

if (targetProperties && targetProperties.global) return false;
// TODO webpack 6 should always default to false
// We use `warm` because overriding `global` with `globalThis` (or a polyfill) is sometimes safe (global.URL), sometimes unsafe (global.process), but we need to warn about it
return futureDefaults ? "warn" : true;

@@ -1655,6 +1711,19 @@ });

const handlerForNames = () => {
if (targetProperties && targetProperties.node) {
return outputModule ? "node-module" : "eval-only";
// TODO webpack@6 remove `node-module` in favor of `eval-only`
if (targetProperties) {
if (targetProperties.node) {
return "eval-only";
}
// For the "universal" target we only evaluate these values
if (
outputModule &&
targetProperties.node === null &&
targetProperties.web === null
) {
return "eval-only";
}
}
// TODO webpack 6 should always default to false
// TODO webpack@6 should we use `warn-even-only`?
return futureDefaults ? "warn-mock" : "mock";

@@ -1866,4 +1935,4 @@ };

/** @type {NonNullable<ResolveOptions["byDependency"]>} */
(resolveOptions.byDependency)["css-import"] = {
/** @type {ResolveOptions} */
const cssResolveOptions = {
// We avoid using any main files because we have to be consistent with CSS `@import`

@@ -1878,2 +1947,13 @@ // and CSS `@import` does not handle `main` files in directories,

};
/** @type {NonNullable<ResolveOptions["byDependency"]>} */
(resolveOptions.byDependency)["css-import"] = cssResolveOptions;
// For CSS modules, i.e. `.class { composes: className from "./style.css" }`
// We inherit for such constructions
/** @type {NonNullable<ResolveOptions["byDependency"]>} */
(resolveOptions.byDependency)["css-import-local-module"] =
cssResolveOptions;
/** @type {NonNullable<ResolveOptions["byDependency"]>} */
(resolveOptions.byDependency)["css-import-global-module"] =
cssResolveOptions;
}

@@ -1880,0 +1960,0 @@

@@ -181,2 +181,3 @@ /*

devtool: config.devtool,
dotenv: config.dotenv,
entry:

@@ -245,2 +246,3 @@ config.entry === undefined

javascript: (parserOptions) => ({
// TODO webpack 6 remove from `ModuleOptions`, keep only `*ByModuleType`
unknownContextRequest: module.unknownContextRequest,

@@ -257,3 +259,2 @@ unknownContextRegExp: module.unknownContextRegExp,

wrappedContextCritical: module.wrappedContextCritical,
// TODO webpack 6 remove
strictExportPresence: module.strictExportPresence,

@@ -260,0 +261,0 @@ strictThisContextOnImports: module.strictThisContextOnImports,

@@ -45,2 +45,3 @@ /*

* @property {boolean | null} nodePrefixForCoreModules node.js allows to use `node:` prefix for core modules
* @property {boolean | null} importMetaDirnameAndFilename node.js allows to use `import.meta.dirname` and `import.meta.filename`
* @property {boolean | null} document has document available (allows script tags)

@@ -182,2 +183,5 @@ * @property {boolean | null} importScripts has importScripts available

nodePrefixForCoreModules: Number(major) < 15 ? v(14, 18) : v(16),
// Added in: v21.2.0, v20.11.0, but Node.js will output experimental warning, we don't want it
// v24.0.0, v22.16.0 - This property is no longer experimental.
importMetaDirnameAndFilename: v(22, 16),
global: true,

@@ -228,2 +232,4 @@ document: false,

nodePrefixForCoreModules: v(15),
// 37.0.0 - Node.js v22.16
importMetaDirnameAndFilename: v(37),

@@ -230,0 +236,0 @@ require: true,

@@ -15,8 +15,10 @@ /*

CSS_TYPES,
JS_AND_CSS_EXPORT_TYPES,
JS_AND_CSS_TYPES,
JS_TYPE
JS_TYPE,
JS_TYPES
} = require("../ModuleSourceTypesConstants");
const RuntimeGlobals = require("../RuntimeGlobals");
const Template = require("../Template");
const CssImportDependency = require("../dependencies/CssImportDependency");
const { getUndoPath } = require("../util/identifier");
const memoize = require("../util/memoize");

@@ -42,4 +44,10 @@

/** @typedef {import("../util/Hash")} Hash */
/** @typedef {import("./CssModulesPlugin").ModuleFactoryCacheEntry} ModuleFactoryCacheEntry */
/** @typedef {import("../CssModule")} CssModule */
/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
/** @typedef {import("../../declarations/WebpackOptions").CssParserExportType} CssParserExportType */
const getPropertyName = memoize(() => require("../util/propertyName"));
const getCssModulesPlugin = memoize(() => require("./CssModulesPlugin"));

@@ -55,5 +63,7 @@ class CssGenerator extends Generator {

this.localIdentName = options.localIdentName;
this.exportsOnly = options.exportsOnly;
this.esModule = options.esModule;
this._exportsOnly = options.exportsOnly;
this._esModule = options.esModule;
this._moduleGraph = moduleGraph;
/** @type {WeakMap<Source, ModuleFactoryCacheEntry>} */
this._moduleFactoryCache = new WeakMap();
}

@@ -67,3 +77,3 @@

getConcatenationBailoutReason(module, context) {
if (!this.esModule) {
if (!this._esModule) {
return "Module is not an ECMAScript module";

@@ -76,20 +86,113 @@ }

/**
* @param {NormalModule} module module for which the code should be generated
* @param {GenerateContext} generateContext context for generate
* @returns {Source | null} generated code
* Generate JavaScript code that requires and concatenates all CSS imports
* @param {NormalModule} module the module to generate CSS text for
* @param {GenerateContext} generateContext the generate context
* @returns {{ expr: string, type: CssParserExportType }[]} JavaScript code that concatenates all imported CSS
*/
generate(module, generateContext) {
const source =
generateContext.type === "javascript"
? new ReplaceSource(new RawSource(""))
: new ReplaceSource(/** @type {Source} */ (module.originalSource()));
_generateImportCode(module, generateContext) {
const moduleGraph = generateContext.moduleGraph;
/** @type {{ expr: string, type: CssParserExportType }[]} */
const parts = [];
/** @type {InitFragment<GenerateContext>[]} */
const initFragments = [];
/** @type {CssData} */
const cssData = {
esModule: /** @type {boolean} */ (this.esModule),
exports: new Map()
};
// Iterate through module.dependencies to maintain source order
for (const dep of module.dependencies) {
if (dep instanceof CssImportDependency) {
/** @type {CssModule} */
const depModule = /** @type {CssModule} */ (moduleGraph.getModule(dep));
const importVar = generateContext.runtimeTemplate.moduleExports({
module: depModule,
chunkGraph: generateContext.chunkGraph,
request: /** @type {CssModule} */ (depModule).userRequest,
weak: false,
runtimeRequirements: generateContext.runtimeRequirements
});
generateContext.runtimeRequirements.add(
RuntimeGlobals.compatGetDefaultExport
);
parts.push({
expr: `(${RuntimeGlobals.compatGetDefaultExport}(${importVar})() || "")`,
type: /** @type {CssParserExportType} */ (
/** @type {BuildMeta} */ (depModule.buildMeta).exportType
)
});
}
}
return parts;
}
/**
* Generate CSS code for the current module
* @param {NormalModule} module the module to generate CSS code for
* @param {GenerateContext} generateContext the generate context
* @returns {string} the CSS code as string
*/
_generateModuleCode(module, generateContext) {
const moduleSourceContent = /** @type {Source} */ (
this.generate(module, {
...generateContext,
type: "css"
})
);
if (!moduleSourceContent) {
return "";
}
const compilation = generateContext.runtimeTemplate.compilation;
const { path: filename } = compilation.getPathWithInfo(
compilation.outputOptions.cssChunkFilename,
{
runtime: generateContext.runtime,
contentHashType: "css"
}
);
const undoPath = getUndoPath(
filename,
compilation.outputOptions.path,
false
);
const CssModulesPlugin = getCssModulesPlugin();
const hooks = CssModulesPlugin.getCompilationHooks(compilation);
const renderedSource = CssModulesPlugin.renderModule(
/** @type {CssModule} */ (module),
{
undoPath,
moduleSourceContent,
moduleFactoryCache: this._moduleFactoryCache,
runtimeTemplate: generateContext.runtimeTemplate
},
hooks
);
if (!renderedSource) {
return "";
}
const content = renderedSource.source();
return typeof content === "string" ? content : content.toString("utf8");
}
/**
* @param {NormalModule} module the current module
* @param {Dependency} dependency the dependency to generate
* @param {InitFragment<GenerateContext>[]} initFragments mutable list of init fragments
* @param {ReplaceSource} source the current replace source which can be modified
* @param {GenerateContext & { cssData: CssData }} generateContext the render context
* @returns {void}
*/
sourceDependency(module, dependency, initFragments, source, generateContext) {
const constructor =
/** @type {DependencyConstructor} */
(dependency.constructor);
const template = generateContext.dependencyTemplates.get(constructor);
if (!template) {
throw new Error(
`No template for dependency: ${dependency.constructor.name}`
);
}
/** @type {DependencyTemplateContext} */
/** @type {InitFragment<GenerateContext>[] | undefined} */

@@ -111,3 +214,4 @@ let chunkInitFragments;

initFragments,
cssData,
cssData: generateContext.cssData,
type: generateContext.type,
get chunkInitFragments() {

@@ -129,30 +233,140 @@ if (!chunkInitFragments) {

/**
* @param {Dependency} dependency dependency
*/
const handleDependency = (dependency) => {
const constructor =
/** @type {DependencyConstructor} */
(dependency.constructor);
const template = generateContext.dependencyTemplates.get(constructor);
if (!template) {
throw new Error(
`No template for dependency: ${dependency.constructor.name}`
template.apply(dependency, source, templateContext);
}
/**
* @param {NormalModule} module the module to generate
* @param {InitFragment<GenerateContext>[]} initFragments mutable list of init fragments
* @param {ReplaceSource} source the current replace source which can be modified
* @param {GenerateContext & { cssData: CssData }} generateContext the generateContext
* @returns {void}
*/
sourceModule(module, initFragments, source, generateContext) {
for (const dependency of module.dependencies) {
this.sourceDependency(
module,
dependency,
initFragments,
source,
generateContext
);
}
if (module.presentationalDependencies !== undefined) {
for (const dependency of module.presentationalDependencies) {
this.sourceDependency(
module,
dependency,
initFragments,
source,
generateContext
);
}
}
}
template.apply(dependency, source, templateContext);
/**
* @param {NormalModule} module module for which the code should be generated
* @param {GenerateContext} generateContext context for generate
* @returns {Source | null} generated code
*/
generate(module, generateContext) {
const exportType = /** @type {BuildMeta} */ (module.buildMeta).exportType;
const source =
generateContext.type === "javascript"
? exportType === "link"
? new ReplaceSource(new RawSource(""))
: new ReplaceSource(/** @type {Source} */ (module.originalSource()))
: new ReplaceSource(/** @type {Source} */ (module.originalSource()));
/** @type {InitFragment<GenerateContext>[]} */
const initFragments = [];
/** @type {CssData} */
const cssData = {
esModule: /** @type {boolean} */ (this._esModule),
exports: new Map()
};
for (const dependency of module.dependencies) {
handleDependency(dependency);
}
this.sourceModule(module, initFragments, source, {
...generateContext,
cssData
});
const generateCssText = () => {
const importCode = this._generateImportCode(module, generateContext);
const moduleCode = this._generateModuleCode(module, generateContext);
if (importCode.length > 0) {
if (
exportType === "css-style-sheet" ||
importCode.some((part) => part.type !== exportType)
) {
generateContext.runtimeRequirements.add(
RuntimeGlobals.cssMergeStyleSheets
);
return `${RuntimeGlobals.cssMergeStyleSheets}([${[...importCode.map((part) => part.expr), JSON.stringify(moduleCode)].join(", ")}])`;
}
return generateContext.runtimeTemplate.concatenation(
...importCode,
moduleCode
);
}
return JSON.stringify(moduleCode);
};
/**
* @returns {string | null} the default export
*/
const generateJSDefaultExport = () => {
switch (exportType) {
case "text": {
return generateCssText();
}
case "css-style-sheet": {
const constOrVar = generateContext.runtimeTemplate.renderConst();
return `(${generateContext.runtimeTemplate.basicFunction("", [
`${constOrVar} cssText = ${generateCssText()};`,
`${constOrVar} sheet = new CSSStyleSheet();`,
"sheet.replaceSync(cssText);",
"return sheet;"
])})()`;
}
default:
return null;
}
};
switch (generateContext.type) {
case "javascript": {
const isCSSModule = /** @type {BuildMeta} */ (module.buildMeta)
.isCSSModule;
const defaultExport = generateJSDefaultExport();
/**
* @param {string} name the export name
* @param {string} value the export value
* @returns {string} the value to be used in the export
*/
const stringifyExportValue = (name, value) => {
if (defaultExport) {
return name === "default" ? value : JSON.stringify(value);
}
return JSON.stringify(value);
};
/** @type {BuildInfo} */
(module.buildInfo).cssData = cssData;
generateContext.runtimeRequirements.add(RuntimeGlobals.module);
// Required for HMR
if (module.hot) {
generateContext.runtimeRequirements.add(RuntimeGlobals.module);
}
if (defaultExport) {
cssData.exports.set("default", /** @type {string} */ (defaultExport));
}
if (cssData.exports.size === 0 && !isCSSModule) {
return new RawSource("");
}
if (generateContext.concatenationScope) {

@@ -162,2 +376,3 @@ const source = new ConcatSource();

const { RESERVED_IDENTIFIER } = getPropertyName();
for (const [name, v] of cssData.exports) {

@@ -182,3 +397,3 @@ const usedName = generateContext.moduleGraph

source.add(
`${generateContext.runtimeTemplate.renderConst()} ${identifier} = ${JSON.stringify(v)};\n`
`${generateContext.runtimeTemplate.renderConst()} ${identifier} = ${stringifyExportValue(name, v)};\n`
);

@@ -189,11 +404,4 @@ }

if (
cssData.exports.size === 0 &&
!(/** @type {BuildMeta} */ (module.buildMeta).isCSSModule)
) {
return new RawSource("");
}
const needNsObj =
this.esModule &&
this._esModule &&
generateContext.moduleGraph

@@ -210,6 +418,17 @@ .getExportsInfo(module)

// Should be after `concatenationScope` to allow module inlining
generateContext.runtimeRequirements.add(RuntimeGlobals.module);
if (!isCSSModule && !needNsObj) {
return new RawSource(
`${module.moduleArgument}.exports = ${defaultExport}`
);
}
const exports = [];
for (const [name, v] of cssData.exports) {
exports.push(`\t${JSON.stringify(name)}: ${JSON.stringify(v)}`);
exports.push(
`\t${JSON.stringify(name)}: ${stringifyExportValue(name, v)}`
);
}

@@ -224,10 +443,6 @@

case "css": {
if (module.presentationalDependencies !== undefined) {
for (const dependency of module.presentationalDependencies) {
handleDependency(dependency);
}
if (!this._generatesJsOnly(module)) {
generateContext.runtimeRequirements.add(RuntimeGlobals.hasCssModules);
}
generateContext.runtimeRequirements.add(RuntimeGlobals.hasCssModules);
return InitFragment.addToSource(source, initFragments, generateContext);

@@ -266,5 +481,4 @@ }

getTypes(module) {
// TODO, find a better way to prevent the original module from being removed after concatenation, maybe it is a bug
if (this.exportsOnly) {
return JS_AND_CSS_EXPORT_TYPES;
if (this._generatesJsOnly(module)) {
return JS_TYPES;
}

@@ -334,6 +548,18 @@ const sourceTypes = new Set();

updateHash(hash, { module }) {
hash.update(/** @type {boolean} */ (this.esModule).toString());
hash.update(/** @type {boolean} */ (this._esModule).toString());
}
/**
* @param {NormalModule} module module
* @returns {boolean} true if the module only outputs JavaScript
*/
_generatesJsOnly(module) {
const exportType = /** @type {BuildMeta} */ (module.buildMeta).exportType;
return (
this._exportsOnly ||
/** @type {boolean} */ (exportType && exportType !== "link")
);
}
}
module.exports = CssGenerator;

@@ -465,2 +465,4 @@ /*

"if(!oldTag) return;",
"// create error before stack unwound to get useful stacktrace later",
"var error = new Error();",
`promises.push(new Promise(${runtimeTemplate.basicFunction(

@@ -467,0 +469,0 @@ "resolve, reject",

@@ -32,7 +32,9 @@ /*

const CssIcssExportDependency = require("../dependencies/CssIcssExportDependency");
const CssIcssFromIdentifierDependency = require("../dependencies/CssIcssFromIdentifierDependency");
const CssIcssGlobalIdentifierDependency = require("../dependencies/CssIcssGlobalIdentifierDependency");
const CssIcssImportDependency = require("../dependencies/CssIcssImportDependency");
const CssIcssLocalIdentifierDependency = require("../dependencies/CssIcssLocalIdentifierDependency");
const CssIcssSelfLocalIdentifierDependency = require("../dependencies/CssIcssSelfLocalIdentifierDependency");
const CssIcssSymbolDependency = require("../dependencies/CssIcssSymbolDependency");
const CssImportDependency = require("../dependencies/CssImportDependency");
const CssLocalIdentifierDependency = require("../dependencies/CssLocalIdentifierDependency");
const CssSelfLocalIdentifierDependency = require("../dependencies/CssSelfLocalIdentifierDependency");
const CssUrlDependency = require("../dependencies/CssUrlDependency");

@@ -49,2 +51,3 @@ const StaticExportsDependency = require("../dependencies/StaticExportsDependency");

const CssGenerator = require("./CssGenerator");
const CssMergeStyleSheetsRuntimeModule = require("./CssMergeStyleSheetsRuntimeModule");
const CssParser = require("./CssParser");

@@ -67,2 +70,3 @@

/** @typedef {import("../util/Hash")} Hash */
/** @typedef {import("../Module").BuildMeta} BuildMeta */

@@ -82,7 +86,9 @@ /**

* @typedef {object} ChunkRenderContext
* @property {Chunk} chunk the chunk
* @property {ChunkGraph} chunkGraph the chunk graph
* @property {CodeGenerationResults} codeGenerationResults results of code generation
* @property {Chunk=} chunk the chunk
* @property {ChunkGraph=} chunkGraph the chunk graph
* @property {CodeGenerationResults=} codeGenerationResults results of code generation
* @property {RuntimeTemplate} runtimeTemplate the runtime template
* @property {string} undoPath undo path to css file
* @property {WeakMap<Source, ModuleFactoryCacheEntry>} moduleFactoryCache moduleFactoryCache
* @property {Source} moduleSourceContent content
*/

@@ -96,2 +102,9 @@

/**
* @typedef {object} ModuleFactoryCacheEntry
* @property {string} undoPath - The undo path to the CSS file
* @property {Inheritance} inheritance - The inheritance chain
* @property {CachedSource} source - The cached source
*/
const getCssLoadingRuntimeModule = memoize(() =>

@@ -200,3 +213,3 @@ require("./CssLoadingRuntimeModule")

constructor() {
/** @type {WeakMap<Source, { undoPath: string, inheritance: Inheritance, source: CachedSource }>} */
/** @type {WeakMap<Source, ModuleFactoryCacheEntry>} */
this._moduleFactoryCache = new WeakMap();

@@ -233,12 +246,12 @@ }

compilation.dependencyTemplates.set(
CssLocalIdentifierDependency,
new CssLocalIdentifierDependency.Template()
CssIcssLocalIdentifierDependency,
new CssIcssLocalIdentifierDependency.Template()
);
compilation.dependencyFactories.set(
CssSelfLocalIdentifierDependency,
CssIcssSelfLocalIdentifierDependency,
selfFactory
);
compilation.dependencyTemplates.set(
CssSelfLocalIdentifierDependency,
new CssSelfLocalIdentifierDependency.Template()
CssIcssSelfLocalIdentifierDependency,
new CssIcssSelfLocalIdentifierDependency.Template()
);

@@ -253,3 +266,19 @@ compilation.dependencyFactories.set(

);
compilation.dependencyFactories.set(
CssIcssFromIdentifierDependency,
normalModuleFactory
);
compilation.dependencyTemplates.set(
CssIcssFromIdentifierDependency,
new CssIcssFromIdentifierDependency.Template()
);
compilation.dependencyFactories.set(
CssIcssGlobalIdentifierDependency,
normalModuleFactory
);
compilation.dependencyTemplates.set(
CssIcssGlobalIdentifierDependency,
new CssIcssGlobalIdentifierDependency.Template()
);
compilation.dependencyTemplates.set(
CssIcssExportDependency,

@@ -276,3 +305,8 @@ new CssIcssExportDependency.Template()

validateParserOptions[type](parserOptions);
const { url, import: importOption, namedExports } = parserOptions;
const {
url,
import: importOption,
namedExports,
exportType
} = parserOptions;

@@ -284,3 +318,4 @@ switch (type) {

url,
namedExports
namedExports,
exportType
});

@@ -292,3 +327,4 @@ case CSS_MODULE_TYPE_GLOBAL:

url,
namedExports
namedExports,
exportType
});

@@ -300,3 +336,4 @@ case CSS_MODULE_TYPE_MODULE:

url,
namedExports
namedExports,
exportType
});

@@ -308,3 +345,4 @@ case CSS_MODULE_TYPE_AUTO:

url,
namedExports
namedExports,
exportType
});

@@ -561,4 +599,2 @@ }

set.add(RuntimeGlobals.makeNamespaceObject);
const CssLoadingRuntimeModule = getCssLoadingRuntimeModule();

@@ -610,2 +646,11 @@ compilation.addRuntimeModule(chunk, new CssLoadingRuntimeModule(set));

});
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.cssMergeStyleSheets)
.tap(PLUGIN_NAME, (chunk) => {
compilation.addRuntimeModule(
chunk,
new CssMergeStyleSheetsRuntimeModule()
);
});
}

@@ -776,14 +821,7 @@ );

* @param {CompilationHooks} hooks hooks
* @returns {Source} css module source
* @returns {Source | null} css module source
*/
renderModule(module, renderContext, hooks) {
const { codeGenerationResults, chunk, undoPath } = renderContext;
const codeGenResult = codeGenerationResults.get(module, chunk.runtime);
const moduleSourceContent =
/** @type {Source} */
(
codeGenResult.sources.get("css") ||
codeGenResult.sources.get("css-import")
);
const cacheEntry = this._moduleFactoryCache.get(moduleSourceContent);
static renderModule(module, renderContext, hooks) {
const { undoPath, moduleFactoryCache, moduleSourceContent } = renderContext;
const cacheEntry = moduleFactoryCache.get(moduleSourceContent);

@@ -810,2 +848,3 @@ /** @type {Inheritance} */

} else {
if (!moduleSourceContent) return null;
const moduleSourceCode =

@@ -865,3 +904,3 @@ /** @type {string} */

source = new CachedSource(moduleSource);
this._moduleFactoryCache.set(moduleSourceContent, {
moduleFactoryCache.set(moduleSourceContent, {
inheritance,

@@ -888,6 +927,6 @@ undoPath,

chunk,
chunkGraph,
codeGenerationResults,
modules,
runtimeTemplate
runtimeTemplate,
chunkGraph
},

@@ -899,3 +938,10 @@ hooks

try {
const moduleSource = this.renderModule(
const codeGenResult = codeGenerationResults.get(module, chunk.runtime);
const moduleSourceContent =
/** @type {Source} */
(
codeGenResult.sources.get("css") ||
codeGenResult.sources.get("css-import")
);
const moduleSource = CssModulesPlugin.renderModule(
module,

@@ -907,2 +953,4 @@ {

codeGenerationResults,
moduleSourceContent,
moduleFactoryCache: this._moduleFactoryCache,
runtimeTemplate

@@ -912,3 +960,5 @@ },

);
source.add(moduleSource);
if (moduleSource) {
source.add(moduleSource);
}
} catch (err) {

@@ -915,0 +965,0 @@ /** @type {Error} */

@@ -10,2 +10,3 @@ /*

const CommentCompilationWarning = require("../CommentCompilationWarning");
const CssModule = require("../CssModule");
const ModuleDependencyWarning = require("../ModuleDependencyWarning");

@@ -18,7 +19,9 @@ const { CSS_MODULE_TYPE_AUTO } = require("../ModuleTypeConstants");

const CssIcssExportDependency = require("../dependencies/CssIcssExportDependency");
const CssIcssFromIdentifierDependency = require("../dependencies/CssIcssFromIdentifierDependency");
const CssIcssGlobalIdentifierDependency = require("../dependencies/CssIcssGlobalIdentifierDependency");
const CssIcssImportDependency = require("../dependencies/CssIcssImportDependency");
const CssIcssLocalIdentifierDependency = require("../dependencies/CssIcssLocalIdentifierDependency");
const CssIcssSelfLocalIdentifierDependency = require("../dependencies/CssIcssSelfLocalIdentifierDependency");
const CssIcssSymbolDependency = require("../dependencies/CssIcssSymbolDependency");
const CssImportDependency = require("../dependencies/CssImportDependency");
const CssLocalIdentifierDependency = require("../dependencies/CssLocalIdentifierDependency");
const CssSelfLocalIdentifierDependency = require("../dependencies/CssSelfLocalIdentifierDependency");
const CssUrlDependency = require("../dependencies/CssUrlDependency");

@@ -39,2 +42,3 @@ const StaticExportsDependency = require("../dependencies/StaticExportsDependency");

/** @typedef {import("./walkCssTokens").CssTokenCallbacks} CssTokenCallbacks */
/** @typedef {import("../../declarations/WebpackOptions").CssParserExportType} CssParserExportType */

@@ -46,2 +50,4 @@ /** @typedef {[number, number]} Range */

const CC_COLON = ":".charCodeAt(0);
const CC_SEMICOLON = ";".charCodeAt(0);
const CC_COMMA = ",".charCodeAt(0);
const CC_SLASH = "/".charCodeAt(0);

@@ -52,2 +58,3 @@ const CC_LEFT_PARENTHESIS = "(".charCodeAt(0);

const CC_UPPER_F = "F".charCodeAt(0);
const CC_RIGHT_CURLY = "}".charCodeAt(0);

@@ -64,2 +71,3 @@ // https://www.w3.org/TR/css-syntax-3/#newline

/^(-\w+-)?animation(-name)?$/i;
const COMPOSES_PROPERTY = /^(composes|compose-with)$/i;
const IS_MODULES = /\.module(s)?\.[^.]+$/i;

@@ -239,2 +247,36 @@ const CSS_COMMENT = /\/\*((?!\*\/).*?)\*\//g;

/** @type {Record<string, number>} */
const ANIMATION_KEYWORDS = {
// animation-direction
normal: 1,
reverse: 1,
alternate: 1,
"alternate-reverse": 1,
// animation-fill-mode
forwards: 1,
backwards: 1,
both: 1,
// animation-iteration-count
infinite: 1,
// animation-play-state
paused: 1,
running: 1,
// animation-timing-function
ease: 1,
"ease-in": 1,
"ease-out": 1,
"ease-in-out": 1,
linear: 1,
"step-end": 1,
"step-start": 1,
// Special
none: Infinity, // No matter how many times you write none, it will never be an animation name
// Global values
initial: Infinity,
inherit: Infinity,
unset: Infinity,
revert: Infinity,
"revert-layer": Infinity
};
class LocConverter {

@@ -301,2 +343,3 @@ /**

* @property {boolean=} namedExports is named exports
* @property {CssParserExportType=} exportType export type
*/

@@ -312,3 +355,4 @@

url = true,
namedExports = true
namedExports = true,
exportType
} = {}) {

@@ -320,2 +364,3 @@ super();

this.namedExports = namedExports;
this.exportType = exportType;
/** @type {Comment[] | undefined} */

@@ -395,9 +440,9 @@ this.comments = undefined;

let modeData;
/** @type {boolean} */
let inAnimationProperty = false;
/** @type {[number, number, boolean] | undefined} */
let lastIdentifier;
/** @type {Set<string>} */
const declaredCssVariables = new Set();
/** @typedef {{ path?: string, value: string }} IcssDefinition */
/** @type {string[]} */
let lastLocalIdentifiers = [];
/** @typedef {{ value: string, isReference?: boolean }} IcssDefinition */
/** @type {Map<string, IcssDefinition>} */

@@ -463,3 +508,325 @@ const icssDefinitions = new Map();

const eatPropertyName = walkCssTokens.eatUntil(":{};");
/**
* @param {string} input input
* @param {number} start start
* @param {number} end end
* @returns {number} end
*/
const comment = (input, start, end) => {
if (!this.comments) this.comments = [];
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(end);
/** @type {Comment} */
const comment = {
value: input.slice(start + 2, end - 2),
range: [start, end],
loc: {
start: { line: sl, column: sc },
end: { line: el, column: ec }
}
};
this.comments.push(comment);
return end;
};
// Vanilla CSS stuff
/**
* @param {string} input input
* @param {number} start name start position
* @param {number} end name end position
* @returns {number} position after handling
*/
const processAtImport = (input, start, end) => {
const tokens = walkCssTokens.eatImportTokens(input, end, {
comment
});
if (!tokens[3]) return end;
const semi = tokens[3][1];
if (!tokens[0]) {
this._emitWarning(
state,
`Expected URL in '${input.slice(start, semi)}'`,
locConverter,
start,
semi
);
return end;
}
const urlToken = tokens[0];
const url = normalizeUrl(input.slice(urlToken[2], urlToken[3]), true);
const newline = walkCssTokens.eatWhiteLine(input, semi);
const { options, errors: commentErrors } = this.parseCommentOptions([
end,
urlToken[1]
]);
if (commentErrors) {
for (const e of commentErrors) {
const { comment } = e;
state.module.addWarning(
new CommentCompilationWarning(
`Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
comment.loc
)
);
}
}
if (options && options.webpackIgnore !== undefined) {
if (typeof options.webpackIgnore !== "boolean") {
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(newline);
state.module.addWarning(
new UnsupportedFeatureWarning(
`\`webpackIgnore\` expected a boolean, but received: ${options.webpackIgnore}.`,
{
start: { line: sl, column: sc },
end: { line: el, column: ec }
}
)
);
} else if (options.webpackIgnore) {
return newline;
}
}
if (url.length === 0) {
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(newline);
const dep = new ConstDependency("", [start, newline]);
module.addPresentationalDependency(dep);
dep.setLoc(sl, sc, el, ec);
return newline;
}
let layer;
if (tokens[1]) {
layer = input.slice(tokens[1][0] + 6, tokens[1][1] - 1).trim();
}
let supports;
if (tokens[2]) {
supports = input.slice(tokens[2][0] + 9, tokens[2][1] - 1).trim();
}
const last = tokens[2] || tokens[1] || tokens[0];
const mediaStart = walkCssTokens.eatWhitespaceAndComments(input, last[1]);
let media;
if (mediaStart !== semi - 1) {
media = input.slice(mediaStart, semi - 1).trim();
}
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(newline);
const dep = new CssImportDependency(
url,
[start, newline],
mode === "local" || mode === "global" ? mode : undefined,
layer,
supports && supports.length > 0 ? supports : undefined,
media && media.length > 0 ? media : undefined
);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
return newline;
};
/**
* @param {string} input input
* @param {number} end end position
* @param {string} name the name of function
* @returns {number} position after handling
*/
const processURLFunction = (input, end, name) => {
const string = walkCssTokens.eatString(input, end);
if (!string) return end;
const { options, errors: commentErrors } = this.parseCommentOptions([
lastTokenEndForComments,
end
]);
if (commentErrors) {
for (const e of commentErrors) {
const { comment } = e;
state.module.addWarning(
new CommentCompilationWarning(
`Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
comment.loc
)
);
}
}
if (options && options.webpackIgnore !== undefined) {
if (typeof options.webpackIgnore !== "boolean") {
const { line: sl, column: sc } = locConverter.get(string[0]);
const { line: el, column: ec } = locConverter.get(string[1]);
state.module.addWarning(
new UnsupportedFeatureWarning(
`\`webpackIgnore\` expected a boolean, but received: ${options.webpackIgnore}.`,
{
start: { line: sl, column: sc },
end: { line: el, column: ec }
}
)
);
} else if (options.webpackIgnore) {
return end;
}
}
const value = normalizeUrl(
input.slice(string[0] + 1, string[1] - 1),
true
);
// Ignore `url()`, `url('')` and `url("")`, they are valid by spec
if (value.length === 0) return end;
const isUrl = name === "url" || name === "src";
const dep = new CssUrlDependency(
value,
[string[0], string[1]],
isUrl ? "string" : "url"
);
const { line: sl, column: sc } = locConverter.get(string[0]);
const { line: el, column: ec } = locConverter.get(string[1]);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
module.addCodeGenerationDependency(dep);
return string[1];
};
/**
* @param {string} input input
* @param {number} start start position
* @param {number} end end position
* @param {number} contentStart start position
* @param {number} contentEnd end position
* @returns {number} position after handling
*/
const processOldURLFunction = (
input,
start,
end,
contentStart,
contentEnd
) => {
const { options, errors: commentErrors } = this.parseCommentOptions([
lastTokenEndForComments,
end
]);
if (commentErrors) {
for (const e of commentErrors) {
const { comment } = e;
state.module.addWarning(
new CommentCompilationWarning(
`Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
comment.loc
)
);
}
}
if (options && options.webpackIgnore !== undefined) {
if (typeof options.webpackIgnore !== "boolean") {
const { line: sl, column: sc } = locConverter.get(
lastTokenEndForComments
);
const { line: el, column: ec } = locConverter.get(end);
state.module.addWarning(
new UnsupportedFeatureWarning(
`\`webpackIgnore\` expected a boolean, but received: ${options.webpackIgnore}.`,
{
start: { line: sl, column: sc },
end: { line: el, column: ec }
}
)
);
} else if (options.webpackIgnore) {
return end;
}
}
const value = normalizeUrl(input.slice(contentStart, contentEnd), false);
// Ignore `url()`, `url('')` and `url("")`, they are valid by spec
if (value.length === 0) return end;
const dep = new CssUrlDependency(value, [start, end], "url");
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(end);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
module.addCodeGenerationDependency(dep);
return end;
};
/**
* @param {string} input input
* @param {number} start start position
* @param {number} end end position
* @returns {number} position after handling
*/
const processImageSetFunction = (input, start, end) => {
lastTokenEndForComments = end;
const values = walkCssTokens.eatImageSetStrings(input, end, {
comment
});
if (values.length === 0) return end;
for (const [index, string] of values.entries()) {
const value = normalizeUrl(
input.slice(string[0] + 1, string[1] - 1),
true
);
if (value.length === 0) return end;
const { options, errors: commentErrors } = this.parseCommentOptions([
index === 0 ? start : values[index - 1][1],
string[1]
]);
if (commentErrors) {
for (const e of commentErrors) {
const { comment } = e;
state.module.addWarning(
new CommentCompilationWarning(
`Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
comment.loc
)
);
}
}
if (options && options.webpackIgnore !== undefined) {
if (typeof options.webpackIgnore !== "boolean") {
const { line: sl, column: sc } = locConverter.get(string[0]);
const { line: el, column: ec } = locConverter.get(string[1]);
state.module.addWarning(
new UnsupportedFeatureWarning(
`\`webpackIgnore\` expected a boolean, but received: ${options.webpackIgnore}.`,
{
start: { line: sl, column: sc },
end: { line: el, column: ec }
}
)
);
} else if (options.webpackIgnore) {
continue;
}
}
const dep = new CssUrlDependency(value, [string[0], string[1]], "url");
const { line: sl, column: sc } = locConverter.get(string[0]);
const { line: el, column: ec } = locConverter.get(string[1]);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
module.addCodeGenerationDependency(dep);
}
// Can contain `url()` inside, so let's return end to allow parse them
return end;
};
// CSS modules stuff
/**
* @param {0 | 1} type import or export

@@ -470,6 +837,6 @@ * @param {string} input input

*/
const parseImportOrExport = (type, input, pos) => {
const processImportOrExport = (type, input, pos) => {
pos = walkCssTokens.eatWhitespaceAndComments(input, pos);
/** @type {string | undefined} */
let importPath;
let request;
if (type === 0) {

@@ -493,3 +860,3 @@ let cc = input.charCodeAt(pos);

state,
`Unexpected '${input[pos]}' at ${pos} during parsing of ':import' (expected string)`,
`Unexpected '${input[pos]}' at ${pos} during parsing of '${type ? ":import" : ":export"}' (expected string)`,
locConverter,

@@ -501,3 +868,3 @@ stringStart,

}
importPath = input.slice(str[0] + 1, str[1] - 1);
request = input.slice(str[0] + 1, str[1] - 1);
pos = str[1];

@@ -528,8 +895,24 @@ pos = walkCssTokens.eatWhitespaceAndComments(input, pos);

if (type === 0) {
icssDefinitions.set(name, {
path: /** @type {string} */ (importPath),
const dep = new CssIcssImportDependency(
/** @type {string} */
(request),
[0, 0],
/** @type {"local" | "global"} */
(mode),
value
});
);
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(end);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
icssDefinitions.set(name, { value, isReference: true });
} else if (type === 1) {
const dep = new CssIcssExportDependency(name, value);
const reexport = icssDefinitions.get(value);
const dep = new CssIcssExportDependency(
name,
value,
reexport && reexport.isReference ? reexport.value : undefined,
undefined
);
const { line: sl, column: sc } = locConverter.get(start);

@@ -624,5 +1007,368 @@ const { line: el, column: ec } = locConverter.get(end);

};
const eatPropertyName = walkCssTokens.eatUntil(":{};");
/**
* @param {string} input input
* @param {number} start name start position
* @param {number} end name end position
* @returns {number} position after handling
*/
const processAtValue = (input, start, end) => {
const semi = eatUntilSemi(input, end);
const atRuleEnd = semi + 1;
const params = input.slice(end, semi);
let [alias, request] = params.split(/\s*from\s*/);
if (request) {
const aliases = alias
.replace(CSS_COMMENT, " ")
.trim()
.replace(/^\(\s*|\s*\)$/g, "")
.split(/\s*,\s*/);
request = request.replace(CSS_COMMENT, "").trim();
const isExplicitImport = request[0] === "'" || request[0] === '"';
if (isExplicitImport) {
request = request.slice(1, -1);
}
for (const alias of aliases) {
const [name, aliasName] = alias.split(/\s+as\s+/);
{
const reexport = icssDefinitions.get(request);
if (reexport) {
request = reexport.value.slice(1, -1);
}
const dep = new CssIcssImportDependency(
request,
[0, 0],
/** @type {"local" | "global"} */
(mode),
name
);
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(end);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
icssDefinitions.set(aliasName || name, {
value: name,
isReference: true
});
}
if (aliasName) {
const reexport = icssDefinitions.get(aliasName);
const dep = new CssIcssExportDependency(
aliasName,
name,
reexport && reexport.isReference ? reexport.value : undefined,
undefined
);
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(end);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
}
{
const reexport = icssDefinitions.get(name);
const dep = new CssIcssExportDependency(
name,
name,
reexport && reexport.isReference ? reexport.value : undefined,
undefined
);
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(end);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
}
}
} else {
const ident = walkCssTokens.eatIdentSequence(alias, 0);
if (!ident) {
this._emitWarning(
state,
`Broken '@value' at-rule: ${input.slice(start, atRuleEnd)}'`,
locConverter,
start,
atRuleEnd
);
const dep = new ConstDependency("", [start, atRuleEnd]);
module.addPresentationalDependency(dep);
return atRuleEnd;
}
const pos = walkCssTokens.eatWhitespaceAndComments(alias, ident[1]);
const name = alias.slice(ident[0], ident[1]);
let value =
alias.charCodeAt(pos) === CC_COLON
? alias.slice(pos + 1)
: alias.slice(ident[1]);
if (value && !/^\s+$/.test(value.replace(CSS_COMMENT, ""))) {
value = value.trim();
}
if (icssDefinitions.has(value)) {
const def =
/** @type {IcssDefinition} */
(icssDefinitions.get(value));
value = def.value;
}
icssDefinitions.set(name, { value });
const dep = new CssIcssExportDependency(name, value);
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(end);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
}
const dep = new ConstDependency("", [start, atRuleEnd]);
module.addPresentationalDependency(dep);
return atRuleEnd;
};
/**
* @param {string} name ICSS symbol name
* @param {number} start start position
* @param {number} end end position
* @returns {number} position after handling
*/
const processICSSSymbol = (name, start, end) => {
const { value, isReference } =
/** @type {IcssDefinition} */
(icssDefinitions.get(name));
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(end);
const dep = new CssIcssSymbolDependency(
name,
value,
[start, end],
isReference
);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
return end;
};
/**
* @param {string} input input
* @param {1 | 2} type type of function
* @param {number} start start position
* @param {number} end end position
* @returns {number} position after handling
*/
const processLocalOrGlobalFunction = (input, type, start, end) => {
// Replace `local(`/` or `global(` (handle legacy `:local(` or `:global(` too)
{
const isColon = input.charCodeAt(start - 1) === CC_COLON;
const dep = new ConstDependency("", [isColon ? start - 1 : start, end]);
module.addPresentationalDependency(dep);
}
end = walkCssTokens.consumeUntil(
input,
start,
type === 1
? {
identifier(input, start, end) {
const name = unescapeIdentifier(input.slice(start, end));
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(end);
const dep = new CssIcssLocalIdentifierDependency(name, [
start,
end
]);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
return end;
}
}
: {},
{},
{ onlyTopLevel: true, functionValue: true }
);
{
// Replace the last `)`
const dep = new ConstDependency("", [end, end + 1]);
module.addPresentationalDependency(dep);
}
return end;
};
/**
* @param {string} input input
* @param {number} end name end position
* @param {{ string?: boolean, identifier: boolean, validate?: (name: string) => boolean, dashed?: boolean }} options types which allowed to handle
* @returns {number} position after handling
*/
const processLocalAtRule = (input, end, options) => {
/** @type {[number, number, boolean] | undefined} */
let value;
let found = false;
walkCssTokens.consumeUntil(
input,
end,
{
string(_input, start, end) {
if (!found && options.string) {
found = true;
value = [start, end, true];
}
return end;
},
identifier(_input, start, end) {
if (!found && options.identifier) {
found = true;
value = [start, end, false];
}
return end;
}
},
{
function(input, start, end) {
// No need to handle `:` (COLON), because it's always a function
const name = input
.slice(start, end - 1)
.replace(/\\/g, "")
.toLowerCase();
const type =
name === "local" ? 1 : name === "global" ? 2 : undefined;
if (!found && type) {
found = true;
return processLocalOrGlobalFunction(input, type, start, end);
}
return end;
}
},
{ onlyTopLevel: true, atRulePrelude: true }
);
if (!value) return end;
let name = value[2]
? input.slice(value[0] + 1, value[1] - 1)
: input.slice(value[0], value[1]);
if (options.validate && !options.validate(name)) return end;
name = unescapeIdentifier(name);
const { line: sl, column: sc } = locConverter.get(value[0]);
const { line: el, column: ec } = locConverter.get(value[1]);
if (options.dashed) {
name = name.slice(2);
declaredCssVariables.add(name);
}
const dep = new CssIcssLocalIdentifierDependency(
name,
[value[0], value[1]],
options.dashed ? "--" : ""
);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
return value[1];
};
/**
* @param {string} input input
* @param {number} end end position
* @returns {number} position after handling
*/
const processVarFunction = (input, end) => {
const customIdent = walkCssTokens.eatIdentSequence(input, end);
if (!customIdent) return end;
let name = input.slice(customIdent[0], customIdent[1]);
// A custom property is any property whose name starts with two dashes (U+002D HYPHEN-MINUS), like --foo.
// The <custom-property-name> production corresponds to this:
// it’s defined as any <dashed-ident> (a valid identifier that starts with two dashes),
// except -- itself, which is reserved for future use by CSS.
if (!name.startsWith("--") || name.length < 3) return end;
name = unescapeIdentifier(
input.slice(customIdent[0] + 2, customIdent[1])
);
const afterCustomIdent = walkCssTokens.eatWhitespaceAndComments(
input,
customIdent[1]
);
if (
input.charCodeAt(afterCustomIdent) === CC_LOWER_F ||
input.charCodeAt(afterCustomIdent) === CC_UPPER_F
) {
const fromWord = walkCssTokens.eatIdentSequence(
input,
afterCustomIdent
);
if (
!fromWord ||
input.slice(fromWord[0], fromWord[1]).toLowerCase() !== "from"
) {
return end;
}
const from = walkCssTokens.eatIdentSequenceOrString(
input,
walkCssTokens.eatWhitespaceAndComments(input, fromWord[1])
);
if (!from) {
return end;
}
const path = input.slice(from[0], from[1]);
if (from[2] === true && path === "global") {
const dep = new ConstDependency("", [customIdent[1], from[1]]);
module.addPresentationalDependency(dep);
return end;
} else if (from[2] === false) {
const { line: sl, column: sc } = locConverter.get(customIdent[0]);
const { line: el, column: ec } = locConverter.get(from[1] - 1);
const dep = new CssIcssFromIdentifierDependency(
path.slice(1, -1),
/** @type {"local" | "global"} */
(mode),
[customIdent[0], from[1] - 1],
name,
name,
"--"
);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
{
const dep = new ConstDependency("", [fromWord[0], from[1]]);
module.addPresentationalDependency(dep);
return end;
}
}
} else {
const { line: sl, column: sc } = locConverter.get(customIdent[0]);
const { line: el, column: ec } = locConverter.get(customIdent[1]);
const dep = new CssIcssSelfLocalIdentifierDependency(
name,
undefined,
[customIdent[0], customIdent[1]],
"--",
declaredCssVariables
);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
return end;
}
return end;
};
/**
* @param {string} input input
* @param {number} pos name start position

@@ -648,3 +1394,3 @@ * @param {number} end name end position

const name = unescapeIdentifier(propertyName.slice(2));
const dep = new CssLocalIdentifierDependency(
const dep = new CssIcssLocalIdentifierDependency(
name,

@@ -660,49 +1406,291 @@ [propertyNameStart, propertyNameEnd],

) {
inAnimationProperty = true;
/** @type {[number, number, boolean][]} */
const animationNames = [];
/** @type {Record<string, number>} */
let parsedAnimationKeywords = Object.create(null);
const end = walkCssTokens.consumeUntil(
input,
pos,
{
string(_input, start, end) {
animationNames.push([start, end, true]);
return end;
},
identifier(input, start, end) {
const keyword = input.slice(start, end).toLowerCase();
parsedAnimationKeywords[keyword] =
typeof parsedAnimationKeywords[keyword] !== "undefined"
? parsedAnimationKeywords[keyword] + 1
: 0;
if (
ANIMATION_KEYWORDS[keyword] &&
parsedAnimationKeywords[keyword] < ANIMATION_KEYWORDS[keyword]
) {
return end;
}
animationNames.push([start, end, false]);
return end;
},
comma(_input, _start, end) {
parsedAnimationKeywords = {};
return end;
}
},
{
function(input, start, end) {
const name = input
.slice(start, end - 1)
.replace(/\\/g, "")
.toLowerCase();
if (isLocalMode() && name === "var") {
return processVarFunction(input, end);
}
const type =
name === "local" ? 1 : name === "global" ? 2 : undefined;
if (type) {
return processLocalOrGlobalFunction(input, type, start, end);
}
return end;
}
},
{ onlyTopLevel: true, declarationValue: true }
);
if (animationNames.length > 0) {
for (const animationName of animationNames) {
const { line: sl, column: sc } = locConverter.get(animationName[0]);
const { line: el, column: ec } = locConverter.get(animationName[1]);
const [start, end, isString] = animationName;
const name = unescapeIdentifier(
isString
? input.slice(start + 1, end - 1)
: input.slice(start, end)
);
const dep = new CssIcssSelfLocalIdentifierDependency(
name,
undefined,
[start, end]
);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
}
}
return end;
} else if (COMPOSES_PROPERTY.test(propertyName)) {
if (lastLocalIdentifiers.length > 1) {
const end = eatUntilSemi(input, pos);
this._emitWarning(
state,
`Composition is only allowed when selector is single local class name not in "${lastLocalIdentifiers.join('", "')}"`,
locConverter,
pos,
end
);
return end;
}
if (lastLocalIdentifiers.length !== 1) return pos;
const lastLocalIdentifier = lastLocalIdentifiers[0];
let end = pos;
/** @type {Set<[number, number]>} */
const classNames = new Set();
while (true) {
pos = walkCssTokens.eatWhitespaceAndComments(input, pos);
let className = walkCssTokens.eatIdentSequence(input, pos);
const ifFunction =
className && input.charCodeAt(className[1]) === CC_LEFT_PARENTHESIS;
let isGlobalFunction = false;
if (className && ifFunction) {
const name = input
.slice(className[0], className[1])
.replace(/\\/g, "")
.toLowerCase();
isGlobalFunction = name === "global";
pos = walkCssTokens.eatWhitespaceAndComments(
input,
className[1] + 1
);
className = walkCssTokens.eatIdentSequence(input, pos);
if (className) {
pos = walkCssTokens.eatWhitespaceAndComments(input, className[1]);
pos += 1;
}
} else if (className) {
pos = walkCssTokens.eatWhitespaceAndComments(input, className[1]);
pos = className[1];
}
// True when we have multiple values
const isComma = input.charCodeAt(pos) === CC_COMMA;
const isSemicolon = input.charCodeAt(pos) === CC_SEMICOLON;
const isRightCurly = input.charCodeAt(pos) === CC_RIGHT_CURLY;
if (isComma || isSemicolon || isRightCurly) {
if (className) {
classNames.add(className);
}
for (const className of classNames) {
const [start, end] = className;
const identifier = unescapeIdentifier(input.slice(start, end));
const reexport = icssDefinitions.get(identifier);
const dep = isGlobalFunction
? new CssIcssGlobalIdentifierDependency(
lastLocalIdentifier,
identifier,
reexport && reexport.isReference
? reexport.value
: undefined,
[start, end]
)
: new CssIcssSelfLocalIdentifierDependency(
lastLocalIdentifier,
identifier,
[start, end],
undefined,
undefined,
reexport && reexport.isReference
? reexport.value
: undefined
);
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(end);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
}
classNames.clear();
if (isSemicolon || isRightCurly) {
end = isSemicolon
? walkCssTokens.eatWhitespace(input, pos + 1)
: pos;
break;
}
pos += 1;
} else if (
classNames.size > 0 &&
className &&
input.slice(className[0], className[1]).toLowerCase() === "from"
) {
let from = walkCssTokens.eatString(input, pos);
if (from) {
const request = input.slice(from[0] + 1, from[1] - 1);
for (const className of classNames) {
const [start, end] = className;
const identifier = unescapeIdentifier(input.slice(start, end));
const dep = new CssIcssFromIdentifierDependency(
request,
/** @type {"local" | "global"} */
(mode),
[start, end],
identifier,
/** @type {string} */
(lastLocalIdentifier)
);
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(end);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
}
classNames.clear();
pos = from[1];
} else {
from = walkCssTokens.eatIdentSequence(input, pos);
if (from && input.slice(from[0], from[1]) === "global") {
for (const className of classNames) {
const [start, end] = className;
const identifier = unescapeIdentifier(
input.slice(start, end)
);
const reexport = icssDefinitions.get(identifier);
const dep = new CssIcssGlobalIdentifierDependency(
/** @type {string} */
(lastLocalIdentifier),
identifier,
reexport && reexport.isReference
? reexport.value
: undefined,
[start, end]
);
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(end);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
}
classNames.clear();
pos = from[1];
} else {
const end = eatUntilSemi(input, pos);
this._emitWarning(
state,
"Incorrect composition, expected global keyword or string value",
locConverter,
pos,
end
);
return end;
}
}
} else if (className) {
classNames.add(className);
} else {
const end = eatUntilSemi(input, pos);
this._emitWarning(
state,
"Incorrect composition, expected class named",
locConverter,
pos,
end
);
return end;
}
}
// Remove `composes` from source code
const dep = new ConstDependency("", [propertyNameStart, end]);
module.addPresentationalDependency(dep);
}
return pos;
};
/**
* @param {string} input input
*/
const processDeclarationValueDone = (input) => {
if (inAnimationProperty && lastIdentifier) {
const { line: sl, column: sc } = locConverter.get(lastIdentifier[0]);
const { line: el, column: ec } = locConverter.get(lastIdentifier[1]);
const name = unescapeIdentifier(
lastIdentifier[2]
? input.slice(lastIdentifier[0], lastIdentifier[1])
: input.slice(lastIdentifier[0] + 1, lastIdentifier[1] - 1)
);
const dep = new CssSelfLocalIdentifierDependency(name, [
lastIdentifier[0],
lastIdentifier[1]
]);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
lastIdentifier = undefined;
}
};
/**
* @param {string} input input
* @param {number} start start
* @param {number} end end
* @returns {number} end
* @param {number} start start position
* @param {number} end end position
* @returns {number} position after handling
*/
const comment = (input, start, end) => {
if (!this.comments) this.comments = [];
const processHashID = (input, start, end) => {
const valueStart = start + 1;
const name = unescapeIdentifier(input.slice(valueStart, end));
const dep = new CssIcssLocalIdentifierDependency(name, [valueStart, end]);
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(end);
/** @type {Comment} */
const comment = {
value: input.slice(start + 2, end - 2),
range: [start, end],
loc: {
start: { line: sl, column: sc },
end: { line: el, column: ec }
}
};
this.comments.push(comment);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
return end;

@@ -745,9 +1733,5 @@ };

modeData = undefined;
lastLocalIdentifiers = [];
}
} else if (isModules) {
if (isLocalMode()) {
processDeclarationValueDone(input);
inAnimationProperty = false;
}
isNextRulePrelude = isNextNestedSyntax(input, end);

@@ -765,61 +1749,10 @@ }

const { options, errors: commentErrors } = this.parseCommentOptions([
lastTokenEndForComments,
end
]);
if (commentErrors) {
for (const e of commentErrors) {
const { comment } = e;
state.module.addWarning(
new CommentCompilationWarning(
`Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
comment.loc
)
);
}
}
if (options && options.webpackIgnore !== undefined) {
if (typeof options.webpackIgnore !== "boolean") {
const { line: sl, column: sc } = locConverter.get(
lastTokenEndForComments
);
const { line: el, column: ec } = locConverter.get(end);
state.module.addWarning(
new UnsupportedFeatureWarning(
`\`webpackIgnore\` expected a boolean, but received: ${options.webpackIgnore}.`,
{
start: { line: sl, column: sc },
end: { line: el, column: ec }
}
)
);
} else if (options.webpackIgnore) {
return end;
}
}
const value = normalizeUrl(
input.slice(contentStart, contentEnd),
false
return processOldURLFunction(
input,
start,
end,
contentStart,
contentEnd
);
// Ignore `url()`, `url('')` and `url("")`, they are valid by spec
if (value.length === 0) return end;
const dep = new CssUrlDependency(value, [start, end], "url");
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(end);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
module.addCodeGenerationDependency(dep);
return end;
},
string: (_input, start, end) => {
switch (scope) {
case CSS_MODE_IN_BLOCK: {
if (inAnimationProperty && balanced.length === 0) {
lastIdentifier = [start, end, false];
}
}
}
return end;
},
atKeyword: (input, start, end) => {

@@ -856,103 +1789,3 @@ const name = input.slice(start, end).toLowerCase();

const tokens = walkCssTokens.eatImportTokens(input, end, {
comment
});
if (!tokens[3]) return end;
const semi = tokens[3][1];
if (!tokens[0]) {
this._emitWarning(
state,
`Expected URL in '${input.slice(start, semi)}'`,
locConverter,
start,
semi
);
return end;
}
const urlToken = tokens[0];
const url = normalizeUrl(
input.slice(urlToken[2], urlToken[3]),
true
);
const newline = walkCssTokens.eatWhiteLine(input, semi);
const { options, errors: commentErrors } = this.parseCommentOptions(
[end, urlToken[1]]
);
if (commentErrors) {
for (const e of commentErrors) {
const { comment } = e;
state.module.addWarning(
new CommentCompilationWarning(
`Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
comment.loc
)
);
}
}
if (options && options.webpackIgnore !== undefined) {
if (typeof options.webpackIgnore !== "boolean") {
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(newline);
state.module.addWarning(
new UnsupportedFeatureWarning(
`\`webpackIgnore\` expected a boolean, but received: ${options.webpackIgnore}.`,
{
start: { line: sl, column: sc },
end: { line: el, column: ec }
}
)
);
} else if (options.webpackIgnore) {
return newline;
}
}
if (url.length === 0) {
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(newline);
const dep = new ConstDependency("", [start, newline]);
module.addPresentationalDependency(dep);
dep.setLoc(sl, sc, el, ec);
return newline;
}
let layer;
if (tokens[1]) {
layer = input.slice(tokens[1][0] + 6, tokens[1][1] - 1).trim();
}
let supports;
if (tokens[2]) {
supports = input.slice(tokens[2][0] + 9, tokens[2][1] - 1).trim();
}
const last = tokens[2] || tokens[1] || tokens[0];
const mediaStart = walkCssTokens.eatWhitespaceAndComments(
input,
last[1]
);
let media;
if (mediaStart !== semi - 1) {
media = input.slice(mediaStart, semi - 1).trim();
}
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(newline);
const dep = new CssImportDependency(
url,
[start, newline],
layer,
supports && supports.length > 0 ? supports : undefined,
media && media.length > 0 ? media : undefined
);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
return newline;
return processAtImport(input, start, end);
}

@@ -962,85 +1795,3 @@ default: {

if (name === "@value") {
const semi = eatUntilSemi(input, end);
const atRuleEnd = semi + 1;
const params = input.slice(end, semi);
let [alias, from] = params.split(/\s*from\s*/);
if (from) {
const aliases = alias
.replace(CSS_COMMENT, " ")
.trim()
.replace(/^\(|\)$/g, "")
.split(/\s*,\s*/);
from = from.replace(CSS_COMMENT, "").trim();
const isExplicitImport = from[0] === "'" || from[0] === '"';
if (isExplicitImport) {
from = from.slice(1, -1);
}
for (const alias of aliases) {
const [name, aliasName] = alias.split(/\s*as\s*/);
icssDefinitions.set(aliasName || name, {
value: name,
path: from
});
}
} else {
const ident = walkCssTokens.eatIdentSequence(alias, 0);
if (!ident) {
this._emitWarning(
state,
`Broken '@value' at-rule: ${input.slice(
start,
atRuleEnd
)}'`,
locConverter,
start,
atRuleEnd
);
const dep = new ConstDependency("", [start, atRuleEnd]);
module.addPresentationalDependency(dep);
return atRuleEnd;
}
const pos = walkCssTokens.eatWhitespaceAndComments(
alias,
ident[1]
);
const name = alias.slice(ident[0], ident[1]);
let value =
alias.charCodeAt(pos) === CC_COLON
? alias.slice(pos + 1)
: alias.slice(ident[1]);
if (value && !/^\s+$/.test(value)) {
value = value.trim();
}
if (icssDefinitions.has(value)) {
const def =
/** @type {IcssDefinition} */
(icssDefinitions.get(value));
value = def.value;
}
icssDefinitions.set(name, { value });
const dep = new CssIcssExportDependency(name, value);
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(end);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
}
const dep = new ConstDependency("", [start, atRuleEnd]);
module.addPresentationalDependency(dep);
return atRuleEnd;
return processAtValue(input, start, end);
} else if (

@@ -1050,38 +1801,12 @@ OPTIONALLY_VENDOR_PREFIXED_KEYFRAMES_AT_RULE.test(name) &&

) {
const ident = walkCssTokens.eatIdentSequenceOrString(
input,
end
);
if (!ident) return end;
const name = unescapeIdentifier(
ident[2] === true
? input.slice(ident[0], ident[1])
: input.slice(ident[0] + 1, ident[1] - 1)
);
const { line: sl, column: sc } = locConverter.get(ident[0]);
const { line: el, column: ec } = locConverter.get(ident[1]);
const dep = new CssLocalIdentifierDependency(name, [
ident[0],
ident[1]
]);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
return ident[1];
return processLocalAtRule(input, end, {
string: true,
identifier: true
});
} else if (name === "@property" && isLocalMode()) {
const ident = walkCssTokens.eatIdentSequence(input, end);
if (!ident) return end;
let name = input.slice(ident[0], ident[1]);
if (!name.startsWith("--") || name.length < 3) return end;
name = unescapeIdentifier(name.slice(2));
declaredCssVariables.add(name);
const { line: sl, column: sc } = locConverter.get(ident[0]);
const { line: el, column: ec } = locConverter.get(ident[1]);
const dep = new CssLocalIdentifierDependency(
name,
[ident[0], ident[1]],
"--"
);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
return ident[1];
return processLocalAtRule(input, end, {
identifier: true,
dashed: true,
validate: (name) => name.startsWith("--") && name.length >= 3
});
} else if (name === "@scope") {

@@ -1101,7 +1826,2 @@ isNextRulePrelude = true;

if (isModules && scope === CSS_MODE_IN_BLOCK) {
if (isLocalMode()) {
processDeclarationValueDone(input);
inAnimationProperty = false;
}
isNextRulePrelude = isNextNestedSyntax(input, end);

@@ -1116,35 +1836,3 @@ }

if (icssDefinitions.has(name)) {
let { path, value } =
/** @type {IcssDefinition} */
(icssDefinitions.get(name));
if (path) {
if (icssDefinitions.has(path)) {
const definition =
/** @type {IcssDefinition} */
(icssDefinitions.get(path));
path = definition.value.slice(1, -1);
}
const dep = new CssIcssImportDependency(path, value, [
start,
end - 1
]);
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(end - 1);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
} else {
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(end);
const dep = new CssIcssSymbolDependency(name, value, [
start,
end
]);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
}
return end;
return processICSSSymbol(name, start, end);
}

@@ -1156,7 +1844,3 @@

// Handle only top level values and not inside functions
if (inAnimationProperty && balanced.length === 0) {
lastIdentifier = [start, end, true];
} else {
return processLocalDeclaration(input, start, end);
}
return processLocalDeclaration(input, start, end);
}

@@ -1178,3 +1862,4 @@ break;

const name = unescapeIdentifier(input.slice(ident[0], ident[1]));
const dep = new CssLocalIdentifierDependency(name, [
lastLocalIdentifiers.push(name);
const dep = new CssIcssLocalIdentifierDependency(name, [
ident[0],

@@ -1194,9 +1879,3 @@ ident[1]

if (isNextRulePrelude && isLocalMode() && isID) {
const valueStart = start + 1;
const name = unescapeIdentifier(input.slice(valueStart, end));
const dep = new CssLocalIdentifierDependency(name, [valueStart, end]);
const { line: sl, column: sc } = locConverter.get(start);
const { line: el, column: ec } = locConverter.get(end);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
return processHashID(input, start, end);
}

@@ -1218,3 +1897,3 @@

if (name === "import") {
const pos = parseImportOrExport(0, input, ident[1]);
const pos = processImportOrExport(0, input, ident[1]);
const dep = new ConstDependency("", [start, pos]);

@@ -1224,3 +1903,3 @@ module.addPresentationalDependency(dep);

} else if (name === "export") {
const pos = parseImportOrExport(1, input, ident[1]);
const pos = processImportOrExport(1, input, ident[1]);
const dep = new ConstDependency("", [start, pos]);

@@ -1237,3 +1916,4 @@ module.addPresentationalDependency(dep);

if (isFn && name === "local") {
const end = ident[1] + 1;
// Eat extra whitespace
const end = walkCssTokens.eatWhitespace(input, ident[1] + 1);
modeData = "local";

@@ -1266,3 +1946,4 @@ const dep = new ConstDependency("", [start, end]);

} else if (isFn && name === "global") {
const end = ident[1] + 1;
// Eat extra whitespace
const end = walkCssTokens.eatWhitespace(input, ident[1] + 1);
modeData = "global";

@@ -1319,204 +2000,9 @@ const dep = new ConstDependency("", [start, end]);

const string = walkCssTokens.eatString(input, end);
if (!string) return end;
const { options, errors: commentErrors } = this.parseCommentOptions(
[lastTokenEndForComments, end]
);
if (commentErrors) {
for (const e of commentErrors) {
const { comment } = e;
state.module.addWarning(
new CommentCompilationWarning(
`Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
comment.loc
)
);
}
}
if (options && options.webpackIgnore !== undefined) {
if (typeof options.webpackIgnore !== "boolean") {
const { line: sl, column: sc } = locConverter.get(string[0]);
const { line: el, column: ec } = locConverter.get(string[1]);
state.module.addWarning(
new UnsupportedFeatureWarning(
`\`webpackIgnore\` expected a boolean, but received: ${options.webpackIgnore}.`,
{
start: { line: sl, column: sc },
end: { line: el, column: ec }
}
)
);
} else if (options.webpackIgnore) {
return end;
}
}
const value = normalizeUrl(
input.slice(string[0] + 1, string[1] - 1),
true
);
// Ignore `url()`, `url('')` and `url("")`, they are valid by spec
if (value.length === 0) return end;
const isUrl = name === "url" || name === "src";
const dep = new CssUrlDependency(
value,
[string[0], string[1]],
isUrl ? "string" : "url"
);
const { line: sl, column: sc } = locConverter.get(string[0]);
const { line: el, column: ec } = locConverter.get(string[1]);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
module.addCodeGenerationDependency(dep);
return string[1];
return processURLFunction(input, end, name);
}
default: {
if (this.url && IMAGE_SET_FUNCTION.test(name)) {
lastTokenEndForComments = end;
const values = walkCssTokens.eatImageSetStrings(input, end, {
comment
});
if (values.length === 0) return end;
for (const [index, string] of values.entries()) {
const value = normalizeUrl(
input.slice(string[0] + 1, string[1] - 1),
true
);
if (value.length === 0) return end;
const { options, errors: commentErrors } =
this.parseCommentOptions([
index === 0 ? start : values[index - 1][1],
string[1]
]);
if (commentErrors) {
for (const e of commentErrors) {
const { comment } = e;
state.module.addWarning(
new CommentCompilationWarning(
`Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
comment.loc
)
);
}
}
if (options && options.webpackIgnore !== undefined) {
if (typeof options.webpackIgnore !== "boolean") {
const { line: sl, column: sc } = locConverter.get(
string[0]
);
const { line: el, column: ec } = locConverter.get(
string[1]
);
state.module.addWarning(
new UnsupportedFeatureWarning(
`\`webpackIgnore\` expected a boolean, but received: ${options.webpackIgnore}.`,
{
start: { line: sl, column: sc },
end: { line: el, column: ec }
}
)
);
} else if (options.webpackIgnore) {
continue;
}
}
const dep = new CssUrlDependency(
value,
[string[0], string[1]],
"url"
);
const { line: sl, column: sc } = locConverter.get(string[0]);
const { line: el, column: ec } = locConverter.get(string[1]);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
module.addCodeGenerationDependency(dep);
}
// Can contain `url()` inside, so let's return end to allow parse them
return end;
} else if (isLocalMode()) {
// Don't rename animation name when we have `var()` function
if (inAnimationProperty && balanced.length === 1) {
lastIdentifier = undefined;
}
if (name === "var") {
const customIdent = walkCssTokens.eatIdentSequence(input, end);
if (!customIdent) return end;
let name = input.slice(customIdent[0], customIdent[1]);
// A custom property is any property whose name starts with two dashes (U+002D HYPHEN-MINUS), like --foo.
// The <custom-property-name> production corresponds to this:
// it’s defined as any <dashed-ident> (a valid identifier that starts with two dashes),
// except -- itself, which is reserved for future use by CSS.
if (!name.startsWith("--") || name.length < 3) return end;
name = unescapeIdentifier(
input.slice(customIdent[0] + 2, customIdent[1])
);
const afterCustomIdent = walkCssTokens.eatWhitespaceAndComments(
input,
customIdent[1]
);
if (
input.charCodeAt(afterCustomIdent) === CC_LOWER_F ||
input.charCodeAt(afterCustomIdent) === CC_UPPER_F
) {
const fromWord = walkCssTokens.eatIdentSequence(
input,
afterCustomIdent
);
if (
!fromWord ||
input.slice(fromWord[0], fromWord[1]).toLowerCase() !==
"from"
) {
return end;
}
const from = walkCssTokens.eatIdentSequenceOrString(
input,
walkCssTokens.eatWhitespaceAndComments(input, fromWord[1])
);
if (!from) {
return end;
}
const path = input.slice(from[0], from[1]);
if (from[2] === true && path === "global") {
const dep = new ConstDependency("", [
customIdent[1],
from[1]
]);
module.addPresentationalDependency(dep);
return end;
} else if (from[2] === false) {
const dep = new CssIcssImportDependency(
path.slice(1, -1),
name,
[customIdent[0], from[1] - 1]
);
const { line: sl, column: sc } = locConverter.get(
customIdent[0]
);
const { line: el, column: ec } = locConverter.get(
from[1] - 1
);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
}
} else {
const { line: sl, column: sc } = locConverter.get(
customIdent[0]
);
const { line: el, column: ec } = locConverter.get(
customIdent[1]
);
const dep = new CssSelfLocalIdentifierDependency(
name,
[customIdent[0], customIdent[1]],
"--",
declaredCssVariables
);
dep.setLoc(sl, sc, el, ec);
module.addDependency(dep);
return end;
}
}
return processImageSetFunction(input, start, end);
} else if (isLocalMode() && name === "var") {
return processVarFunction(input, end);
}

@@ -1553,7 +2039,7 @@ }

if (isModules) {
// Reset stack for `:global .class :local .class-other` selector after
modeData = undefined;
const popped = balanced.pop();
if (scope === CSS_MODE_IN_BLOCK && isLocalMode()) {
processDeclarationValueDone(input);
if (!popped) {
// Reset stack for `:global .class :local .class-other` selector after
modeData = undefined;
}

@@ -1570,13 +2056,34 @@ }

(module.buildInfo).strict = true;
/** @type {BuildMeta} */
(module.buildMeta).exportsType = this.namedExports
? "namespace"
: "default";
if (!this.namedExports) {
/** @type {BuildMeta} */
(module.buildMeta).defaultObject = "redirect";
const buildMeta = /** @type {BuildMeta} */ (state.module.buildMeta);
buildMeta.exportsType = this.namedExports ? "namespace" : "default";
buildMeta.defaultObject = this.namedExports ? false : "redirect-warn";
buildMeta.exportType = this.exportType;
if (!buildMeta.exportType) {
// Inherit exportType from parent module to ensure consistency.
// When a CSS file is imported with syntax like `import "./basic.css" with { type: "css" }`,
// the parent module's exportType is set to "css-style-sheet".
// Child modules imported via @import should inherit this exportType
// instead of using the default "link", ensuring that the entire
// import chain uses the same export format.
const parent = state.compilation.moduleGraph.getIssuer(module);
if (parent instanceof CssModule) {
buildMeta.exportType = /** @type {BuildMeta} */ (
parent.buildMeta
).exportType;
}
}
module.addDependency(new StaticExportsDependency([], true));
// TODO this.namedExports?
if (
buildMeta.exportType === "text" ||
buildMeta.exportType === "css-style-sheet"
) {
module.addDependency(new StaticExportsDependency(["default"], true));
} else {
module.addDependency(new StaticExportsDependency([], true));
}
return state;

@@ -1583,0 +2090,0 @@ }

@@ -1201,2 +1201,98 @@ /*

/**
* @param {string} input input css
* @param {number} pos pos
* @param {CssTokenCallbacks} callbacks callbacks
* @param {CssTokenCallbacks} additional additional callbacks
* @param {{ onlyTopLevel?: boolean, declarationValue?: boolean, atRulePrelude?: boolean, functionValue?: boolean }=} options options
* @returns {number} pos
*/
const consumeUntil = (input, pos, callbacks, additional, options = {}) => {
let needHandle = true;
let needTerminate = false;
/** @type {CssTokenCallbacks} */
const servicedCallbacks = {};
let balanced = 0;
if (options.onlyTopLevel) {
servicedCallbacks.function = (input, start, end) => {
balanced++;
if (!options.functionValue) {
needHandle = false;
}
if (additional.function !== undefined) {
return additional.function(input, start, end);
}
return end;
};
servicedCallbacks.leftParenthesis = (_input, _start, end) => {
balanced++;
needHandle = false;
return end;
};
servicedCallbacks.rightParenthesis = (_input, _start, end) => {
balanced--;
if (balanced === 0) {
needHandle = true;
}
return end;
};
}
if (options.declarationValue) {
servicedCallbacks.semicolon = (_input, _start, end) => {
needTerminate = true;
return end;
};
servicedCallbacks.rightCurlyBracket = (_input, _start, end) => {
needTerminate = true;
return end;
};
} else if (options.functionValue) {
servicedCallbacks.rightParenthesis = (_input, _start, end) => {
balanced--;
if (balanced === 0) {
needTerminate = true;
}
return end;
};
} else if (options.atRulePrelude) {
servicedCallbacks.leftCurlyBracket = (_input, _start, end) => {
needTerminate = true;
return end;
};
}
while (pos < input.length) {
// Consume comments.
pos = consumeComments(
input,
pos,
needHandle ? { ...servicedCallbacks, ...callbacks } : servicedCallbacks
);
const start = pos;
// Consume the next input code point.
pos++;
pos = consumeAToken(
input,
pos,
needHandle ? { ...servicedCallbacks, ...callbacks } : servicedCallbacks
);
if (needTerminate) {
return start;
}
}
return pos;
};
/**
* @param {string} input input

@@ -1612,2 +1708,3 @@ * @param {number} pos position

module.exports.consumeUntil = consumeUntil;
module.exports.eatComments = eatComments;

@@ -1614,0 +1711,0 @@ module.exports.eatIdentSequence = eatIdentSequence;

@@ -33,5 +33,9 @@ /*

// Avoid override `layer` for `Module` class, because it is a feature to run module in specific layer
/** @type {CSSModuleCreateData['cssLayer']} */
this.cssLayer = options.cssLayer;
/** @type {CSSModuleCreateData['supports']} */
this.supports = options.supports;
/** @type {CSSModuleCreateData['media']} */
this.media = options.media;
/** @type {CSSModuleCreateData['inheritance']} */
this.inheritance = options.inheritance;

@@ -154,3 +158,4 @@ }

media: /** @type {EXPECTED_ANY} */ (null),
inheritance: /** @type {EXPECTED_ANY} */ (null)
inheritance: /** @type {EXPECTED_ANY} */ (null),
extractSourceMap: /** @type {EXPECTED_ANY} */ (null)
});

@@ -157,0 +162,0 @@ obj.deserialize(context);

@@ -357,16 +357,16 @@ /*

apply(compiler) {
const definitions = this.definitions;
/**
* @type {Map<string, Set<string>>}
*/
const finalByNestedKey = new Map();
/**
* @type {Map<string, Set<string>>}
*/
const nestedByFinalKey = new Map();
compiler.hooks.compilation.tap(
PLUGIN_NAME,
(compilation, { normalModuleFactory }) => {
const definitions = this.definitions;
/**
* @type {Map<string, Set<string>>}
*/
const finalByNestedKey = new Map();
/**
* @type {Map<string, Set<string>>}
*/
const nestedByFinalKey = new Map();
const logger = compilation.getLogger("webpack.DefinePlugin");

@@ -373,0 +373,0 @@ compilation.dependencyTemplates.set(

@@ -129,11 +129,2 @@ /*

// #region Unsupported
parser.hooks.expression
.for("require.main")
.tap(
PLUGIN_NAME,
expressionIsUnsupported(
parser,
"require.main is not supported by webpack."
)
);
parser.hooks.call

@@ -140,0 +131,0 @@ .for("require.main.require")

@@ -18,2 +18,3 @@ /*

evaluateToIdentifier,
expressionIsUnsupported,
toConstantDependency

@@ -202,3 +203,14 @@ } = require("../javascript/JavascriptParserHelpers");

);
parser.hooks.expression
.for("require.extensions")
.tap(
PLUGIN_NAME,
expressionIsUnsupported(
parser,
"require.extensions is not supported by webpack. Use a loader instead."
)
);
parser.hooks.expression
.for(RuntimeGlobals.moduleLoaded)

@@ -205,0 +217,0 @@ .tap(PLUGIN_NAME, (expr) => {

@@ -9,7 +9,14 @@ /*

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 CssIcssImportDependency = require("./CssIcssImportDependency");
const NullDependency = require("./NullDependency");
const getCssParser = memoize(() => require("../css/CssParser"));
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
/** @typedef {import("../../declarations/WebpackOptions").CssGeneratorExportsConvention} CssGeneratorExportsConvention */
/** @typedef {import("../../declarations/WebpackOptions").CssGeneratorLocalIdentName} CssGeneratorLocalIdentName */
/** @typedef {import("../CssModule")} CssModule */

@@ -25,12 +32,78 @@ /** @typedef {import("../Dependency")} Dependency */

/** @typedef {import("../util/Hash")} Hash */
/** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
/** @typedef {import("../css/CssParser").Range} Range */
/**
* @param {string} local css local
* @param {CssModule} module module
* @param {ChunkGraph} chunkGraph chunk graph
* @param {RuntimeTemplate} runtimeTemplate runtime template
* @returns {string} local ident
*/
const getLocalIdent = (local, module, chunkGraph, runtimeTemplate) => {
const generator = /** @type {CssGenerator} */ (module.generator);
const localIdentName =
/** @type {CssGeneratorLocalIdentName} */
(generator.localIdentName);
const relativeResourcePath = makePathsRelative(
/** @type {string} */
(module.context),
/** @type {string} */
(module.getResource()),
runtimeTemplate.compilation.compiler.root
);
const { hashFunction, hashDigest, hashDigestLength, hashSalt, uniqueName } =
runtimeTemplate.outputOptions;
const hash = createHash(hashFunction);
if (hashSalt) {
hash.update(hashSalt);
}
hash.update(relativeResourcePath);
if (!/\[local\]/.test(localIdentName)) {
hash.update(local);
}
const localIdentHash = hash.digest(hashDigest).slice(0, hashDigestLength);
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");
};
// 0 - replace, 1 - append, 2 - once
/** @typedef {0 | 1 | 2} ExportMode */
// 0 - none, 1 - name, 1 - value
/** @typedef {0 | 1 | 2} InterpolationMode */
class CssIcssExportDependency extends NullDependency {
/**
* @param {string} name name
* @param {string} value value
* Example of dependency:
*
* :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 {Range=} range range
*/
constructor(name, value) {
constructor(name, value, reexport, range) {
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._hashUpdate = undefined;

@@ -95,5 +168,4 @@ }

);
this._hashUpdate = JSON.stringify(names);
this._hashUpdate = `exportsConvention|${JSON.stringify(names)}|localIdentName|${JSON.stringify(generator.localIdentName)}`;
}
hash.update("exportsConvention");
hash.update(this._hashUpdate);

@@ -109,2 +181,6 @@ }

write(this.value);
write(this.reexport);
write(this.range);
write(this.interpolationMode);
write(this.exportMode);
super.serialize(context);

@@ -120,2 +196,6 @@ }

this.value = read();
this.reexport = read();
this.range = read();
this.interpolationMode = read();
this.exportMode = read();
super.deserialize(context);

@@ -128,4 +208,98 @@ }

) {
// TODO looking how to cache
/**
* @param {string} symbol the name of symbol
* @param {DependencyTemplateContext} templateContext the context object
* @returns {string | undefined} found reference
*/
static findReference(symbol, templateContext) {
for (const item of templateContext.module.dependencies) {
if (item instanceof CssIcssImportDependency) {
// Looking for the referring module
const module = templateContext.moduleGraph.getModule(item);
if (!module) {
return undefined;
}
for (let i = module.dependencies.length - 1; i >= 0; i--) {
const nestedDep = module.dependencies[i];
if (
nestedDep instanceof CssIcssExportDependency &&
symbol === nestedDep.name
) {
if (nestedDep.reexport) {
return this.findReference(nestedDep.reexport, {
...templateContext,
module
});
}
return CssIcssExportDependency.Template.getIdentifier(nestedDep, {
...templateContext,
module
});
}
}
}
}
}
/**
* @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) {
const dep = /** @type {CssIcssExportDependency} */ (dependency);
if (
dep.interpolationMode ===
CssIcssExportDependency.INTERPOLATION_MODE.NAME ||
dep.interpolationMode === CssIcssExportDependency.INTERPOLATION_MODE.VALUE
) {
const { module: m, moduleGraph, runtime } = 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,
/** @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];
const prefix =
/** @type {CssIcssExportDependency & { prefix: string }} */
(dependency).prefix;
return (
(prefix || "") +
getCssParser().escapeIdentifier(
getLocalIdent(
local,
/** @type {CssModule} */
(templateContext.module),
templateContext.chunkGraph,
templateContext.runtimeTemplate
)
)
);
}
return /** @type {string} */ (dep.value);
}
/**
* @param {Dependency} dependency the dependency for which the template should be applied
* @param {ReplaceSource} source the current replace source which can be modified

@@ -135,4 +309,7 @@ * @param {DependencyTemplateContext} templateContext the context object

*/
apply(dependency, source, { cssData, module: m, runtime, moduleGraph }) {
apply(dependency, source, templateContext) {
const dep = /** @type {CssIcssExportDependency} */ (dependency);
if (!dep.range && templateContext.type !== "javascript") return;
const { cssData } = templateContext;
const { module: m, moduleGraph, runtime } = templateContext;
const module = /** @type {CssModule} */ (m);

@@ -155,8 +332,70 @@ const generator = /** @type {CssGenerator} */ (module.generator);

for (const used of [...usedNames, ...names]) {
cssData.exports.set(used, dep.value);
const allNames = new Set([...usedNames, ...names]);
/** @type {string} */
let value;
if (dep.reexport) {
const resolved = CssIcssExportDependencyTemplate.findReference(
dep.reexport,
templateContext
);
if (resolved) {
dep.value = resolved;
}
}
if (typeof dep.interpolationMode !== "undefined") {
value = CssIcssExportDependencyTemplate.getIdentifier(
dep,
templateContext
);
} else {
value = dep.value;
}
if (templateContext.type === "javascript") {
for (const used of allNames) {
if (dep.exportMode === 2) {
if (cssData.exports.has(used)) return;
cssData.exports.set(
used,
`${getCssParser().unescapeIdentifier(value)}`
);
} else {
const originalValue =
dep.exportMode === 0 ? undefined : cssData.exports.get(used);
const newValue = getCssParser().unescapeIdentifier(value);
cssData.exports.set(
used,
`${originalValue ? `${originalValue}${newValue ? " " : ""}` : ""}${newValue}`
);
}
}
} else if (
dep.range &&
templateContext.type === "css" &&
dep.exportMode !== 1
) {
source.replace(dep.range[0], dep.range[1] - 1, value);
}
}
};
/** @type {Record<"REPLACE" | "APPEND" | "ONCE", ExportMode>} */
CssIcssExportDependency.EXPORT_MODE = {
REPLACE: 0,
APPEND: 1,
ONCE: 2
};
/** @type {Record<"NONE" | "NAME" | "VALUE", InterpolationMode>} */
CssIcssExportDependency.INTERPOLATION_MODE = {
NONE: 0,
NAME: 1,
VALUE: 2
};
makeSerializable(

@@ -163,0 +402,0 @@ CssIcssExportDependency,

@@ -8,6 +8,5 @@ /*

const WebpackError = require("../WebpackError");
const makeSerializable = require("../util/makeSerializable");
const CssIcssExportDependency = require("./CssIcssExportDependency");
const CssLocalIdentifierDependency = require("./CssLocalIdentifierDependency");
const ModuleDependency = require("./ModuleDependency");
const CssImportDependency = require("./CssImportDependency");

@@ -18,19 +17,23 @@ /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */

/** @typedef {import("../Module")} Module */
/** @typedef {import("../ModuleGraph")} ModuleGraph */
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
/** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
/** @typedef {import("../../declarations/WebpackOptions").CssGeneratorExportsConvention} CssGeneratorExportsConvention */
class CssIcssImportDependency extends ModuleDependency {
class CssIcssImportDependency extends CssImportDependency {
/**
* Example of dependency:
*
*:import('./style.css') { IMPORTED_NAME: v-primary }
* :import('./style.css') { IMPORTED_NAME: v-primary }
* @param {string} request request request path which needs resolving
* @param {string} exportName export name
* @param {Range} range the range of dependency
* @param {"local" | "global"} mode mode of the parsed CSS
* @param {string} name importName name
*/
constructor(request, exportName, range) {
super(request);
this.exportName = exportName;
this.range = range;
constructor(request, range, mode, name) {
super(request, range, mode);
this.name = name;
}

@@ -42,7 +45,48 @@

get category() {
return "css-import";
/**
* @returns {string | null} an identifier to merge equal requests
*/
getResourceIdentifier() {
return `${super.getResourceIdentifier()}|mode${this.mode}|name${this.name}`;
}
/**
* 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) {
return [
{
name: [this.name],
canMangle: true
}
];
}
/**
* Returns warnings
* @param {ModuleGraph} moduleGraph module graph
* @returns {WebpackError[] | null | undefined} warnings
*/
getWarnings(moduleGraph) {
const module = moduleGraph.getModule(this);
if (
module &&
!moduleGraph.getExportsInfo(module).isExportProvided(this.name)
) {
const error = new WebpackError(
`Referenced name "${this.name}" in "${this.userRequest}" not found`
);
error.module = module;
return [error];
}
return null;
}
/**
* @param {ObjectSerializerContext} context context

@@ -52,4 +96,3 @@ */

const { write } = context;
write(this.range);
write(this.exportName);
write(this.name);
super.serialize(context);

@@ -63,4 +106,3 @@ }

const { read } = context;
this.range = read();
this.exportName = read();
this.name = read();
super.deserialize(context);

@@ -71,3 +113,3 @@ }

CssIcssImportDependency.Template = class CssIcssImportDependencyTemplate extends (
ModuleDependency.Template
CssImportDependency.Template
) {

@@ -81,39 +123,3 @@ /**

apply(dependency, source, templateContext) {
const dep = /** @type {CssIcssImportDependency} */ (dependency);
const { range } = dep;
const module =
/** @type {Module} */
(templateContext.moduleGraph.getModule(dep));
let value;
for (const item of module.dependencies) {
if (
item instanceof CssLocalIdentifierDependency &&
dep.exportName === item.name
) {
value = CssLocalIdentifierDependency.Template.getIdentifier(
item,
dep.exportName,
{
...templateContext,
module
}
);
break;
} else if (
item instanceof CssIcssExportDependency &&
dep.exportName === item.name
) {
value = item.value;
break;
}
}
if (!value) {
throw new Error(
`Imported '${dep.exportName}' name from '${dep.request}' not found`
);
}
source.replace(range[0], range[1], value);
// We remove everything in CSS parser
}

@@ -120,0 +126,0 @@ };

@@ -9,2 +9,3 @@ /*

const makeSerializable = require("../util/makeSerializable");
const CssIcssExportDependency = require("./CssIcssExportDependency");
const NullDependency = require("./NullDependency");

@@ -28,10 +29,12 @@

* @param {string} name name
* @param {string} value value
* @param {string} symbol symbol
* @param {Range} range range
* @param {boolean=} isReference true when is reference, otherwise false
*/
constructor(name, value, range) {
constructor(name, symbol, range, isReference) {
super();
this.name = name;
this.value = value;
this.symbol = symbol;
this.range = range;
this.isReference = isReference;
this._hashUpdate = undefined;

@@ -41,3 +44,3 @@ }

get type() {
return "css @value identifier";
return "css symbol identifier";
}

@@ -63,19 +66,2 @@

/**
* Returns the exported names
* @param {ModuleGraph} moduleGraph module graph
* @returns {ExportsSpec | undefined} export names
*/
getExports(moduleGraph) {
return {
exports: [
{
name: this.name,
canMangle: true
}
],
dependencies: undefined
};
}
/**
* Returns list of exports referenced by this dependency

@@ -87,3 +73,3 @@ * @param {ModuleGraph} moduleGraph module graph

getReferencedExports(moduleGraph, runtime) {
return [[this.name]];
return [[this.symbol]];
}

@@ -97,4 +83,6 @@

write(this.name);
write(this.symbol);
write(this.value);
write(this.range);
write(this.isReference);
super.serialize(context);

@@ -109,4 +97,6 @@ }

this.name = read();
this.symbol = read();
this.value = read();
this.range = read();
this.isReference = read();
super.deserialize(context);

@@ -116,3 +106,3 @@ }

CssIcssSymbolDependency.Template = class CssValueAtRuleDependencyTemplate extends (
CssIcssSymbolDependency.Template = class CssIcssSymbolDependencyTemplate extends (
NullDependency.Template

@@ -126,8 +116,20 @@ ) {

*/
apply(dependency, source, { cssData }) {
const dep = /** @type {CssIcssSymbolDependency} */ (dependency);
apply(dependency, source, templateContext) {
if (templateContext.type === "css") {
const dep = /** @type {CssIcssSymbolDependency} */ (dependency);
/** @type {string | undefined} */
const value = dep.isReference
? CssIcssExportDependency.Template.findReference(
dep.symbol,
templateContext
)
: dep.symbol;
source.replace(dep.range[0], dep.range[1] - 1, dep.value);
if (!value) {
// TODO generate warning
return;
}
cssData.exports.set(dep.name, dep.value);
source.replace(dep.range[0], dep.range[1] - 1, value);
}
}

@@ -134,0 +136,0 @@ };

@@ -24,9 +24,11 @@ /*

* @param {Range} range range of the argument
* @param {string | undefined} layer layer
* @param {string | undefined} supports list of supports conditions
* @param {string | undefined} media list of media conditions
* @param {"local" | "global"=} mode mode of the parsed CSS
* @param {string=} layer layer
* @param {string=} supports list of supports conditions
* @param {string=} media list of media conditions
*/
constructor(request, range, layer, supports, media) {
constructor(request, range, mode, layer, supports, media) {
super(request);
this.range = range;
this.mode = mode;
this.layer = layer;

@@ -42,3 +44,3 @@ this.supports = supports;

get category() {
return "css-import";
return `css-import${this.mode ? `-${this.mode}-module` : ""}`;
}

@@ -52,2 +54,6 @@

if (this.mode) {
str += `|mode${this.mode}`;
}
if (this.layer) {

@@ -73,2 +79,4 @@ str += `|layer${this.layer}`;

const { write } = context;
write(this.range);
write(this.mode);
write(this.layer);

@@ -85,2 +93,4 @@ write(this.supports);

const { read } = context;
this.range = read();
this.mode = read();
this.layer = read();

@@ -87,0 +97,0 @@ this.supports = read();

@@ -102,3 +102,3 @@ /*

this.importedModule
)};`;
)};\n`;
}

@@ -105,0 +105,0 @@

@@ -12,2 +12,3 @@ /*

const HarmonyImportDependency = require("./HarmonyImportDependency");
const { ImportPhaseUtils } = require("./ImportPhase");
const NullDependency = require("./NullDependency");

@@ -124,3 +125,7 @@

if (isRelatedHarmonyImportDependency(dependency, d)) {
if (/** @type {HarmonyImportDependency} */ (d).defer) {
if (
ImportPhaseUtils.isDefer(
/** @type {HarmonyImportDependency} */ (d).phase
)
) {
deferDependency = /** @type {HarmonyImportDependency} */ (d);

@@ -127,0 +132,0 @@ } else {

@@ -10,2 +10,3 @@ /*

const HarmonyImportDependency = require("./HarmonyImportDependency");
const { ImportPhase } = require("./ImportPhase");
const NullDependency = require("./NullDependency");

@@ -18,3 +19,3 @@

constructor(request) {
super(request, Number.NaN);
super(request, Infinity, ImportPhase.Evaluation);
this.weak = true;

@@ -21,0 +22,0 @@ }

@@ -10,2 +10,3 @@ /*

const HarmonyImportSpecifierDependency = require("./HarmonyImportSpecifierDependency");
const { ImportPhase } = require("./ImportPhase");

@@ -41,3 +42,13 @@ /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */

constructor(request, sourceOrder, ids, name, range, attributes, operator) {
super(request, sourceOrder, ids, name, range, false, attributes, []);
super(
request,
sourceOrder,
ids,
name,
range,
false,
ImportPhase.Evaluation,
attributes,
[]
);
this.operator = operator;

@@ -44,0 +55,0 @@ }

@@ -8,2 +8,3 @@ /*

const CompatibilityPlugin = require("../CompatibilityPlugin");
const WebpackError = require("../WebpackError");

@@ -19,6 +20,6 @@ const { getImportAttributes } = require("../javascript/JavascriptParser");

const {
getImportMode,
harmonySpecifierTag
} = require("./HarmonyImportDependencyParserPlugin");
const HarmonyImportSideEffectDependency = require("./HarmonyImportSideEffectDependency");
const { ImportPhaseUtils, createGetImportPhase } = require("./ImportPhase");

@@ -31,2 +32,3 @@ /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */

/** @typedef {import("./HarmonyImportDependencyParserPlugin").HarmonySettings} HarmonySettings */
/** @typedef {import("../CompatibilityPlugin").CompatibilitySettings} CompatibilitySettings */

@@ -42,2 +44,3 @@ const { HarmonyStarExportsList } = HarmonyExportImportedSpecifierDependency;

constructor(options) {
this.options = options;
this.exportPresenceMode =

@@ -51,3 +54,2 @@ options.reexportExportsPresence !== undefined

: ExportPresenceModes.AUTO;
this.deferImport = options.deferImport;
}

@@ -61,2 +63,4 @@

const { exportPresenceMode } = this;
const getImportPhase = createGetImportPhase(this.options.deferImport);
parser.hooks.export.tap(PLUGIN_NAME, (statement) => {

@@ -86,12 +90,10 @@ const dep = new HarmonyExportHeaderDependency(

parser.state.module.addPresentationalDependency(clearDep);
let defer = false;
if (this.deferImport) {
({ defer } = getImportMode(parser, statement));
if (defer) {
const error = new WebpackError(
"Deferred re-export (`export defer * as namespace from '...'`) is not a part of the Import Defer proposal.\nUse the following code instead:\n import defer * as namespace from '...';\n export { namespace };"
);
error.loc = statement.loc || undefined;
parser.state.current.addError(error);
}
const phase = getImportPhase(parser, statement);
if (phase && ImportPhaseUtils.isDefer(phase)) {
const error = new WebpackError(
"Deferred re-export (`export defer * as namespace from '...'`) is not a part of the Import Defer proposal.\nUse the following code instead:\n import defer * as namespace from '...';\n export { namespace };"
);
error.loc = statement.loc || undefined;
parser.state.current.addError(error);
}

@@ -101,4 +103,4 @@ const sideEffectDep = new HarmonyImportSideEffectDependency(

parser.state.lastHarmonyImportOrder,
getImportAttributes(statement),
defer
phase,
getImportAttributes(statement)
);

@@ -168,2 +170,14 @@ sideEffectDep.loc = Object.create(

(statement, id, name, idx) => {
// CompatibilityPlugin may change exports name
// not handle re-export or import then export situation as current CompatibilityPlugin only
// rename symbol in declaration module, not change exported symbol
const variable = parser.getTagData(
id,
CompatibilityPlugin.nestedWebpackIdentifierTag
);
if (variable && /** @type {CompatibilitySettings} */ (variable).name) {
// CompatibilityPlugin changes exports to a new name, should updates exports name
id = /** @type {CompatibilitySettings} */ (variable).name;
}
const settings =

@@ -186,4 +200,4 @@ /** @type {HarmonySettings} */

null,
settings.attributes,
settings.defer
settings.phase,
settings.attributes
)

@@ -220,5 +234,2 @@ : new HarmonyExportSpecifierDependency(id, name);

const attributes = getImportAttributes(statement);
const defer = this.deferImport
? getImportMode(parser, statement).defer
: false;
const dep = new HarmonyExportImportedSpecifierDependency(

@@ -235,4 +246,4 @@ /** @type {string} */

harmonyStarExports,
attributes,
defer
getImportPhase(parser, statement),
attributes
);

@@ -239,0 +250,0 @@ if (harmonyStarExports) {

@@ -30,2 +30,3 @@ /*

const HarmonyImportDependency = require("./HarmonyImportDependency");
const { ImportPhaseUtils } = require("./ImportPhase");
const processExportInfo = require("./processExportInfo");

@@ -61,2 +62,3 @@

/** @typedef {import("./HarmonyImportDependency").ExportPresenceMode} ExportPresenceMode */
/** @typedef {import("../dependencies/ImportPhase").ImportPhaseType} ImportPhaseType */

@@ -381,4 +383,4 @@ /** @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 */

* @param {HarmonyStarExportsList | null} allStarExports all star exports in the module
* @param {ImportPhaseType} phase import phase
* @param {ImportAttributes=} attributes import attributes
* @param {boolean=} defer is defer phase
*/

@@ -394,6 +396,6 @@ constructor(

allStarExports,
attributes,
defer
phase,
attributes
) {
super(request, sourceOrder, attributes, defer);
super(request, sourceOrder, phase, attributes);

@@ -1057,2 +1059,5 @@ this.ids = ids;

const importVar = dep.getImportVar(moduleGraph);
const isDeferred =
ImportPhaseUtils.isDefer(dep.phase) &&
!(/** @type {BuildMeta} */ (importedModule.buildMeta).async);

@@ -1062,4 +1067,3 @@ if (

mode.type === "reexport-fake-namespace-object") &&
dep.defer &&
!moduleGraph.isAsync(importedModule)
isDeferred
) {

@@ -1209,3 +1213,3 @@ initFragments.push(

: InitFragment.STAGE_HARMONY_IMPORTS,
dep.sourceOrder,
/** @type {number} */ (dep.sourceOrder),
key,

@@ -1271,3 +1275,3 @@ runtimeCondition

: InitFragment.STAGE_HARMONY_IMPORTS,
dep.sourceOrder
/** @type {number} */ (dep.sourceOrder)
)

@@ -1274,0 +1278,0 @@ );

@@ -15,2 +15,3 @@ /*

const { filterRuntime, mergeRuntime } = require("../util/runtime");
const { ImportPhaseUtils } = require("./ImportPhase");
const ModuleDependency = require("./ModuleDependency");

@@ -27,2 +28,3 @@

/** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */
/** @typedef {import("./ImportPhase").ImportPhaseType} ImportPhaseType */
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */

@@ -65,10 +67,9 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */

* @param {number} sourceOrder source order
* @param {ImportPhaseType} phase import phase
* @param {ImportAttributes=} attributes import attributes
* @param {boolean=} defer import attributes
*/
constructor(request, sourceOrder, attributes, defer) {
super(request);
this.sourceOrder = sourceOrder;
constructor(request, sourceOrder, phase, attributes) {
super(request, sourceOrder);
this.phase = phase;
this.attributes = attributes;
this.defer = defer;
}

@@ -85,3 +86,3 @@

let str = super.getResourceIdentifier();
if (this.defer) {
if (ImportPhaseUtils.isDefer(this.phase)) {
str += "|defer";

@@ -111,6 +112,10 @@ }

const module = /** @type {Module} */ (moduleGraph.getParentModule(this));
const importedModule = /** @type {Module} */ (moduleGraph.getModule(this));
const meta = moduleGraph.getMeta(module);
const defer = this.defer;
const metaKey = defer ? "deferredImportVarMap" : "importVarMap";
const isDeferred =
ImportPhaseUtils.isDefer(this.phase) &&
!(/** @type {BuildMeta} */ (importedModule.buildMeta).async);
const metaKey = isDeferred ? "deferredImportVarMap" : "importVarMap";
let importVarMap = meta[metaKey];

@@ -123,15 +128,8 @@ if (!importVarMap) {

let importVar = importVarMap.get(
/** @type {Module} */
(moduleGraph.getModule(this))
);
let importVar = importVarMap.get(importedModule);
if (importVar) return importVar;
importVar = `${Template.toIdentifier(
`${this.userRequest}`
)}__WEBPACK_${this.defer ? "DEFERRED_" : ""}IMPORTED_MODULE_${importVarMap.size}__`;
importVarMap.set(
/** @type {Module} */
(moduleGraph.getModule(this)),
importVar
);
)}__WEBPACK_${isDeferred ? "DEFERRED_" : ""}IMPORTED_MODULE_${importVarMap.size}__`;
importVarMap.set(importedModule, importVar);
return importVar;

@@ -176,3 +174,3 @@ }

runtimeRequirements,
defer: this.defer
dependency: this
});

@@ -299,5 +297,4 @@ }

const { write } = context;
write(this.sourceOrder);
write(this.attributes);
write(this.defer);
write(this.phase);
super.serialize(context);

@@ -311,5 +308,4 @@ }

const { read } = context;
this.sourceOrder = read();
this.attributes = read();
this.defer = read();
this.phase = read();
super.deserialize(context);

@@ -356,3 +352,3 @@ }

: dep.request;
const key = `${dep.defer ? "deferred " : ""}harmony import ${moduleKey}`;
const key = `${ImportPhaseUtils.isDefer(dep.phase) ? "deferred " : ""}harmony import ${moduleKey}`;

@@ -395,3 +391,3 @@ const runtimeCondition = dep.weak

InitFragment.STAGE_HARMONY_IMPORTS,
dep.sourceOrder,
/** @type {number} */ (dep.sourceOrder),
key,

@@ -409,3 +405,3 @@ runtimeCondition

InitFragment.STAGE_ASYNC_HARMONY_IMPORTS,
dep.sourceOrder,
/** @type {number} */ (dep.sourceOrder),
`${key} compat`,

@@ -420,3 +416,3 @@ runtimeCondition

InitFragment.STAGE_HARMONY_IMPORTS,
dep.sourceOrder,
/** @type {number} */ (dep.sourceOrder),
key,

@@ -423,0 +419,0 @@ runtimeCondition

@@ -8,3 +8,2 @@ /*

const CommentCompilationWarning = require("../CommentCompilationWarning");
const HotModuleReplacementPlugin = require("../HotModuleReplacementPlugin");

@@ -25,2 +24,3 @@ const WebpackError = require("../WebpackError");

const HarmonyImportSpecifierDependency = require("./HarmonyImportSpecifierDependency");
const { ImportPhaseUtils, createGetImportPhase } = require("./ImportPhase");

@@ -41,2 +41,3 @@ /** @typedef {import("estree").Expression} Expression */

/** @typedef {import("./HarmonyImportDependency").Ids} Ids */
/** @typedef {import("./ImportPhase").ImportPhaseType} ImportPhaseType */

@@ -53,3 +54,3 @@ const harmonySpecifierTag = Symbol("harmony import");

* @property {ImportAttributes=} attributes
* @property {boolean | undefined} defer
* @property {ImportPhaseType} phase
*/

@@ -64,2 +65,3 @@

constructor(options) {
this.options = options;
this.exportPresenceMode =

@@ -74,3 +76,2 @@ options.importExportsPresence !== undefined

this.strictThisContextOnImports = options.strictThisContextOnImports;
this.deferImport = options.deferImport;
}

@@ -85,2 +86,4 @@

const getImportPhase = createGetImportPhase(this.options.deferImport);
/**

@@ -129,22 +132,20 @@ * @param {Members} members members

const attributes = getImportAttributes(statement);
let defer = false;
if (this.deferImport) {
({ defer } = getImportMode(parser, statement));
if (
defer &&
(statement.specifiers.length !== 1 ||
statement.specifiers[0].type !== "ImportNamespaceSpecifier")
) {
const error = new WebpackError(
"Deferred import can only be used with `import * as namespace from '...'` syntax."
);
error.loc = statement.loc || undefined;
parser.state.current.addError(error);
}
const phase = getImportPhase(parser, statement);
if (
ImportPhaseUtils.isDefer(phase) &&
(statement.specifiers.length !== 1 ||
statement.specifiers[0].type !== "ImportNamespaceSpecifier")
) {
const error = new WebpackError(
"Deferred import can only be used with `import * as namespace from '...'` syntax."
);
error.loc = statement.loc || undefined;
parser.state.current.addError(error);
}
const sideEffectDep = new HarmonyImportSideEffectDependency(
/** @type {string} */ (source),
parser.state.lastHarmonyImportOrder,
attributes,
defer
phase,
attributes
);

@@ -159,5 +160,3 @@ sideEffectDep.loc = /** @type {DependencyLocation} */ (statement.loc);

const ids = id === null ? [] : [id];
const defer = this.deferImport
? getImportMode(parser, statement).defer
: false;
const phase = getImportPhase(parser, statement);
parser.tagVariable(

@@ -172,3 +171,3 @@ name,

attributes: getImportAttributes(statement),
defer
phase
})

@@ -250,5 +249,5 @@ );

exportPresenceMode,
settings.phase,
settings.attributes,
[],
settings.defer
[]
);

@@ -301,5 +300,5 @@ dep.referencedPropertiesInDestructuring =

exportPresenceMode,
settings.phase,
settings.attributes,
ranges,
settings.defer
ranges
);

@@ -352,5 +351,5 @@ dep.referencedPropertiesInDestructuring =

exportPresenceMode,
settings.phase,
settings.attributes,
ranges,
settings.defer
ranges
);

@@ -422,42 +421,2 @@ dep.directImport = members.length === 0;

/**
* @param {JavascriptParser} parser parser
* @param {ExportNamedDeclaration | ExportAllDeclaration | ImportDeclaration} node node
* @returns {{ defer: boolean }} import attributes
*/
function getImportMode(parser, node) {
const result = { defer: "phase" in node && node.phase === "defer" };
if (!node.range) {
return result;
}
const { options, errors } = parser.parseCommentOptions(node.range);
if (errors) {
for (const e of errors) {
const { comment } = e;
if (!comment.loc) continue;
parser.state.module.addWarning(
new CommentCompilationWarning(
`Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
comment.loc
)
);
}
}
if (!options) return result;
if (options.webpackDefer) {
if (typeof options.webpackDefer === "boolean") {
result.defer = options.webpackDefer;
} else if (node.loc) {
parser.state.module.addWarning(
new CommentCompilationWarning(
"webpackDefer magic comment expected a boolean value.",
node.loc
)
);
}
}
return result;
}
module.exports.getImportMode = getImportMode;
module.exports.harmonySpecifierTag = harmonySpecifierTag;

@@ -19,2 +19,3 @@ /*

/** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */
/** @typedef {import("./ImportPhase").ImportPhaseType} ImportPhaseType */

@@ -25,7 +26,7 @@ class HarmonyImportSideEffectDependency extends HarmonyImportDependency {

* @param {number} sourceOrder source order
* @param {ImportPhaseType} phase import phase
* @param {ImportAttributes=} attributes import attributes
* @param {boolean=} defer is defer phase
*/
constructor(request, sourceOrder, attributes, defer) {
super(request, sourceOrder, attributes, defer);
constructor(request, sourceOrder, phase, attributes) {
super(request, sourceOrder, phase, attributes);
}

@@ -32,0 +33,0 @@

@@ -18,2 +18,3 @@ /*

const HarmonyImportDependency = require("./HarmonyImportDependency");
const { ImportPhaseUtils } = require("./ImportPhase");

@@ -40,2 +41,3 @@ /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */

/** @typedef {HarmonyImportDependency.Ids} Ids */
/** @typedef {import("./ImportPhase").ImportPhaseType} ImportPhaseType */

@@ -54,5 +56,5 @@ const idsSymbol = Symbol("HarmonyImportSpecifierDependency.ids");

* @param {ExportPresenceMode} exportPresenceMode export presence mode
* @param {ImportPhaseType} phase import phase
* @param {ImportAttributes | undefined} attributes import attributes
* @param {IdRanges | undefined} idRanges ranges for members of ids; the two arrays are right-aligned
* @param {boolean=} defer is defer phase
*/

@@ -66,7 +68,7 @@ constructor(

exportPresenceMode,
phase,
attributes,
idRanges, // TODO webpack 6 make this non-optional. It must always be set to properly trim ids.
defer
idRanges // TODO webpack 6 make this non-optional. It must always be set to properly trim ids.
) {
super(request, sourceOrder, attributes, defer);
super(request, sourceOrder, phase, attributes);
this.ids = ids;

@@ -447,3 +449,3 @@ this.name = name;

asiSafe: dep.asiSafe,
deferredImport: dep.defer
deferredImport: ImportPhaseUtils.isDefer(dep.phase)
}

@@ -455,3 +457,3 @@ );

asiSafe: dep.asiSafe,
deferredImport: dep.defer
deferredImport: ImportPhaseUtils.isDefer(dep.phase)
}) + propertyAccess(ids);

@@ -466,3 +468,3 @@ } else {

asiSafe: dep.asiSafe,
deferredImport: dep.defer
deferredImport: ImportPhaseUtils.isDefer(dep.phase)
}

@@ -492,3 +494,3 @@ );

runtimeRequirements,
defer: dep.defer
dependency: dep
});

@@ -495,0 +497,0 @@ }

@@ -25,2 +25,3 @@ /*

/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
/** @typedef {import("./ImportPhase").ImportPhaseType} ImportPhaseType */

@@ -31,9 +32,11 @@ class ImportDependency extends ModuleDependency {

* @param {Range} range expression range
* @param {RawReferencedExports | null=} referencedExports list of referenced exports
* @param {RawReferencedExports | null} referencedExports list of referenced exports
* @param {ImportPhaseType} phase import phase
* @param {ImportAttributes=} attributes import attributes
*/
constructor(request, range, referencedExports, attributes) {
constructor(request, range, referencedExports, phase, attributes) {
super(request);
this.range = range;
this.referencedExports = referencedExports;
this.phase = phase;
this.attributes = attributes;

@@ -104,2 +107,3 @@ }

context.write(this.referencedExports);
context.write(this.phase);
context.write(this.attributes);

@@ -115,2 +119,3 @@ super.serialize(context);

this.referencedExports = context.read();
this.phase = context.read();
this.attributes = context.read();

@@ -147,2 +152,3 @@ super.deserialize(context);

strict: /** @type {BuildMeta} */ (module.buildMeta).strictHarmonyModule,
dependency: dep,
message: "import()",

@@ -149,0 +155,0 @@ runtimeRequirements

@@ -19,2 +19,3 @@ /*

/** @typedef {ImportDependency.RawReferencedExports} RawReferencedExports */
/** @typedef {import("./ImportPhase").ImportPhaseType} ImportPhaseType */

@@ -25,7 +26,8 @@ class ImportEagerDependency extends ImportDependency {

* @param {Range} range expression range
* @param {RawReferencedExports | null=} referencedExports list of referenced exports
* @param {RawReferencedExports | null} referencedExports list of referenced exports
* @param {ImportPhaseType} phase import phase
* @param {ImportAttributes=} attributes import attributes
*/
constructor(request, range, referencedExports, attributes) {
super(request, range, referencedExports, attributes);
constructor(request, range, referencedExports, phase, attributes) {
super(request, range, referencedExports, phase, attributes);
}

@@ -68,2 +70,3 @@

message: "import() eager",
dependency: dep,
runtimeRequirements

@@ -70,0 +73,0 @@ });

@@ -9,2 +9,4 @@ /*

const { pathToFileURL } = require("url");
const { SyncBailHook } = require("tapable");
const Compilation = require("../Compilation");
const ModuleDependencyWarning = require("../ModuleDependencyWarning");

@@ -15,2 +17,3 @@ const {

} = require("../ModuleTypeConstants");
const RuntimeGlobals = require("../RuntimeGlobals");
const Template = require("../Template");

@@ -36,2 +39,4 @@ const BasicEvaluatedExpression = require("../javascript/BasicEvaluatedExpression");

/** @typedef {import("../javascript/JavascriptParser").Members} Members */
/** @typedef {import("../javascript/JavascriptParser").DestructuringAssignmentProperty} DestructuringAssignmentProperty */
/** @typedef {import("./ConstDependency").RawRuntimeRequirements} RawRuntimeRequirements */

@@ -44,4 +49,32 @@ const getCriticalDependencyWarning = memoize(() =>

/**
* @typedef {object} ImportMetaPluginHooks
* @property {SyncBailHook<[DestructuringAssignmentProperty], string | void>} propertyInDestructuring
*/
/** @type {WeakMap<Compilation, ImportMetaPluginHooks>} */
const compilationHooksMap = new WeakMap();
class ImportMetaPlugin {
/**
* @param {Compilation} compilation the compilation
* @returns {ImportMetaPluginHooks} the attached hooks
*/
static getCompilationHooks(compilation) {
if (!(compilation instanceof Compilation)) {
throw new TypeError(
"The 'compilation' argument must be an instance of Compilation"
);
}
let hooks = compilationHooksMap.get(compilation);
if (hooks === undefined) {
hooks = {
propertyInDestructuring: new SyncBailHook(["property"])
};
compilationHooksMap.set(compilation, hooks);
}
return hooks;
}
/**
* @param {Compiler} compiler compiler

@@ -53,2 +86,4 @@ */

(compilation, { normalModuleFactory }) => {
const hooks = ImportMetaPlugin.getCompilationHooks(compilation);
/**

@@ -143,5 +178,15 @@ * @param {NormalModule} module module

/** @type {RawRuntimeRequirements} */
const runtimeRequirements = [];
let str = "";
for (const { id: prop } of referencedPropertiesInDestructuring) {
switch (prop) {
for (const prop of referencedPropertiesInDestructuring) {
const value = hooks.propertyInDestructuring.call(prop);
if (value) {
str += value;
continue;
}
switch (prop.id) {
case "url":

@@ -153,6 +198,14 @@ str += `url: ${importMetaUrl()},`;

break;
case "main":
str += `main: ${RuntimeGlobals.moduleCache}[${RuntimeGlobals.entryModuleId}] === ${RuntimeGlobals.module},`;
runtimeRequirements.push(
RuntimeGlobals.moduleCache,
RuntimeGlobals.entryModuleId,
RuntimeGlobals.module
);
break;
default:
str += `[${JSON.stringify(
prop
)}]: ${importMetaUnknownProperty([prop])},`;
prop.id
)}]: ${importMetaUnknownProperty([prop.id])},`;
break;

@@ -163,3 +216,4 @@ }

`({${str}})`,
/** @type {Range} */ (metaProperty.range)
/** @type {Range} */ (metaProperty.range),
runtimeRequirements
);

@@ -208,13 +262,13 @@ dep.loc = /** @type {DependencyLocation} */ (metaProperty.loc);

// import.meta.webpack
parser.hooks.typeof
parser.hooks.expression
.for("import.meta.webpack")
.tap(
PLUGIN_NAME,
toConstantDependency(parser, JSON.stringify("number"))
toConstantDependency(parser, importMetaWebpackVersion())
);
parser.hooks.expression
parser.hooks.typeof
.for("import.meta.webpack")
.tap(
PLUGIN_NAME,
toConstantDependency(parser, importMetaWebpackVersion())
toConstantDependency(parser, JSON.stringify("number"))
);

@@ -228,2 +282,26 @@ parser.hooks.evaluateTypeof

parser.hooks.expression
.for("import.meta.main")
.tap(
PLUGIN_NAME,
toConstantDependency(
parser,
`${RuntimeGlobals.moduleCache}[${RuntimeGlobals.entryModuleId}] === ${RuntimeGlobals.module}`,
[
RuntimeGlobals.moduleCache,
RuntimeGlobals.entryModuleId,
RuntimeGlobals.module
]
)
);
parser.hooks.typeof
.for("import.meta.main")
.tap(
PLUGIN_NAME,
toConstantDependency(parser, JSON.stringify("boolean"))
);
parser.hooks.evaluateTypeof
.for("import.meta.main")
.tap(PLUGIN_NAME, evaluateToString("boolean"));
// Unknown properties

@@ -233,2 +311,12 @@ parser.hooks.unhandledExpressionMemberChain

.tap(PLUGIN_NAME, (expr, members) => {
// keep import.meta.env unknown property
// don't evaluate import.meta.env.UNKNOWN_PROPERTY -> undefined.UNKNOWN_PROPERTY
// `dirname` and `filename` logic in NodeStuffPlugin
if (
members[0] === "env" ||
members[0] === "dirname" ||
members[0] === "filename"
) {
return true;
}
const dep = new ConstDependency(

@@ -235,0 +323,0 @@ importMetaUnknownProperty(members),

@@ -20,2 +20,3 @@ /*

const ImportEagerDependency = require("./ImportEagerDependency");
const { ImportPhaseUtils, createGetImportPhase } = require("./ImportPhase");
const ImportWeakDependency = require("./ImportWeakDependency");

@@ -315,23 +316,7 @@

let phase = expr.phase;
if (!phase && importOptions && importOptions.webpackDefer !== undefined) {
if (typeof importOptions.webpackDefer !== "boolean") {
parser.state.module.addWarning(
new UnsupportedFeatureWarning(
`\`webpackDefer\` expected a boolean, but received: ${importOptions.webpackDefer}.`,
/** @type {DependencyLocation} */ (expr.loc)
)
);
} else if (importOptions.webpackDefer) {
phase = "defer";
}
}
if (phase === "defer") {
parser.state.module.addWarning(
new UnsupportedFeatureWarning(
"import.defer() is not implemented yet.",
/** @type {DependencyLocation} */ (expr.loc)
)
);
}
const phase = createGetImportPhase(this.options.deferImport)(
parser,
expr,
() => importOptions
);

@@ -538,2 +523,3 @@ if (importOptions) {

exports,
phase,
attributes

@@ -547,2 +533,3 @@ );

exports,
phase,
attributes

@@ -564,2 +551,3 @@ );

exports,
phase,
attributes

@@ -576,2 +564,12 @@ );

}
if (ImportPhaseUtils.isDefer(phase)) {
parser.state.module.addWarning(
new UnsupportedFeatureWarning(
"import.defer() is not yet supported for ContextModule (the import path is a dynamic expression).",
/** @type {DependencyLocation} */ (expr.loc)
)
);
}
const dep = ContextDependencyHelpers.create(

@@ -578,0 +576,0 @@ ImportContextDependency,

@@ -19,2 +19,3 @@ /*

/** @typedef {ImportDependency.RawReferencedExports} RawReferencedExports */
/** @typedef {import("./ImportPhase").ImportPhaseType} ImportPhaseType */

@@ -25,7 +26,8 @@ class ImportWeakDependency extends ImportDependency {

* @param {Range} range expression range
* @param {RawReferencedExports | null=} referencedExports list of referenced exports
* @param {RawReferencedExports | null} referencedExports list of referenced exports
* @param {ImportPhaseType} phase import phase
* @param {ImportAttributes=} attributes import attributes
*/
constructor(request, range, referencedExports, attributes) {
super(request, range, referencedExports, attributes);
constructor(request, range, referencedExports, phase, attributes) {
super(request, range, referencedExports, phase, attributes);
this.weak = true;

@@ -66,2 +68,3 @@ }

weak: true,
dependency: dep,
runtimeRequirements

@@ -68,0 +71,0 @@ });

@@ -21,7 +21,9 @@ /*

* @param {string} request request path which needs resolving
* @param {number=} sourceOrder source order
*/
constructor(request) {
constructor(request, sourceOrder) {
super();
this.request = request;
this.userRequest = request;
this.sourceOrder = sourceOrder;
/** @type {Range | undefined} */

@@ -78,2 +80,3 @@ this.range = undefined;

write(this.range);
write(this.sourceOrder);
super.serialize(context);

@@ -91,2 +94,3 @@ }

this.range = read();
this.sourceOrder = read();
super.deserialize(context);

@@ -93,0 +97,0 @@ }

@@ -20,3 +20,3 @@ /*

constructor(request, range) {
super(request);
super(request, Infinity);
this.range = range;

@@ -23,0 +23,0 @@ this.weak = true;

@@ -22,3 +22,3 @@ /*

/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
/** @typedef {import("./dependencies/ModuleDependency")} ModuleDependency */
/**

@@ -364,2 +364,9 @@ * @typedef {object} UpdateHashContext

/**
* @param {Dependency} dependency dep
* @returns {boolean} true if the dependency is a low priority dependency
*/
Dependency.isLowPriorityDependency = (dependency) =>
/** @type {ModuleDependency} */ (dependency).sourceOrder === Infinity;
// TODO remove in webpack 6

@@ -366,0 +373,0 @@ Object.defineProperty(Dependency.prototype, "disconnect", {

@@ -44,2 +44,3 @@ /*

* @property {CssData} cssData the css exports data
* @property {string} type the css exports data
*/

@@ -46,0 +47,0 @@

@@ -42,12 +42,14 @@ /*

apply(compiler) {
/** @type {Record<string, CodeValue>} */
const definitions = {};
for (const key of this.keys) {
const value =
process.env[key] !== undefined
? process.env[key]
: this.defaultValues[key];
const definePlugin = new DefinePlugin({});
if (value === undefined) {
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
/** @type {Record<string, CodeValue>} */
const definitions = {};
for (const key of this.keys) {
const value =
process.env[key] !== undefined
? process.env[key]
: this.defaultValues[key];
if (value === undefined) {
const error = new WebpackError(

@@ -61,10 +63,11 @@ `${PLUGIN_NAME} - ${key} environment variable is undefined.\n\n` +

compilation.errors.push(error);
});
}
const defValue =
value === undefined ? "undefined" : JSON.stringify(value);
definitions[`process.env.${key}`] = defValue;
definitions[`import.meta.env.${key}`] = defValue;
}
definitions[`process.env.${key}`] =
value === undefined ? "undefined" : JSON.stringify(value);
}
new DefinePlugin(definitions).apply(compiler);
definePlugin.definitions = definitions;
});
definePlugin.apply(compiler);
}

@@ -71,0 +74,0 @@ }

@@ -9,7 +9,3 @@ /*

const RuntimeModule = require("../RuntimeModule");
const Template = require("../Template");
// CompatibilityPlugin renames `__webpack_require__` but doesn’t account for `export { __webpack_require__ }`, so we create a temporary variable to handle it.
const EXPORT_TEMP_NAME = "__webpack_require_temp__";
class ExportWebpackRequireRuntimeModule extends RuntimeModule {

@@ -31,6 +27,3 @@ constructor() {

generate() {
return Template.asString([
`var ${EXPORT_TEMP_NAME} = ${RuntimeGlobals.require};`,
`export { ${EXPORT_TEMP_NAME} as ${RuntimeGlobals.require} };`
]);
return `export { ${RuntimeGlobals.require} };`;
}

@@ -37,0 +30,0 @@ }

@@ -21,2 +21,3 @@ /*

/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */
/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").Rules} Rules */
/** @typedef {import("./ChunkGraph").ModuleId} ModuleId */

@@ -167,2 +168,17 @@ /** @typedef {import("./Compiler")} Compiler */

sourceMap.sources = moduleFilenames;
sourceMap.ignoreList = options.ignoreList
? sourceMap.sources.reduce(
/** @type {(acc: number[], sourceName: string, idx: number) => number[]} */ (
(acc, sourceName, idx) => {
const rule = /** @type {Rules} */ (options.ignoreList);
if (ModuleFilenameHelpers.matchPart(sourceName, rule)) {
acc.push(idx);
}
return acc;
}
),
[]
)
: [];
if (options.noSources) {

@@ -169,0 +185,0 @@ sourceMap.sourcesContent = undefined;

@@ -8,2 +8,3 @@ /*

const { ImportPhaseUtils } = require("./dependencies/ImportPhase");
const { equals } = require("./util/ArrayHelpers");

@@ -1349,4 +1350,7 @@ const SortableSet = require("./util/SortableSet");

rawTarget.connection.dependency &&
/** @type {HarmonyImportDependency} */
(rawTarget.connection.dependency).defer
ImportPhaseUtils.isDefer(
/** @type {HarmonyImportDependency} */ (
rawTarget.connection.dependency
).phase
)
)

@@ -1353,0 +1357,0 @@ };

@@ -31,2 +31,3 @@ /*

/** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../declarations/WebpackOptions").ExternalsType} ExternalsType */
/** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */

@@ -446,6 +447,2 @@ /** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */

) => {
if (!Array.isArray(moduleAndSpecifiers)) {
moduleAndSpecifiers = [moduleAndSpecifiers];
}
/** @type {Imported} */

@@ -470,2 +467,11 @@ let imported = true;

if (!Array.isArray(moduleAndSpecifiers)) {
moduleAndSpecifiers = [moduleAndSpecifiers];
}
// Return to `namespace` when the external request includes a specific export
if (moduleAndSpecifiers.length > 1) {
imported = true;
}
const initFragment = new ModuleExternalInitFragment(

@@ -479,19 +485,3 @@ moduleAndSpecifiers[0],

const normalizedImported = initFragment.getImported();
const specifiers =
normalizedImported === true
? undefined
: /** @type {[string, string][]} */ (
normalizedImported.map(([name, rawFinalName]) => {
let finalName = rawFinalName;
let counter = 0;
if (concatenationScope) {
while (!concatenationScope.registerUsedName(finalName)) {
finalName = `${finalName}_${counter++}`;
}
}
return [name, finalName];
})
);
const baseAccess = `${initFragment.getNamespaceIdentifier()}${propertyAccess(

@@ -525,3 +515,3 @@ moduleAndSpecifiers,

: undefined,
specifiers,
specifiers: normalizedImported === true ? undefined : normalizedImported,
runtimeRequirements: moduleRemapping

@@ -640,3 +630,3 @@ ? RUNTIME_REQUIREMENTS_FOR_MODULE

* @param {ExternalModuleRequest} request request
* @param {string} type type
* @param {ExternalsType} type type
* @param {string} userRequest user request

@@ -651,3 +641,3 @@ * @param {DependencyMeta=} dependencyMeta dependency meta

this.request = request;
/** @type {string} */
/** @type {ExternalsType} */
this.externalType = type;

@@ -831,2 +821,6 @@ /** @type {string} */

/**
* @private
* @returns {{ request: string | string[], externalType: ExternalsType }} the request and external type
*/
_getRequestAndExternalType() {

@@ -844,4 +838,4 @@ let { request, externalType } = this;

* e.g. resolve "module" or "import" from "module-import" type
* @param {string} externalType raw external type
* @returns {string} resolved external type
* @param {ExternalsType} externalType raw external type
* @returns {ExternalsType} resolved external type
*/

@@ -878,3 +872,3 @@ _resolveExternalType(externalType) {

* @param {string | string[]} request request
* @param {string} externalType the external type
* @param {ExternalsType} externalType the external type
* @param {RuntimeTemplate} runtimeTemplate the runtime template

@@ -972,4 +966,2 @@ * @param {ModuleGraph} moduleGraph the module graph

case "promise":
case "const":
case "let":
case "assign":

@@ -976,0 +968,0 @@ default:

@@ -19,2 +19,3 @@ /*

/** @typedef {import("../declarations/WebpackOptions").ResolveOptions} ResolveOptions */
/** @typedef {import("../declarations/WebpackOptions").ExternalsType} ExternalsType */
/** @typedef {import("../declarations/WebpackOptions").ExternalItemValue} ExternalItemValue */

@@ -54,3 +55,3 @@ /** @typedef {import("../declarations/WebpackOptions").ExternalItemObjectKnown} ExternalItemObjectKnown */

* @param {string} request request
* @param {(err: Error | null | undefined, value: ExternalValue | undefined, ty: ExternalType | undefined) => void} cb cb
* @param {(err: Error | null | undefined, value: ExternalValue | undefined, ty: ExternalsType | undefined) => void} cb cb
*/

@@ -95,3 +96,2 @@ (externalsFunction, context, request, cb) => {

/** @typedef {string | string[] | boolean | Record<string, string | string[]>} ExternalValue */
/** @typedef {string | undefined} ExternalType */

@@ -102,3 +102,3 @@ const PLUGIN_NAME = "ExternalModuleFactoryPlugin";

/**
* @param {string} type default external type
* @param {ExternalsType} type default external type
* @param {Externals} externals externals config

@@ -129,3 +129,3 @@ */

* @param {ExternalValue} value the external config
* @param {ExternalType | undefined} type type of external
* @param {ExternalsType | undefined} type type of external
* @param {HandleExternalCallback} callback callback

@@ -139,3 +139,3 @@ * @returns {void}

}
/** @type {string | string[] | Record<string, string|string[]>} */
/** @type {ExternalValue} */
let externalConfig = value === true ? dependency.request : value;

@@ -149,3 +149,5 @@ // When no explicit type is specified, extract it from the externalConfig

const idx = externalConfig.indexOf(" ");
type = externalConfig.slice(0, idx);
type =
/** @type {ExternalsType} */
(externalConfig.slice(0, idx));
externalConfig = externalConfig.slice(idx + 1);

@@ -159,3 +161,3 @@ } else if (

const idx = firstItem.indexOf(" ");
type = firstItem.slice(0, idx);
type = /** @type {ExternalsType} */ (firstItem.slice(0, idx));
externalConfig = [

@@ -266,3 +268,3 @@ firstItem.slice(idx + 1),

* @param {ExternalValue=} value value
* @param {ExternalType=} type type
* @param {ExternalsType=} type type
* @returns {void}

@@ -269,0 +271,0 @@ */

@@ -12,2 +12,3 @@ /*

/** @typedef {import("../declarations/WebpackOptions").ExternalsType} ExternalsType */
/** @typedef {import("../declarations/WebpackOptions").Externals} Externals */

@@ -21,3 +22,3 @@ /** @typedef {import("./Compiler")} Compiler */

/**
* @param {string} type default external type
* @param {ExternalsType} type default external type
* @param {Externals} externals externals config

@@ -24,0 +25,0 @@ */

@@ -260,2 +260,3 @@ /*

request: this.request,
dependency: dep,
strict: false, // TODO this should be inherited from the original module

@@ -262,0 +263,0 @@ message: "import()",

@@ -18,2 +18,3 @@ /*

/** @typedef {import("../util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
/** @typedef {import("../Module").BuildMeta} BuildMeta */

@@ -250,3 +251,5 @@ /**

(!filter || filter(module)) &&
chunkGraph.getNumberOfModuleChunks(module) !== 0
(chunkGraph.getNumberOfModuleChunks(module) !== 0 ||
// CSS modules need IDs even when not in chunks, for generating CSS class names(i.e. [id]-[local])
/** @type {BuildMeta} */ (module.buildMeta).isCSSModule)
) {

@@ -253,0 +256,0 @@ modules.push(module);

@@ -235,2 +235,5 @@ /*

},
get DotenvPlugin() {
return require("./DotenvPlugin");
},
get EntryOptionPlugin() {

@@ -359,2 +362,5 @@ return require("./EntryOptionPlugin");

},
get ManifestPlugin() {
return require("./ManifestPlugin");
},
get Template() {

@@ -361,0 +367,0 @@ return require("./Template");

@@ -19,6 +19,20 @@ /*

const getAllChunks = (entrypoint, excludedChunk1, excludedChunk2) => {
/** @type {Set<Entrypoint>} */
const queue = new Set([entrypoint]);
/** @type {Set<Entrypoint>} */
const groups = new Set([]);
for (const group of queue) {
if (group !== entrypoint) {
groups.add(group);
}
for (const parent of group.parentsIterable) {
if (parent instanceof Entrypoint) queue.add(parent);
}
}
groups.add(entrypoint);
/** @type {Set<Chunk>} */
const chunks = new Set();
for (const entrypoint of queue) {
for (const chunk of entrypoint.chunks) {
for (const group of groups) {
for (const chunk of group.chunks) {
if (chunk === excludedChunk1) continue;

@@ -28,5 +42,2 @@ if (chunk === excludedChunk2) continue;

}
for (const parent of entrypoint.parentsIterable) {
if (parent instanceof Entrypoint) queue.add(parent);
}
}

@@ -33,0 +44,0 @@ return chunks;

@@ -105,103 +105,2 @@ /*

/**
* @param {NormalModule} module module for which the code should be generated
* @param {GenerateContext} generateContext context for generate
* @returns {Source | null} generated code
*/
generate(module, generateContext) {
const originalSource = module.originalSource();
if (!originalSource) {
return DEFAULT_SOURCE.source();
}
const source = new ReplaceSource(originalSource);
/** @type {InitFragment<GenerateContext>[]} */
const initFragments = [];
this.sourceModule(module, initFragments, source, generateContext);
return InitFragment.addToSource(source, initFragments, generateContext);
}
/**
* @param {Error} error the error
* @param {NormalModule} module module for which the code should be generated
* @param {GenerateContext} generateContext context for generate
* @returns {Source | null} generated code
*/
generateError(error, module, generateContext) {
return new RawSource(`throw new Error(${JSON.stringify(error.message)});`);
}
/**
* @param {Module} module the module to generate
* @param {InitFragment<GenerateContext>[]} initFragments mutable list of init fragments
* @param {ReplaceSource} source the current replace source which can be modified
* @param {GenerateContext} generateContext the generateContext
* @returns {void}
*/
sourceModule(module, initFragments, source, generateContext) {
for (const dependency of module.dependencies) {
this.sourceDependency(
module,
dependency,
initFragments,
source,
generateContext
);
}
if (module.presentationalDependencies !== undefined) {
for (const dependency of module.presentationalDependencies) {
this.sourceDependency(
module,
dependency,
initFragments,
source,
generateContext
);
}
}
for (const childBlock of module.blocks) {
this.sourceBlock(
module,
childBlock,
initFragments,
source,
generateContext
);
}
}
/**
* @param {Module} module the module to generate
* @param {DependenciesBlock} block the dependencies block which will be processed
* @param {InitFragment<GenerateContext>[]} initFragments mutable list of init fragments
* @param {ReplaceSource} source the current replace source which can be modified
* @param {GenerateContext} generateContext the generateContext
* @returns {void}
*/
sourceBlock(module, block, initFragments, source, generateContext) {
for (const dependency of block.dependencies) {
this.sourceDependency(
module,
dependency,
initFragments,
source,
generateContext
);
}
for (const childBlock of block.blocks) {
this.sourceBlock(
module,
childBlock,
initFragments,
source,
generateContext
);
}
}
/**
* @param {Module} module the current module

@@ -275,4 +174,105 @@ * @param {Dependency} dependency the dependency to generate

}
/**
* @param {Module} module the module to generate
* @param {DependenciesBlock} block the dependencies block which will be processed
* @param {InitFragment<GenerateContext>[]} initFragments mutable list of init fragments
* @param {ReplaceSource} source the current replace source which can be modified
* @param {GenerateContext} generateContext the generateContext
* @returns {void}
*/
sourceBlock(module, block, initFragments, source, generateContext) {
for (const dependency of block.dependencies) {
this.sourceDependency(
module,
dependency,
initFragments,
source,
generateContext
);
}
for (const childBlock of block.blocks) {
this.sourceBlock(
module,
childBlock,
initFragments,
source,
generateContext
);
}
}
/**
* @param {Module} module the module to generate
* @param {InitFragment<GenerateContext>[]} initFragments mutable list of init fragments
* @param {ReplaceSource} source the current replace source which can be modified
* @param {GenerateContext} generateContext the generateContext
* @returns {void}
*/
sourceModule(module, initFragments, source, generateContext) {
for (const dependency of module.dependencies) {
this.sourceDependency(
module,
dependency,
initFragments,
source,
generateContext
);
}
if (module.presentationalDependencies !== undefined) {
for (const dependency of module.presentationalDependencies) {
this.sourceDependency(
module,
dependency,
initFragments,
source,
generateContext
);
}
}
for (const childBlock of module.blocks) {
this.sourceBlock(
module,
childBlock,
initFragments,
source,
generateContext
);
}
}
/**
* @param {NormalModule} module module for which the code should be generated
* @param {GenerateContext} generateContext context for generate
* @returns {Source | null} generated code
*/
generate(module, generateContext) {
const originalSource = module.originalSource();
if (!originalSource) {
return DEFAULT_SOURCE.source();
}
const source = new ReplaceSource(originalSource);
/** @type {InitFragment<GenerateContext>[]} */
const initFragments = [];
this.sourceModule(module, initFragments, source, generateContext);
return InitFragment.addToSource(source, initFragments, generateContext);
}
/**
* @param {Error} error the error
* @param {NormalModule} module module for which the code should be generated
* @param {GenerateContext} generateContext context for generate
* @returns {Source | null} generated code
*/
generateError(error, module, generateContext) {
return new RawSource(`throw new Error(${JSON.stringify(error.message)});`);
}
}
module.exports = JavascriptGenerator;

@@ -301,12 +301,16 @@ /*

.for(type)
.tap(PLUGIN_NAME, (_options) => {
.tap(PLUGIN_NAME, (options) => {
switch (type) {
case JAVASCRIPT_MODULE_TYPE_AUTO: {
return new JavascriptParser("auto");
return new JavascriptParser("auto", { parse: options.parse });
}
case JAVASCRIPT_MODULE_TYPE_DYNAMIC: {
return new JavascriptParser("script");
return new JavascriptParser("script", {
parse: options.parse
});
}
case JAVASCRIPT_MODULE_TYPE_ESM: {
return new JavascriptParser("module");
return new JavascriptParser("module", {
parse: options.parse
});
}

@@ -954,3 +958,4 @@ }

if (avoidEntryIife) {
renamedInlinedModule = this.getRenamedInlineModule(
renamedInlinedModule = this._getRenamedInlineModule(
compilation,
allModules,

@@ -1589,6 +1594,3 @@ renderContext,

...(needModuleDefer
? [
"// delete __webpack_module_deferred_exports__[module];",
"// skipped because strictModuleErrorHandling is not enabled."
]
? ["delete __webpack_module_deferred_exports__[moduleId];"]
: [])

@@ -1614,2 +1616,3 @@ ]),

/**
* @param {Compilation} compilation compilation
* @param {Module[]} allModules allModules

@@ -1624,3 +1627,4 @@ * @param {MainRenderContext} renderContext renderContext

*/
getRenamedInlineModule(
_getRenamedInlineModule(
compilation,
allModules,

@@ -1672,6 +1676,12 @@ renderContext,

const code = /** @type {string} */ (moduleSource.source());
const ast = JavascriptParser._parse(code, {
sourceType: "auto"
});
const { ast } = JavascriptParser._parse(
code,
{
sourceType: "auto",
ranges: true
},
JavascriptParser._getModuleParseFunction(compilation, m)
);
const scopeManager = eslintScope.analyze(ast, {

@@ -1678,0 +1688,0 @@ ecmaVersion: 6,

@@ -67,3 +67,9 @@ /*

buildMeta.defaultObject =
typeof data === "object" ? "redirect-warn" : false;
typeof data === "object"
? this.options.namedExports === false
? false
: this.options.namedExports === true
? "redirect"
: "redirect-warn"
: false;
state.module.addDependency(

@@ -70,0 +76,0 @@ new JsonExportsDependency(

@@ -108,12 +108,2 @@ /*

/**
* @param {Chunk} chunk the chunk
* @param {RuntimeRequirements} set runtime requirements
* @param {LibraryContext<T>} libraryContext context
* @returns {void}
*/
runtimeRequirements(chunk, set, libraryContext) {
set.add(RuntimeGlobals.exports);
}
/**
* @param {LibraryOptions} library normalized library option

@@ -120,0 +110,0 @@ * @returns {T | false} preprocess as needed by overriding

@@ -167,2 +167,6 @@ /*

}
// See comment above
instructions.push(
`${external}["default"] = module["default"] || module;`
);
if (handledNames.length > 0) {

@@ -169,0 +173,0 @@ const name = `${external}handledNames`;

@@ -341,3 +341,3 @@ /*

" }\n"
}})(${runtimeTemplate.outputOptions.globalObject}, ${
}})(${runtimeTemplate.globalObject}, ${
runtimeTemplate.supportsArrowFunction()

@@ -344,0 +344,0 @@ ? `(${externalsArguments(externals)}) =>`

@@ -42,2 +42,4 @@ /*

/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
/** @typedef {import("../declarations/WebpackOptions").CssParserExportType} CssParserExportType */
/**

@@ -120,2 +122,3 @@ * @template T

* @property {("default" | "namespace" | "flagged" | "dynamic")=} exportsType
* @property {CssParserExportType=} exportType
* @property {(false | "redirect" | "redirect-warn")=} defaultObject

@@ -122,0 +125,0 @@ * @property {boolean=} strictHarmonyModule

@@ -12,2 +12,3 @@ /*

const HarmonyImportDependency = require("./dependencies/HarmonyImportDependency");
const { ImportPhaseUtils } = require("./dependencies/ImportPhase");
const SortableSet = require("./util/SortableSet");

@@ -848,3 +849,3 @@ const WeakTupleMap = require("./util/WeakTupleMap");

}
if (connection.dependency.defer) return true;
if (ImportPhaseUtils.isDefer(connection.dependency.phase)) return true;
}

@@ -851,0 +852,0 @@ return false;

@@ -48,7 +48,2 @@ /*

/**
* @type {ReadonlySet<"javascript" | "css-export">}
*/
const JS_AND_CSS_EXPORT_TYPES = new Set(["javascript", "css-export"]);
/**
* @type {ReadonlySet<"javascript" | "css-url">}

@@ -115,3 +110,2 @@ */

module.exports.CSS_URL_TYPES = CSS_URL_TYPES;
module.exports.JS_AND_CSS_EXPORT_TYPES = JS_AND_CSS_EXPORT_TYPES;
module.exports.JS_AND_CSS_TYPES = JS_AND_CSS_TYPES;

@@ -118,0 +112,0 @@ module.exports.JS_AND_CSS_URL_TYPES = JS_AND_CSS_URL_TYPES;

@@ -26,3 +26,3 @@ /*

*/
/** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
/** @typedef {import("../declarations/WebpackOptions").WebpackOptions} WebpackOptions */
/** @typedef {import("../declarations/WebpackOptions").WatchOptions} WatchOptions */

@@ -29,0 +29,0 @@ /** @typedef {import("./Compiler")} Compiler */

@@ -10,2 +10,3 @@ /*

/** @typedef {import("../../declarations/WebpackOptions").ExternalsType} ExternalsType */
/** @typedef {import("../Compiler")} Compiler */

@@ -77,2 +78,9 @@

/**
* @param {ExternalsType} type default external type
*/
constructor(type = "node-commonjs") {
this.type = type;
}
/**
* Apply the plugin

@@ -83,3 +91,3 @@ * @param {Compiler} compiler the compiler instance

apply(compiler) {
new ExternalsPlugin("node-commonjs", builtins).apply(compiler);
new ExternalsPlugin(this.type, builtins).apply(compiler);
}

@@ -86,0 +94,0 @@ }

@@ -22,4 +22,2 @@ /*

// TODO webpack 6 remove
const PLUGIN_NAME = "ReadFileCompileWasmPlugin";

@@ -26,0 +24,0 @@

@@ -10,3 +10,4 @@ /*

JAVASCRIPT_MODULE_TYPE_AUTO,
JAVASCRIPT_MODULE_TYPE_DYNAMIC
JAVASCRIPT_MODULE_TYPE_DYNAMIC,
JAVASCRIPT_MODULE_TYPE_ESM
} = require("./ModuleTypeConstants");

@@ -18,6 +19,5 @@ const NodeStuffInWebError = require("./NodeStuffInWebError");

const ExternalModuleDependency = require("./dependencies/ExternalModuleDependency");
const {
evaluateToString,
expressionIsUnsupported
} = require("./javascript/JavascriptParserHelpers");
const ExternalModuleInitFragmentDependency = require("./dependencies/ExternalModuleInitFragmentDependency");
const ImportMetaPlugin = require("./dependencies/ImportMetaPlugin");
const { evaluateToString } = require("./javascript/JavascriptParserHelpers");
const { relative } = require("./util/fs");

@@ -32,2 +32,3 @@ const { parseResource } = require("./util/identifier");

/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("./javascript/JavascriptParser").Expression} Expression */
/** @typedef {import("./javascript/JavascriptParser").Range} Range */

@@ -37,2 +38,3 @@ /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */

const PLUGIN_NAME = "NodeStuffPlugin";
const URL_MODULE_CONSTANT_FUNCTION_NAME = "__webpack_fileURLToPath__";

@@ -53,3 +55,4 @@ class NodeStuffPlugin {

apply(compiler) {
const options = this.options;
const { options } = this;
compiler.hooks.compilation.tap(

@@ -62,90 +65,259 @@ PLUGIN_NAME,

);
compilation.dependencyTemplates.set(
ExternalModuleInitFragmentDependency,
new ExternalModuleInitFragmentDependency.Template()
);
/**
* @param {JavascriptParser} parser the parser
* @param {JavascriptParserOptions} parserOptions options
* @param {NodeOptions} nodeOptions options
* @returns {void}
*/
const handler = (parser, parserOptions) => {
if (parserOptions.node === false) return;
const globalHandler = (parser, nodeOptions) => {
/**
* @param {Expression} expr expression
* @returns {ConstDependency} const dependency
*/
const getGlobalDep = (expr) => {
if (compilation.outputOptions.environment.globalThis) {
return new ConstDependency(
"globalThis",
/** @type {Range} */ (expr.range)
);
}
let localOptions = options;
if (parserOptions.node) {
localOptions = { ...localOptions, ...parserOptions.node };
}
return new ConstDependency(
RuntimeGlobals.global,
/** @type {Range} */ (expr.range),
[RuntimeGlobals.global]
);
};
if (localOptions.global !== false) {
const withWarning = localOptions.global === "warn";
parser.hooks.expression.for("global").tap(PLUGIN_NAME, (expr) => {
const withWarning = nodeOptions.global === "warn";
parser.hooks.expression.for("global").tap(PLUGIN_NAME, (expr) => {
const dep = getGlobalDep(expr);
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
parser.state.module.addPresentationalDependency(dep);
if (withWarning) {
parser.state.module.addWarning(
new NodeStuffInWebError(
dep.loc,
"global",
"The global namespace object is a Node.js feature and isn't available in browsers."
)
);
}
});
parser.hooks.rename.for("global").tap(PLUGIN_NAME, (expr) => {
const dep = getGlobalDep(expr);
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
parser.state.module.addPresentationalDependency(dep);
return false;
});
};
const hooks = ImportMetaPlugin.getCompilationHooks(compilation);
/**
* @param {JavascriptParser} parser the parser
* @param {"__filename" | "__dirname" | "import.meta.filename" | "import.meta.dirname"} expressionName expression name
* @param {(module: NormalModule) => string} fn function
* @param {"filename" | "dirname"} property a property
* @returns {void}
*/
const setModuleConstant = (parser, expressionName, fn, property) => {
parser.hooks.expression
.for(expressionName)
.tap(PLUGIN_NAME, (expr) => {
const dep = new ConstDependency(
RuntimeGlobals.global,
/** @type {Range} */ (expr.range),
[RuntimeGlobals.global]
fn(parser.state.module),
/** @type {Range} */
(expr.range)
);
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
parser.state.module.addPresentationalDependency(dep);
return true;
});
// TODO webpack 6 remove
if (withWarning) {
parser.state.module.addWarning(
new NodeStuffInWebError(
dep.loc,
"global",
"The global namespace object is a Node.js feature and isn't available in browsers."
)
);
if (
expressionName === "import.meta.filename" ||
expressionName === "import.meta.dirname"
) {
hooks.propertyInDestructuring.tap(PLUGIN_NAME, (usingProperty) => {
if (usingProperty.id === property) {
return `${property}: ${fn(parser.state.module)},`;
}
});
parser.hooks.rename.for("global").tap(PLUGIN_NAME, (expr) => {
const dep = new ConstDependency(
RuntimeGlobals.global,
/** @type {Range} */ (expr.range),
[RuntimeGlobals.global]
}
};
/**
* @param {JavascriptParser} parser the parser
* @param {"__filename" | "__dirname" | "import.meta.filename" | "import.meta.dirname"} expressionName expression name
* @param {(module: NormalModule) => string} fn function
* @param {"filename" | "dirname"} property a property
* @param {string=} warning warning
* @returns {void}
*/
const setCachedModuleConstant = (
parser,
expressionName,
fn,
property,
warning
) => {
parser.hooks.expression
.for(expressionName)
.tap(PLUGIN_NAME, (expr) => {
const dep = new CachedConstDependency(
JSON.stringify(fn(parser.state.module)),
/** @type {Range} */
(expr.range),
`__webpack_${property}__`
);
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
parser.state.module.addPresentationalDependency(dep);
return false;
});
}
/**
* @param {string} expressionName expression name
* @param {(module: NormalModule) => string} fn function
* @param {string=} warning warning
* @returns {void}
*/
const setModuleConstant = (expressionName, fn, warning) => {
parser.hooks.expression
.for(expressionName)
.tap(PLUGIN_NAME, (expr) => {
const dep = new CachedConstDependency(
JSON.stringify(fn(parser.state.module)),
/** @type {Range} */
(expr.range),
expressionName
if (warning) {
parser.state.module.addWarning(
new NodeStuffInWebError(dep.loc, expressionName, warning)
);
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
parser.state.module.addPresentationalDependency(dep);
}
// TODO webpack 6 remove
return true;
});
if (
expressionName === "import.meta.filename" ||
expressionName === "import.meta.dirname"
) {
hooks.propertyInDestructuring.tap(PLUGIN_NAME, (usingProperty) => {
if (property === usingProperty.id) {
if (warning) {
parser.state.module.addWarning(
new NodeStuffInWebError(dep.loc, expressionName, warning)
new NodeStuffInWebError(
usingProperty.loc,
expressionName,
warning
)
);
}
return `${property}: ${JSON.stringify(fn(parser.state.module))},`;
}
});
}
};
/**
* @param {JavascriptParser} parser the parser
* @param {"__filename" | "__dirname" | "import.meta.filename" | "import.meta.dirname"} expressionName expression name
* @param {string} value value
* @param {"filename" | "dirname"} property a property
* @param {string=} warning warning
* @returns {void}
*/
const setConstant = (
parser,
expressionName,
value,
property,
warning
) =>
setCachedModuleConstant(
parser,
expressionName,
() => value,
property,
warning
);
/**
* @param {JavascriptParser} parser the parser
* @param {"__filename" | "__dirname" | "import.meta.filename" | "import.meta.dirname"} expressionName expression name
* @param {"dirname" | "filename"} property property
* @param {() => string} value function to get value
* @returns {void}
*/
const setUrlModuleConstant = (
parser,
expressionName,
property,
value
) => {
parser.hooks.expression
.for(expressionName)
.tap(PLUGIN_NAME, (expr) => {
const { importMetaName, environment, module } =
compilation.outputOptions;
if (
module &&
importMetaName === "import.meta" &&
(expressionName === "import.meta.filename" ||
expressionName === "import.meta.dirname") &&
environment.importMetaDirnameAndFilename
) {
return true;
});
};
}
/**
* @param {string} expressionName expression name
* @param {(value: string) => string} fn function
* @returns {void}
*/
const setUrlModuleConstant = (expressionName, fn) => {
parser.hooks.expression
.for(expressionName)
.tap(PLUGIN_NAME, (expr) => {
const dep = new ExternalModuleDependency(
// Generate `import.meta.dirname` and `import.meta.filename` when:
// - they are supported by the environment
// - it is a universal target, because we can't use `import mod from "node:url"; ` at the top file
const dep =
environment.importMetaDirnameAndFilename ||
(compiler.platform.web === null &&
compiler.platform.node === null &&
module)
? new ConstDependency(
`${importMetaName}.${property}`,
/** @type {Range} */
(expr.range)
)
: new ExternalModuleDependency(
"url",
[
{
name: "fileURLToPath",
value: URL_MODULE_CONSTANT_FUNCTION_NAME
}
],
undefined,
`${URL_MODULE_CONSTANT_FUNCTION_NAME}(${value()})`,
/** @type {Range} */ (expr.range),
`__webpack_${property}__`
);
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
parser.state.module.addPresentationalDependency(dep);
return true;
});
if (
expressionName === "import.meta.filename" ||
expressionName === "import.meta.dirname"
) {
hooks.propertyInDestructuring.tap(PLUGIN_NAME, (usingProperty) => {
if (property === usingProperty.id) {
const { importMetaName, environment, module } =
compilation.outputOptions;
if (
module &&
importMetaName === "import.meta" &&
(expressionName === "import.meta.filename" ||
expressionName === "import.meta.dirname") &&
environment.importMetaDirnameAndFilename
) {
return `${property}: ${importMetaName}.${property},`;
}
if (environment.importMetaDirnameAndFilename) {
return `${property}: ${importMetaName}.${property},`;
}
const dep = new ExternalModuleInitFragmentDependency(
"url",

@@ -155,36 +327,47 @@ [

name: "fileURLToPath",
value: "__webpack_fileURLToPath__"
value: URL_MODULE_CONSTANT_FUNCTION_NAME
}
],
undefined,
fn("__webpack_fileURLToPath__"),
/** @type {Range} */ (expr.range),
expressionName
undefined
);
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
dep.loc = /** @type {DependencyLocation} */ (usingProperty.loc);
parser.state.module.addPresentationalDependency(dep);
return true;
});
};
return `${property}: ${URL_MODULE_CONSTANT_FUNCTION_NAME}(${value()}),`;
}
});
}
};
/**
* @param {string} expressionName expression name
* @param {string} value value
* @param {string=} warning warning
* @returns {void}
*/
const setConstant = (expressionName, value, warning) =>
setModuleConstant(expressionName, () => value, warning);
/**
* @param {JavascriptParser} parser the parser
* @param {NodeOptions} nodeOptions options
* @param {{ dirname: "__dirname" | "import.meta.dirname", filename: "__filename" | "import.meta.filename" }} identifiers options
* @returns {void}
*/
const dirnameAndFilenameHandler = (
parser,
nodeOptions,
{ dirname, filename }
) => {
// Keep `import.meta.filename` in code
if (
nodeOptions.__filename === false &&
filename === "import.meta.filename"
) {
setModuleConstant(parser, filename, () => filename, "filename");
}
const context = compiler.context;
if (localOptions.__filename) {
switch (localOptions.__filename) {
if (nodeOptions.__filename) {
switch (nodeOptions.__filename) {
case "mock":
setConstant("__filename", "/index.js");
setConstant(parser, filename, "/index.js", "filename");
break;
case "warn-mock":
setConstant(
"__filename",
parser,
filename,
"/index.js",
"filename",
"__filename is a Node.js feature and isn't available in browsers."

@@ -197,14 +380,42 @@ );

setUrlModuleConstant(
"__filename",
(functionName) => `${functionName}(${importMetaName}.url)`
parser,
filename,
"filename",
() => `${importMetaName}.url`
);
break;
}
case "eval-only":
// Keep `import.meta.filename` in the source code for the ES module output, or create a fallback using `import.meta.url` if possible
if (compilation.outputOptions.module) {
const { importMetaName } = compilation.outputOptions;
setUrlModuleConstant(
parser,
filename,
"filename",
() => `${importMetaName}.url`
);
}
// Replace `import.meta.filename` with `__filename` for the non-ES module output
else if (filename === "import.meta.filename") {
setModuleConstant(
parser,
filename,
() => "__filename",
"filename"
);
}
break;
case true:
setModuleConstant("__filename", (module) =>
relative(
/** @type {InputFileSystem} */ (compiler.inputFileSystem),
context,
module.resource
)
setCachedModuleConstant(
parser,
filename,
(module) =>
relative(
/** @type {InputFileSystem} */ (compiler.inputFileSystem),
compiler.context,
module.resource
),
"filename"
);

@@ -222,11 +433,22 @@ break;

}
if (localOptions.__dirname) {
switch (localOptions.__dirname) {
// Keep `import.meta.dirname` in code
if (
nodeOptions.__dirname === false &&
dirname === "import.meta.dirname"
) {
setModuleConstant(parser, dirname, () => dirname, "dirname");
}
if (nodeOptions.__dirname) {
switch (nodeOptions.__dirname) {
case "mock":
setConstant("__dirname", "/");
setConstant(parser, dirname, "/", "dirname");
break;
case "warn-mock":
setConstant(
"__dirname",
parser,
dirname,
"/",
"dirname",
"__dirname is a Node.js feature and isn't available in browsers."

@@ -239,15 +461,42 @@ );

setUrlModuleConstant(
"__dirname",
(functionName) =>
`${functionName}(${importMetaName}.url + "/..").slice(0, -1)`
parser,
dirname,
"dirname",
() => `${importMetaName}.url.replace(/\\/(?:[^\\/]*)$/, "")`
);
break;
}
case "eval-only":
// Keep `import.meta.dirname` in the source code for the ES module output and replace `__dirname` on `import.meta.dirname`
if (compilation.outputOptions.module) {
const { importMetaName } = compilation.outputOptions;
setUrlModuleConstant(
parser,
dirname,
"dirname",
() => `${importMetaName}.url.replace(/\\/(?:[^\\/]*)$/, "")`
);
}
// Replace `import.meta.dirname` with `__dirname` for the non-ES module output
else if (dirname === "import.meta.dirname") {
setModuleConstant(
parser,
dirname,
() => "__dirname",
"dirname"
);
}
break;
case true:
setModuleConstant("__dirname", (module) =>
relative(
/** @type {InputFileSystem} */ (compiler.inputFileSystem),
context,
/** @type {string} */ (module.context)
)
setCachedModuleConstant(
parser,
dirname,
(module) =>
relative(
/** @type {InputFileSystem} */ (compiler.inputFileSystem),
compiler.context,
/** @type {string} */ (module.context)
),
"dirname"
);

@@ -258,3 +507,3 @@ break;

parser.hooks.evaluateIdentifier
.for("__dirname")
.for(dirname)
.tap(PLUGIN_NAME, (expr) => {

@@ -268,11 +517,51 @@ if (!parser.state.module) return;

}
parser.hooks.expression
.for("require.extensions")
.tap(
PLUGIN_NAME,
expressionIsUnsupported(
parser,
"require.extensions is not supported by webpack. Use a loader instead."
)
};
/**
* @param {JavascriptParser} parser the parser
* @param {JavascriptParserOptions} parserOptions the javascript parser options
* @param {boolean} a true when we need to handle `__filename` and `__dirname`, otherwise false
* @param {boolean} b true when we need to handle `import.meta.filename` and `import.meta.dirname`, otherwise false
*/
const handler = (parser, parserOptions, a, b) => {
if (b && parserOptions.node === false) {
// Keep `import.meta.dirname` and `import.meta.filename` in code
setModuleConstant(
parser,
"import.meta.dirname",
() => "import.meta.dirname",
"dirname"
);
setModuleConstant(
parser,
"import.meta.filename",
() => "import.meta.filename",
"filename"
);
return;
}
let localOptions = options;
if (parserOptions.node) {
localOptions = { ...localOptions, ...parserOptions.node };
}
if (localOptions.global !== false) {
globalHandler(parser, localOptions);
}
if (a) {
dirnameAndFilenameHandler(parser, localOptions, {
dirname: "__dirname",
filename: "__filename"
});
}
if (b && parserOptions.importMeta !== false) {
dirnameAndFilenameHandler(parser, localOptions, {
dirname: "import.meta.dirname",
filename: "import.meta.filename"
});
}
};

@@ -282,6 +571,15 @@

.for(JAVASCRIPT_MODULE_TYPE_AUTO)
.tap(PLUGIN_NAME, handler);
.tap(PLUGIN_NAME, (parser, parserOptions) => {
handler(parser, parserOptions, true, true);
});
normalModuleFactory.hooks.parser
.for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
.tap(PLUGIN_NAME, handler);
.tap(PLUGIN_NAME, (parser, parserOptions) => {
handler(parser, parserOptions, true, false);
});
normalModuleFactory.hooks.parser
.for(JAVASCRIPT_MODULE_TYPE_ESM)
.tap(PLUGIN_NAME, (parser, parserOptions) => {
handler(parser, parserOptions, false, true);
});
}

@@ -288,0 +586,0 @@ );

@@ -99,3 +99,2 @@ /*

/** @typedef {import("./util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
/** @typedef {import("../declarations/WebpackOptions").RuleSetRule["extractSourceMap"]} ExtractSourceMapOptions */
/**

@@ -259,3 +258,3 @@ * @template T

* @property {ResolveOptions=} resolveOptions options used for resolving requests from this module
* @property {boolean=} extractSourceMap enable/disable extracting source map
* @property {boolean} extractSourceMap enable/disable extracting source map
*/

@@ -358,30 +357,32 @@

// Info from Factory
/** @type {string} */
/** @type {NormalModuleCreateData['request']} */
this.request = request;
/** @type {string} */
/** @type {NormalModuleCreateData['userRequest']} */
this.userRequest = userRequest;
/** @type {string} */
/** @type {NormalModuleCreateData['rawRequest']} */
this.rawRequest = rawRequest;
/** @type {boolean} */
this.binary = /^(asset|webassembly)\b/.test(type);
/** @type {undefined | Parser} */
/** @type {NormalModuleCreateData['parser'] | undefined} */
this.parser = parser;
/** @type {undefined | ParserOptions} */
/** @type {NormalModuleCreateData['parserOptions']} */
this.parserOptions = parserOptions;
/** @type {undefined | Generator} */
/** @type {NormalModuleCreateData['generator'] | undefined} */
this.generator = generator;
/** @type {undefined | GeneratorOptions} */
/** @type {NormalModuleCreateData['generatorOptions']} */
this.generatorOptions = generatorOptions;
/** @type {string} */
/** @type {NormalModuleCreateData['resource']} */
this.resource = resource;
/** @type {NormalModuleCreateData['resourceResolveData']} */
this.resourceResolveData = resourceResolveData;
/** @type {string | undefined} */
/** @type {NormalModuleCreateData['matchResource']} */
this.matchResource = matchResource;
/** @type {LoaderItem[]} */
/** @type {NormalModuleCreateData['loaders']} */
this.loaders = loaders;
if (resolveOptions !== undefined) {
// already declared in super class
/** @type {NormalModuleCreateData['resolveOptions']} */
this.resolveOptions = resolveOptions;
}
/** @type {ExtractSourceMapOptions} */
/** @type {NormalModuleCreateData['extractSourceMap']} */
this.extractSourceMap = extractSourceMap;

@@ -493,2 +494,3 @@

this.loaders = m.loaders;
this.extractSourceMap = m.extractSourceMap;
}

@@ -1728,3 +1730,2 @@

write(this._codeGeneratorData);
write(this.extractSourceMap);
super.serialize(context);

@@ -1754,3 +1755,4 @@ }

generatorOptions: /** @type {EXPECTED_ANY} */ (null),
resolveOptions: /** @type {EXPECTED_ANY} */ (null)
resolveOptions: /** @type {EXPECTED_ANY} */ (null),
extractSourceMap: /** @type {EXPECTED_ANY} */ (null)
});

@@ -1771,3 +1773,2 @@ obj.deserialize(context);

this._codeGeneratorData = read();
this.extractSourceMap = read();
super.deserialize(context);

@@ -1774,0 +1775,0 @@ }

@@ -38,7 +38,25 @@ /*

defer
? `var webpackDone = ${RuntimeGlobals.asyncModuleDoneSymbol} = hasSymbol ? Symbol("webpack done") : "__webpack_done__";`
? Template.asString([
`var webpackDone = ${RuntimeGlobals.asyncModuleDoneSymbol} = hasSymbol ? Symbol("webpack done") : "__webpack_done__";`,
`var webpackDefer = ${RuntimeGlobals.deferredModuleAsyncTransitiveDependenciesSymbol} = hasSymbol ? Symbol("webpack defer") : "__webpack_defer__";`,
`${RuntimeGlobals.deferredModuleAsyncTransitiveDependencies} = ${runtimeTemplate.basicFunction(
"asyncDeps",
[
Template.indent([
"var hasUnresolvedAsyncSubgraph = asyncDeps.some((id) => {",
Template.indent([
"var cache = __webpack_module_cache__[id];",
"return !cache || cache[webpackDone] === false;"
]),
"});",
"if (hasUnresolvedAsyncSubgraph) {",
Template.indent([
"return ({ then(onFulfilled, onRejected) { return Promise.all(asyncDeps.map(__webpack_require__)).then(onFulfilled, onRejected) } })"
]),
"}"
])
]
)}`
])
: "",
defer
? `var webpackDefer = ${RuntimeGlobals.makeDeferredNamespaceObjectSymbol} = hasSymbol ? Symbol("webpack defer") : "__webpack_defer__";`
: "",
`var resolveQueue = ${runtimeTemplate.basicFunction("queue", [

@@ -67,11 +85,4 @@ "if(queue && queue.d < 1) {",

Template.indent([
"var asyncDeps = dep[webpackDefer];",
`var hasUnresolvedAsyncSubgraph = asyncDeps.some(${runtimeTemplate.basicFunction(
"id",
[
"var cache = __webpack_module_cache__[id];",
"return !cache || cache[webpackDone] === false;"
]
)});`,
"if (hasUnresolvedAsyncSubgraph) {",
`var asyncDeps = ${RuntimeGlobals.deferredModuleAsyncTransitiveDependencies}(dep[webpackDefer]);`,
"if (asyncDeps) {",
Template.indent([

@@ -81,8 +92,7 @@ "var d = dep;",

Template.indent([
"then(callback) {",
"then(onFulfilled, onRejected) {",
Template.indent([
"Promise.all(asyncDeps.map(__webpack_require__))",
`.then(${runtimeTemplate.returningFunction(
"callback(d)"
)});`
`asyncDeps.then(${runtimeTemplate.returningFunction(
"onFulfilled(d)"
)}, onRejected);`
]),

@@ -89,0 +99,0 @@ "}"

@@ -26,3 +26,4 @@ /*

const compilation = /** @type {Compilation} */ (this.compilation);
const { scriptType, importMetaName, path } = compilation.outputOptions;
const { scriptType, importMetaName, path, environment } =
compilation.outputOptions;
const chunkName = compilation.getPath(

@@ -45,2 +46,6 @@ JavascriptModulesPlugin.getChunkFilenameTemplate(

const global = environment.globalThis
? "globalThis"
: RuntimeGlobals.global;
return Template.asString([

@@ -51,4 +56,4 @@ "var scriptUrl;",

: Template.asString([
`if (${RuntimeGlobals.global}.importScripts) scriptUrl = ${RuntimeGlobals.global}.location + "";`,
`var document = ${RuntimeGlobals.global}.document;`,
`if (${global}.importScripts) scriptUrl = ${global}.location + "";`,
`var document = ${global}.document;`,
"if (!scriptUrl && document) {",

@@ -55,0 +60,0 @@ Template.indent([

@@ -11,4 +11,8 @@ /*

/** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
/** @typedef {import("../Module").ExportsType} ExportsType */
/** @typedef {import("../ChunkGraph").ModuleId} ModuleId */
/**
* @param {import("../Module").ExportsType} exportsType exports type
* @param {ExportsType} exportsType exports type
* @returns {string} mode

@@ -23,58 +27,78 @@ */

}
/**
* @param {import("../ModuleTemplate").RuntimeTemplate} _runtimeTemplate runtimeTemplate
* @param {import("../Module").ExportsType} exportsType exportsType
* @param {string} moduleId moduleId
* @param {(import("../ChunkGraph").ModuleId | null)[]} asyncDepsIds asyncDepsIds
* @returns {string} function
* @param {ExportsType} exportsType exportsType
* @param {(ModuleId | null)[]} asyncDepsIds asyncDepsIds
* @param {RuntimeRequirements} runtimeRequirements runtime requirements
* @returns {string} call make optimized deferred namespace object
*/
function getOptimizedDeferredModule(
_runtimeTemplate,
moduleId,
exportsType,
moduleId,
asyncDepsIds
asyncDepsIds,
runtimeRequirements
) {
const isAsync = asyncDepsIds && asyncDepsIds.length;
const init = `${RuntimeGlobals.require}(${moduleId})${
isAsync ? `[${RuntimeGlobals.asyncModuleExportSymbol}]` : ""
}`;
const props = [
`/* ${exportsType} */ get a() {`,
// if exportsType is "namespace" we can generate the most optimized code,
// on the second access, we can avoid trigger the getter.
// we can also do this if exportsType is "dynamic" and there is a "__esModule" property on it.
exportsType === "namespace" || exportsType === "dynamic"
? Template.indent([
`var exports = ${init};`,
`${
exportsType === "dynamic" ? "if (exports.__esModule) " : ""
}Object.defineProperty(this, "a", { value: exports });`,
"return exports;"
])
: Template.indent([`return ${init};`]),
isAsync ? "}," : "}",
isAsync
? `[${
RuntimeGlobals.makeDeferredNamespaceObjectSymbol
}]: ${JSON.stringify(asyncDepsIds.filter((x) => x !== null))}`
runtimeRequirements.add(RuntimeGlobals.makeOptimizedDeferredNamespaceObject);
const mode = getMakeDeferredNamespaceModeFromExportsType(exportsType);
return `${RuntimeGlobals.makeOptimizedDeferredNamespaceObject}(${moduleId}, ${mode}${
asyncDepsIds.length > 0
? `, ${JSON.stringify(asyncDepsIds.filter((x) => x !== null))}`
: ""
];
return Template.asString(["{", Template.indent(props), "}"]);
})`;
}
const strictModuleCache = [
"if (cachedModule && cachedModule.error === undefined) {",
Template.indent([
"var exports = cachedModule.exports;",
"if (mode == 0) return exports;",
`if (mode == 1) return ${RuntimeGlobals.createFakeNamespaceObject}(exports);`,
`if (mode == 2) return ${RuntimeGlobals.createFakeNamespaceObject}(exports, 2);`,
`if (mode == 3) return ${RuntimeGlobals.createFakeNamespaceObject}(exports, 6);` // 2 | 4
]),
"}"
];
const nonStrictModuleCache = [
"// optimization not applied when output.strictModuleErrorHandling is off"
];
class MakeOptimizedDeferredNamespaceObjectRuntimeModule extends HelperRuntimeModule {
/**
* @param {boolean} hasAsyncRuntime if async module is used.
*/
constructor(hasAsyncRuntime) {
super("make optimized deferred namespace object");
this.hasAsyncRuntime = hasAsyncRuntime;
}
/**
* @returns {string | null} runtime code
*/
generate() {
if (!this.compilation) return null;
const fn = RuntimeGlobals.makeOptimizedDeferredNamespaceObject;
const hasAsync = this.hasAsyncRuntime;
return Template.asString([
// Note: must be a function (not arrow), because this is used in body!
`${fn} = function(moduleId, mode${hasAsync ? ", asyncDeps" : ""}) {`,
Template.indent([
"// mode: 0 => namespace (esm)",
"// mode: 1 => default-only (esm strict cjs)",
"// mode: 2 => default-with-named (esm-cjs compat)",
"// mode: 3 => dynamic (if exports has __esModule, then esm, otherwise default-with-named)",
"var r = this;",
hasAsync ? "var isAsync = asyncDeps && asyncDeps.length;" : "",
"var obj = {",
Template.indent([
"get a() {",
Template.indent([
"var exports = r(moduleId);",
hasAsync
? `if(isAsync) exports = exports[${RuntimeGlobals.asyncModuleExportSymbol}];`
: "",
// if exportsType is "namespace" we can generate the most optimized code,
// on the second access, we can avoid trigger the getter.
// we can also do this if exportsType is "dynamic" and there is a "__esModule" property on it.
'if(mode == 0 || (mode == 3 && exports.__esModule)) Object.defineProperty(this, "a", { value: exports });',
"return exports;"
]),
"}"
]),
"};",
hasAsync
? `if(isAsync) obj[${RuntimeGlobals.deferredModuleAsyncTransitiveDependenciesSymbol}] = asyncDeps;`
: "",
"return obj;"
]),
"};"
]);
}
}
class MakeDeferredNamespaceObjectRuntimeModule extends HelperRuntimeModule {

@@ -97,4 +121,2 @@ /**

const hasAsync = this.hasAsyncRuntime;
const strictError =
this.compilation.options.output.strictModuleErrorHandling;
const init = runtimeTemplate.supportsOptionalChaining()

@@ -110,3 +132,14 @@ ? "init?.();"

"var cachedModule = __webpack_module_cache__[moduleId];",
...(strictError ? strictModuleCache : nonStrictModuleCache),
"if (cachedModule && cachedModule.error === undefined) {",
Template.indent([
"var exports = cachedModule.exports;",
hasAsync
? `if (${RuntimeGlobals.asyncModuleExportSymbol} in exports) exports = exports[${RuntimeGlobals.asyncModuleExportSymbol}];`
: "",
"if (mode == 0) return exports;",
`if (mode == 1) return ${RuntimeGlobals.createFakeNamespaceObject}(exports);`,
`if (mode == 2) return ${RuntimeGlobals.createFakeNamespaceObject}(exports, 2);`,
`if (mode == 3) return ${RuntimeGlobals.createFakeNamespaceObject}(exports, 6);` // 2 | 4
]),
"}",
"",

@@ -144,5 +177,3 @@ `var init = ${runtimeTemplate.basicFunction("", [

"",
`var ns = ${
strictError ? "" : "cachedModule && cachedModule.exports || "
}__webpack_module_deferred_exports__[moduleId] || (__webpack_module_deferred_exports__[moduleId] = { __proto__: null });`,
"var ns = __webpack_module_deferred_exports__[moduleId] || (__webpack_module_deferred_exports__[moduleId] = { __proto__: null });",
"var handler = {",

@@ -169,3 +200,3 @@ Template.indent([

hasAsync
? `case ${RuntimeGlobals.makeDeferredNamespaceObjectSymbol}:`
? `case ${RuntimeGlobals.deferredModuleAsyncTransitiveDependenciesSymbol}:`
: "",

@@ -217,5 +248,8 @@ Template.indent("return true;"),

module.exports = MakeDeferredNamespaceObjectRuntimeModule;
module.exports.MakeDeferredNamespaceObjectRuntimeModule =
MakeDeferredNamespaceObjectRuntimeModule;
module.exports.MakeOptimizedDeferredNamespaceObjectRuntimeModule =
MakeOptimizedDeferredNamespaceObjectRuntimeModule;
module.exports.getMakeDeferredNamespaceModeFromExportsType =
getMakeDeferredNamespaceModeFromExportsType;
module.exports.getOptimizedDeferredModule = getOptimizedDeferredModule;

@@ -82,2 +82,8 @@ /*

/**
* merge multiple CSS stylesheets (CSSStyleSheet or string) into one CSS text string
* Arguments: (sheets: Array<CSSStyleSheet | string> | CSSStyleSheet | string) => string
*/
module.exports.cssMergeStyleSheets = "__webpack_require__.mcs";
/**
* The current scope when getting a module from a remote

@@ -88,2 +94,14 @@ */

/**
* resolve async transitive dependencies for deferred module
*/
module.exports.deferredModuleAsyncTransitiveDependencies =
"__webpack_require__.zT";
/**
* the internal symbol for getting the async transitive dependencies for deferred module
*/
module.exports.deferredModuleAsyncTransitiveDependenciesSymbol =
"__webpack_require__.zS";
/**
* the exported property define getters function

@@ -263,10 +281,10 @@ */

/**
* the internal symbol that makeDeferredNamespaceObject is using.
* define compatibility on export
*/
module.exports.makeDeferredNamespaceObjectSymbol = "__webpack_require__.zS";
module.exports.makeNamespaceObject = "__webpack_require__.r";
/**
* define compatibility on export
* make a optimized deferred namespace object
*/
module.exports.makeNamespaceObject = "__webpack_require__.r";
module.exports.makeOptimizedDeferredNamespaceObject = "__webpack_require__.zO";

@@ -273,0 +291,0 @@ /**

@@ -27,3 +27,6 @@ /*

const LoadScriptRuntimeModule = require("./runtime/LoadScriptRuntimeModule");
const MakeDeferredNamespaceObjectRuntime = require("./runtime/MakeDeferredNamespaceObjectRuntime");
const {
MakeDeferredNamespaceObjectRuntimeModule,
MakeOptimizedDeferredNamespaceObjectRuntimeModule
} = require("./runtime/MakeDeferredNamespaceObjectRuntime");
const MakeNamespaceObjectRuntimeModule = require("./runtime/MakeNamespaceObjectRuntimeModule");

@@ -82,2 +85,3 @@ const NonceRuntimeModule = require("./runtime/NonceRuntimeModule");

RuntimeGlobals.onChunksLoaded,
RuntimeGlobals.makeOptimizedDeferredNamespaceObject,
RuntimeGlobals.makeDeferredNamespaceObject

@@ -101,7 +105,7 @@ ];

],
[RuntimeGlobals.makeOptimizedDeferredNamespaceObject]: [
RuntimeGlobals.require
],
[RuntimeGlobals.makeDeferredNamespaceObject]: [
RuntimeGlobals.definePropertyGetters,
RuntimeGlobals.makeNamespaceObject,
RuntimeGlobals.createFakeNamespaceObject,
RuntimeGlobals.hasOwnProperty,
RuntimeGlobals.require

@@ -197,2 +201,13 @@ ],

compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.makeOptimizedDeferredNamespaceObject)
.tap("RuntimePlugin", (chunk, runtimeRequirement) => {
compilation.addRuntimeModule(
chunk,
new MakeOptimizedDeferredNamespaceObjectRuntimeModule(
runtimeRequirement.has(RuntimeGlobals.asyncModule)
)
);
return true;
});
compilation.hooks.runtimeRequirementInTree
.for(RuntimeGlobals.makeDeferredNamespaceObject)

@@ -202,3 +217,3 @@ .tap("RuntimePlugin", (chunk, runtimeRequirement) => {

chunk,
new MakeDeferredNamespaceObjectRuntime(
new MakeDeferredNamespaceObjectRuntimeModule(
runtimeRequirement.has(RuntimeGlobals.asyncModule)

@@ -246,3 +261,9 @@ )

const module = new AutoPublicPathRuntimeModule();
if (scriptType !== "module") set.add(RuntimeGlobals.global);
if (
scriptType !== "module" &&
!outputOptions.environment.globalThis
) {
set.add(RuntimeGlobals.global);
}
compilation.addRuntimeModule(chunk, module);

@@ -249,0 +270,0 @@ } else {

@@ -14,2 +14,3 @@ /*

} = require("./async-modules/AsyncModuleHelpers");
const { ImportPhaseUtils } = require("./dependencies/ImportPhase");
const {

@@ -21,5 +22,13 @@ getMakeDeferredNamespaceModeFromExportsType,

const compileBooleanMatcher = require("./util/compileBooleanMatcher");
const memoize = require("./util/memoize");
const propertyAccess = require("./util/propertyAccess");
const { forEachRuntime, subtractRuntime } = require("./util/runtime");
const getHarmonyImportDependency = memoize(() =>
require("./dependencies/HarmonyImportDependency")
);
const getImportDependency = memoize(() =>
require("./dependencies/ImportDependency")
);
/** @typedef {import("./config/defaults").OutputNormalizedWithDefaults} OutputOptions */

@@ -37,2 +46,4 @@ /** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */

/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
/** @typedef {import("./dependencies/ImportPhase").ImportPhaseType} ImportPhaseType */
/** @typedef {import("./NormalModuleFactory").ModuleDependency} ModuleDependency */

@@ -623,2 +634,3 @@ /**

* @param {boolean=} options.weak if the dependency is weak (will create a nice error message)
* @param {Dependency} options.dependency dependency
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements

@@ -635,2 +647,3 @@ * @returns {string} the promise expression

weak,
dependency,
runtimeRequirements

@@ -692,38 +705,41 @@ }) {

}
const moduleIdExpr = this.moduleId({
module,
chunkGraph,
request,
weak
});
const exportsType = module.getExportsType(chunkGraph.moduleGraph, strict);
let fakeType = 16;
switch (exportsType) {
case "namespace":
const isModuleDeferred =
(dependency instanceof getHarmonyImportDependency() ||
dependency instanceof getImportDependency()) &&
ImportPhaseUtils.isDefer(dependency.phase) &&
!(/** @type {BuildMeta} */ (module.buildMeta).async);
if (isModuleDeferred) {
runtimeRequirements.add(RuntimeGlobals.makeDeferredNamespaceObject);
const mode = getMakeDeferredNamespaceModeFromExportsType(exportsType);
const asyncDeps = Array.from(
getOutgoingAsyncModules(chunkGraph.moduleGraph, module),
(m) => chunkGraph.getModuleId(m)
).filter((id) => id !== null);
if (asyncDeps.length) {
if (header) {
const rawModule = this.moduleRaw({
module,
chunkGraph,
request,
weak,
runtimeRequirements
});
appending = `.then(${this.basicFunction(
"",
`${header}return ${rawModule};`
`${header}return ${RuntimeGlobals.deferredModuleAsyncTransitiveDependencies}(${JSON.stringify(asyncDeps)});`
)})`;
} else {
runtimeRequirements.add(RuntimeGlobals.require);
appending = `.then(${RuntimeGlobals.require}.bind(${RuntimeGlobals.require}, ${comment}${idExpr}))`;
appending = `.then(${this.returningFunction(`${RuntimeGlobals.deferredModuleAsyncTransitiveDependencies}(${JSON.stringify(asyncDeps)})`)})`;
}
break;
case "dynamic":
fakeType |= 4;
/* fall through */
case "default-with-named":
fakeType |= 2;
/* fall through */
case "default-only":
runtimeRequirements.add(RuntimeGlobals.createFakeNamespaceObject);
if (chunkGraph.moduleGraph.isAsync(module)) {
appending += `.then(${RuntimeGlobals.makeDeferredNamespaceObject}.bind(${RuntimeGlobals.require}, ${comment}${idExpr}, ${mode}))`;
} else if (header) {
appending = `.then(${this.basicFunction(
"",
`${header}return ${RuntimeGlobals.makeDeferredNamespaceObject}(${comment}${idExpr}, ${mode});`
)})`;
} else {
runtimeRequirements.add(RuntimeGlobals.require);
appending = `.then(${RuntimeGlobals.makeDeferredNamespaceObject}.bind(${RuntimeGlobals.require}, ${comment}${idExpr}, ${mode}))`;
}
} else {
let fakeType = 16;
switch (exportsType) {
case "namespace":
if (header) {

@@ -745,19 +761,52 @@ const rawModule = this.moduleRaw({

}
appending += `.then(${this.returningFunction(
`${RuntimeGlobals.createFakeNamespaceObject}(m, ${fakeType})`,
"m"
)})`;
} else {
fakeType |= 1;
if (header) {
const returnExpression = `${RuntimeGlobals.createFakeNamespaceObject}(${moduleIdExpr}, ${fakeType})`;
appending = `.then(${this.basicFunction(
"",
`${header}return ${returnExpression};`
break;
case "dynamic":
fakeType |= 4;
/* fall through */
case "default-with-named":
fakeType |= 2;
/* fall through */
case "default-only":
runtimeRequirements.add(RuntimeGlobals.createFakeNamespaceObject);
if (chunkGraph.moduleGraph.isAsync(module)) {
if (header) {
const rawModule = this.moduleRaw({
module,
chunkGraph,
request,
weak,
runtimeRequirements
});
appending = `.then(${this.basicFunction(
"",
`${header}return ${rawModule};`
)})`;
} else {
runtimeRequirements.add(RuntimeGlobals.require);
appending = `.then(${RuntimeGlobals.require}.bind(${RuntimeGlobals.require}, ${comment}${idExpr}))`;
}
appending += `.then(${this.returningFunction(
`${RuntimeGlobals.createFakeNamespaceObject}(m, ${fakeType})`,
"m"
)})`;
} else {
appending = `.then(${RuntimeGlobals.createFakeNamespaceObject}.bind(${RuntimeGlobals.require}, ${comment}${idExpr}, ${fakeType}))`;
fakeType |= 1;
if (header) {
const moduleIdExpr = this.moduleId({
module,
chunkGraph,
request,
weak
});
const returnExpression = `${RuntimeGlobals.createFakeNamespaceObject}(${moduleIdExpr}, ${fakeType})`;
appending = `.then(${this.basicFunction(
"",
`${header}return ${returnExpression};`
)})`;
} else {
appending = `.then(${RuntimeGlobals.createFakeNamespaceObject}.bind(${RuntimeGlobals.require}, ${comment}${idExpr}, ${fakeType}))`;
}
}
}
break;
break;
}
}

@@ -816,3 +865,3 @@

* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
* @param {boolean=} options.defer if set, the module will be deferred
* @param {ModuleDependency} options.dependency module dependency
* @returns {[string, string]} the import statement and the compat statement

@@ -829,3 +878,3 @@ */

weak,
defer,
dependency,
runtimeRequirements

@@ -878,3 +927,10 @@ }) {

let importContent;
if (defer && !(/** @type {BuildMeta} */ (module.buildMeta).async)) {
const isModuleDeferred =
(dependency instanceof getHarmonyImportDependency() ||
dependency instanceof getImportDependency()) &&
ImportPhaseUtils.isDefer(dependency.phase) &&
!(/** @type {BuildMeta} */ (module.buildMeta).async);
if (isModuleDeferred) {
/** @type {Set<Module>} */

@@ -884,6 +940,6 @@ const outgoingAsyncModules = getOutgoingAsyncModules(moduleGraph, module);

importContent = `/* deferred harmony import */ ${optDeclaration}${importVar} = ${getOptimizedDeferredModule(
this,
moduleId,
exportsType,
moduleId,
Array.from(outgoingAsyncModules, (mod) => chunkGraph.getModuleId(mod))
Array.from(outgoingAsyncModules, (mod) => chunkGraph.getModuleId(mod)),
runtimeRequirements
)};\n`;

@@ -922,3 +978,3 @@

* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
* @param {boolean=} options.defer if true, the module will be deferred.
* @param {ModuleDependency} options.dependency module dependency
* @returns {string} expression

@@ -941,3 +997,3 @@ */

runtimeRequirements,
defer
dependency
}) {

@@ -958,4 +1014,7 @@ if (!module) {

const isDeferred =
defer && !(/** @type {BuildMeta} */ (module.buildMeta).async);
const isModuleDeferred =
(dependency instanceof getHarmonyImportDependency() ||
dependency instanceof getImportDependency()) &&
ImportPhaseUtils.isDefer(dependency.phase) &&
!(/** @type {BuildMeta} */ (module.buildMeta).async);

@@ -965,3 +1024,3 @@ if (defaultInterop) {

if (exportName.length > 0 && exportName[0] === "default") {
if (isDeferred && exportsType !== "namespace") {
if (isModuleDeferred && exportsType !== "namespace") {
const exportsInfo = moduleGraph.getExportsInfo(module);

@@ -1020,3 +1079,3 @@ const name = exportName.slice(1);

}
} else if (isDeferred) {
} else if (isModuleDeferred) {
// now exportName.length is 0

@@ -1064,3 +1123,3 @@ // fall through to the end of this function, create the namespace there.

const access = `${importVar}${
isDeferred ? ".a" : ""
isModuleDeferred ? ".a" : ""
}${comment}${propertyAccess(used)}`;

@@ -1076,3 +1135,3 @@ if (isCall && callContext === false) {

}
if (isDeferred) {
if (isModuleDeferred) {
initFragments.push(

@@ -1079,0 +1138,0 @@ new InitFragment(

@@ -23,2 +23,3 @@ /*

/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */
/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").Rules} Rules */
/** @typedef {import("./CacheFacade").ItemCacheFacade} ItemCacheFacade */

@@ -437,2 +438,21 @@ /** @typedef {import("./Chunk")} Chunk */

sourceMap.sources = /** @type {string[]} */ (moduleFilenames);
sourceMap.ignoreList = options.ignoreList
? sourceMap.sources.reduce(
/** @type {(acc: number[], sourceName: string, idx: number) => number[]} */ (
(acc, sourceName, idx) => {
const rule = /** @type {Rules} */ (
options.ignoreList
);
if (
ModuleFilenameHelpers.matchPart(sourceName, rule)
) {
acc.push(idx);
}
return acc;
}
),
[]
)
: [];
if (options.noSources) {

@@ -439,0 +459,0 @@ sourceMap.sourcesContent = undefined;

@@ -22,2 +22,3 @@ /*

/** @typedef {import("../ModuleGraph")} ModuleGraph */
/** @typedef {import("../dependencies/ModuleDependency")} ModuleDependency */

@@ -528,5 +529,5 @@ /**

}
return /** @type { HarmonyImportSideEffectDependency | HarmonyImportSpecifierDependency} */ (
dep
).sourceOrder;
return /** @type {number} */ (
/** @type {ModuleDependency} */ (dep).sourceOrder
);
};

@@ -533,0 +534,0 @@

@@ -76,6 +76,6 @@ /*

require("../dependencies/CssImportDependency"),
"dependencies/CssLocalIdentifierDependency": () =>
require("../dependencies/CssLocalIdentifierDependency"),
"dependencies/CssSelfLocalIdentifierDependency": () =>
require("../dependencies/CssSelfLocalIdentifierDependency"),
"dependencies/CssIcssLocalIdentifierDependency": () =>
require("../dependencies/CssIcssLocalIdentifierDependency"),
"dependencies/CssIcssSelfLocalIdentifierDependency": () =>
require("../dependencies/CssIcssSelfLocalIdentifierDependency"),
"dependencies/CssIcssImportDependency": () =>

@@ -82,0 +82,0 @@ require("../dependencies/CssIcssImportDependency"),

@@ -23,3 +23,3 @@ /*

/**
* @typedef {{ request: string, importVar: string }} ImportObjRequestItem
* @typedef {{ request: string, importVar: string, dependency: WebAssemblyImportDependency }} ImportObjRequestItem
*/

@@ -74,3 +74,4 @@

request: dep.request,
importVar: `WEBPACK_IMPORTED_MODULE_${depModules.size}`
importVar: `WEBPACK_IMPORTED_MODULE_${depModules.size}`,
dependency: dep
});

@@ -92,3 +93,3 @@ }

depModules,
([importedModule, { request, importVar }]) => {
([importedModule, { request, importVar, dependency }]) => {
if (moduleGraph.isAsync(importedModule)) {

@@ -105,3 +106,4 @@ promises.push(importVar);

importVar,
runtimeRequirements
runtimeRequirements,
dependency
});

@@ -139,3 +141,4 @@ }

runtime,
runtimeRequirements
runtimeRequirements,
dependency: dep
})}`;

@@ -142,0 +145,0 @@ });

@@ -74,2 +74,3 @@ /*

(importData = {
dependency: moduleDep,
importVar: `m${index}`,

@@ -110,3 +111,4 @@ index,

runtime,
runtimeRequirements
runtimeRequirements,
dependency: dep
})

@@ -143,3 +145,4 @@ );

runtime,
runtimeRequirements
runtimeRequirements,
dependency: dep
})};`,

@@ -160,3 +163,3 @@ `if(WebAssembly.Global) ${exportProp} = ` +

importedModules,
([module, { importVar, request, reexports }]) => {
([module, { importVar, request, reexports, dependency }]) => {
const importStatement = runtimeTemplate.importStatement({

@@ -169,3 +172,4 @@ module,

originModule: module,
runtimeRequirements
runtimeRequirements,
dependency
});

@@ -172,0 +176,0 @@ return importStatement[0] + importStatement[1] + reexports.join("\n");

@@ -80,3 +80,2 @@ /*

if (compiler.options.experiments.syncWebAssembly) {
// TODO webpack 6 remove FetchCompileWasmPlugin
const FetchCompileWasmPlugin = require("../web/FetchCompileWasmPlugin");

@@ -99,3 +98,2 @@

if (compiler.options.experiments.syncWebAssembly) {
// TODO webpack 6 remove ReadFileCompileWasmPlugin
const ReadFileCompileWasmPlugin = require("../node/ReadFileCompileWasmPlugin");

@@ -124,5 +122,13 @@

case "universal": {
const UniversalCompileAsyncWasmPlugin = require("../wasm-async/UniversalCompileAsyncWasmPlugin");
if (compiler.options.experiments.syncWebAssembly) {
throw new Error(
"Universal wasm loading type is only supported by asynchronous web assembly."
);
}
new UniversalCompileAsyncWasmPlugin().apply(compiler);
if (compiler.options.experiments.asyncWebAssembly) {
const UniversalCompileAsyncWasmPlugin = require("../wasm-async/UniversalCompileAsyncWasmPlugin");
new UniversalCompileAsyncWasmPlugin().apply(compiler);
}
break;

@@ -129,0 +135,0 @@ }

@@ -20,4 +20,2 @@ /*

// TODO webpack 6 remove
const PLUGIN_NAME = "FetchCompileWasmPlugin";

@@ -24,0 +22,0 @@

@@ -109,25 +109,32 @@ /*

/**
* @callback WebpackFunctionSingle
* @template T
* @param {T[] | T} options options
* @returns {T[]} array of options
*/
const asArray = (options) =>
Array.isArray(options) ? [...options] : [options];
/**
* @overload
* @param {WebpackOptions} options options object
* @param {Callback<Stats>=} callback callback
* @param {Callback<Stats>} callback callback
* @returns {Compiler | null} the compiler object
*/
/**
* @callback WebpackFunctionMulti
* @overload
* @param {WebpackOptions} options options object
* @returns {Compiler} the compiler object
*/
/**
* @overload
* @param {MultiWebpackOptions} options options objects
* @param {Callback<MultiStats>=} callback callback
* @param {Callback<MultiStats>} callback callback
* @returns {MultiCompiler | null} the multi compiler object
*/
/**
* @template T
* @param {T[] | T} options options
* @returns {T[]} array of options
* @overload
* @param {MultiWebpackOptions} options options objects
* @returns {MultiCompiler} the multi compiler object
*/
const asArray = (options) =>
Array.isArray(options) ? [...options] : [options];
/**
* @callback WebpackCallback
* @param {WebpackOptions | MultiWebpackOptions} options options

@@ -137,78 +144,74 @@ * @param {Callback<Stats> & Callback<MultiStats>=} callback callback

*/
const webpack = /** @type {WebpackFunctionSingle & WebpackFunctionMulti} */ (
/** @type {WebpackCallback} */
(options, callback) => {
const create = () => {
if (
!asArray(/** @type {WebpackOptions} */ (options)).every(
webpackOptionsSchemaCheck
)
) {
getValidateSchema()(webpackOptionsSchema, options);
util.deprecate(
() => {},
"webpack bug: Pre-compiled schema reports error while real schema is happy. This has performance drawbacks.",
"DEP_WEBPACK_PRE_COMPILED_SCHEMA_INVALID"
)();
}
/** @type {MultiCompiler|Compiler} */
let compiler;
/** @type {boolean | undefined} */
let watch = false;
/** @type {WatchOptions | WatchOptions[]} */
let watchOptions;
if (Array.isArray(options)) {
/** @type {MultiCompiler} */
compiler = createMultiCompiler(
options,
/** @type {MultiCompilerOptions} */
(options)
);
watch = options.some((options) => options.watch);
watchOptions = options.map((options) => options.watchOptions || {});
const webpack = (options, callback) => {
const create = () => {
if (
!asArray(/** @type {WebpackOptions} */ (options)).every(
webpackOptionsSchemaCheck
)
) {
getValidateSchema()(webpackOptionsSchema, options);
util.deprecate(
() => {},
"webpack bug: Pre-compiled schema reports error while real schema is happy. This has performance drawbacks.",
"DEP_WEBPACK_PRE_COMPILED_SCHEMA_INVALID"
)();
}
/** @type {MultiCompiler|Compiler} */
let compiler;
/** @type {boolean | undefined} */
let watch = false;
/** @type {WatchOptions | WatchOptions[]} */
let watchOptions;
if (Array.isArray(options)) {
/** @type {MultiCompiler} */
compiler = createMultiCompiler(
options,
/** @type {MultiCompilerOptions} */
(options)
);
watch = options.some((options) => options.watch);
watchOptions = options.map((options) => options.watchOptions || {});
} else {
const webpackOptions = /** @type {WebpackOptions} */ (options);
/** @type {Compiler} */
compiler = createCompiler(webpackOptions);
watch = webpackOptions.watch;
watchOptions = webpackOptions.watchOptions || {};
}
return { compiler, watch, watchOptions };
};
if (callback) {
try {
const { compiler, watch, watchOptions } = create();
if (watch) {
compiler.watch(watchOptions, callback);
} else {
const webpackOptions = /** @type {WebpackOptions} */ (options);
/** @type {Compiler} */
compiler = createCompiler(webpackOptions);
watch = webpackOptions.watch;
watchOptions = webpackOptions.watchOptions || {};
}
return { compiler, watch, watchOptions };
};
if (callback) {
try {
const { compiler, watch, watchOptions } = create();
if (watch) {
compiler.watch(watchOptions, callback);
} else {
compiler.run((err, stats) => {
compiler.close((err2) => {
callback(
err || err2,
/** @type {options extends WebpackOptions ? Stats : MultiStats} */
(stats)
);
});
compiler.run((err, stats) => {
compiler.close((err2) => {
callback(
err || err2,
/** @type {options extends WebpackOptions ? Stats : MultiStats} */
(stats)
);
});
}
return compiler;
} catch (err) {
process.nextTick(() => callback(/** @type {Error} */ (err)));
return null;
});
}
} else {
const { compiler, watch } = create();
if (watch) {
util.deprecate(
() => {},
"A 'callback' argument needs to be provided to the 'webpack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.",
"DEP_WEBPACK_WATCH_WITHOUT_CALLBACK"
)();
}
return compiler;
} catch (err) {
process.nextTick(() => callback(/** @type {Error} */ (err)));
return null;
}
} else {
const { compiler, watch } = create();
if (watch) {
util.deprecate(
() => {},
"A 'callback' argument needs to be provided to the 'webpack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.",
"DEP_WEBPACK_WATCH_WITHOUT_CALLBACK"
)();
}
return compiler;
}
);
};
module.exports = webpack;

@@ -21,2 +21,3 @@ /*

const NodeStuffPlugin = require("./NodeStuffPlugin");
const OptionsApply = require("./OptionsApply");

@@ -113,3 +114,11 @@

new NodeTargetPlugin().apply(compiler);
// Some older versions of Node.js don't support all built-in modules via import, only via `require`,
// but шt seems like there shouldn't be a warning here since these versions are rarely used in real applications
new NodeTargetPlugin(
options.output.module &&
compiler.platform.node === null &&
compiler.platform.web === null
? "module-import"
: "node-commonjs"
).apply(compiler);

@@ -131,3 +140,5 @@ // Handle external CSS `@import` and `url()`

} else if (
dependencyType === "css-import" &&
(dependencyType === "css-import" ||
dependencyType === "css-import-local-module" ||
dependencyType === "css-import-global-module") &&
options.experiments.css

@@ -155,3 +166,5 @@ ) {

} else if (
dependencyType === "css-import" &&
(dependencyType === "css-import" ||
dependencyType === "css-import-local-module" ||
dependencyType === "css-import-global-module") &&
options.experiments.css

@@ -301,2 +314,10 @@ ) {

if (options.dotenv) {
const DotenvPlugin = require("./DotenvPlugin");
new DotenvPlugin(
typeof options.dotenv === "boolean" ? {} : options.dotenv
).apply(compiler);
}
if (options.devtool) {

@@ -452,7 +473,7 @@ if (options.devtool.includes("source-map")) {

new LoaderPlugin().apply(compiler);
if (options.node !== false) {
const NodeStuffPlugin = require("./NodeStuffPlugin");
new NodeStuffPlugin(options.node).apply(compiler);
}
new NodeStuffPlugin({
global: options.node ? options.node.global : false,
__dirname: options.node ? options.node.__dirname : false,
__filename: options.node ? options.node.__filename : false
}).apply(compiler);
new APIPlugin().apply(compiler);

@@ -676,4 +697,7 @@ new ExportsInfoApiPlugin().apply(compiler);

const defValue = JSON.stringify(options.optimization.nodeEnv);
new DefinePlugin({
"process.env.NODE_ENV": JSON.stringify(options.optimization.nodeEnv)
"process.env.NODE_ENV": defValue,
"import.meta.env.NODE_ENV": defValue
}).apply(compiler);

@@ -680,0 +704,0 @@ }

@@ -164,2 +164,6 @@ declare namespace webpack {

interface ImportMetaEnv {
[key: string]: string | boolean | undefined;
}
interface ImportMeta {

@@ -169,2 +173,3 @@ url: string;

webpackHot: webpack.Hot;
env: ImportMetaEnv;
webpackContext: (

@@ -171,0 +176,0 @@ request: string,

{
"name": "webpack",
"version": "5.102.1",
"version": "5.103.0",
"description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",

@@ -101,3 +101,3 @@ "homepage": "https://github.com/webpack/webpack",

"json-parse-even-better-errors": "^2.3.1",
"loader-runner": "^4.2.0",
"loader-runner": "^4.3.1",
"mime-types": "^2.1.27",

@@ -115,4 +115,4 @@ "neo-async": "^2.6.2",

"@codspeed/core": "^5.0.1",
"@eslint/js": "^9.36.0",
"@eslint/markdown": "^7.3.0",
"@eslint/js": "^9.37.0",
"@eslint/markdown": "^7.4.0",
"@stylistic/eslint-plugin": "^5.4.0",

@@ -123,5 +123,5 @@ "@types/glob-to-regexp": "^0.4.4",

"@types/mime-types": "^2.1.4",
"@types/node": "^24.5.2",
"@types/node": "^24.9.1",
"@types/xxhashjs": "^0.2.4",
"assemblyscript": "^0.28.8",
"assemblyscript": "^0.28.9",
"babel-loader": "^10.0.0",

@@ -137,3 +137,3 @@ "bundle-loader": "^0.5.6",

"es6-promise-polyfill": "^1.2.0",
"eslint": "^9.36.0",
"eslint": "^9.37.0",
"eslint-config-prettier": "^10.1.1",

@@ -146,3 +146,3 @@ "eslint-config-webpack": "^4.5.1",

"eslint-plugin-prettier": "^5.5.0",
"eslint-plugin-unicorn": "^61.0.1",
"eslint-plugin-unicorn": "^62.0.0",
"file-loader": "^6.0.0",

@@ -162,8 +162,9 @@ "fork-ts-checker-webpack-plugin": "^9.0.2",

"json5": "^2.1.3",
"less": "^4.0.0",
"less": "^4.4.2",
"less-loader": "^12.2.0",
"lint-staged": "^16.1.2",
"lint-staged": "^16.2.3",
"lodash": "^4.17.19",
"lodash-es": "^4.17.15",
"memfs": "^4.14.0",
"memfs": "^4.49.0",
"meriyah": "^6.1.4",
"mini-css-extract-plugin": "^2.9.0",

@@ -174,2 +175,3 @@ "mini-svg-data-uri": "^1.2.3",

"open-cli": "^8.0.0",
"pkg-pr-new": "^0.0.60",
"prettier": "^3.6.0",

@@ -181,4 +183,4 @@ "prettier-2": "npm:prettier@^2",

"raw-loader": "^4.0.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"rimraf": "^3.0.2",

@@ -190,3 +192,3 @@ "script-loader": "^0.7.2",

"terser": "^5.43.1",
"three": "^0.180.0",
"three": "^0.181.0",
"tinybench": "^5.0.0",

@@ -193,0 +195,0 @@ "toml": "^3.0.0",

@@ -6,2 +6,2 @@ /*

*/
"use strict";function r(t,{instancePath:e="",parentData:a,parentDataProperty:n,rootData:o=t}={}){if(!Array.isArray(t))return r.errors=[{params:{type:"array"}}],!1;{const e=t.length;for(let a=0;a<e;a++){let e=t[a];const n=0;if("string"!=typeof e)return r.errors=[{params:{type:"string"}}],!1;if(e.length<1)return r.errors=[{params:{}}],!1;if(0!==n)break}}return r.errors=null,!0}function t(e,{instancePath:a="",parentData:n,parentDataProperty:o,rootData:s=e}={}){let l=null,p=0;if(0===p){if(!e||"object"!=typeof e||Array.isArray(e))return t.errors=[{params:{type:"object"}}],!1;{let n;if(void 0===e.external&&(n="external"))return t.errors=[{params:{missingProperty:n}}],!1;{const n=p;for(const r in e)if("external"!==r&&"shareScope"!==r)return t.errors=[{params:{additionalProperty:r}}],!1;if(n===p){if(void 0!==e.external){let n=e.external;const o=p,u=p;let f=!1;const m=p;if(p==p)if("string"==typeof n){if(n.length<1){const r={params:{}};null===l?l=[r]:l.push(r),p++}}else{const r={params:{type:"string"}};null===l?l=[r]:l.push(r),p++}var i=m===p;if(f=f||i,!f){const t=p;r(n,{instancePath:a+"/external",parentData:e,parentDataProperty:"external",rootData:s})||(l=null===l?r.errors:l.concat(r.errors),p=l.length),i=t===p,f=f||i}if(!f){const r={params:{}};return null===l?l=[r]:l.push(r),p++,t.errors=l,!1}p=u,null!==l&&(u?l.length=u:l=null);var c=o===p}else c=!0;if(c)if(void 0!==e.shareScope){let r=e.shareScope;const a=p;if(p===a){if("string"!=typeof r)return t.errors=[{params:{type:"string"}}],!1;if(r.length<1)return t.errors=[{params:{}}],!1}c=a===p}else c=!0}}}}return t.errors=l,0===p}function e(a,{instancePath:n="",parentData:o,parentDataProperty:s,rootData:l=a}={}){let p=null,i=0;if(0===i){if(!a||"object"!=typeof a||Array.isArray(a))return e.errors=[{params:{type:"object"}}],!1;for(const o in a){let s=a[o];const u=i,f=i;let m=!1;const y=i;t(s,{instancePath:n+"/"+o.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:a,parentDataProperty:o,rootData:l})||(p=null===p?t.errors:p.concat(t.errors),i=p.length);var c=y===i;if(m=m||c,!m){const t=i;if(i==i)if("string"==typeof s){if(s.length<1){const r={params:{}};null===p?p=[r]:p.push(r),i++}}else{const r={params:{type:"string"}};null===p?p=[r]:p.push(r),i++}if(c=t===i,m=m||c,!m){const t=i;r(s,{instancePath:n+"/"+o.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:a,parentDataProperty:o,rootData:l})||(p=null===p?r.errors:p.concat(r.errors),i=p.length),c=t===i,m=m||c}}if(!m){const r={params:{}};return null===p?p=[r]:p.push(r),i++,e.errors=p,!1}if(i=f,null!==p&&(f?p.length=f:p=null),u!==i)break}}return e.errors=p,0===i}function a(r,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:s=r}={}){let l=null,p=0;const i=p;let c=!1;const u=p;if(p===u)if(Array.isArray(r)){const a=r.length;for(let n=0;n<a;n++){let a=r[n];const o=p,i=p;let c=!1;const u=p;if(p==p)if("string"==typeof a){if(a.length<1){const r={params:{}};null===l?l=[r]:l.push(r),p++}}else{const r={params:{type:"string"}};null===l?l=[r]:l.push(r),p++}var f=u===p;if(c=c||f,!c){const o=p;e(a,{instancePath:t+"/"+n,parentData:r,parentDataProperty:n,rootData:s})||(l=null===l?e.errors:l.concat(e.errors),p=l.length),f=o===p,c=c||f}if(c)p=i,null!==l&&(i?l.length=i:l=null);else{const r={params:{}};null===l?l=[r]:l.push(r),p++}if(o!==p)break}}else{const r={params:{type:"array"}};null===l?l=[r]:l.push(r),p++}var m=u===p;if(c=c||m,!c){const a=p;e(r,{instancePath:t,parentData:n,parentDataProperty:o,rootData:s})||(l=null===l?e.errors:l.concat(e.errors),p=l.length),m=a===p,c=c||m}if(!c){const r={params:{}};return null===l?l=[r]:l.push(r),p++,a.errors=l,!1}return p=i,null!==l&&(i?l.length=i:l=null),a.errors=l,0===p}function n(r,{instancePath:t="",parentData:e,parentDataProperty:o,rootData:s=r}={}){let l=null,p=0;if(0===p){if(!r||"object"!=typeof r||Array.isArray(r))return n.errors=[{params:{type:"object"}}],!1;{let e;if(void 0===r.remoteType&&(e="remoteType")||void 0===r.remotes&&(e="remotes"))return n.errors=[{params:{missingProperty:e}}],!1;{const e=p;for(const t in r)if("remoteType"!==t&&"remotes"!==t&&"shareScope"!==t)return n.errors=[{params:{additionalProperty:t}}],!1;if(e===p){if(void 0!==r.remoteType){let t=r.remoteType;const e=p,a=p;let o=!1,s=null;const c=p;if("var"!==t&&"module"!==t&&"assign"!==t&&"this"!==t&&"window"!==t&&"self"!==t&&"global"!==t&&"commonjs"!==t&&"commonjs2"!==t&&"commonjs-module"!==t&&"commonjs-static"!==t&&"amd"!==t&&"amd-require"!==t&&"umd"!==t&&"umd2"!==t&&"jsonp"!==t&&"system"!==t&&"promise"!==t&&"import"!==t&&"module-import"!==t&&"script"!==t&&"node-commonjs"!==t){const r={params:{}};null===l?l=[r]:l.push(r),p++}if(c===p&&(o=!0,s=0),!o){const r={params:{passingSchemas:s}};return null===l?l=[r]:l.push(r),p++,n.errors=l,!1}p=a,null!==l&&(a?l.length=a:l=null);var i=e===p}else i=!0;if(i){if(void 0!==r.remotes){const e=p;a(r.remotes,{instancePath:t+"/remotes",parentData:r,parentDataProperty:"remotes",rootData:s})||(l=null===l?a.errors:l.concat(a.errors),p=l.length),i=e===p}else i=!0;if(i)if(void 0!==r.shareScope){let t=r.shareScope;const e=p;if(p===e){if("string"!=typeof t)return n.errors=[{params:{type:"string"}}],!1;if(t.length<1)return n.errors=[{params:{}}],!1}i=e===p}else i=!0}}}}}return n.errors=l,0===p}module.exports=n,module.exports.default=n;
"use strict";function r(t,{instancePath:e="",parentData:a,parentDataProperty:n,rootData:s=t}={}){if(!Array.isArray(t))return r.errors=[{params:{type:"array"}}],!1;{const e=t.length;for(let a=0;a<e;a++){let e=t[a];const n=0;if("string"!=typeof e)return r.errors=[{params:{type:"string"}}],!1;if(e.length<1)return r.errors=[{params:{}}],!1;if(0!==n)break}}return r.errors=null,!0}function t(e,{instancePath:a="",parentData:n,parentDataProperty:s,rootData:o=e}={}){let l=null,p=0;if(0===p){if(!e||"object"!=typeof e||Array.isArray(e))return t.errors=[{params:{type:"object"}}],!1;{let n;if(void 0===e.external&&(n="external"))return t.errors=[{params:{missingProperty:n}}],!1;{const n=p;for(const r in e)if("external"!==r&&"shareScope"!==r)return t.errors=[{params:{additionalProperty:r}}],!1;if(n===p){if(void 0!==e.external){let n=e.external;const s=p,u=p;let f=!1;const m=p;if(p==p)if("string"==typeof n){if(n.length<1){const r={params:{}};null===l?l=[r]:l.push(r),p++}}else{const r={params:{type:"string"}};null===l?l=[r]:l.push(r),p++}var i=m===p;if(f=f||i,!f){const t=p;r(n,{instancePath:a+"/external",parentData:e,parentDataProperty:"external",rootData:o})||(l=null===l?r.errors:l.concat(r.errors),p=l.length),i=t===p,f=f||i}if(!f){const r={params:{}};return null===l?l=[r]:l.push(r),p++,t.errors=l,!1}p=u,null!==l&&(u?l.length=u:l=null);var c=s===p}else c=!0;if(c)if(void 0!==e.shareScope){let r=e.shareScope;const a=p;if(p===a){if("string"!=typeof r)return t.errors=[{params:{type:"string"}}],!1;if(r.length<1)return t.errors=[{params:{}}],!1}c=a===p}else c=!0}}}}return t.errors=l,0===p}function e(a,{instancePath:n="",parentData:s,parentDataProperty:o,rootData:l=a}={}){let p=null,i=0;if(0===i){if(!a||"object"!=typeof a||Array.isArray(a))return e.errors=[{params:{type:"object"}}],!1;for(const s in a){let o=a[s];const u=i,f=i;let m=!1;const y=i;t(o,{instancePath:n+"/"+s.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:a,parentDataProperty:s,rootData:l})||(p=null===p?t.errors:p.concat(t.errors),i=p.length);var c=y===i;if(m=m||c,!m){const t=i;if(i==i)if("string"==typeof o){if(o.length<1){const r={params:{}};null===p?p=[r]:p.push(r),i++}}else{const r={params:{type:"string"}};null===p?p=[r]:p.push(r),i++}if(c=t===i,m=m||c,!m){const t=i;r(o,{instancePath:n+"/"+s.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:a,parentDataProperty:s,rootData:l})||(p=null===p?r.errors:p.concat(r.errors),i=p.length),c=t===i,m=m||c}}if(!m){const r={params:{}};return null===p?p=[r]:p.push(r),i++,e.errors=p,!1}if(i=f,null!==p&&(f?p.length=f:p=null),u!==i)break}}return e.errors=p,0===i}function a(r,{instancePath:t="",parentData:n,parentDataProperty:s,rootData:o=r}={}){let l=null,p=0;const i=p;let c=!1;const u=p;if(p===u)if(Array.isArray(r)){const a=r.length;for(let n=0;n<a;n++){let a=r[n];const s=p,i=p;let c=!1;const u=p;if(p==p)if("string"==typeof a){if(a.length<1){const r={params:{}};null===l?l=[r]:l.push(r),p++}}else{const r={params:{type:"string"}};null===l?l=[r]:l.push(r),p++}var f=u===p;if(c=c||f,!c){const s=p;e(a,{instancePath:t+"/"+n,parentData:r,parentDataProperty:n,rootData:o})||(l=null===l?e.errors:l.concat(e.errors),p=l.length),f=s===p,c=c||f}if(c)p=i,null!==l&&(i?l.length=i:l=null);else{const r={params:{}};null===l?l=[r]:l.push(r),p++}if(s!==p)break}}else{const r={params:{type:"array"}};null===l?l=[r]:l.push(r),p++}var m=u===p;if(c=c||m,!c){const a=p;e(r,{instancePath:t,parentData:n,parentDataProperty:s,rootData:o})||(l=null===l?e.errors:l.concat(e.errors),p=l.length),m=a===p,c=c||m}if(!c){const r={params:{}};return null===l?l=[r]:l.push(r),p++,a.errors=l,!1}return p=i,null!==l&&(i?l.length=i:l=null),a.errors=l,0===p}function n(r,{instancePath:t="",parentData:e,parentDataProperty:s,rootData:o=r}={}){let l=null,p=0;if(0===p){if(!r||"object"!=typeof r||Array.isArray(r))return n.errors=[{params:{type:"object"}}],!1;{let e;if(void 0===r.remoteType&&(e="remoteType")||void 0===r.remotes&&(e="remotes"))return n.errors=[{params:{missingProperty:e}}],!1;{const e=p;for(const t in r)if("remoteType"!==t&&"remotes"!==t&&"shareScope"!==t)return n.errors=[{params:{additionalProperty:t}}],!1;if(e===p){if(void 0!==r.remoteType){let t=r.remoteType;const e=p,a=p;let s=!1,o=null;const c=p;if("var"!==t&&"module"!==t&&"assign"!==t&&"this"!==t&&"window"!==t&&"self"!==t&&"global"!==t&&"commonjs"!==t&&"commonjs2"!==t&&"commonjs-module"!==t&&"commonjs-static"!==t&&"amd"!==t&&"amd-require"!==t&&"umd"!==t&&"umd2"!==t&&"jsonp"!==t&&"system"!==t&&"promise"!==t&&"import"!==t&&"module-import"!==t&&"script"!==t&&"node-commonjs"!==t&&"asset"!==t&&"css-import"!==t&&"css-url"!==t){const r={params:{}};null===l?l=[r]:l.push(r),p++}if(c===p&&(s=!0,o=0),!s){const r={params:{passingSchemas:o}};return null===l?l=[r]:l.push(r),p++,n.errors=l,!1}p=a,null!==l&&(a?l.length=a:l=null);var i=e===p}else i=!0;if(i){if(void 0!==r.remotes){const e=p;a(r.remotes,{instancePath:t+"/remotes",parentData:r,parentDataProperty:"remotes",rootData:o})||(l=null===l?a.errors:l.concat(a.errors),p=l.length),i=e===p}else i=!0;if(i)if(void 0!==r.shareScope){let t=r.shareScope;const e=p;if(p===e){if("string"!=typeof t)return n.errors=[{params:{type:"string"}}],!1;if(t.length<1)return n.errors=[{params:{}}],!1}i=e===p}else i=!0}}}}}return n.errors=l,0===p}module.exports=n,module.exports.default=n;

@@ -27,3 +27,6 @@ {

"script",
"node-commonjs"
"node-commonjs",
"asset",
"css-import",
"css-url"
]

@@ -30,0 +33,0 @@ },

@@ -6,2 +6,2 @@ /*

*/
"use strict";function o(m,{instancePath:r="",parentData:s,parentDataProperty:t,rootData:e=m}={}){return"var"!==m&&"module"!==m&&"assign"!==m&&"this"!==m&&"window"!==m&&"self"!==m&&"global"!==m&&"commonjs"!==m&&"commonjs2"!==m&&"commonjs-module"!==m&&"commonjs-static"!==m&&"amd"!==m&&"amd-require"!==m&&"umd"!==m&&"umd2"!==m&&"jsonp"!==m&&"system"!==m&&"promise"!==m&&"import"!==m&&"module-import"!==m&&"script"!==m&&"node-commonjs"!==m?(o.errors=[{params:{}}],!1):(o.errors=null,!0)}module.exports=o,module.exports.default=o;
"use strict";function o(s,{instancePath:r="",parentData:m,parentDataProperty:t,rootData:e=s}={}){return"var"!==s&&"module"!==s&&"assign"!==s&&"this"!==s&&"window"!==s&&"self"!==s&&"global"!==s&&"commonjs"!==s&&"commonjs2"!==s&&"commonjs-module"!==s&&"commonjs-static"!==s&&"amd"!==s&&"amd-require"!==s&&"umd"!==s&&"umd2"!==s&&"jsonp"!==s&&"system"!==s&&"promise"!==s&&"import"!==s&&"module-import"!==s&&"script"!==s&&"node-commonjs"!==s&&"asset"!==s&&"css-import"!==s&&"css-url"!==s?(o.errors=[{params:{}}],!1):(o.errors=null,!0)}module.exports=o,module.exports.default=o;

@@ -6,2 +6,2 @@ /*

*/
const t=/^(?:[A-Za-z]:[\\/]|\\\\|\/)/;module.exports=D,module.exports.default=D;const e={definitions:{AmdContainer:{type:"string",minLength:1},AuxiliaryComment:{anyOf:[{type:"string"},{$ref:"#/definitions/LibraryCustomUmdCommentObject"}]},EntryRuntime:{anyOf:[{enum:[!1]},{type:"string",minLength:1}]},Exposes:{anyOf:[{type:"array",items:{anyOf:[{$ref:"#/definitions/ExposesItem"},{$ref:"#/definitions/ExposesObject"}]}},{$ref:"#/definitions/ExposesObject"}]},ExposesConfig:{type:"object",additionalProperties:!1,properties:{import:{anyOf:[{$ref:"#/definitions/ExposesItem"},{$ref:"#/definitions/ExposesItems"}]},name:{type:"string"}},required:["import"]},ExposesItem:{type:"string",minLength:1},ExposesItems:{type:"array",items:{$ref:"#/definitions/ExposesItem"}},ExposesObject:{type:"object",additionalProperties:{anyOf:[{$ref:"#/definitions/ExposesConfig"},{$ref:"#/definitions/ExposesItem"},{$ref:"#/definitions/ExposesItems"}]}},ExternalsType:{enum:["var","module","assign","this","window","self","global","commonjs","commonjs2","commonjs-module","commonjs-static","amd","amd-require","umd","umd2","jsonp","system","promise","import","module-import","script","node-commonjs"]},LibraryCustomUmdCommentObject:{type:"object",additionalProperties:!1,properties:{amd:{type:"string"},commonjs:{type:"string"},commonjs2:{type:"string"},root:{type:"string"}}},LibraryCustomUmdObject:{type:"object",additionalProperties:!1,properties:{amd:{type:"string",minLength:1},commonjs:{type:"string",minLength:1},root:{anyOf:[{type:"array",items:{type:"string",minLength:1}},{type:"string",minLength:1}]}}},LibraryExport:{anyOf:[{type:"array",items:{type:"string",minLength:1}},{type:"string",minLength:1}]},LibraryName:{anyOf:[{type:"array",items:{type:"string",minLength:1},minItems:1},{type:"string",minLength:1},{$ref:"#/definitions/LibraryCustomUmdObject"}]},LibraryOptions:{type:"object",additionalProperties:!1,properties:{amdContainer:{$ref:"#/definitions/AmdContainer"},auxiliaryComment:{$ref:"#/definitions/AuxiliaryComment"},export:{$ref:"#/definitions/LibraryExport"},name:{$ref:"#/definitions/LibraryName"},type:{$ref:"#/definitions/LibraryType"},umdNamedDefine:{$ref:"#/definitions/UmdNamedDefine"}},required:["type"]},LibraryType:{anyOf:[{enum:["var","module","assign","assign-properties","this","window","self","global","commonjs","commonjs2","commonjs-module","commonjs-static","amd","amd-require","umd","umd2","jsonp","system"]},{type:"string"}]},Remotes:{anyOf:[{type:"array",items:{anyOf:[{$ref:"#/definitions/RemotesItem"},{$ref:"#/definitions/RemotesObject"}]}},{$ref:"#/definitions/RemotesObject"}]},RemotesConfig:{type:"object",additionalProperties:!1,properties:{external:{anyOf:[{$ref:"#/definitions/RemotesItem"},{$ref:"#/definitions/RemotesItems"}]},shareScope:{type:"string",minLength:1}},required:["external"]},RemotesItem:{type:"string",minLength:1},RemotesItems:{type:"array",items:{$ref:"#/definitions/RemotesItem"}},RemotesObject:{type:"object",additionalProperties:{anyOf:[{$ref:"#/definitions/RemotesConfig"},{$ref:"#/definitions/RemotesItem"},{$ref:"#/definitions/RemotesItems"}]}},Shared:{anyOf:[{type:"array",items:{anyOf:[{$ref:"#/definitions/SharedItem"},{$ref:"#/definitions/SharedObject"}]}},{$ref:"#/definitions/SharedObject"}]},SharedConfig:{type:"object",additionalProperties:!1,properties:{eager:{type:"boolean"},import:{anyOf:[{enum:[!1]},{$ref:"#/definitions/SharedItem"}]},packageName:{type:"string",minLength:1},requiredVersion:{anyOf:[{enum:[!1]},{type:"string"}]},shareKey:{type:"string",minLength:1},shareScope:{type:"string",minLength:1},singleton:{type:"boolean"},strictVersion:{type:"boolean"},version:{anyOf:[{enum:[!1]},{type:"string"}]}}},SharedItem:{type:"string",minLength:1},SharedObject:{type:"object",additionalProperties:{anyOf:[{$ref:"#/definitions/SharedConfig"},{$ref:"#/definitions/SharedItem"}]}},UmdNamedDefine:{type:"boolean"}},type:"object",additionalProperties:!1,properties:{exposes:{$ref:"#/definitions/Exposes"},filename:{type:"string",absolutePath:!1},library:{$ref:"#/definitions/LibraryOptions"},name:{type:"string"},remoteType:{oneOf:[{$ref:"#/definitions/ExternalsType"}]},remotes:{$ref:"#/definitions/Remotes"},runtime:{$ref:"#/definitions/EntryRuntime"},shareScope:{type:"string",minLength:1},shared:{$ref:"#/definitions/Shared"}}},r=Object.prototype.hasOwnProperty;function n(t,{instancePath:e="",parentData:r,parentDataProperty:s,rootData:a=t}={}){if(!Array.isArray(t))return n.errors=[{params:{type:"array"}}],!1;{const e=t.length;for(let r=0;r<e;r++){let e=t[r];const s=0;if("string"!=typeof e)return n.errors=[{params:{type:"string"}}],!1;if(e.length<1)return n.errors=[{params:{}}],!1;if(0!==s)break}}return n.errors=null,!0}function s(t,{instancePath:e="",parentData:r,parentDataProperty:a,rootData:o=t}={}){let i=null,l=0;if(0===l){if(!t||"object"!=typeof t||Array.isArray(t))return s.errors=[{params:{type:"object"}}],!1;{let r;if(void 0===t.import&&(r="import"))return s.errors=[{params:{missingProperty:r}}],!1;{const r=l;for(const e in t)if("import"!==e&&"name"!==e)return s.errors=[{params:{additionalProperty:e}}],!1;if(r===l){if(void 0!==t.import){let r=t.import;const a=l,c=l;let m=!1;const u=l;if(l==l)if("string"==typeof r){if(r.length<1){const t={params:{}};null===i?i=[t]:i.push(t),l++}}else{const t={params:{type:"string"}};null===i?i=[t]:i.push(t),l++}var p=u===l;if(m=m||p,!m){const s=l;n(r,{instancePath:e+"/import",parentData:t,parentDataProperty:"import",rootData:o})||(i=null===i?n.errors:i.concat(n.errors),l=i.length),p=s===l,m=m||p}if(!m){const t={params:{}};return null===i?i=[t]:i.push(t),l++,s.errors=i,!1}l=c,null!==i&&(c?i.length=c:i=null);var f=a===l}else f=!0;if(f)if(void 0!==t.name){const e=l;if("string"!=typeof t.name)return s.errors=[{params:{type:"string"}}],!1;f=e===l}else f=!0}}}}return s.errors=i,0===l}function a(t,{instancePath:e="",parentData:r,parentDataProperty:o,rootData:i=t}={}){let l=null,p=0;if(0===p){if(!t||"object"!=typeof t||Array.isArray(t))return a.errors=[{params:{type:"object"}}],!1;for(const r in t){let o=t[r];const c=p,m=p;let u=!1;const y=p;s(o,{instancePath:e+"/"+r.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:t,parentDataProperty:r,rootData:i})||(l=null===l?s.errors:l.concat(s.errors),p=l.length);var f=y===p;if(u=u||f,!u){const s=p;if(p==p)if("string"==typeof o){if(o.length<1){const t={params:{}};null===l?l=[t]:l.push(t),p++}}else{const t={params:{type:"string"}};null===l?l=[t]:l.push(t),p++}if(f=s===p,u=u||f,!u){const s=p;n(o,{instancePath:e+"/"+r.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:t,parentDataProperty:r,rootData:i})||(l=null===l?n.errors:l.concat(n.errors),p=l.length),f=s===p,u=u||f}}if(!u){const t={params:{}};return null===l?l=[t]:l.push(t),p++,a.errors=l,!1}if(p=m,null!==l&&(m?l.length=m:l=null),c!==p)break}}return a.errors=l,0===p}function o(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:s=t}={}){let i=null,l=0;const p=l;let f=!1;const c=l;if(l===c)if(Array.isArray(t)){const r=t.length;for(let n=0;n<r;n++){let r=t[n];const o=l,p=l;let f=!1;const c=l;if(l==l)if("string"==typeof r){if(r.length<1){const t={params:{}};null===i?i=[t]:i.push(t),l++}}else{const t={params:{type:"string"}};null===i?i=[t]:i.push(t),l++}var m=c===l;if(f=f||m,!f){const o=l;a(r,{instancePath:e+"/"+n,parentData:t,parentDataProperty:n,rootData:s})||(i=null===i?a.errors:i.concat(a.errors),l=i.length),m=o===l,f=f||m}if(f)l=p,null!==i&&(p?i.length=p:i=null);else{const t={params:{}};null===i?i=[t]:i.push(t),l++}if(o!==l)break}}else{const t={params:{type:"array"}};null===i?i=[t]:i.push(t),l++}var u=c===l;if(f=f||u,!f){const o=l;a(t,{instancePath:e,parentData:r,parentDataProperty:n,rootData:s})||(i=null===i?a.errors:i.concat(a.errors),l=i.length),u=o===l,f=f||u}if(!f){const t={params:{}};return null===i?i=[t]:i.push(t),l++,o.errors=i,!1}return l=p,null!==i&&(p?i.length=p:i=null),o.errors=i,0===l}function i(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:s=t}={}){let a=null,o=0;const l=o;let p=!1;const f=o;if("string"!=typeof t){const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}var c=f===o;if(p=p||c,!p){const e=o;if(o==o)if(t&&"object"==typeof t&&!Array.isArray(t)){const e=o;for(const e in t)if("amd"!==e&&"commonjs"!==e&&"commonjs2"!==e&&"root"!==e){const t={params:{additionalProperty:e}};null===a?a=[t]:a.push(t),o++;break}if(e===o){if(void 0!==t.amd){const e=o;if("string"!=typeof t.amd){const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}var m=e===o}else m=!0;if(m){if(void 0!==t.commonjs){const e=o;if("string"!=typeof t.commonjs){const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}m=e===o}else m=!0;if(m){if(void 0!==t.commonjs2){const e=o;if("string"!=typeof t.commonjs2){const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}m=e===o}else m=!0;if(m)if(void 0!==t.root){const e=o;if("string"!=typeof t.root){const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}m=e===o}else m=!0}}}}else{const t={params:{type:"object"}};null===a?a=[t]:a.push(t),o++}c=e===o,p=p||c}if(!p){const t={params:{}};return null===a?a=[t]:a.push(t),o++,i.errors=a,!1}return o=l,null!==a&&(l?a.length=l:a=null),i.errors=a,0===o}function l(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:s=t}={}){let a=null,o=0;const i=o;let p=!1;const f=o;if(o===f)if(Array.isArray(t))if(t.length<1){const t={params:{limit:1}};null===a?a=[t]:a.push(t),o++}else{const e=t.length;for(let r=0;r<e;r++){let e=t[r];const n=o;if(o===n)if("string"==typeof e){if(e.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}if(n!==o)break}}else{const t={params:{type:"array"}};null===a?a=[t]:a.push(t),o++}var c=f===o;if(p=p||c,!p){const e=o;if(o===e)if("string"==typeof t){if(t.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}if(c=e===o,p=p||c,!p){const e=o;if(o==o)if(t&&"object"==typeof t&&!Array.isArray(t)){const e=o;for(const e in t)if("amd"!==e&&"commonjs"!==e&&"root"!==e){const t={params:{additionalProperty:e}};null===a?a=[t]:a.push(t),o++;break}if(e===o){if(void 0!==t.amd){let e=t.amd;const r=o;if(o===r)if("string"==typeof e){if(e.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}var m=r===o}else m=!0;if(m){if(void 0!==t.commonjs){let e=t.commonjs;const r=o;if(o===r)if("string"==typeof e){if(e.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}m=r===o}else m=!0;if(m)if(void 0!==t.root){let e=t.root;const r=o,n=o;let s=!1;const i=o;if(o===i)if(Array.isArray(e)){const t=e.length;for(let r=0;r<t;r++){let t=e[r];const n=o;if(o===n)if("string"==typeof t){if(t.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}if(n!==o)break}}else{const t={params:{type:"array"}};null===a?a=[t]:a.push(t),o++}var u=i===o;if(s=s||u,!s){const t=o;if(o===t)if("string"==typeof e){if(e.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}u=t===o,s=s||u}if(s)o=n,null!==a&&(n?a.length=n:a=null);else{const t={params:{}};null===a?a=[t]:a.push(t),o++}m=r===o}else m=!0}}}else{const t={params:{type:"object"}};null===a?a=[t]:a.push(t),o++}c=e===o,p=p||c}}if(!p){const t={params:{}};return null===a?a=[t]:a.push(t),o++,l.errors=a,!1}return o=i,null!==a&&(i?a.length=i:a=null),l.errors=a,0===o}function p(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:s=t}={}){let a=null,o=0;if(0===o){if(!t||"object"!=typeof t||Array.isArray(t))return p.errors=[{params:{type:"object"}}],!1;{let r;if(void 0===t.type&&(r="type"))return p.errors=[{params:{missingProperty:r}}],!1;{const r=o;for(const e in t)if("amdContainer"!==e&&"auxiliaryComment"!==e&&"export"!==e&&"name"!==e&&"type"!==e&&"umdNamedDefine"!==e)return p.errors=[{params:{additionalProperty:e}}],!1;if(r===o){if(void 0!==t.amdContainer){let e=t.amdContainer;const r=o;if(o==o){if("string"!=typeof e)return p.errors=[{params:{type:"string"}}],!1;if(e.length<1)return p.errors=[{params:{}}],!1}var f=r===o}else f=!0;if(f){if(void 0!==t.auxiliaryComment){const r=o;i(t.auxiliaryComment,{instancePath:e+"/auxiliaryComment",parentData:t,parentDataProperty:"auxiliaryComment",rootData:s})||(a=null===a?i.errors:a.concat(i.errors),o=a.length),f=r===o}else f=!0;if(f){if(void 0!==t.export){let e=t.export;const r=o,n=o;let s=!1;const i=o;if(o===i)if(Array.isArray(e)){const t=e.length;for(let r=0;r<t;r++){let t=e[r];const n=o;if(o===n)if("string"==typeof t){if(t.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}if(n!==o)break}}else{const t={params:{type:"array"}};null===a?a=[t]:a.push(t),o++}var c=i===o;if(s=s||c,!s){const t=o;if(o===t)if("string"==typeof e){if(e.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}c=t===o,s=s||c}if(!s){const t={params:{}};return null===a?a=[t]:a.push(t),o++,p.errors=a,!1}o=n,null!==a&&(n?a.length=n:a=null),f=r===o}else f=!0;if(f){if(void 0!==t.name){const r=o;l(t.name,{instancePath:e+"/name",parentData:t,parentDataProperty:"name",rootData:s})||(a=null===a?l.errors:a.concat(l.errors),o=a.length),f=r===o}else f=!0;if(f){if(void 0!==t.type){let e=t.type;const r=o,n=o;let s=!1;const i=o;if("var"!==e&&"module"!==e&&"assign"!==e&&"assign-properties"!==e&&"this"!==e&&"window"!==e&&"self"!==e&&"global"!==e&&"commonjs"!==e&&"commonjs2"!==e&&"commonjs-module"!==e&&"commonjs-static"!==e&&"amd"!==e&&"amd-require"!==e&&"umd"!==e&&"umd2"!==e&&"jsonp"!==e&&"system"!==e){const t={params:{}};null===a?a=[t]:a.push(t),o++}var m=i===o;if(s=s||m,!s){const t=o;if("string"!=typeof e){const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}m=t===o,s=s||m}if(!s){const t={params:{}};return null===a?a=[t]:a.push(t),o++,p.errors=a,!1}o=n,null!==a&&(n?a.length=n:a=null),f=r===o}else f=!0;if(f)if(void 0!==t.umdNamedDefine){const e=o;if("boolean"!=typeof t.umdNamedDefine)return p.errors=[{params:{type:"boolean"}}],!1;f=e===o}else f=!0}}}}}}}}return p.errors=a,0===o}function f(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:s=t}={}){if(!Array.isArray(t))return f.errors=[{params:{type:"array"}}],!1;{const e=t.length;for(let r=0;r<e;r++){let e=t[r];const n=0;if("string"!=typeof e)return f.errors=[{params:{type:"string"}}],!1;if(e.length<1)return f.errors=[{params:{}}],!1;if(0!==n)break}}return f.errors=null,!0}function c(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:s=t}={}){let a=null,o=0;if(0===o){if(!t||"object"!=typeof t||Array.isArray(t))return c.errors=[{params:{type:"object"}}],!1;{let r;if(void 0===t.external&&(r="external"))return c.errors=[{params:{missingProperty:r}}],!1;{const r=o;for(const e in t)if("external"!==e&&"shareScope"!==e)return c.errors=[{params:{additionalProperty:e}}],!1;if(r===o){if(void 0!==t.external){let r=t.external;const n=o,p=o;let m=!1;const u=o;if(o==o)if("string"==typeof r){if(r.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}var i=u===o;if(m=m||i,!m){const n=o;f(r,{instancePath:e+"/external",parentData:t,parentDataProperty:"external",rootData:s})||(a=null===a?f.errors:a.concat(f.errors),o=a.length),i=n===o,m=m||i}if(!m){const t={params:{}};return null===a?a=[t]:a.push(t),o++,c.errors=a,!1}o=p,null!==a&&(p?a.length=p:a=null);var l=n===o}else l=!0;if(l)if(void 0!==t.shareScope){let e=t.shareScope;const r=o;if(o===r){if("string"!=typeof e)return c.errors=[{params:{type:"string"}}],!1;if(e.length<1)return c.errors=[{params:{}}],!1}l=r===o}else l=!0}}}}return c.errors=a,0===o}function m(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:s=t}={}){let a=null,o=0;if(0===o){if(!t||"object"!=typeof t||Array.isArray(t))return m.errors=[{params:{type:"object"}}],!1;for(const r in t){let n=t[r];const l=o,p=o;let u=!1;const y=o;c(n,{instancePath:e+"/"+r.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:t,parentDataProperty:r,rootData:s})||(a=null===a?c.errors:a.concat(c.errors),o=a.length);var i=y===o;if(u=u||i,!u){const l=o;if(o==o)if("string"==typeof n){if(n.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}if(i=l===o,u=u||i,!u){const l=o;f(n,{instancePath:e+"/"+r.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:t,parentDataProperty:r,rootData:s})||(a=null===a?f.errors:a.concat(f.errors),o=a.length),i=l===o,u=u||i}}if(!u){const t={params:{}};return null===a?a=[t]:a.push(t),o++,m.errors=a,!1}if(o=p,null!==a&&(p?a.length=p:a=null),l!==o)break}}return m.errors=a,0===o}function u(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:s=t}={}){let a=null,o=0;const i=o;let l=!1;const p=o;if(o===p)if(Array.isArray(t)){const r=t.length;for(let n=0;n<r;n++){let r=t[n];const i=o,l=o;let p=!1;const c=o;if(o==o)if("string"==typeof r){if(r.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}var f=c===o;if(p=p||f,!p){const i=o;m(r,{instancePath:e+"/"+n,parentData:t,parentDataProperty:n,rootData:s})||(a=null===a?m.errors:a.concat(m.errors),o=a.length),f=i===o,p=p||f}if(p)o=l,null!==a&&(l?a.length=l:a=null);else{const t={params:{}};null===a?a=[t]:a.push(t),o++}if(i!==o)break}}else{const t={params:{type:"array"}};null===a?a=[t]:a.push(t),o++}var c=p===o;if(l=l||c,!l){const i=o;m(t,{instancePath:e,parentData:r,parentDataProperty:n,rootData:s})||(a=null===a?m.errors:a.concat(m.errors),o=a.length),c=i===o,l=l||c}if(!l){const t={params:{}};return null===a?a=[t]:a.push(t),o++,u.errors=a,!1}return o=i,null!==a&&(i?a.length=i:a=null),u.errors=a,0===o}const y={type:"object",additionalProperties:!1,properties:{eager:{type:"boolean"},import:{anyOf:[{enum:[!1]},{$ref:"#/definitions/SharedItem"}]},packageName:{type:"string",minLength:1},requiredVersion:{anyOf:[{enum:[!1]},{type:"string"}]},shareKey:{type:"string",minLength:1},shareScope:{type:"string",minLength:1},singleton:{type:"boolean"},strictVersion:{type:"boolean"},version:{anyOf:[{enum:[!1]},{type:"string"}]}}};function h(t,{instancePath:e="",parentData:n,parentDataProperty:s,rootData:a=t}={}){let o=null,i=0;if(0===i){if(!t||"object"!=typeof t||Array.isArray(t))return h.errors=[{params:{type:"object"}}],!1;{const e=i;for(const e in t)if(!r.call(y.properties,e))return h.errors=[{params:{additionalProperty:e}}],!1;if(e===i){if(void 0!==t.eager){const e=i;if("boolean"!=typeof t.eager)return h.errors=[{params:{type:"boolean"}}],!1;var l=e===i}else l=!0;if(l){if(void 0!==t.import){let e=t.import;const r=i,n=i;let s=!1;const a=i;if(!1!==e){const t={params:{}};null===o?o=[t]:o.push(t),i++}var p=a===i;if(s=s||p,!s){const t=i;if(i==i)if("string"==typeof e){if(e.length<1){const t={params:{}};null===o?o=[t]:o.push(t),i++}}else{const t={params:{type:"string"}};null===o?o=[t]:o.push(t),i++}p=t===i,s=s||p}if(!s){const t={params:{}};return null===o?o=[t]:o.push(t),i++,h.errors=o,!1}i=n,null!==o&&(n?o.length=n:o=null),l=r===i}else l=!0;if(l){if(void 0!==t.packageName){let e=t.packageName;const r=i;if(i===r){if("string"!=typeof e)return h.errors=[{params:{type:"string"}}],!1;if(e.length<1)return h.errors=[{params:{}}],!1}l=r===i}else l=!0;if(l){if(void 0!==t.requiredVersion){let e=t.requiredVersion;const r=i,n=i;let s=!1;const a=i;if(!1!==e){const t={params:{}};null===o?o=[t]:o.push(t),i++}var f=a===i;if(s=s||f,!s){const t=i;if("string"!=typeof e){const t={params:{type:"string"}};null===o?o=[t]:o.push(t),i++}f=t===i,s=s||f}if(!s){const t={params:{}};return null===o?o=[t]:o.push(t),i++,h.errors=o,!1}i=n,null!==o&&(n?o.length=n:o=null),l=r===i}else l=!0;if(l){if(void 0!==t.shareKey){let e=t.shareKey;const r=i;if(i===r){if("string"!=typeof e)return h.errors=[{params:{type:"string"}}],!1;if(e.length<1)return h.errors=[{params:{}}],!1}l=r===i}else l=!0;if(l){if(void 0!==t.shareScope){let e=t.shareScope;const r=i;if(i===r){if("string"!=typeof e)return h.errors=[{params:{type:"string"}}],!1;if(e.length<1)return h.errors=[{params:{}}],!1}l=r===i}else l=!0;if(l){if(void 0!==t.singleton){const e=i;if("boolean"!=typeof t.singleton)return h.errors=[{params:{type:"boolean"}}],!1;l=e===i}else l=!0;if(l){if(void 0!==t.strictVersion){const e=i;if("boolean"!=typeof t.strictVersion)return h.errors=[{params:{type:"boolean"}}],!1;l=e===i}else l=!0;if(l)if(void 0!==t.version){let e=t.version;const r=i,n=i;let s=!1;const a=i;if(!1!==e){const t={params:{}};null===o?o=[t]:o.push(t),i++}var c=a===i;if(s=s||c,!s){const t=i;if("string"!=typeof e){const t={params:{type:"string"}};null===o?o=[t]:o.push(t),i++}c=t===i,s=s||c}if(!s){const t={params:{}};return null===o?o=[t]:o.push(t),i++,h.errors=o,!1}i=n,null!==o&&(n?o.length=n:o=null),l=r===i}else l=!0}}}}}}}}}}return h.errors=o,0===i}function g(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:s=t}={}){let a=null,o=0;if(0===o){if(!t||"object"!=typeof t||Array.isArray(t))return g.errors=[{params:{type:"object"}}],!1;for(const r in t){let n=t[r];const l=o,p=o;let f=!1;const c=o;h(n,{instancePath:e+"/"+r.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:t,parentDataProperty:r,rootData:s})||(a=null===a?h.errors:a.concat(h.errors),o=a.length);var i=c===o;if(f=f||i,!f){const t=o;if(o==o)if("string"==typeof n){if(n.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}i=t===o,f=f||i}if(!f){const t={params:{}};return null===a?a=[t]:a.push(t),o++,g.errors=a,!1}if(o=p,null!==a&&(p?a.length=p:a=null),l!==o)break}}return g.errors=a,0===o}function d(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:s=t}={}){let a=null,o=0;const i=o;let l=!1;const p=o;if(o===p)if(Array.isArray(t)){const r=t.length;for(let n=0;n<r;n++){let r=t[n];const i=o,l=o;let p=!1;const c=o;if(o==o)if("string"==typeof r){if(r.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}var f=c===o;if(p=p||f,!p){const i=o;g(r,{instancePath:e+"/"+n,parentData:t,parentDataProperty:n,rootData:s})||(a=null===a?g.errors:a.concat(g.errors),o=a.length),f=i===o,p=p||f}if(p)o=l,null!==a&&(l?a.length=l:a=null);else{const t={params:{}};null===a?a=[t]:a.push(t),o++}if(i!==o)break}}else{const t={params:{type:"array"}};null===a?a=[t]:a.push(t),o++}var c=p===o;if(l=l||c,!l){const i=o;g(t,{instancePath:e,parentData:r,parentDataProperty:n,rootData:s})||(a=null===a?g.errors:a.concat(g.errors),o=a.length),c=i===o,l=l||c}if(!l){const t={params:{}};return null===a?a=[t]:a.push(t),o++,d.errors=a,!1}return o=i,null!==a&&(i?a.length=i:a=null),d.errors=a,0===o}function D(n,{instancePath:s="",parentData:a,parentDataProperty:i,rootData:l=n}={}){let f=null,c=0;if(0===c){if(!n||"object"!=typeof n||Array.isArray(n))return D.errors=[{params:{type:"object"}}],!1;{const a=c;for(const t in n)if(!r.call(e.properties,t))return D.errors=[{params:{additionalProperty:t}}],!1;if(a===c){if(void 0!==n.exposes){const t=c;o(n.exposes,{instancePath:s+"/exposes",parentData:n,parentDataProperty:"exposes",rootData:l})||(f=null===f?o.errors:f.concat(o.errors),c=f.length);var m=t===c}else m=!0;if(m){if(void 0!==n.filename){let e=n.filename;const r=c;if(c===r){if("string"!=typeof e)return D.errors=[{params:{type:"string"}}],!1;if(e.includes("!")||!1!==t.test(e))return D.errors=[{params:{}}],!1}m=r===c}else m=!0;if(m){if(void 0!==n.library){const t=c;p(n.library,{instancePath:s+"/library",parentData:n,parentDataProperty:"library",rootData:l})||(f=null===f?p.errors:f.concat(p.errors),c=f.length),m=t===c}else m=!0;if(m){if(void 0!==n.name){const t=c;if("string"!=typeof n.name)return D.errors=[{params:{type:"string"}}],!1;m=t===c}else m=!0;if(m){if(void 0!==n.remoteType){let t=n.remoteType;const e=c,r=c;let s=!1,a=null;const o=c;if("var"!==t&&"module"!==t&&"assign"!==t&&"this"!==t&&"window"!==t&&"self"!==t&&"global"!==t&&"commonjs"!==t&&"commonjs2"!==t&&"commonjs-module"!==t&&"commonjs-static"!==t&&"amd"!==t&&"amd-require"!==t&&"umd"!==t&&"umd2"!==t&&"jsonp"!==t&&"system"!==t&&"promise"!==t&&"import"!==t&&"module-import"!==t&&"script"!==t&&"node-commonjs"!==t){const t={params:{}};null===f?f=[t]:f.push(t),c++}if(o===c&&(s=!0,a=0),!s){const t={params:{passingSchemas:a}};return null===f?f=[t]:f.push(t),c++,D.errors=f,!1}c=r,null!==f&&(r?f.length=r:f=null),m=e===c}else m=!0;if(m){if(void 0!==n.remotes){const t=c;u(n.remotes,{instancePath:s+"/remotes",parentData:n,parentDataProperty:"remotes",rootData:l})||(f=null===f?u.errors:f.concat(u.errors),c=f.length),m=t===c}else m=!0;if(m){if(void 0!==n.runtime){let t=n.runtime;const e=c,r=c;let s=!1;const a=c;if(!1!==t){const t={params:{}};null===f?f=[t]:f.push(t),c++}var y=a===c;if(s=s||y,!s){const e=c;if(c===e)if("string"==typeof t){if(t.length<1){const t={params:{}};null===f?f=[t]:f.push(t),c++}}else{const t={params:{type:"string"}};null===f?f=[t]:f.push(t),c++}y=e===c,s=s||y}if(!s){const t={params:{}};return null===f?f=[t]:f.push(t),c++,D.errors=f,!1}c=r,null!==f&&(r?f.length=r:f=null),m=e===c}else m=!0;if(m){if(void 0!==n.shareScope){let t=n.shareScope;const e=c;if(c===e){if("string"!=typeof t)return D.errors=[{params:{type:"string"}}],!1;if(t.length<1)return D.errors=[{params:{}}],!1}m=e===c}else m=!0;if(m)if(void 0!==n.shared){const t=c;d(n.shared,{instancePath:s+"/shared",parentData:n,parentDataProperty:"shared",rootData:l})||(f=null===f?d.errors:f.concat(d.errors),c=f.length),m=t===c}else m=!0}}}}}}}}}}return D.errors=f,0===c}
const t=/^(?:[A-Za-z]:[\\/]|\\\\|\/)/;module.exports=D,module.exports.default=D;const e={definitions:{AmdContainer:{type:"string",minLength:1},AuxiliaryComment:{anyOf:[{type:"string"},{$ref:"#/definitions/LibraryCustomUmdCommentObject"}]},EntryRuntime:{anyOf:[{enum:[!1]},{type:"string",minLength:1}]},Exposes:{anyOf:[{type:"array",items:{anyOf:[{$ref:"#/definitions/ExposesItem"},{$ref:"#/definitions/ExposesObject"}]}},{$ref:"#/definitions/ExposesObject"}]},ExposesConfig:{type:"object",additionalProperties:!1,properties:{import:{anyOf:[{$ref:"#/definitions/ExposesItem"},{$ref:"#/definitions/ExposesItems"}]},name:{type:"string"}},required:["import"]},ExposesItem:{type:"string",minLength:1},ExposesItems:{type:"array",items:{$ref:"#/definitions/ExposesItem"}},ExposesObject:{type:"object",additionalProperties:{anyOf:[{$ref:"#/definitions/ExposesConfig"},{$ref:"#/definitions/ExposesItem"},{$ref:"#/definitions/ExposesItems"}]}},ExternalsType:{enum:["var","module","assign","this","window","self","global","commonjs","commonjs2","commonjs-module","commonjs-static","amd","amd-require","umd","umd2","jsonp","system","promise","import","module-import","script","node-commonjs","asset","css-import","css-url"]},LibraryCustomUmdCommentObject:{type:"object",additionalProperties:!1,properties:{amd:{type:"string"},commonjs:{type:"string"},commonjs2:{type:"string"},root:{type:"string"}}},LibraryCustomUmdObject:{type:"object",additionalProperties:!1,properties:{amd:{type:"string",minLength:1},commonjs:{type:"string",minLength:1},root:{anyOf:[{type:"array",items:{type:"string",minLength:1}},{type:"string",minLength:1}]}}},LibraryExport:{anyOf:[{type:"array",items:{type:"string",minLength:1}},{type:"string",minLength:1}]},LibraryName:{anyOf:[{type:"array",items:{type:"string",minLength:1},minItems:1},{type:"string",minLength:1},{$ref:"#/definitions/LibraryCustomUmdObject"}]},LibraryOptions:{type:"object",additionalProperties:!1,properties:{amdContainer:{$ref:"#/definitions/AmdContainer"},auxiliaryComment:{$ref:"#/definitions/AuxiliaryComment"},export:{$ref:"#/definitions/LibraryExport"},name:{$ref:"#/definitions/LibraryName"},type:{$ref:"#/definitions/LibraryType"},umdNamedDefine:{$ref:"#/definitions/UmdNamedDefine"}},required:["type"]},LibraryType:{anyOf:[{enum:["var","module","assign","assign-properties","this","window","self","global","commonjs","commonjs2","commonjs-module","commonjs-static","amd","amd-require","umd","umd2","jsonp","system"]},{type:"string"}]},Remotes:{anyOf:[{type:"array",items:{anyOf:[{$ref:"#/definitions/RemotesItem"},{$ref:"#/definitions/RemotesObject"}]}},{$ref:"#/definitions/RemotesObject"}]},RemotesConfig:{type:"object",additionalProperties:!1,properties:{external:{anyOf:[{$ref:"#/definitions/RemotesItem"},{$ref:"#/definitions/RemotesItems"}]},shareScope:{type:"string",minLength:1}},required:["external"]},RemotesItem:{type:"string",minLength:1},RemotesItems:{type:"array",items:{$ref:"#/definitions/RemotesItem"}},RemotesObject:{type:"object",additionalProperties:{anyOf:[{$ref:"#/definitions/RemotesConfig"},{$ref:"#/definitions/RemotesItem"},{$ref:"#/definitions/RemotesItems"}]}},Shared:{anyOf:[{type:"array",items:{anyOf:[{$ref:"#/definitions/SharedItem"},{$ref:"#/definitions/SharedObject"}]}},{$ref:"#/definitions/SharedObject"}]},SharedConfig:{type:"object",additionalProperties:!1,properties:{eager:{type:"boolean"},import:{anyOf:[{enum:[!1]},{$ref:"#/definitions/SharedItem"}]},packageName:{type:"string",minLength:1},requiredVersion:{anyOf:[{enum:[!1]},{type:"string"}]},shareKey:{type:"string",minLength:1},shareScope:{type:"string",minLength:1},singleton:{type:"boolean"},strictVersion:{type:"boolean"},version:{anyOf:[{enum:[!1]},{type:"string"}]}}},SharedItem:{type:"string",minLength:1},SharedObject:{type:"object",additionalProperties:{anyOf:[{$ref:"#/definitions/SharedConfig"},{$ref:"#/definitions/SharedItem"}]}},UmdNamedDefine:{type:"boolean"}},type:"object",additionalProperties:!1,properties:{exposes:{$ref:"#/definitions/Exposes"},filename:{type:"string",absolutePath:!1},library:{$ref:"#/definitions/LibraryOptions"},name:{type:"string"},remoteType:{oneOf:[{$ref:"#/definitions/ExternalsType"}]},remotes:{$ref:"#/definitions/Remotes"},runtime:{$ref:"#/definitions/EntryRuntime"},shareScope:{type:"string",minLength:1},shared:{$ref:"#/definitions/Shared"}}},r=Object.prototype.hasOwnProperty;function n(t,{instancePath:e="",parentData:r,parentDataProperty:s,rootData:a=t}={}){if(!Array.isArray(t))return n.errors=[{params:{type:"array"}}],!1;{const e=t.length;for(let r=0;r<e;r++){let e=t[r];const s=0;if("string"!=typeof e)return n.errors=[{params:{type:"string"}}],!1;if(e.length<1)return n.errors=[{params:{}}],!1;if(0!==s)break}}return n.errors=null,!0}function s(t,{instancePath:e="",parentData:r,parentDataProperty:a,rootData:o=t}={}){let i=null,l=0;if(0===l){if(!t||"object"!=typeof t||Array.isArray(t))return s.errors=[{params:{type:"object"}}],!1;{let r;if(void 0===t.import&&(r="import"))return s.errors=[{params:{missingProperty:r}}],!1;{const r=l;for(const e in t)if("import"!==e&&"name"!==e)return s.errors=[{params:{additionalProperty:e}}],!1;if(r===l){if(void 0!==t.import){let r=t.import;const a=l,c=l;let m=!1;const u=l;if(l==l)if("string"==typeof r){if(r.length<1){const t={params:{}};null===i?i=[t]:i.push(t),l++}}else{const t={params:{type:"string"}};null===i?i=[t]:i.push(t),l++}var p=u===l;if(m=m||p,!m){const s=l;n(r,{instancePath:e+"/import",parentData:t,parentDataProperty:"import",rootData:o})||(i=null===i?n.errors:i.concat(n.errors),l=i.length),p=s===l,m=m||p}if(!m){const t={params:{}};return null===i?i=[t]:i.push(t),l++,s.errors=i,!1}l=c,null!==i&&(c?i.length=c:i=null);var f=a===l}else f=!0;if(f)if(void 0!==t.name){const e=l;if("string"!=typeof t.name)return s.errors=[{params:{type:"string"}}],!1;f=e===l}else f=!0}}}}return s.errors=i,0===l}function a(t,{instancePath:e="",parentData:r,parentDataProperty:o,rootData:i=t}={}){let l=null,p=0;if(0===p){if(!t||"object"!=typeof t||Array.isArray(t))return a.errors=[{params:{type:"object"}}],!1;for(const r in t){let o=t[r];const c=p,m=p;let u=!1;const y=p;s(o,{instancePath:e+"/"+r.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:t,parentDataProperty:r,rootData:i})||(l=null===l?s.errors:l.concat(s.errors),p=l.length);var f=y===p;if(u=u||f,!u){const s=p;if(p==p)if("string"==typeof o){if(o.length<1){const t={params:{}};null===l?l=[t]:l.push(t),p++}}else{const t={params:{type:"string"}};null===l?l=[t]:l.push(t),p++}if(f=s===p,u=u||f,!u){const s=p;n(o,{instancePath:e+"/"+r.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:t,parentDataProperty:r,rootData:i})||(l=null===l?n.errors:l.concat(n.errors),p=l.length),f=s===p,u=u||f}}if(!u){const t={params:{}};return null===l?l=[t]:l.push(t),p++,a.errors=l,!1}if(p=m,null!==l&&(m?l.length=m:l=null),c!==p)break}}return a.errors=l,0===p}function o(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:s=t}={}){let i=null,l=0;const p=l;let f=!1;const c=l;if(l===c)if(Array.isArray(t)){const r=t.length;for(let n=0;n<r;n++){let r=t[n];const o=l,p=l;let f=!1;const c=l;if(l==l)if("string"==typeof r){if(r.length<1){const t={params:{}};null===i?i=[t]:i.push(t),l++}}else{const t={params:{type:"string"}};null===i?i=[t]:i.push(t),l++}var m=c===l;if(f=f||m,!f){const o=l;a(r,{instancePath:e+"/"+n,parentData:t,parentDataProperty:n,rootData:s})||(i=null===i?a.errors:i.concat(a.errors),l=i.length),m=o===l,f=f||m}if(f)l=p,null!==i&&(p?i.length=p:i=null);else{const t={params:{}};null===i?i=[t]:i.push(t),l++}if(o!==l)break}}else{const t={params:{type:"array"}};null===i?i=[t]:i.push(t),l++}var u=c===l;if(f=f||u,!f){const o=l;a(t,{instancePath:e,parentData:r,parentDataProperty:n,rootData:s})||(i=null===i?a.errors:i.concat(a.errors),l=i.length),u=o===l,f=f||u}if(!f){const t={params:{}};return null===i?i=[t]:i.push(t),l++,o.errors=i,!1}return l=p,null!==i&&(p?i.length=p:i=null),o.errors=i,0===l}function i(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:s=t}={}){let a=null,o=0;const l=o;let p=!1;const f=o;if("string"!=typeof t){const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}var c=f===o;if(p=p||c,!p){const e=o;if(o==o)if(t&&"object"==typeof t&&!Array.isArray(t)){const e=o;for(const e in t)if("amd"!==e&&"commonjs"!==e&&"commonjs2"!==e&&"root"!==e){const t={params:{additionalProperty:e}};null===a?a=[t]:a.push(t),o++;break}if(e===o){if(void 0!==t.amd){const e=o;if("string"!=typeof t.amd){const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}var m=e===o}else m=!0;if(m){if(void 0!==t.commonjs){const e=o;if("string"!=typeof t.commonjs){const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}m=e===o}else m=!0;if(m){if(void 0!==t.commonjs2){const e=o;if("string"!=typeof t.commonjs2){const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}m=e===o}else m=!0;if(m)if(void 0!==t.root){const e=o;if("string"!=typeof t.root){const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}m=e===o}else m=!0}}}}else{const t={params:{type:"object"}};null===a?a=[t]:a.push(t),o++}c=e===o,p=p||c}if(!p){const t={params:{}};return null===a?a=[t]:a.push(t),o++,i.errors=a,!1}return o=l,null!==a&&(l?a.length=l:a=null),i.errors=a,0===o}function l(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:s=t}={}){let a=null,o=0;const i=o;let p=!1;const f=o;if(o===f)if(Array.isArray(t))if(t.length<1){const t={params:{limit:1}};null===a?a=[t]:a.push(t),o++}else{const e=t.length;for(let r=0;r<e;r++){let e=t[r];const n=o;if(o===n)if("string"==typeof e){if(e.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}if(n!==o)break}}else{const t={params:{type:"array"}};null===a?a=[t]:a.push(t),o++}var c=f===o;if(p=p||c,!p){const e=o;if(o===e)if("string"==typeof t){if(t.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}if(c=e===o,p=p||c,!p){const e=o;if(o==o)if(t&&"object"==typeof t&&!Array.isArray(t)){const e=o;for(const e in t)if("amd"!==e&&"commonjs"!==e&&"root"!==e){const t={params:{additionalProperty:e}};null===a?a=[t]:a.push(t),o++;break}if(e===o){if(void 0!==t.amd){let e=t.amd;const r=o;if(o===r)if("string"==typeof e){if(e.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}var m=r===o}else m=!0;if(m){if(void 0!==t.commonjs){let e=t.commonjs;const r=o;if(o===r)if("string"==typeof e){if(e.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}m=r===o}else m=!0;if(m)if(void 0!==t.root){let e=t.root;const r=o,n=o;let s=!1;const i=o;if(o===i)if(Array.isArray(e)){const t=e.length;for(let r=0;r<t;r++){let t=e[r];const n=o;if(o===n)if("string"==typeof t){if(t.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}if(n!==o)break}}else{const t={params:{type:"array"}};null===a?a=[t]:a.push(t),o++}var u=i===o;if(s=s||u,!s){const t=o;if(o===t)if("string"==typeof e){if(e.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}u=t===o,s=s||u}if(s)o=n,null!==a&&(n?a.length=n:a=null);else{const t={params:{}};null===a?a=[t]:a.push(t),o++}m=r===o}else m=!0}}}else{const t={params:{type:"object"}};null===a?a=[t]:a.push(t),o++}c=e===o,p=p||c}}if(!p){const t={params:{}};return null===a?a=[t]:a.push(t),o++,l.errors=a,!1}return o=i,null!==a&&(i?a.length=i:a=null),l.errors=a,0===o}function p(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:s=t}={}){let a=null,o=0;if(0===o){if(!t||"object"!=typeof t||Array.isArray(t))return p.errors=[{params:{type:"object"}}],!1;{let r;if(void 0===t.type&&(r="type"))return p.errors=[{params:{missingProperty:r}}],!1;{const r=o;for(const e in t)if("amdContainer"!==e&&"auxiliaryComment"!==e&&"export"!==e&&"name"!==e&&"type"!==e&&"umdNamedDefine"!==e)return p.errors=[{params:{additionalProperty:e}}],!1;if(r===o){if(void 0!==t.amdContainer){let e=t.amdContainer;const r=o;if(o==o){if("string"!=typeof e)return p.errors=[{params:{type:"string"}}],!1;if(e.length<1)return p.errors=[{params:{}}],!1}var f=r===o}else f=!0;if(f){if(void 0!==t.auxiliaryComment){const r=o;i(t.auxiliaryComment,{instancePath:e+"/auxiliaryComment",parentData:t,parentDataProperty:"auxiliaryComment",rootData:s})||(a=null===a?i.errors:a.concat(i.errors),o=a.length),f=r===o}else f=!0;if(f){if(void 0!==t.export){let e=t.export;const r=o,n=o;let s=!1;const i=o;if(o===i)if(Array.isArray(e)){const t=e.length;for(let r=0;r<t;r++){let t=e[r];const n=o;if(o===n)if("string"==typeof t){if(t.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}if(n!==o)break}}else{const t={params:{type:"array"}};null===a?a=[t]:a.push(t),o++}var c=i===o;if(s=s||c,!s){const t=o;if(o===t)if("string"==typeof e){if(e.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}c=t===o,s=s||c}if(!s){const t={params:{}};return null===a?a=[t]:a.push(t),o++,p.errors=a,!1}o=n,null!==a&&(n?a.length=n:a=null),f=r===o}else f=!0;if(f){if(void 0!==t.name){const r=o;l(t.name,{instancePath:e+"/name",parentData:t,parentDataProperty:"name",rootData:s})||(a=null===a?l.errors:a.concat(l.errors),o=a.length),f=r===o}else f=!0;if(f){if(void 0!==t.type){let e=t.type;const r=o,n=o;let s=!1;const i=o;if("var"!==e&&"module"!==e&&"assign"!==e&&"assign-properties"!==e&&"this"!==e&&"window"!==e&&"self"!==e&&"global"!==e&&"commonjs"!==e&&"commonjs2"!==e&&"commonjs-module"!==e&&"commonjs-static"!==e&&"amd"!==e&&"amd-require"!==e&&"umd"!==e&&"umd2"!==e&&"jsonp"!==e&&"system"!==e){const t={params:{}};null===a?a=[t]:a.push(t),o++}var m=i===o;if(s=s||m,!s){const t=o;if("string"!=typeof e){const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}m=t===o,s=s||m}if(!s){const t={params:{}};return null===a?a=[t]:a.push(t),o++,p.errors=a,!1}o=n,null!==a&&(n?a.length=n:a=null),f=r===o}else f=!0;if(f)if(void 0!==t.umdNamedDefine){const e=o;if("boolean"!=typeof t.umdNamedDefine)return p.errors=[{params:{type:"boolean"}}],!1;f=e===o}else f=!0}}}}}}}}return p.errors=a,0===o}function f(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:s=t}={}){if(!Array.isArray(t))return f.errors=[{params:{type:"array"}}],!1;{const e=t.length;for(let r=0;r<e;r++){let e=t[r];const n=0;if("string"!=typeof e)return f.errors=[{params:{type:"string"}}],!1;if(e.length<1)return f.errors=[{params:{}}],!1;if(0!==n)break}}return f.errors=null,!0}function c(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:s=t}={}){let a=null,o=0;if(0===o){if(!t||"object"!=typeof t||Array.isArray(t))return c.errors=[{params:{type:"object"}}],!1;{let r;if(void 0===t.external&&(r="external"))return c.errors=[{params:{missingProperty:r}}],!1;{const r=o;for(const e in t)if("external"!==e&&"shareScope"!==e)return c.errors=[{params:{additionalProperty:e}}],!1;if(r===o){if(void 0!==t.external){let r=t.external;const n=o,p=o;let m=!1;const u=o;if(o==o)if("string"==typeof r){if(r.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}var i=u===o;if(m=m||i,!m){const n=o;f(r,{instancePath:e+"/external",parentData:t,parentDataProperty:"external",rootData:s})||(a=null===a?f.errors:a.concat(f.errors),o=a.length),i=n===o,m=m||i}if(!m){const t={params:{}};return null===a?a=[t]:a.push(t),o++,c.errors=a,!1}o=p,null!==a&&(p?a.length=p:a=null);var l=n===o}else l=!0;if(l)if(void 0!==t.shareScope){let e=t.shareScope;const r=o;if(o===r){if("string"!=typeof e)return c.errors=[{params:{type:"string"}}],!1;if(e.length<1)return c.errors=[{params:{}}],!1}l=r===o}else l=!0}}}}return c.errors=a,0===o}function m(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:s=t}={}){let a=null,o=0;if(0===o){if(!t||"object"!=typeof t||Array.isArray(t))return m.errors=[{params:{type:"object"}}],!1;for(const r in t){let n=t[r];const l=o,p=o;let u=!1;const y=o;c(n,{instancePath:e+"/"+r.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:t,parentDataProperty:r,rootData:s})||(a=null===a?c.errors:a.concat(c.errors),o=a.length);var i=y===o;if(u=u||i,!u){const l=o;if(o==o)if("string"==typeof n){if(n.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}if(i=l===o,u=u||i,!u){const l=o;f(n,{instancePath:e+"/"+r.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:t,parentDataProperty:r,rootData:s})||(a=null===a?f.errors:a.concat(f.errors),o=a.length),i=l===o,u=u||i}}if(!u){const t={params:{}};return null===a?a=[t]:a.push(t),o++,m.errors=a,!1}if(o=p,null!==a&&(p?a.length=p:a=null),l!==o)break}}return m.errors=a,0===o}function u(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:s=t}={}){let a=null,o=0;const i=o;let l=!1;const p=o;if(o===p)if(Array.isArray(t)){const r=t.length;for(let n=0;n<r;n++){let r=t[n];const i=o,l=o;let p=!1;const c=o;if(o==o)if("string"==typeof r){if(r.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}var f=c===o;if(p=p||f,!p){const i=o;m(r,{instancePath:e+"/"+n,parentData:t,parentDataProperty:n,rootData:s})||(a=null===a?m.errors:a.concat(m.errors),o=a.length),f=i===o,p=p||f}if(p)o=l,null!==a&&(l?a.length=l:a=null);else{const t={params:{}};null===a?a=[t]:a.push(t),o++}if(i!==o)break}}else{const t={params:{type:"array"}};null===a?a=[t]:a.push(t),o++}var c=p===o;if(l=l||c,!l){const i=o;m(t,{instancePath:e,parentData:r,parentDataProperty:n,rootData:s})||(a=null===a?m.errors:a.concat(m.errors),o=a.length),c=i===o,l=l||c}if(!l){const t={params:{}};return null===a?a=[t]:a.push(t),o++,u.errors=a,!1}return o=i,null!==a&&(i?a.length=i:a=null),u.errors=a,0===o}const y={type:"object",additionalProperties:!1,properties:{eager:{type:"boolean"},import:{anyOf:[{enum:[!1]},{$ref:"#/definitions/SharedItem"}]},packageName:{type:"string",minLength:1},requiredVersion:{anyOf:[{enum:[!1]},{type:"string"}]},shareKey:{type:"string",minLength:1},shareScope:{type:"string",minLength:1},singleton:{type:"boolean"},strictVersion:{type:"boolean"},version:{anyOf:[{enum:[!1]},{type:"string"}]}}};function h(t,{instancePath:e="",parentData:n,parentDataProperty:s,rootData:a=t}={}){let o=null,i=0;if(0===i){if(!t||"object"!=typeof t||Array.isArray(t))return h.errors=[{params:{type:"object"}}],!1;{const e=i;for(const e in t)if(!r.call(y.properties,e))return h.errors=[{params:{additionalProperty:e}}],!1;if(e===i){if(void 0!==t.eager){const e=i;if("boolean"!=typeof t.eager)return h.errors=[{params:{type:"boolean"}}],!1;var l=e===i}else l=!0;if(l){if(void 0!==t.import){let e=t.import;const r=i,n=i;let s=!1;const a=i;if(!1!==e){const t={params:{}};null===o?o=[t]:o.push(t),i++}var p=a===i;if(s=s||p,!s){const t=i;if(i==i)if("string"==typeof e){if(e.length<1){const t={params:{}};null===o?o=[t]:o.push(t),i++}}else{const t={params:{type:"string"}};null===o?o=[t]:o.push(t),i++}p=t===i,s=s||p}if(!s){const t={params:{}};return null===o?o=[t]:o.push(t),i++,h.errors=o,!1}i=n,null!==o&&(n?o.length=n:o=null),l=r===i}else l=!0;if(l){if(void 0!==t.packageName){let e=t.packageName;const r=i;if(i===r){if("string"!=typeof e)return h.errors=[{params:{type:"string"}}],!1;if(e.length<1)return h.errors=[{params:{}}],!1}l=r===i}else l=!0;if(l){if(void 0!==t.requiredVersion){let e=t.requiredVersion;const r=i,n=i;let s=!1;const a=i;if(!1!==e){const t={params:{}};null===o?o=[t]:o.push(t),i++}var f=a===i;if(s=s||f,!s){const t=i;if("string"!=typeof e){const t={params:{type:"string"}};null===o?o=[t]:o.push(t),i++}f=t===i,s=s||f}if(!s){const t={params:{}};return null===o?o=[t]:o.push(t),i++,h.errors=o,!1}i=n,null!==o&&(n?o.length=n:o=null),l=r===i}else l=!0;if(l){if(void 0!==t.shareKey){let e=t.shareKey;const r=i;if(i===r){if("string"!=typeof e)return h.errors=[{params:{type:"string"}}],!1;if(e.length<1)return h.errors=[{params:{}}],!1}l=r===i}else l=!0;if(l){if(void 0!==t.shareScope){let e=t.shareScope;const r=i;if(i===r){if("string"!=typeof e)return h.errors=[{params:{type:"string"}}],!1;if(e.length<1)return h.errors=[{params:{}}],!1}l=r===i}else l=!0;if(l){if(void 0!==t.singleton){const e=i;if("boolean"!=typeof t.singleton)return h.errors=[{params:{type:"boolean"}}],!1;l=e===i}else l=!0;if(l){if(void 0!==t.strictVersion){const e=i;if("boolean"!=typeof t.strictVersion)return h.errors=[{params:{type:"boolean"}}],!1;l=e===i}else l=!0;if(l)if(void 0!==t.version){let e=t.version;const r=i,n=i;let s=!1;const a=i;if(!1!==e){const t={params:{}};null===o?o=[t]:o.push(t),i++}var c=a===i;if(s=s||c,!s){const t=i;if("string"!=typeof e){const t={params:{type:"string"}};null===o?o=[t]:o.push(t),i++}c=t===i,s=s||c}if(!s){const t={params:{}};return null===o?o=[t]:o.push(t),i++,h.errors=o,!1}i=n,null!==o&&(n?o.length=n:o=null),l=r===i}else l=!0}}}}}}}}}}return h.errors=o,0===i}function g(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:s=t}={}){let a=null,o=0;if(0===o){if(!t||"object"!=typeof t||Array.isArray(t))return g.errors=[{params:{type:"object"}}],!1;for(const r in t){let n=t[r];const l=o,p=o;let f=!1;const c=o;h(n,{instancePath:e+"/"+r.replace(/~/g,"~0").replace(/\//g,"~1"),parentData:t,parentDataProperty:r,rootData:s})||(a=null===a?h.errors:a.concat(h.errors),o=a.length);var i=c===o;if(f=f||i,!f){const t=o;if(o==o)if("string"==typeof n){if(n.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}i=t===o,f=f||i}if(!f){const t={params:{}};return null===a?a=[t]:a.push(t),o++,g.errors=a,!1}if(o=p,null!==a&&(p?a.length=p:a=null),l!==o)break}}return g.errors=a,0===o}function d(t,{instancePath:e="",parentData:r,parentDataProperty:n,rootData:s=t}={}){let a=null,o=0;const i=o;let l=!1;const p=o;if(o===p)if(Array.isArray(t)){const r=t.length;for(let n=0;n<r;n++){let r=t[n];const i=o,l=o;let p=!1;const c=o;if(o==o)if("string"==typeof r){if(r.length<1){const t={params:{}};null===a?a=[t]:a.push(t),o++}}else{const t={params:{type:"string"}};null===a?a=[t]:a.push(t),o++}var f=c===o;if(p=p||f,!p){const i=o;g(r,{instancePath:e+"/"+n,parentData:t,parentDataProperty:n,rootData:s})||(a=null===a?g.errors:a.concat(g.errors),o=a.length),f=i===o,p=p||f}if(p)o=l,null!==a&&(l?a.length=l:a=null);else{const t={params:{}};null===a?a=[t]:a.push(t),o++}if(i!==o)break}}else{const t={params:{type:"array"}};null===a?a=[t]:a.push(t),o++}var c=p===o;if(l=l||c,!l){const i=o;g(t,{instancePath:e,parentData:r,parentDataProperty:n,rootData:s})||(a=null===a?g.errors:a.concat(g.errors),o=a.length),c=i===o,l=l||c}if(!l){const t={params:{}};return null===a?a=[t]:a.push(t),o++,d.errors=a,!1}return o=i,null!==a&&(i?a.length=i:a=null),d.errors=a,0===o}function D(n,{instancePath:s="",parentData:a,parentDataProperty:i,rootData:l=n}={}){let f=null,c=0;if(0===c){if(!n||"object"!=typeof n||Array.isArray(n))return D.errors=[{params:{type:"object"}}],!1;{const a=c;for(const t in n)if(!r.call(e.properties,t))return D.errors=[{params:{additionalProperty:t}}],!1;if(a===c){if(void 0!==n.exposes){const t=c;o(n.exposes,{instancePath:s+"/exposes",parentData:n,parentDataProperty:"exposes",rootData:l})||(f=null===f?o.errors:f.concat(o.errors),c=f.length);var m=t===c}else m=!0;if(m){if(void 0!==n.filename){let e=n.filename;const r=c;if(c===r){if("string"!=typeof e)return D.errors=[{params:{type:"string"}}],!1;if(e.includes("!")||!1!==t.test(e))return D.errors=[{params:{}}],!1}m=r===c}else m=!0;if(m){if(void 0!==n.library){const t=c;p(n.library,{instancePath:s+"/library",parentData:n,parentDataProperty:"library",rootData:l})||(f=null===f?p.errors:f.concat(p.errors),c=f.length),m=t===c}else m=!0;if(m){if(void 0!==n.name){const t=c;if("string"!=typeof n.name)return D.errors=[{params:{type:"string"}}],!1;m=t===c}else m=!0;if(m){if(void 0!==n.remoteType){let t=n.remoteType;const e=c,r=c;let s=!1,a=null;const o=c;if("var"!==t&&"module"!==t&&"assign"!==t&&"this"!==t&&"window"!==t&&"self"!==t&&"global"!==t&&"commonjs"!==t&&"commonjs2"!==t&&"commonjs-module"!==t&&"commonjs-static"!==t&&"amd"!==t&&"amd-require"!==t&&"umd"!==t&&"umd2"!==t&&"jsonp"!==t&&"system"!==t&&"promise"!==t&&"import"!==t&&"module-import"!==t&&"script"!==t&&"node-commonjs"!==t&&"asset"!==t&&"css-import"!==t&&"css-url"!==t){const t={params:{}};null===f?f=[t]:f.push(t),c++}if(o===c&&(s=!0,a=0),!s){const t={params:{passingSchemas:a}};return null===f?f=[t]:f.push(t),c++,D.errors=f,!1}c=r,null!==f&&(r?f.length=r:f=null),m=e===c}else m=!0;if(m){if(void 0!==n.remotes){const t=c;u(n.remotes,{instancePath:s+"/remotes",parentData:n,parentDataProperty:"remotes",rootData:l})||(f=null===f?u.errors:f.concat(u.errors),c=f.length),m=t===c}else m=!0;if(m){if(void 0!==n.runtime){let t=n.runtime;const e=c,r=c;let s=!1;const a=c;if(!1!==t){const t={params:{}};null===f?f=[t]:f.push(t),c++}var y=a===c;if(s=s||y,!s){const e=c;if(c===e)if("string"==typeof t){if(t.length<1){const t={params:{}};null===f?f=[t]:f.push(t),c++}}else{const t={params:{type:"string"}};null===f?f=[t]:f.push(t),c++}y=e===c,s=s||y}if(!s){const t={params:{}};return null===f?f=[t]:f.push(t),c++,D.errors=f,!1}c=r,null!==f&&(r?f.length=r:f=null),m=e===c}else m=!0;if(m){if(void 0!==n.shareScope){let t=n.shareScope;const e=c;if(c===e){if("string"!=typeof t)return D.errors=[{params:{type:"string"}}],!1;if(t.length<1)return D.errors=[{params:{}}],!1}m=e===c}else m=!0;if(m)if(void 0!==n.shared){const t=c;d(n.shared,{instancePath:s+"/shared",parentData:n,parentDataProperty:"shared",rootData:l})||(f=null===f?d.errors:f.concat(d.errors),c=f.length),m=t===c}else m=!0}}}}}}}}}}return D.errors=f,0===c}

@@ -131,3 +131,6 @@ {

"script",
"node-commonjs"
"node-commonjs",
"asset",
"css-import",
"css-url"
]

@@ -134,0 +137,0 @@ },

@@ -6,2 +6,2 @@ /*

*/
"use strict";function r(t,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:n=t}={}){if(!t||"object"!=typeof t||Array.isArray(t))return r.errors=[{params:{type:"object"}}],!1;{const e=0;for(const e in t)if("import"!==e&&"namedExports"!==e&&"url"!==e)return r.errors=[{params:{additionalProperty:e}}],!1;if(0===e){if(void 0!==t.import){const e=0;if("boolean"!=typeof t.import)return r.errors=[{params:{type:"boolean"}}],!1;var s=0===e}else s=!0;if(s){if(void 0!==t.namedExports){const e=0;if("boolean"!=typeof t.namedExports)return r.errors=[{params:{type:"boolean"}}],!1;s=0===e}else s=!0;if(s)if(void 0!==t.url){const e=0;if("boolean"!=typeof t.url)return r.errors=[{params:{type:"boolean"}}],!1;s=0===e}else s=!0}}}return r.errors=null,!0}function t(e,{instancePath:o="",parentData:a,parentDataProperty:n,rootData:s=e}={}){let p=null,i=0;return r(e,{instancePath:o,parentData:a,parentDataProperty:n,rootData:s})||(p=null===p?r.errors:p.concat(r.errors),i=p.length),t.errors=p,0===i}module.exports=t,module.exports.default=t;
"use strict";function r(e,{instancePath:t="",parentData:o,parentDataProperty:a,rootData:n=e}={}){if(!e||"object"!=typeof e||Array.isArray(e))return r.errors=[{params:{type:"object"}}],!1;{const t=0;for(const t in e)if("exportType"!==t&&"import"!==t&&"namedExports"!==t&&"url"!==t)return r.errors=[{params:{additionalProperty:t}}],!1;if(0===t){if(void 0!==e.exportType){let t=e.exportType;const o=0;if("link"!==t&&"text"!==t&&"css-style-sheet"!==t)return r.errors=[{params:{}}],!1;var s=0===o}else s=!0;if(s){if(void 0!==e.import){const t=0;if("boolean"!=typeof e.import)return r.errors=[{params:{type:"boolean"}}],!1;s=0===t}else s=!0;if(s){if(void 0!==e.namedExports){const t=0;if("boolean"!=typeof e.namedExports)return r.errors=[{params:{type:"boolean"}}],!1;s=0===t}else s=!0;if(s)if(void 0!==e.url){const t=0;if("boolean"!=typeof e.url)return r.errors=[{params:{type:"boolean"}}],!1;s=0===t}else s=!0}}}}return r.errors=null,!0}function e(t,{instancePath:o="",parentData:a,parentDataProperty:n,rootData:s=t}={}){let p=null,i=0;return r(t,{instancePath:o,parentData:a,parentDataProperty:n,rootData:s})||(p=null===p?r.errors:p.concat(r.errors),i=p.length),e.errors=p,0===i}module.exports=e,module.exports.default=e;

@@ -6,2 +6,2 @@ /*

*/
"use strict";function e(r,{instancePath:t="",parentData:o,parentDataProperty:n,rootData:a=r}={}){let s=null,l=0;if(0===l){if(!r||"object"!=typeof r||Array.isArray(r))return e.errors=[{params:{type:"object"}}],!1;{const t=l;for(const t in r)if("esModule"!==t&&"exportsConvention"!==t&&"exportsOnly"!==t&&"localIdentName"!==t)return e.errors=[{params:{additionalProperty:t}}],!1;if(t===l){if(void 0!==r.esModule){const t=l;if("boolean"!=typeof r.esModule)return e.errors=[{params:{type:"boolean"}}],!1;var i=t===l}else i=!0;if(i){if(void 0!==r.exportsConvention){let t=r.exportsConvention;const o=l,n=l;let a=!1;const c=l;if("as-is"!==t&&"camel-case"!==t&&"camel-case-only"!==t&&"dashes"!==t&&"dashes-only"!==t){const e={params:{}};null===s?s=[e]:s.push(e),l++}var p=c===l;if(a=a||p,!a){const e=l;if(!(t instanceof Function)){const e={params:{}};null===s?s=[e]:s.push(e),l++}p=e===l,a=a||p}if(!a){const r={params:{}};return null===s?s=[r]:s.push(r),l++,e.errors=s,!1}l=n,null!==s&&(n?s.length=n:s=null),i=o===l}else i=!0;if(i){if(void 0!==r.exportsOnly){const t=l;if("boolean"!=typeof r.exportsOnly)return e.errors=[{params:{type:"boolean"}}],!1;i=t===l}else i=!0;if(i)if(void 0!==r.localIdentName){const t=l;if("string"!=typeof r.localIdentName)return e.errors=[{params:{type:"string"}}],!1;i=t===l}else i=!0}}}}}return e.errors=s,0===l}function r(t,{instancePath:o="",parentData:n,parentDataProperty:a,rootData:s=t}={}){let l=null,i=0;return e(t,{instancePath:o,parentData:n,parentDataProperty:a,rootData:s})||(l=null===l?e.errors:l.concat(e.errors),i=l.length),r.errors=l,0===i}module.exports=r,module.exports.default=r;
"use strict";function e(r,{instancePath:t="",parentData:o,parentDataProperty:n,rootData:a=r}={}){let s=null,l=0;if(0===l){if(!r||"object"!=typeof r||Array.isArray(r))return e.errors=[{params:{type:"object"}}],!1;{const t=l;for(const t in r)if("esModule"!==t&&"exportType"!==t&&"exportsConvention"!==t&&"exportsOnly"!==t&&"localIdentName"!==t)return e.errors=[{params:{additionalProperty:t}}],!1;if(t===l){if(void 0!==r.esModule){const t=l;if("boolean"!=typeof r.esModule)return e.errors=[{params:{type:"boolean"}}],!1;var i=t===l}else i=!0;if(i){if(void 0!==r.exportType){let t=r.exportType;const o=l;if("link"!==t&&"text"!==t&&"css-style-sheet"!==t)return e.errors=[{params:{}}],!1;i=o===l}else i=!0;if(i){if(void 0!==r.exportsConvention){let t=r.exportsConvention;const o=l,n=l;let a=!1;const c=l;if("as-is"!==t&&"camel-case"!==t&&"camel-case-only"!==t&&"dashes"!==t&&"dashes-only"!==t){const e={params:{}};null===s?s=[e]:s.push(e),l++}var p=c===l;if(a=a||p,!a){const e=l;if(!(t instanceof Function)){const e={params:{}};null===s?s=[e]:s.push(e),l++}p=e===l,a=a||p}if(!a){const r={params:{}};return null===s?s=[r]:s.push(r),l++,e.errors=s,!1}l=n,null!==s&&(n?s.length=n:s=null),i=o===l}else i=!0;if(i){if(void 0!==r.exportsOnly){const t=l;if("boolean"!=typeof r.exportsOnly)return e.errors=[{params:{type:"boolean"}}],!1;i=t===l}else i=!0;if(i)if(void 0!==r.localIdentName){const t=l;if("string"!=typeof r.localIdentName)return e.errors=[{params:{type:"string"}}],!1;i=t===l}else i=!0}}}}}}return e.errors=s,0===l}function r(t,{instancePath:o="",parentData:n,parentDataProperty:a,rootData:s=t}={}){let l=null,i=0;return e(t,{instancePath:o,parentData:n,parentDataProperty:a,rootData:s})||(l=null===l?e.errors:l.concat(e.errors),i=l.length),r.errors=l,0===i}module.exports=r,module.exports.default=r;

@@ -6,2 +6,2 @@ /*

*/
"use strict";function r(t,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:n=t}={}){if(!t||"object"!=typeof t||Array.isArray(t))return r.errors=[{params:{type:"object"}}],!1;{const e=0;for(const e in t)if("import"!==e&&"namedExports"!==e&&"url"!==e)return r.errors=[{params:{additionalProperty:e}}],!1;if(0===e){if(void 0!==t.import){const e=0;if("boolean"!=typeof t.import)return r.errors=[{params:{type:"boolean"}}],!1;var s=0===e}else s=!0;if(s){if(void 0!==t.namedExports){const e=0;if("boolean"!=typeof t.namedExports)return r.errors=[{params:{type:"boolean"}}],!1;s=0===e}else s=!0;if(s)if(void 0!==t.url){const e=0;if("boolean"!=typeof t.url)return r.errors=[{params:{type:"boolean"}}],!1;s=0===e}else s=!0}}}return r.errors=null,!0}function t(e,{instancePath:o="",parentData:a,parentDataProperty:n,rootData:s=e}={}){let p=null,i=0;return r(e,{instancePath:o,parentData:a,parentDataProperty:n,rootData:s})||(p=null===p?r.errors:p.concat(r.errors),i=p.length),t.errors=p,0===i}module.exports=t,module.exports.default=t;
"use strict";function r(e,{instancePath:t="",parentData:o,parentDataProperty:a,rootData:n=e}={}){if(!e||"object"!=typeof e||Array.isArray(e))return r.errors=[{params:{type:"object"}}],!1;{const t=0;for(const t in e)if("exportType"!==t&&"import"!==t&&"namedExports"!==t&&"url"!==t)return r.errors=[{params:{additionalProperty:t}}],!1;if(0===t){if(void 0!==e.exportType){let t=e.exportType;const o=0;if("link"!==t&&"text"!==t&&"css-style-sheet"!==t)return r.errors=[{params:{}}],!1;var s=0===o}else s=!0;if(s){if(void 0!==e.import){const t=0;if("boolean"!=typeof e.import)return r.errors=[{params:{type:"boolean"}}],!1;s=0===t}else s=!0;if(s){if(void 0!==e.namedExports){const t=0;if("boolean"!=typeof e.namedExports)return r.errors=[{params:{type:"boolean"}}],!1;s=0===t}else s=!0;if(s)if(void 0!==e.url){const t=0;if("boolean"!=typeof e.url)return r.errors=[{params:{type:"boolean"}}],!1;s=0===t}else s=!0}}}}return r.errors=null,!0}function e(t,{instancePath:o="",parentData:a,parentDataProperty:n,rootData:s=t}={}){let p=null,i=0;return r(t,{instancePath:o,parentData:a,parentDataProperty:n,rootData:s})||(p=null===p?r.errors:p.concat(r.errors),i=p.length),e.errors=p,0===i}module.exports=e,module.exports.default=e;

@@ -6,2 +6,2 @@ /*

*/
"use strict";function e(r,{instancePath:t="",parentData:o,parentDataProperty:n,rootData:a=r}={}){let s=null,l=0;if(0===l){if(!r||"object"!=typeof r||Array.isArray(r))return e.errors=[{params:{type:"object"}}],!1;{const t=l;for(const t in r)if("esModule"!==t&&"exportsConvention"!==t&&"exportsOnly"!==t&&"localIdentName"!==t)return e.errors=[{params:{additionalProperty:t}}],!1;if(t===l){if(void 0!==r.esModule){const t=l;if("boolean"!=typeof r.esModule)return e.errors=[{params:{type:"boolean"}}],!1;var i=t===l}else i=!0;if(i){if(void 0!==r.exportsConvention){let t=r.exportsConvention;const o=l,n=l;let a=!1;const c=l;if("as-is"!==t&&"camel-case"!==t&&"camel-case-only"!==t&&"dashes"!==t&&"dashes-only"!==t){const e={params:{}};null===s?s=[e]:s.push(e),l++}var p=c===l;if(a=a||p,!a){const e=l;if(!(t instanceof Function)){const e={params:{}};null===s?s=[e]:s.push(e),l++}p=e===l,a=a||p}if(!a){const r={params:{}};return null===s?s=[r]:s.push(r),l++,e.errors=s,!1}l=n,null!==s&&(n?s.length=n:s=null),i=o===l}else i=!0;if(i){if(void 0!==r.exportsOnly){const t=l;if("boolean"!=typeof r.exportsOnly)return e.errors=[{params:{type:"boolean"}}],!1;i=t===l}else i=!0;if(i)if(void 0!==r.localIdentName){const t=l;if("string"!=typeof r.localIdentName)return e.errors=[{params:{type:"string"}}],!1;i=t===l}else i=!0}}}}}return e.errors=s,0===l}function r(t,{instancePath:o="",parentData:n,parentDataProperty:a,rootData:s=t}={}){let l=null,i=0;return e(t,{instancePath:o,parentData:n,parentDataProperty:a,rootData:s})||(l=null===l?e.errors:l.concat(e.errors),i=l.length),r.errors=l,0===i}module.exports=r,module.exports.default=r;
"use strict";function e(r,{instancePath:t="",parentData:o,parentDataProperty:n,rootData:a=r}={}){let s=null,l=0;if(0===l){if(!r||"object"!=typeof r||Array.isArray(r))return e.errors=[{params:{type:"object"}}],!1;{const t=l;for(const t in r)if("esModule"!==t&&"exportType"!==t&&"exportsConvention"!==t&&"exportsOnly"!==t&&"localIdentName"!==t)return e.errors=[{params:{additionalProperty:t}}],!1;if(t===l){if(void 0!==r.esModule){const t=l;if("boolean"!=typeof r.esModule)return e.errors=[{params:{type:"boolean"}}],!1;var i=t===l}else i=!0;if(i){if(void 0!==r.exportType){let t=r.exportType;const o=l;if("link"!==t&&"text"!==t&&"css-style-sheet"!==t)return e.errors=[{params:{}}],!1;i=o===l}else i=!0;if(i){if(void 0!==r.exportsConvention){let t=r.exportsConvention;const o=l,n=l;let a=!1;const c=l;if("as-is"!==t&&"camel-case"!==t&&"camel-case-only"!==t&&"dashes"!==t&&"dashes-only"!==t){const e={params:{}};null===s?s=[e]:s.push(e),l++}var p=c===l;if(a=a||p,!a){const e=l;if(!(t instanceof Function)){const e={params:{}};null===s?s=[e]:s.push(e),l++}p=e===l,a=a||p}if(!a){const r={params:{}};return null===s?s=[r]:s.push(r),l++,e.errors=s,!1}l=n,null!==s&&(n?s.length=n:s=null),i=o===l}else i=!0;if(i){if(void 0!==r.exportsOnly){const t=l;if("boolean"!=typeof r.exportsOnly)return e.errors=[{params:{type:"boolean"}}],!1;i=t===l}else i=!0;if(i)if(void 0!==r.localIdentName){const t=l;if("string"!=typeof r.localIdentName)return e.errors=[{params:{type:"string"}}],!1;i=t===l}else i=!0}}}}}}return e.errors=s,0===l}function r(t,{instancePath:o="",parentData:n,parentDataProperty:a,rootData:s=t}={}){let l=null,i=0;return e(t,{instancePath:o,parentData:n,parentDataProperty:a,rootData:s})||(l=null===l?e.errors:l.concat(e.errors),i=l.length),r.errors=l,0===i}module.exports=r,module.exports.default=r;

@@ -6,2 +6,2 @@ /*

*/
"use strict";function r(t,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:n=t}={}){if(!t||"object"!=typeof t||Array.isArray(t))return r.errors=[{params:{type:"object"}}],!1;{const e=0;for(const e in t)if("import"!==e&&"namedExports"!==e&&"url"!==e)return r.errors=[{params:{additionalProperty:e}}],!1;if(0===e){if(void 0!==t.import){const e=0;if("boolean"!=typeof t.import)return r.errors=[{params:{type:"boolean"}}],!1;var s=0===e}else s=!0;if(s){if(void 0!==t.namedExports){const e=0;if("boolean"!=typeof t.namedExports)return r.errors=[{params:{type:"boolean"}}],!1;s=0===e}else s=!0;if(s)if(void 0!==t.url){const e=0;if("boolean"!=typeof t.url)return r.errors=[{params:{type:"boolean"}}],!1;s=0===e}else s=!0}}}return r.errors=null,!0}function t(e,{instancePath:o="",parentData:a,parentDataProperty:n,rootData:s=e}={}){let p=null,i=0;return r(e,{instancePath:o,parentData:a,parentDataProperty:n,rootData:s})||(p=null===p?r.errors:p.concat(r.errors),i=p.length),t.errors=p,0===i}module.exports=t,module.exports.default=t;
"use strict";function r(e,{instancePath:t="",parentData:o,parentDataProperty:a,rootData:n=e}={}){if(!e||"object"!=typeof e||Array.isArray(e))return r.errors=[{params:{type:"object"}}],!1;{const t=0;for(const t in e)if("exportType"!==t&&"import"!==t&&"namedExports"!==t&&"url"!==t)return r.errors=[{params:{additionalProperty:t}}],!1;if(0===t){if(void 0!==e.exportType){let t=e.exportType;const o=0;if("link"!==t&&"text"!==t&&"css-style-sheet"!==t)return r.errors=[{params:{}}],!1;var s=0===o}else s=!0;if(s){if(void 0!==e.import){const t=0;if("boolean"!=typeof e.import)return r.errors=[{params:{type:"boolean"}}],!1;s=0===t}else s=!0;if(s){if(void 0!==e.namedExports){const t=0;if("boolean"!=typeof e.namedExports)return r.errors=[{params:{type:"boolean"}}],!1;s=0===t}else s=!0;if(s)if(void 0!==e.url){const t=0;if("boolean"!=typeof e.url)return r.errors=[{params:{type:"boolean"}}],!1;s=0===t}else s=!0}}}}return r.errors=null,!0}function e(t,{instancePath:o="",parentData:a,parentDataProperty:n,rootData:s=t}={}){let p=null,i=0;return r(t,{instancePath:o,parentData:a,parentDataProperty:n,rootData:s})||(p=null===p?r.errors:p.concat(r.errors),i=p.length),e.errors=p,0===i}module.exports=e,module.exports.default=e;

@@ -6,2 +6,2 @@ /*

*/
"use strict";function r(t,{instancePath:e="",parentData:o,parentDataProperty:a,rootData:n=t}={}){if(!t||"object"!=typeof t||Array.isArray(t))return r.errors=[{params:{type:"object"}}],!1;{const e=0;for(const e in t)if("import"!==e&&"namedExports"!==e&&"url"!==e)return r.errors=[{params:{additionalProperty:e}}],!1;if(0===e){if(void 0!==t.import){const e=0;if("boolean"!=typeof t.import)return r.errors=[{params:{type:"boolean"}}],!1;var s=0===e}else s=!0;if(s){if(void 0!==t.namedExports){const e=0;if("boolean"!=typeof t.namedExports)return r.errors=[{params:{type:"boolean"}}],!1;s=0===e}else s=!0;if(s)if(void 0!==t.url){const e=0;if("boolean"!=typeof t.url)return r.errors=[{params:{type:"boolean"}}],!1;s=0===e}else s=!0}}}return r.errors=null,!0}function t(e,{instancePath:o="",parentData:a,parentDataProperty:n,rootData:s=e}={}){let p=null,i=0;return r(e,{instancePath:o,parentData:a,parentDataProperty:n,rootData:s})||(p=null===p?r.errors:p.concat(r.errors),i=p.length),t.errors=p,0===i}module.exports=t,module.exports.default=t;
"use strict";function r(e,{instancePath:t="",parentData:o,parentDataProperty:a,rootData:n=e}={}){if(!e||"object"!=typeof e||Array.isArray(e))return r.errors=[{params:{type:"object"}}],!1;{const t=0;for(const t in e)if("exportType"!==t&&"import"!==t&&"namedExports"!==t&&"url"!==t)return r.errors=[{params:{additionalProperty:t}}],!1;if(0===t){if(void 0!==e.exportType){let t=e.exportType;const o=0;if("link"!==t&&"text"!==t&&"css-style-sheet"!==t)return r.errors=[{params:{}}],!1;var s=0===o}else s=!0;if(s){if(void 0!==e.import){const t=0;if("boolean"!=typeof e.import)return r.errors=[{params:{type:"boolean"}}],!1;s=0===t}else s=!0;if(s){if(void 0!==e.namedExports){const t=0;if("boolean"!=typeof e.namedExports)return r.errors=[{params:{type:"boolean"}}],!1;s=0===t}else s=!0;if(s)if(void 0!==e.url){const t=0;if("boolean"!=typeof e.url)return r.errors=[{params:{type:"boolean"}}],!1;s=0===t}else s=!0}}}}return r.errors=null,!0}function e(t,{instancePath:o="",parentData:a,parentDataProperty:n,rootData:s=t}={}){let p=null,i=0;return r(t,{instancePath:o,parentData:a,parentDataProperty:n,rootData:s})||(p=null===p?r.errors:p.concat(r.errors),i=p.length),e.errors=p,0===i}module.exports=e,module.exports.default=e;

@@ -6,2 +6,2 @@ /*

*/
"use strict";function r(e,{instancePath:t="",parentData:o,parentDataProperty:a,rootData:s=e}={}){if(!e||"object"!=typeof e||Array.isArray(e))return r.errors=[{params:{type:"object"}}],!1;{const t=0;for(const t in e)if("exportsDepth"!==t&&"parse"!==t)return r.errors=[{params:{additionalProperty:t}}],!1;if(0===t){if(void 0!==e.exportsDepth){const t=0;if("number"!=typeof e.exportsDepth)return r.errors=[{params:{type:"number"}}],!1;var n=0===t}else n=!0;if(n)if(void 0!==e.parse){const t=0;if(!(e.parse instanceof Function))return r.errors=[{params:{}}],!1;n=0===t}else n=!0}}return r.errors=null,!0}module.exports=r,module.exports.default=r;
"use strict";function r(e,{instancePath:t="",parentData:o,parentDataProperty:a,rootData:s=e}={}){if(!e||"object"!=typeof e||Array.isArray(e))return r.errors=[{params:{type:"object"}}],!1;{const t=0;for(const t in e)if("exportsDepth"!==t&&"namedExports"!==t&&"parse"!==t)return r.errors=[{params:{additionalProperty:t}}],!1;if(0===t){if(void 0!==e.exportsDepth){const t=0;if("number"!=typeof e.exportsDepth)return r.errors=[{params:{type:"number"}}],!1;var n=0===t}else n=!0;if(n){if(void 0!==e.namedExports){const t=0;if("boolean"!=typeof e.namedExports)return r.errors=[{params:{type:"boolean"}}],!1;n=0===t}else n=!0;if(n)if(void 0!==e.parse){const t=0;if(!(e.parse instanceof Function))return r.errors=[{params:{}}],!1;n=0===t}else n=!0}}}return r.errors=null,!0}module.exports=r,module.exports.default=r;

@@ -6,2 +6,2 @@ /*

*/
const e=/^(?:[A-Za-z]:[\\/]|\\\\|\/)/;module.exports=l,module.exports.default=l;const n={definitions:{rule:{anyOf:[{instanceof:"RegExp"},{type:"string",minLength:1},{instanceof:"Function"}]},rules:{anyOf:[{type:"array",items:{oneOf:[{$ref:"#/definitions/rule"}]}},{$ref:"#/definitions/rule"}]}},type:"object",additionalProperties:!1,properties:{append:{anyOf:[{enum:[!1,null]},{type:"string",minLength:1},{instanceof:"Function"}]},columns:{type:"boolean"},debugIds:{type:"boolean"},exclude:{oneOf:[{$ref:"#/definitions/rules"}]},fallbackModuleFilenameTemplate:{anyOf:[{type:"string",minLength:1},{instanceof:"Function"}]},fileContext:{type:"string"},filename:{anyOf:[{enum:[!1,null]},{type:"string",absolutePath:!1,minLength:1}]},include:{oneOf:[{$ref:"#/definitions/rules"}]},module:{type:"boolean"},moduleFilenameTemplate:{anyOf:[{type:"string",minLength:1},{instanceof:"Function"}]},namespace:{type:"string"},noSources:{type:"boolean"},publicPath:{type:"string"},sourceRoot:{type:"string"},test:{$ref:"#/definitions/rules"}}},t=Object.prototype.hasOwnProperty;function s(e,{instancePath:n="",parentData:t,parentDataProperty:l,rootData:r=e}={}){let o=null,a=0;const i=a;let u=!1;const p=a;if(a===p)if(Array.isArray(e)){const n=e.length;for(let t=0;t<n;t++){let n=e[t];const s=a,l=a;let r=!1,i=null;const u=a,p=a;let c=!1;const m=a;if(!(n instanceof RegExp)){const e={params:{}};null===o?o=[e]:o.push(e),a++}var f=m===a;if(c=c||f,!c){const e=a;if(a===e)if("string"==typeof n){if(n.length<1){const e={params:{}};null===o?o=[e]:o.push(e),a++}}else{const e={params:{type:"string"}};null===o?o=[e]:o.push(e),a++}if(f=e===a,c=c||f,!c){const e=a;if(!(n instanceof Function)){const e={params:{}};null===o?o=[e]:o.push(e),a++}f=e===a,c=c||f}}if(c)a=p,null!==o&&(p?o.length=p:o=null);else{const e={params:{}};null===o?o=[e]:o.push(e),a++}if(u===a&&(r=!0,i=0),r)a=l,null!==o&&(l?o.length=l:o=null);else{const e={params:{passingSchemas:i}};null===o?o=[e]:o.push(e),a++}if(s!==a)break}}else{const e={params:{type:"array"}};null===o?o=[e]:o.push(e),a++}var c=p===a;if(u=u||c,!u){const n=a,t=a;let s=!1;const l=a;if(!(e instanceof RegExp)){const e={params:{}};null===o?o=[e]:o.push(e),a++}var m=l===a;if(s=s||m,!s){const n=a;if(a===n)if("string"==typeof e){if(e.length<1){const e={params:{}};null===o?o=[e]:o.push(e),a++}}else{const e={params:{type:"string"}};null===o?o=[e]:o.push(e),a++}if(m=n===a,s=s||m,!s){const n=a;if(!(e instanceof Function)){const e={params:{}};null===o?o=[e]:o.push(e),a++}m=n===a,s=s||m}}if(s)a=t,null!==o&&(t?o.length=t:o=null);else{const e={params:{}};null===o?o=[e]:o.push(e),a++}c=n===a,u=u||c}if(!u){const e={params:{}};return null===o?o=[e]:o.push(e),a++,s.errors=o,!1}return a=i,null!==o&&(i?o.length=i:o=null),s.errors=o,0===a}function l(r,{instancePath:o="",parentData:a,parentDataProperty:i,rootData:u=r}={}){let p=null,f=0;if(0===f){if(!r||"object"!=typeof r||Array.isArray(r))return l.errors=[{params:{type:"object"}}],!1;{const a=f;for(const e in r)if(!t.call(n.properties,e))return l.errors=[{params:{additionalProperty:e}}],!1;if(a===f){if(void 0!==r.append){let e=r.append;const n=f,t=f;let s=!1;const o=f;if(!1!==e&&null!==e){const e={params:{}};null===p?p=[e]:p.push(e),f++}var c=o===f;if(s=s||c,!s){const n=f;if(f===n)if("string"==typeof e){if(e.length<1){const e={params:{}};null===p?p=[e]:p.push(e),f++}}else{const e={params:{type:"string"}};null===p?p=[e]:p.push(e),f++}if(c=n===f,s=s||c,!s){const n=f;if(!(e instanceof Function)){const e={params:{}};null===p?p=[e]:p.push(e),f++}c=n===f,s=s||c}}if(!s){const e={params:{}};return null===p?p=[e]:p.push(e),f++,l.errors=p,!1}f=t,null!==p&&(t?p.length=t:p=null);var m=n===f}else m=!0;if(m){if(void 0!==r.columns){const e=f;if("boolean"!=typeof r.columns)return l.errors=[{params:{type:"boolean"}}],!1;m=e===f}else m=!0;if(m){if(void 0!==r.debugIds){const e=f;if("boolean"!=typeof r.debugIds)return l.errors=[{params:{type:"boolean"}}],!1;m=e===f}else m=!0;if(m){if(void 0!==r.exclude){const e=f,n=f;let t=!1,a=null;const i=f;if(s(r.exclude,{instancePath:o+"/exclude",parentData:r,parentDataProperty:"exclude",rootData:u})||(p=null===p?s.errors:p.concat(s.errors),f=p.length),i===f&&(t=!0,a=0),!t){const e={params:{passingSchemas:a}};return null===p?p=[e]:p.push(e),f++,l.errors=p,!1}f=n,null!==p&&(n?p.length=n:p=null),m=e===f}else m=!0;if(m){if(void 0!==r.fallbackModuleFilenameTemplate){let e=r.fallbackModuleFilenameTemplate;const n=f,t=f;let s=!1;const o=f;if(f===o)if("string"==typeof e){if(e.length<1){const e={params:{}};null===p?p=[e]:p.push(e),f++}}else{const e={params:{type:"string"}};null===p?p=[e]:p.push(e),f++}var h=o===f;if(s=s||h,!s){const n=f;if(!(e instanceof Function)){const e={params:{}};null===p?p=[e]:p.push(e),f++}h=n===f,s=s||h}if(!s){const e={params:{}};return null===p?p=[e]:p.push(e),f++,l.errors=p,!1}f=t,null!==p&&(t?p.length=t:p=null),m=n===f}else m=!0;if(m){if(void 0!==r.fileContext){const e=f;if("string"!=typeof r.fileContext)return l.errors=[{params:{type:"string"}}],!1;m=e===f}else m=!0;if(m){if(void 0!==r.filename){let n=r.filename;const t=f,s=f;let o=!1;const a=f;if(!1!==n&&null!==n){const e={params:{}};null===p?p=[e]:p.push(e),f++}var y=a===f;if(o=o||y,!o){const t=f;if(f===t)if("string"==typeof n){if(n.includes("!")||!1!==e.test(n)){const e={params:{}};null===p?p=[e]:p.push(e),f++}else if(n.length<1){const e={params:{}};null===p?p=[e]:p.push(e),f++}}else{const e={params:{type:"string"}};null===p?p=[e]:p.push(e),f++}y=t===f,o=o||y}if(!o){const e={params:{}};return null===p?p=[e]:p.push(e),f++,l.errors=p,!1}f=s,null!==p&&(s?p.length=s:p=null),m=t===f}else m=!0;if(m){if(void 0!==r.include){const e=f,n=f;let t=!1,a=null;const i=f;if(s(r.include,{instancePath:o+"/include",parentData:r,parentDataProperty:"include",rootData:u})||(p=null===p?s.errors:p.concat(s.errors),f=p.length),i===f&&(t=!0,a=0),!t){const e={params:{passingSchemas:a}};return null===p?p=[e]:p.push(e),f++,l.errors=p,!1}f=n,null!==p&&(n?p.length=n:p=null),m=e===f}else m=!0;if(m){if(void 0!==r.module){const e=f;if("boolean"!=typeof r.module)return l.errors=[{params:{type:"boolean"}}],!1;m=e===f}else m=!0;if(m){if(void 0!==r.moduleFilenameTemplate){let e=r.moduleFilenameTemplate;const n=f,t=f;let s=!1;const o=f;if(f===o)if("string"==typeof e){if(e.length<1){const e={params:{}};null===p?p=[e]:p.push(e),f++}}else{const e={params:{type:"string"}};null===p?p=[e]:p.push(e),f++}var g=o===f;if(s=s||g,!s){const n=f;if(!(e instanceof Function)){const e={params:{}};null===p?p=[e]:p.push(e),f++}g=n===f,s=s||g}if(!s){const e={params:{}};return null===p?p=[e]:p.push(e),f++,l.errors=p,!1}f=t,null!==p&&(t?p.length=t:p=null),m=n===f}else m=!0;if(m){if(void 0!==r.namespace){const e=f;if("string"!=typeof r.namespace)return l.errors=[{params:{type:"string"}}],!1;m=e===f}else m=!0;if(m){if(void 0!==r.noSources){const e=f;if("boolean"!=typeof r.noSources)return l.errors=[{params:{type:"boolean"}}],!1;m=e===f}else m=!0;if(m){if(void 0!==r.publicPath){const e=f;if("string"!=typeof r.publicPath)return l.errors=[{params:{type:"string"}}],!1;m=e===f}else m=!0;if(m){if(void 0!==r.sourceRoot){const e=f;if("string"!=typeof r.sourceRoot)return l.errors=[{params:{type:"string"}}],!1;m=e===f}else m=!0;if(m)if(void 0!==r.test){const e=f;s(r.test,{instancePath:o+"/test",parentData:r,parentDataProperty:"test",rootData:u})||(p=null===p?s.errors:p.concat(s.errors),f=p.length),m=e===f}else m=!0}}}}}}}}}}}}}}}}return l.errors=p,0===f}
const n=/^(?:[A-Za-z]:[\\/]|\\\\|\/)/;module.exports=l,module.exports.default=l;const e={definitions:{rule:{anyOf:[{instanceof:"RegExp"},{type:"string",minLength:1},{instanceof:"Function"}]},rules:{anyOf:[{type:"array",items:{oneOf:[{$ref:"#/definitions/rule"}]}},{$ref:"#/definitions/rule"}]}},type:"object",additionalProperties:!1,properties:{append:{anyOf:[{enum:[!1,null]},{type:"string",minLength:1},{instanceof:"Function"}]},columns:{type:"boolean"},debugIds:{type:"boolean"},exclude:{oneOf:[{$ref:"#/definitions/rules"}]},fallbackModuleFilenameTemplate:{anyOf:[{type:"string",minLength:1},{instanceof:"Function"}]},fileContext:{type:"string"},filename:{anyOf:[{enum:[!1,null]},{type:"string",absolutePath:!1,minLength:1}]},ignoreList:{oneOf:[{$ref:"#/definitions/rules"}]},include:{oneOf:[{$ref:"#/definitions/rules"}]},module:{type:"boolean"},moduleFilenameTemplate:{anyOf:[{type:"string",minLength:1},{instanceof:"Function"}]},namespace:{type:"string"},noSources:{type:"boolean"},publicPath:{type:"string"},sourceRoot:{type:"string"},test:{oneOf:[{$ref:"#/definitions/rules"}]}}},t=Object.prototype.hasOwnProperty;function s(n,{instancePath:e="",parentData:t,parentDataProperty:l,rootData:r=n}={}){let o=null,a=0;const i=a;let u=!1;const p=a;if(a===p)if(Array.isArray(n)){const e=n.length;for(let t=0;t<e;t++){let e=n[t];const s=a,l=a;let r=!1,i=null;const u=a,p=a;let c=!1;const m=a;if(!(e instanceof RegExp)){const n={params:{}};null===o?o=[n]:o.push(n),a++}var f=m===a;if(c=c||f,!c){const n=a;if(a===n)if("string"==typeof e){if(e.length<1){const n={params:{}};null===o?o=[n]:o.push(n),a++}}else{const n={params:{type:"string"}};null===o?o=[n]:o.push(n),a++}if(f=n===a,c=c||f,!c){const n=a;if(!(e instanceof Function)){const n={params:{}};null===o?o=[n]:o.push(n),a++}f=n===a,c=c||f}}if(c)a=p,null!==o&&(p?o.length=p:o=null);else{const n={params:{}};null===o?o=[n]:o.push(n),a++}if(u===a&&(r=!0,i=0),r)a=l,null!==o&&(l?o.length=l:o=null);else{const n={params:{passingSchemas:i}};null===o?o=[n]:o.push(n),a++}if(s!==a)break}}else{const n={params:{type:"array"}};null===o?o=[n]:o.push(n),a++}var c=p===a;if(u=u||c,!u){const e=a,t=a;let s=!1;const l=a;if(!(n instanceof RegExp)){const n={params:{}};null===o?o=[n]:o.push(n),a++}var m=l===a;if(s=s||m,!s){const e=a;if(a===e)if("string"==typeof n){if(n.length<1){const n={params:{}};null===o?o=[n]:o.push(n),a++}}else{const n={params:{type:"string"}};null===o?o=[n]:o.push(n),a++}if(m=e===a,s=s||m,!s){const e=a;if(!(n instanceof Function)){const n={params:{}};null===o?o=[n]:o.push(n),a++}m=e===a,s=s||m}}if(s)a=t,null!==o&&(t?o.length=t:o=null);else{const n={params:{}};null===o?o=[n]:o.push(n),a++}c=e===a,u=u||c}if(!u){const n={params:{}};return null===o?o=[n]:o.push(n),a++,s.errors=o,!1}return a=i,null!==o&&(i?o.length=i:o=null),s.errors=o,0===a}function l(r,{instancePath:o="",parentData:a,parentDataProperty:i,rootData:u=r}={}){let p=null,f=0;if(0===f){if(!r||"object"!=typeof r||Array.isArray(r))return l.errors=[{params:{type:"object"}}],!1;{const a=f;for(const n in r)if(!t.call(e.properties,n))return l.errors=[{params:{additionalProperty:n}}],!1;if(a===f){if(void 0!==r.append){let n=r.append;const e=f,t=f;let s=!1;const o=f;if(!1!==n&&null!==n){const n={params:{}};null===p?p=[n]:p.push(n),f++}var c=o===f;if(s=s||c,!s){const e=f;if(f===e)if("string"==typeof n){if(n.length<1){const n={params:{}};null===p?p=[n]:p.push(n),f++}}else{const n={params:{type:"string"}};null===p?p=[n]:p.push(n),f++}if(c=e===f,s=s||c,!s){const e=f;if(!(n instanceof Function)){const n={params:{}};null===p?p=[n]:p.push(n),f++}c=e===f,s=s||c}}if(!s){const n={params:{}};return null===p?p=[n]:p.push(n),f++,l.errors=p,!1}f=t,null!==p&&(t?p.length=t:p=null);var m=e===f}else m=!0;if(m){if(void 0!==r.columns){const n=f;if("boolean"!=typeof r.columns)return l.errors=[{params:{type:"boolean"}}],!1;m=n===f}else m=!0;if(m){if(void 0!==r.debugIds){const n=f;if("boolean"!=typeof r.debugIds)return l.errors=[{params:{type:"boolean"}}],!1;m=n===f}else m=!0;if(m){if(void 0!==r.exclude){const n=f,e=f;let t=!1,a=null;const i=f;if(s(r.exclude,{instancePath:o+"/exclude",parentData:r,parentDataProperty:"exclude",rootData:u})||(p=null===p?s.errors:p.concat(s.errors),f=p.length),i===f&&(t=!0,a=0),!t){const n={params:{passingSchemas:a}};return null===p?p=[n]:p.push(n),f++,l.errors=p,!1}f=e,null!==p&&(e?p.length=e:p=null),m=n===f}else m=!0;if(m){if(void 0!==r.fallbackModuleFilenameTemplate){let n=r.fallbackModuleFilenameTemplate;const e=f,t=f;let s=!1;const o=f;if(f===o)if("string"==typeof n){if(n.length<1){const n={params:{}};null===p?p=[n]:p.push(n),f++}}else{const n={params:{type:"string"}};null===p?p=[n]:p.push(n),f++}var h=o===f;if(s=s||h,!s){const e=f;if(!(n instanceof Function)){const n={params:{}};null===p?p=[n]:p.push(n),f++}h=e===f,s=s||h}if(!s){const n={params:{}};return null===p?p=[n]:p.push(n),f++,l.errors=p,!1}f=t,null!==p&&(t?p.length=t:p=null),m=e===f}else m=!0;if(m){if(void 0!==r.fileContext){const n=f;if("string"!=typeof r.fileContext)return l.errors=[{params:{type:"string"}}],!1;m=n===f}else m=!0;if(m){if(void 0!==r.filename){let e=r.filename;const t=f,s=f;let o=!1;const a=f;if(!1!==e&&null!==e){const n={params:{}};null===p?p=[n]:p.push(n),f++}var g=a===f;if(o=o||g,!o){const t=f;if(f===t)if("string"==typeof e){if(e.includes("!")||!1!==n.test(e)){const n={params:{}};null===p?p=[n]:p.push(n),f++}else if(e.length<1){const n={params:{}};null===p?p=[n]:p.push(n),f++}}else{const n={params:{type:"string"}};null===p?p=[n]:p.push(n),f++}g=t===f,o=o||g}if(!o){const n={params:{}};return null===p?p=[n]:p.push(n),f++,l.errors=p,!1}f=s,null!==p&&(s?p.length=s:p=null),m=t===f}else m=!0;if(m){if(void 0!==r.ignoreList){const n=f,e=f;let t=!1,a=null;const i=f;if(s(r.ignoreList,{instancePath:o+"/ignoreList",parentData:r,parentDataProperty:"ignoreList",rootData:u})||(p=null===p?s.errors:p.concat(s.errors),f=p.length),i===f&&(t=!0,a=0),!t){const n={params:{passingSchemas:a}};return null===p?p=[n]:p.push(n),f++,l.errors=p,!1}f=e,null!==p&&(e?p.length=e:p=null),m=n===f}else m=!0;if(m){if(void 0!==r.include){const n=f,e=f;let t=!1,a=null;const i=f;if(s(r.include,{instancePath:o+"/include",parentData:r,parentDataProperty:"include",rootData:u})||(p=null===p?s.errors:p.concat(s.errors),f=p.length),i===f&&(t=!0,a=0),!t){const n={params:{passingSchemas:a}};return null===p?p=[n]:p.push(n),f++,l.errors=p,!1}f=e,null!==p&&(e?p.length=e:p=null),m=n===f}else m=!0;if(m){if(void 0!==r.module){const n=f;if("boolean"!=typeof r.module)return l.errors=[{params:{type:"boolean"}}],!1;m=n===f}else m=!0;if(m){if(void 0!==r.moduleFilenameTemplate){let n=r.moduleFilenameTemplate;const e=f,t=f;let s=!1;const o=f;if(f===o)if("string"==typeof n){if(n.length<1){const n={params:{}};null===p?p=[n]:p.push(n),f++}}else{const n={params:{type:"string"}};null===p?p=[n]:p.push(n),f++}var y=o===f;if(s=s||y,!s){const e=f;if(!(n instanceof Function)){const n={params:{}};null===p?p=[n]:p.push(n),f++}y=e===f,s=s||y}if(!s){const n={params:{}};return null===p?p=[n]:p.push(n),f++,l.errors=p,!1}f=t,null!==p&&(t?p.length=t:p=null),m=e===f}else m=!0;if(m){if(void 0!==r.namespace){const n=f;if("string"!=typeof r.namespace)return l.errors=[{params:{type:"string"}}],!1;m=n===f}else m=!0;if(m){if(void 0!==r.noSources){const n=f;if("boolean"!=typeof r.noSources)return l.errors=[{params:{type:"boolean"}}],!1;m=n===f}else m=!0;if(m){if(void 0!==r.publicPath){const n=f;if("string"!=typeof r.publicPath)return l.errors=[{params:{type:"string"}}],!1;m=n===f}else m=!0;if(m){if(void 0!==r.sourceRoot){const n=f;if("string"!=typeof r.sourceRoot)return l.errors=[{params:{type:"string"}}],!1;m=n===f}else m=!0;if(m)if(void 0!==r.test){const n=f,e=f;let t=!1,a=null;const i=f;if(s(r.test,{instancePath:o+"/test",parentData:r,parentDataProperty:"test",rootData:u})||(p=null===p?s.errors:p.concat(s.errors),f=p.length),i===f&&(t=!0,a=0),!t){const n={params:{passingSchemas:a}};return null===p?p=[n]:p.push(n),f++,l.errors=p,!1}f=e,null!==p&&(e?p.length=e:p=null),m=n===f}else m=!0}}}}}}}}}}}}}}}}}return l.errors=p,0===f}
{
"definitions": {
"rule": {
"description": "Include source maps for modules based on their extension (defaults to .js and .css).",
"description": "Condition used to match resource (string, RegExp or Function).",
"anyOf": [

@@ -21,3 +21,3 @@ {

"rules": {
"description": "Include source maps for modules based on their extension (defaults to .js and .css).",
"description": "One or multiple conditions used to match resource.",
"anyOf": [

@@ -110,2 +110,10 @@ {

},
"ignoreList": {
"description": "Decide whether to ignore source files that match the specified value in the SourceMap.",
"oneOf": [
{
"$ref": "#/definitions/rules"
}
]
},
"include": {

@@ -154,5 +162,10 @@ "description": "Include source maps for module paths that match the given value.",

"test": {
"$ref": "#/definitions/rules"
"description": "Include source maps for modules based on their extension (defaults to .js and .css).",
"oneOf": [
{
"$ref": "#/definitions/rules"
}
]
}
}
}
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Ivan Kopeykin @vankop
*/
"use strict";
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 NullDependency = require("./NullDependency");
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
/** @typedef {import("../../declarations/WebpackOptions").CssGeneratorExportsConvention} CssGeneratorExportsConvention */
/** @typedef {import("../../declarations/WebpackOptions").CssGeneratorLocalIdentName} CssGeneratorLocalIdentName */
/** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../CssModule")} CssModule */
/** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
/** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
/** @typedef {import("../ModuleGraph")} ModuleGraph */
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
/** @typedef {import("../css/CssGenerator")} CssGenerator */
/** @typedef {import("../css/CssParser").Range} Range */
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
/** @typedef {import("../util/Hash")} Hash */
const getCssParser = memoize(() => require("../css/CssParser"));
/**
* @param {string} local css local
* @param {CssModule} module module
* @param {ChunkGraph} chunkGraph chunk graph
* @param {RuntimeTemplate} runtimeTemplate runtime template
* @returns {string} local ident
*/
const getLocalIdent = (local, module, chunkGraph, runtimeTemplate) => {
const generator = /** @type {CssGenerator} */ (module.generator);
const localIdentName =
/** @type {CssGeneratorLocalIdentName} */
(generator.localIdentName);
const relativeResourcePath = makePathsRelative(
/** @type {string} */
(module.context),
/** @type {string} */
(module.getResource()),
runtimeTemplate.compilation.compiler.root
);
const { hashFunction, hashDigest, hashDigestLength, hashSalt, uniqueName } =
runtimeTemplate.outputOptions;
const hash = createHash(hashFunction);
if (hashSalt) {
hash.update(hashSalt);
}
hash.update(relativeResourcePath);
if (!/\[local\]/.test(localIdentName)) {
hash.update(local);
}
const localIdentHash = hash.digest(hashDigest).slice(0, hashDigestLength);
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");
};
class CssLocalIdentifierDependency extends NullDependency {
/**
* @param {string} name name
* @param {Range} range range
* @param {string=} prefix prefix
*/
constructor(name, range, prefix = "") {
super();
this.name = name;
this.range = range;
this.prefix = prefix;
this._conventionNames = undefined;
this._hashUpdate = undefined;
}
get type() {
return "css local identifier";
}
/**
* @param {string} name export name
* @param {CssGeneratorExportsConvention} convention convention of the export name
* @returns {string[]} convention results
*/
getExportsConventionNames(name, convention) {
if (this._conventionNames) {
return this._conventionNames;
}
this._conventionNames = cssExportConvention(this.name, convention);
return this._conventionNames;
}
/**
* Returns the exported names
* @param {ModuleGraph} moduleGraph module graph
* @returns {ExportsSpec | undefined} export names
*/
getExports(moduleGraph) {
const module = /** @type {CssModule} */ (moduleGraph.getParentModule(this));
const generator = /** @type {CssGenerator} */ (module.generator);
const names = this.getExportsConventionNames(
this.name,
/** @type {CssGeneratorExportsConvention} */ (generator.convention)
);
return {
exports: names.map((name) => ({
name,
canMangle: true
})),
dependencies: undefined
};
}
/**
* Update the hash
* @param {Hash} hash hash to be updated
* @param {UpdateHashContext} context context
* @returns {void}
*/
updateHash(hash, { chunkGraph }) {
if (this._hashUpdate === undefined) {
const module =
/** @type {CssModule} */
(chunkGraph.moduleGraph.getParentModule(this));
const generator = /** @type {CssGenerator} */ (module.generator);
const names = this.getExportsConventionNames(
this.name,
/** @type {CssGeneratorExportsConvention} */
(generator.convention)
);
this._hashUpdate = `exportsConvention|${JSON.stringify(names)}|localIdentName|${JSON.stringify(generator.localIdentName)}`;
}
hash.update(this._hashUpdate);
}
/**
* @param {ObjectSerializerContext} context context
*/
serialize(context) {
const { write } = context;
write(this.name);
write(this.range);
write(this.prefix);
super.serialize(context);
}
/**
* @param {ObjectDeserializerContext} context context
*/
deserialize(context) {
const { read } = context;
this.name = read();
this.range = read();
this.prefix = read();
super.deserialize(context);
}
}
CssLocalIdentifierDependency.Template = class CssLocalIdentifierDependencyTemplate extends (
NullDependency.Template
) {
/**
* @param {Dependency} dependency the dependency for which the template should be applied
* @param {string} local local name
* @param {DependencyTemplateContext} templateContext the context object
* @returns {string} identifier
*/
static getIdentifier(
dependency,
local,
{ module: m, chunkGraph, runtimeTemplate }
) {
const dep = /** @type {CssLocalIdentifierDependency} */ (dependency);
const module = /** @type {CssModule} */ (m);
return (
dep.prefix +
getCssParser().escapeIdentifier(
getLocalIdent(local, module, chunkGraph, runtimeTemplate)
)
);
}
/**
* @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 { module: m, moduleGraph, runtime, cssData } = templateContext;
const dep = /** @type {CssLocalIdentifierDependency} */ (dependency);
const module = /** @type {CssModule} */ (m);
const generator = /** @type {CssGenerator} */ (module.generator);
const names = dep.getExportsConventionNames(
dep.name,
/** @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];
const identifier = CssLocalIdentifierDependencyTemplate.getIdentifier(
dep,
local,
templateContext
);
source.replace(dep.range[0], dep.range[1] - 1, identifier);
for (const used of [...usedNames, ...names]) {
cssData.exports.set(used, getCssParser().unescapeIdentifier(identifier));
}
}
};
makeSerializable(
CssLocalIdentifierDependency,
"webpack/lib/dependencies/CssLocalIdentifierDependency"
);
module.exports = CssLocalIdentifierDependency;
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Ivan Kopeykin @vankop
*/
"use strict";
const Dependency = require("../Dependency");
const makeSerializable = require("../util/makeSerializable");
const CssLocalIdentifierDependency = require("./CssLocalIdentifierDependency");
/** @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 */
class CssSelfLocalIdentifierDependency extends CssLocalIdentifierDependency {
/**
* @param {string} name 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)
*/
constructor(name, range, prefix = "", declaredSet = undefined) {
super(name, range, prefix);
this.declaredSet = declaredSet;
}
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)) 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 [[this.name]];
}
/**
* @param {ObjectSerializerContext} context context
*/
serialize(context) {
const { write } = context;
write(this.declaredSet);
super.serialize(context);
}
/**
* @param {ObjectDeserializerContext} context context
*/
deserialize(context) {
const { read } = context;
this.declaredSet = read();
super.deserialize(context);
}
}
CssSelfLocalIdentifierDependency.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 {CssSelfLocalIdentifierDependency} */ (dependency);
if (dep.declaredSet && !dep.declaredSet.has(dep.name)) return;
super.apply(dependency, source, templateContext);
}
};
makeSerializable(
CssSelfLocalIdentifierDependency,
"webpack/lib/dependencies/CssSelfLocalIdentifierDependency"
);
module.exports = CssSelfLocalIdentifierDependency;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display