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
869
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.103.0
to
5.104.0
+7
hot/emitter-event-target.js
if (typeof EventTarget !== "function") {
throw new Error(
"Environment doesn't support lazy compilation (requires EventTarget)"
);
}
module.exports = new EventTarget();
"use strict";
/* global __resourceQuery */
var isNodeLikeEnv =
typeof global !== "undefined" && typeof global.process !== "undefined";
var handler = isNodeLikeEnv
? require("./lazy-compilation-node")
: require("./lazy-compilation-web");
handler.setUrl(decodeURIComponent(__resourceQuery.slice(1)));
/**
* @param {{ data: string, onError: (err: Error) => void, active: boolean, module: module }} options options
* @returns {() => void} function to destroy response
*/
module.exports = handler;
/**
* @param {boolean} isHTTPS true when need https module, otherwise false
* @returns {Promise<import("http") | import("https")>}
*/
module.exports = function (isHTTPS) {
return isHTTPS ? import("https") : import("http");
};
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Alexander Akait @alexander-akait
*/
"use strict";
/**
* @type {Readonly<"javascript">}
*/
const JAVASCRIPT_TYPE = "javascript";
/**
* @type {Readonly<"runtime">}
*/
const RUNTIME_TYPE = "runtime";
/**
* @type {Readonly<"webassembly">}
*/
const WEBASSEMBLY_TYPE = "webassembly";
/**
* @type {Readonly<"asset">}
*/
const ASSET_TYPE = "asset";
/**
* @type {Readonly<"css">}
*/
const CSS_TYPE = "css";
/**
* @type {Readonly<"css-import">}
*/
const CSS_IMPORT_TYPE = "css-import";
/**
* @type {Readonly<"css-url">}
*/
const CSS_URL_TYPE = "css-url";
/**
* @type {Readonly<"share-init">}
*/
const SHARED_INIT_TYPE = "share-init";
/**
* @type {Readonly<"remote">}
*/
const REMOTE_GENERATOR_TYPE = "remote";
/**
* @type {Readonly<"consume-shared">}
*/
const CONSUME_SHARED_GENERATOR_TYPE = "consume-shared";
/**
* @type {Readonly<"unknown">}
*/
const UNKNOWN_TYPE = "unknown";
/**
* @typedef {JAVASCRIPT_TYPE |
* RUNTIME_TYPE |
* WEBASSEMBLY_TYPE |
* ASSET_TYPE |
* CSS_TYPE |
* CSS_IMPORT_TYPE |
* CSS_URL_TYPE |
* SHARED_INIT_TYPE |
* REMOTE_GENERATOR_TYPE |
* CONSUME_SHARED_GENERATOR_TYPE |
* UNKNOWN_TYPE} AllTypes
*/
/**
* @type {ReadonlySet<never>}
*/
const NO_TYPES = new Set();
/**
* @type {ReadonlySet<"asset">}
*/
const ASSET_TYPES = new Set([ASSET_TYPE]);
/**
* @type {ReadonlySet<"asset" | "javascript" | "asset">}
*/
const ASSET_AND_JAVASCRIPT_TYPES = new Set([ASSET_TYPE, JAVASCRIPT_TYPE]);
/**
* @type {ReadonlySet<"css-url" | "asset">}
*/
const ASSET_AND_CSS_URL_TYPES = new Set([ASSET_TYPE, CSS_URL_TYPE]);
/**
* @type {ReadonlySet<"javascript" | "css-url" | "asset">}
*/
const ASSET_AND_JAVASCRIPT_AND_CSS_URL_TYPES = new Set([
ASSET_TYPE,
JAVASCRIPT_TYPE,
CSS_URL_TYPE
]);
/**
* @type {ReadonlySet<"javascript">}
*/
const JAVASCRIPT_TYPES = new Set([JAVASCRIPT_TYPE]);
/**
* @type {ReadonlySet<"javascript" | "css-url">}
*/
const JAVASCRIPT_AND_CSS_URL_TYPES = new Set([JAVASCRIPT_TYPE, CSS_URL_TYPE]);
/**
* @type {ReadonlySet<"javascript" | "css">}
*/
const JAVASCRIPT_AND_CSS_TYPES = new Set([JAVASCRIPT_TYPE, CSS_TYPE]);
/**
* @type {ReadonlySet<"css">}
*/
const CSS_TYPES = new Set([CSS_TYPE]);
/**
* @type {ReadonlySet<"css-url">}
*/
const CSS_URL_TYPES = new Set([CSS_URL_TYPE]);
/**
* @type {ReadonlySet<"css-import">}
*/
const CSS_IMPORT_TYPES = new Set([CSS_IMPORT_TYPE]);
/**
* @type {ReadonlySet<"webassembly">}
*/
const WEBASSEMBLY_TYPES = new Set([WEBASSEMBLY_TYPE]);
/**
* @type {ReadonlySet<"runtime">}
*/
const RUNTIME_TYPES = new Set([RUNTIME_TYPE]);
/**
* @type {ReadonlySet<"remote" | "share-init">}
*/
const REMOTE_AND_SHARE_INIT_TYPES = new Set([
REMOTE_GENERATOR_TYPE,
SHARED_INIT_TYPE
]);
/**
* @type {ReadonlySet<"consume-shared">}
*/
const CONSUME_SHARED_TYPES = new Set([CONSUME_SHARED_GENERATOR_TYPE]);
/**
* @type {ReadonlySet<"share-init">}
*/
const SHARED_INIT_TYPES = new Set([SHARED_INIT_TYPE]);
module.exports.ASSET_AND_CSS_URL_TYPES = ASSET_AND_CSS_URL_TYPES;
module.exports.ASSET_AND_JAVASCRIPT_AND_CSS_URL_TYPES =
ASSET_AND_JAVASCRIPT_AND_CSS_URL_TYPES;
module.exports.ASSET_AND_JAVASCRIPT_TYPES = ASSET_AND_JAVASCRIPT_TYPES;
module.exports.ASSET_TYPE = ASSET_TYPE;
module.exports.ASSET_TYPES = ASSET_TYPES;
module.exports.CONSUME_SHARED_TYPES = CONSUME_SHARED_TYPES;
module.exports.CSS_IMPORT_TYPE = CSS_IMPORT_TYPE;
module.exports.CSS_IMPORT_TYPES = CSS_IMPORT_TYPES;
module.exports.CSS_TYPE = CSS_TYPE;
module.exports.CSS_TYPE = CSS_TYPE;
module.exports.CSS_TYPES = CSS_TYPES;
module.exports.CSS_URL_TYPE = CSS_URL_TYPE;
module.exports.CSS_URL_TYPES = CSS_URL_TYPES;
module.exports.JAVASCRIPT_AND_CSS_TYPES = JAVASCRIPT_AND_CSS_TYPES;
module.exports.JAVASCRIPT_AND_CSS_URL_TYPES = JAVASCRIPT_AND_CSS_URL_TYPES;
module.exports.JAVASCRIPT_TYPE = JAVASCRIPT_TYPE;
module.exports.JAVASCRIPT_TYPES = JAVASCRIPT_TYPES;
module.exports.NO_TYPES = NO_TYPES;
module.exports.REMOTE_AND_SHARE_INIT_TYPES = REMOTE_AND_SHARE_INIT_TYPES;
module.exports.RUNTIME_TYPE = RUNTIME_TYPE;
module.exports.RUNTIME_TYPES = RUNTIME_TYPES;
module.exports.SHARED_INIT_TYPE = SHARED_INIT_TYPE;
module.exports.SHARED_INIT_TYPES = SHARED_INIT_TYPES;
module.exports.UNKNOWN_TYPE = UNKNOWN_TYPE;
module.exports.WEBASSEMBLY_TYPE = WEBASSEMBLY_TYPE;
module.exports.WEBASSEMBLY_TYPES = WEBASSEMBLY_TYPES;
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Alexander Akait @alexander-akait
*/
"use strict";
const Hash = require("../Hash");
const { digest, update } = require("./hash-digest");
/** @typedef {import("../../../declarations/WebpackOptions").HashDigest} Encoding */
/** @typedef {() => Hash} HashFactory */
const BULK_SIZE = 3;
// We are using an object instead of a Map as this will stay static during the runtime
// so access to it can be optimized by v8
/** @type {{[key: string]: Map<string, string>}} */
const digestCaches = {};
class BulkUpdateHash extends Hash {
/**
* @param {Hash | HashFactory} hashOrFactory function to create a hash
* @param {string=} hashKey key for caching
*/
constructor(hashOrFactory, hashKey) {
super();
this.hashKey = hashKey;
if (typeof hashOrFactory === "function") {
this.hashFactory = hashOrFactory;
this.hash = undefined;
} else {
this.hashFactory = undefined;
this.hash = hashOrFactory;
}
this.buffer = "";
}
/**
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
* @overload
* @param {string | Buffer} data data
* @returns {Hash} updated hash
*/
/**
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
* @overload
* @param {string} data data
* @param {Encoding} inputEncoding data encoding
* @returns {Hash} updated hash
*/
/**
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
* @param {string | Buffer} data data
* @param {Encoding=} inputEncoding data encoding
* @returns {Hash} updated hash
*/
update(data, inputEncoding) {
if (
inputEncoding !== undefined ||
typeof data !== "string" ||
data.length > BULK_SIZE
) {
if (this.hash === undefined) {
this.hash = /** @type {HashFactory} */ (this.hashFactory)();
}
if (this.buffer.length > 0) {
update(this.hash, this.buffer);
this.buffer = "";
}
if (typeof data === "string" && inputEncoding) {
update(this.hash, data, inputEncoding);
} else {
update(this.hash, data);
}
} else {
this.buffer += data;
if (this.buffer.length > BULK_SIZE) {
if (this.hash === undefined) {
this.hash = /** @type {HashFactory} */ (this.hashFactory)();
}
update(this.hash, this.buffer);
this.buffer = "";
}
}
return this;
}
/**
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
* @overload
* @returns {Buffer} digest
*/
/**
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
* @overload
* @param {Encoding} encoding encoding of the return value
* @returns {string} digest
*/
/**
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
* @param {Encoding=} encoding encoding of the return value
* @returns {string | Buffer} digest
*/
digest(encoding) {
let digestCache;
const buffer = this.buffer;
if (this.hash === undefined) {
// short data for hash, we can use caching
const cacheKey = `${this.hashKey}-${encoding}`;
digestCache = digestCaches[cacheKey];
if (digestCache === undefined) {
digestCache = digestCaches[cacheKey] = new Map();
}
const cacheEntry = digestCache.get(buffer);
if (cacheEntry !== undefined) return cacheEntry;
this.hash = /** @type {HashFactory} */ (this.hashFactory)();
}
if (buffer.length > 0) {
update(this.hash, buffer);
}
if (!encoding) {
const result = digest(this.hash, undefined, Boolean(this.hashKey));
if (digestCache !== undefined) {
digestCache.set(buffer, result);
}
return result;
}
const result = digest(this.hash, encoding, Boolean(this.hashKey));
if (digestCache !== undefined) {
digestCache.set(buffer, result);
}
return result;
}
}
module.exports = BulkUpdateHash;
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Alexander Akait @alexander-akait
*/
"use strict";
const Hash = require("../Hash");
/** @typedef {import("../../../declarations/WebpackOptions").HashDigest} Encoding */
/* istanbul ignore next */
class DebugHash extends Hash {
constructor() {
super();
this.string = "";
}
/**
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
* @overload
* @param {string | Buffer} data data
* @returns {Hash} updated hash
*/
/**
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
* @overload
* @param {string} data data
* @param {Encoding} inputEncoding data encoding
* @returns {Hash} updated hash
*/
/**
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
* @param {string | Buffer} data data
* @param {Encoding=} inputEncoding data encoding
* @returns {Hash} updated hash
*/
update(data, inputEncoding) {
if (typeof data !== "string") data = data.toString("utf8");
const prefix = Buffer.from("@webpack-debug-digest@").toString("hex");
if (data.startsWith(prefix)) {
data = Buffer.from(data.slice(prefix.length), "hex").toString();
}
this.string += `[${data}](${
/** @type {string} */
(
// eslint-disable-next-line unicorn/error-message
new Error().stack
).split("\n", 3)[2]
})\n`;
return this;
}
/**
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
* @overload
* @returns {Buffer} digest
*/
/**
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
* @overload
* @param {Encoding} encoding encoding of the return value
* @returns {string} digest
*/
/**
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
* @param {Encoding=} encoding encoding of the return value
* @returns {string | Buffer} digest
*/
digest(encoding) {
return Buffer.from(`@webpack-debug-digest@${this.string}`).toString("hex");
}
}
module.exports = DebugHash;
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Alexander Akait @alexander-akait
*/
"use strict";
/** @typedef {import("../Hash")} Hash */
/** @typedef {import("../../../declarations/WebpackOptions").HashDigest} Encoding */
/** @typedef {"26" | "32" | "36" | "49" | "52" | "58" | "62"} Base */
/* cSpell:disable */
/** @type {Record<Base, string>} */
const ENCODE_TABLE = Object.freeze({
26: "abcdefghijklmnopqrstuvwxyz",
32: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
36: "0123456789abcdefghijklmnopqrstuvwxyz",
49: "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ",
52: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
58: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",
62: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
});
/* cSpell:enable */
const ZERO = BigInt("0");
const EIGHT = BigInt("8");
const FF = BigInt("0xff");
/**
* It encodes octet arrays by doing long divisions on all significant digits in the array, creating a representation of that number in the new base.
* Then for every leading zero in the input (not significant as a number) it will encode as a single leader character.
* This is the first in the alphabet and will decode as 8 bits. The other characters depend upon the base.
* For example, a base58 alphabet packs roughly 5.858 bits per character.
* This means the encoded string 000f (using a base16, 0-f alphabet) will actually decode to 4 bytes unlike a canonical hex encoding which uniformly packs 4 bits into each character.
* While unusual, this does mean that no padding is required, and it works for bases like 43.
* @param {Buffer} buffer buffer
* @param {Base} base base
* @returns {string} encoded buffer
*/
const encode = (buffer, base) => {
if (buffer.length === 0) return "";
const bigIntBase = BigInt(ENCODE_TABLE[base].length);
// Convert buffer to BigInt efficiently using bitwise operations
let value = ZERO;
for (let i = 0; i < buffer.length; i++) {
value = (value << EIGHT) | BigInt(buffer[i]);
}
// Convert to baseX string efficiently using array
const digits = [];
if (value === ZERO) return ENCODE_TABLE[base][0];
while (value > ZERO) {
const remainder = Number(value % bigIntBase);
digits.push(ENCODE_TABLE[base][remainder]);
value /= bigIntBase;
}
return digits.reverse().join("");
};
/**
* @param {string} data string
* @param {Base} base base
* @returns {Buffer} buffer
*/
const decode = (data, base) => {
if (data.length === 0) return Buffer.from("");
const bigIntBase = BigInt(ENCODE_TABLE[base].length);
// Convert the baseX string to a BigInt value
let value = ZERO;
for (let i = 0; i < data.length; i++) {
const digit = ENCODE_TABLE[base].indexOf(data[i]);
if (digit === -1) {
throw new Error(`Invalid character at position ${i}: ${data[i]}`);
}
value = value * bigIntBase + BigInt(digit);
}
// If value is 0, return a single-byte buffer with value 0
if (value === ZERO) {
return Buffer.alloc(1);
}
// Determine buffer size efficiently by counting bytes
let temp = value;
let byteLength = 0;
while (temp > ZERO) {
temp >>= EIGHT;
byteLength++;
}
// Create buffer and fill it from right to left
const buffer = Buffer.alloc(byteLength);
for (let i = byteLength - 1; i >= 0; i--) {
buffer[i] = Number(value & FF);
value >>= EIGHT;
}
return buffer;
};
// Compatibility with the old hash libraries, they can return different structures, so let's stringify them firstly
/**
* @param {string | { toString: (radix: number) => string }} value value
* @param {string} encoding encoding
* @returns {string} string
*/
const toString = (value, encoding) =>
typeof value === "string"
? value
: Buffer.from(value.toString(16), "hex").toString(
/** @type {NodeJS.BufferEncoding} */
(encoding)
);
/**
* @param {Buffer | { toString: (radix: number) => string }} value value
* @returns {Buffer} buffer
*/
const toBuffer = (value) =>
Buffer.isBuffer(value) ? value : Buffer.from(value.toString(16), "hex");
let isBase64URLSupported = false;
try {
isBase64URLSupported = Boolean(Buffer.from("", "base64url"));
} catch (_err) {
// Nothing
}
/**
* @param {Hash} hash hash
* @param {string | Buffer} data data
* @param {Encoding=} encoding encoding of the return value
* @returns {void}
*/
const update = (hash, data, encoding) => {
if (encoding === "base64url" && !isBase64URLSupported) {
const base64String = /** @type {string} */ (data)
.replace(/-/g, "+")
.replace(/_/g, "/");
const buf = Buffer.from(base64String, "base64");
hash.update(buf);
return;
} else if (
typeof data === "string" &&
encoding &&
typeof ENCODE_TABLE[/** @type {Base} */ (encoding.slice(4))] !== "undefined"
) {
const buf = decode(data, /** @type {Base} */ (encoding.slice(4)));
hash.update(buf);
return;
}
if (encoding) {
hash.update(/** @type {string} */ (data), encoding);
} else {
hash.update(data);
}
};
/**
* @overload
* @param {Hash} hash hash
* @returns {Buffer} digest
*/
/**
* @overload
* @param {Hash} hash hash
* @param {undefined} encoding encoding of the return value
* @param {boolean=} isSafe true when we await right types from digest(), otherwise false
* @returns {Buffer} digest
*/
/**
* @overload
* @param {Hash} hash hash
* @param {Encoding} encoding encoding of the return value
* @param {boolean=} isSafe true when we await right types from digest(), otherwise false
* @returns {string} digest
*/
/**
* @param {Hash} hash hash
* @param {Encoding=} encoding encoding of the return value
* @param {boolean=} isSafe true when we await right types from digest(), otherwise false
* @returns {string | Buffer} digest
*/
const digest = (hash, encoding, isSafe) => {
if (typeof encoding === "undefined") {
return isSafe ? hash.digest() : toBuffer(hash.digest());
}
if (encoding === "base64url" && !isBase64URLSupported) {
const digest = isSafe
? hash.digest("base64")
: toString(hash.digest("base64"), "base64");
return digest.replace(/\+/g, "-").replace(/\//g, "_").replace(/[=]+$/, "");
} else if (
typeof ENCODE_TABLE[/** @type {Base} */ (encoding.slice(4))] !== "undefined"
) {
const buf = isSafe ? hash.digest() : toBuffer(hash.digest());
return encode(
buf,
/** @type {Base} */
(encoding.slice(4))
);
}
return isSafe
? hash.digest(encoding)
: toString(hash.digest(encoding), encoding);
};
module.exports.decode = decode;
module.exports.digest = digest;
module.exports.encode = encode;
module.exports.update = update;
+18
-3

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

};
/** @type {EventTarget | NodeJS.EventEmitter} */
var hotEmitter = require("./emitter");
hotEmitter.on("webpackHotUpdate", function (currentHash) {
lastHash = currentHash;
/**
* @param {CustomEvent<{ currentHash: string }>} event event or hash
*/
var handler = function (event) {
lastHash = typeof event === "string" ? event : event.detail.currentHash;
if (!upToDate() && module.hot.status() === "idle") {

@@ -72,3 +76,14 @@ log("info", "[HMR] Checking for updates on the server...");

}
});
};
if (typeof EventTarget !== "undefined" && hotEmitter instanceof EventTarget) {
hotEmitter.addEventListener(
"webpackHotUpdate",
/** @type {EventListener} */
(handler)
);
} else {
hotEmitter.on("webpackHotUpdate", handler);
}
log("info", "[HMR] Waiting for update signal from WDS...");

@@ -75,0 +90,0 @@ } else {

+45
-29

@@ -0,5 +1,5 @@

"use strict";
/* global __resourceQuery */
"use strict";
var urlBase = decodeURIComponent(__resourceQuery.slice(1));

@@ -13,25 +13,2 @@

var data = options.data;
var onError = options.onError;
var active = options.active;
var module = options.module;
/** @type {import("http").IncomingMessage} */
var response;
var request = (
urlBase.startsWith("https") ? require("https") : require("http")
).request(
urlBase + data,
{
agent: false,
headers: { accept: "text/event-stream" }
},
function (res) {
response = res;
response.on("error", errorHandler);
if (!active && !module.hot) {
console.log(
"Hot Module Replacement is not enabled. Waiting for process restart..."
);
}
}
);

@@ -44,9 +21,48 @@ /**

"Problem communicating active modules to the server: " + err.message;
onError(err);
options.onError(err);
}
request.on("error", errorHandler);
request.end();
/** @type {Promise<import("http") | import("https")>} */
var mod = require("./load-http")(urlBase.startsWith("https"));
/** @type {import("http").ClientRequest} */
var request;
/** @type {import("http").IncomingMessage} */
var response;
mod.then(function (client) {
request = client.request(
urlBase + data,
{
agent: false,
headers: { accept: "text/event-stream" }
},
function (res) {
response = res;
response.on("error", errorHandler);
if (!options.active && !options.module.hot) {
console.log(
"Hot Module Replacement is not enabled. Waiting for process restart..."
);
}
}
);
request.on("error", errorHandler);
request.end();
});
return function () {
response.destroy();
if (response) {
response.destroy();
}
};
};
/**
* @param {string} value new url value
*/
exports.setUrl = function (value) {
urlBase = value;
};

@@ -0,5 +1,5 @@

"use strict";
/* global __resourceQuery */
"use strict";
if (typeof EventSource !== "function") {

@@ -57,11 +57,14 @@ throw new Error(

var onError = options.onError;
var active = options.active;
var module = options.module;
errorHandlers.add(onError);
var value = activeKeys.get(data) || 0;
activeKeys.set(data, value + 1);
if (value === 0) {
updateEventSource();
}
if (!active && !module.hot) {
if (!options.active && !options.module.hot) {
console.log(

@@ -85,1 +88,8 @@ "Hot Module Replacement is not enabled. Waiting for process restart..."

};
/**
* @param {string} value new url value
*/
exports.setUrl = function (value) {
urlBase = value;
};

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

if (module.hot) {
/** @type {undefined|string} */
/** @type {undefined | string} */
var lastHash;

@@ -83,5 +83,9 @@ var upToDate = function upToDate() {

};
/** @type {EventTarget | NodeJS.EventEmitter} */
var hotEmitter = require("./emitter");
hotEmitter.on("webpackHotUpdate", function (currentHash) {
lastHash = currentHash;
/**
* @param {CustomEvent<{ currentHash: string }>} event event or hash
*/
var handler = function (event) {
lastHash = typeof event === "string" ? event : event.detail.currentHash;
if (!upToDate()) {

@@ -101,3 +105,14 @@ var status = module.hot.status();

}
});
};
if (typeof EventTarget !== "undefined" && hotEmitter instanceof EventTarget) {
hotEmitter.addEventListener(
"webpackHotUpdate",
/** @type {EventListener} */
(handler)
);
} else {
hotEmitter.on("webpackHotUpdate", handler);
}
log("info", "[HMR] Waiting for update signal from WDS...");

@@ -104,0 +119,0 @@ } else {

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

},
__webpack_global__: {
expr: RuntimeGlobals.require,
req: [RuntimeGlobals.require],
type: "function",
assign: false
},
__webpack_public_path__: {

@@ -47,0 +53,0 @@ expr: RuntimeGlobals.publicPath,

@@ -12,7 +12,10 @@ /*

const {
CSS_TYPE,
CSS_URL_TYPE,
CSS_URL_TYPES,
JS_AND_CSS_URL_TYPES,
JS_TYPES,
JAVASCRIPT_AND_CSS_URL_TYPES,
JAVASCRIPT_TYPE,
JAVASCRIPT_TYPES,
NO_TYPES
} = require("../ModuleSourceTypesConstants");
} = require("../ModuleSourceTypeConstants");
const RuntimeGlobals = require("../RuntimeGlobals");

@@ -23,2 +26,3 @@

/** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
/** @typedef {import("../Module").SourceType} SourceType */
/** @typedef {import("../Module").SourceTypes} SourceTypes */

@@ -51,3 +55,3 @@ /** @typedef {import("../ModuleGraph")} ModuleGraph */

switch (type) {
case "javascript": {
case JAVASCRIPT_TYPE: {
if (!originalSource) {

@@ -78,3 +82,3 @@ return new RawSource("");

}
case "css-url": {
case CSS_URL_TYPE: {
if (!originalSource) {

@@ -106,3 +110,3 @@ return null;

switch (generateContext.type) {
case "javascript": {
case JAVASCRIPT_TYPE: {
return new RawSource(

@@ -144,8 +148,8 @@ `throw new Error(${JSON.stringify(error.message)});`

if (sourceTypes.size > 0) {
if (sourceTypes.has("javascript") && sourceTypes.has("css")) {
return JS_AND_CSS_URL_TYPES;
} else if (sourceTypes.has("css")) {
if (sourceTypes.has(JAVASCRIPT_TYPE) && sourceTypes.has(CSS_TYPE)) {
return JAVASCRIPT_AND_CSS_URL_TYPES;
} else if (sourceTypes.has(CSS_TYPE)) {
return CSS_URL_TYPES;
}
return JS_TYPES;
return JAVASCRIPT_TYPES;
}

@@ -158,3 +162,3 @@

* @param {NormalModule} module the module
* @param {string=} type source type
* @param {SourceType=} type source type
* @returns {number} estimate size of the module

@@ -161,0 +165,0 @@ */

@@ -14,10 +14,13 @@ /*

ASSET_AND_CSS_URL_TYPES,
ASSET_AND_JS_AND_CSS_URL_TYPES,
ASSET_AND_JS_TYPES,
ASSET_AND_JAVASCRIPT_AND_CSS_URL_TYPES,
ASSET_AND_JAVASCRIPT_TYPES,
ASSET_TYPES,
CSS_TYPE,
CSS_URL_TYPE,
CSS_URL_TYPES,
JS_AND_CSS_URL_TYPES,
JS_TYPES,
JAVASCRIPT_AND_CSS_URL_TYPES,
JAVASCRIPT_TYPE,
JAVASCRIPT_TYPES,
NO_TYPES
} = require("../ModuleSourceTypesConstants");
} = require("../ModuleSourceTypeConstants");
const { ASSET_MODULE_TYPE } = require("../ModuleTypeConstants");

@@ -47,2 +50,3 @@ const RuntimeGlobals = require("../RuntimeGlobals");

/** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
/** @typedef {import("../Module").SourceType} SourceType */
/** @typedef {import("../Module").SourceTypes} SourceTypes */

@@ -336,3 +340,3 @@ /** @typedef {import("../ModuleGraph")} ModuleGraph */

if (generatorOptions.publicPath !== undefined && type === "javascript") {
if (generatorOptions.publicPath !== undefined && type === JAVASCRIPT_TYPE) {
const { path, info } = runtimeTemplate.compilation.getAssetPathWithInfo(

@@ -352,3 +356,3 @@ generatorOptions.publicPath,

generatorOptions.publicPath !== undefined &&
type === "css-url"
type === CSS_URL_TYPE
) {

@@ -367,3 +371,3 @@ const { path, info } = runtimeTemplate.compilation.getAssetPathWithInfo(

assetPath = path + filename;
} else if (type === "javascript") {
} else if (type === JAVASCRIPT_TYPE) {
// add __webpack_require__.p

@@ -375,3 +379,3 @@ runtimeRequirements.add(RuntimeGlobals.publicPath);

);
} else if (type === "css-url") {
} else if (type === CSS_URL_TYPE) {
const compilation = runtimeTemplate.compilation;

@@ -527,3 +531,3 @@ const path =

const needContent = type === "javascript" || type === "css-url";
const needContent = type === JAVASCRIPT_TYPE || type === CSS_URL_TYPE;

@@ -539,3 +543,5 @@ const data = getData ? getData() : undefined;

content =
type === "javascript" ? JSON.stringify(encodedSource) : encodedSource;
type === JAVASCRIPT_TYPE
? JSON.stringify(encodedSource)
: encodedSource;

@@ -581,3 +587,3 @@ if (data) {

if (data && (type === "javascript" || type === "css-url")) {
if (data && (type === JAVASCRIPT_TYPE || type === CSS_URL_TYPE)) {
data.set("url", { [type]: assetPath, ...data.get("url") });

@@ -610,3 +616,3 @@ }

if (type === "javascript") {
if (type === JAVASCRIPT_TYPE) {
if (concatenationScope) {

@@ -627,3 +633,3 @@ concatenationScope.registerNamespaceExport(

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

@@ -646,3 +652,3 @@ }

}
case "javascript": {
case JAVASCRIPT_TYPE: {
return new RawSource(

@@ -676,8 +682,8 @@ `throw new Error(${JSON.stringify(error.message)});`

if (sourceTypes.size > 0) {
if (sourceTypes.has("javascript") && sourceTypes.has("css")) {
return JS_AND_CSS_URL_TYPES;
} else if (sourceTypes.has("css")) {
if (sourceTypes.has(JAVASCRIPT_TYPE) && sourceTypes.has(CSS_TYPE)) {
return JAVASCRIPT_AND_CSS_URL_TYPES;
} else if (sourceTypes.has(CSS_TYPE)) {
return CSS_URL_TYPES;
}
return JS_TYPES;
return JAVASCRIPT_TYPES;
}

@@ -689,8 +695,8 @@

if (sourceTypes.size > 0) {
if (sourceTypes.has("javascript") && sourceTypes.has("css")) {
return ASSET_AND_JS_AND_CSS_URL_TYPES;
} else if (sourceTypes.has("css")) {
if (sourceTypes.has(JAVASCRIPT_TYPE) && sourceTypes.has(CSS_TYPE)) {
return ASSET_AND_JAVASCRIPT_AND_CSS_URL_TYPES;
} else if (sourceTypes.has(CSS_TYPE)) {
return ASSET_AND_CSS_URL_TYPES;
}
return ASSET_AND_JS_TYPES;
return ASSET_AND_JAVASCRIPT_TYPES;
}

@@ -703,3 +709,3 @@

* @param {NormalModule} module the module
* @param {string=} type source type
* @param {SourceType=} type source type
* @returns {number} estimate size of the module

@@ -706,0 +712,0 @@ */

@@ -12,7 +12,10 @@ /*

const {
CSS_TYPE,
CSS_URL_TYPE,
CSS_URL_TYPES,
JS_AND_CSS_URL_TYPES,
JS_TYPES,
JAVASCRIPT_AND_CSS_URL_TYPES,
JAVASCRIPT_TYPE,
JAVASCRIPT_TYPES,
NO_TYPES
} = require("../ModuleSourceTypesConstants");
} = require("../ModuleSourceTypeConstants");
const RuntimeGlobals = require("../RuntimeGlobals");

@@ -23,2 +26,3 @@

/** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
/** @typedef {import("../Module").SourceType} SourceType */
/** @typedef {import("../Module").SourceTypes} SourceTypes */

@@ -51,3 +55,3 @@ /** @typedef {import("../ModuleGraph")} ModuleGraph */

switch (type) {
case "javascript": {
case JAVASCRIPT_TYPE: {
if (!originalSource) {

@@ -77,3 +81,3 @@ return new RawSource("");

}
case "css-url": {
case CSS_URL_TYPE: {
if (!originalSource) {

@@ -105,3 +109,3 @@ return null;

switch (generateContext.type) {
case "javascript": {
case JAVASCRIPT_TYPE: {
return new RawSource(

@@ -143,8 +147,8 @@ `throw new Error(${JSON.stringify(error.message)});`

if (sourceTypes.size > 0) {
if (sourceTypes.has("javascript") && sourceTypes.has("css")) {
return JS_AND_CSS_URL_TYPES;
} else if (sourceTypes.has("css")) {
if (sourceTypes.has(JAVASCRIPT_TYPE) && sourceTypes.has(CSS_TYPE)) {
return JAVASCRIPT_AND_CSS_URL_TYPES;
} else if (sourceTypes.has(CSS_TYPE)) {
return CSS_URL_TYPES;
}
return JS_TYPES;
return JAVASCRIPT_TYPES;
}

@@ -157,3 +161,3 @@

* @param {NormalModule} module the module
* @param {string=} type source type
* @param {SourceType=} type source type
* @returns {number} estimate size of the module

@@ -160,0 +164,0 @@ */

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

const Module = require("../Module");
const { JS_TYPES } = require("../ModuleSourceTypesConstants");
const {
JAVASCRIPT_TYPE,
JAVASCRIPT_TYPES
} = require("../ModuleSourceTypeConstants");
const { ASSET_MODULE_TYPE_RAW_DATA_URL } = require("../ModuleTypeConstants");

@@ -51,3 +54,3 @@ const RuntimeGlobals = require("../RuntimeGlobals");

getSourceTypes() {
return JS_TYPES;
return JAVASCRIPT_TYPES;
}

@@ -118,3 +121,3 @@

sources.set(
"javascript",
JAVASCRIPT_TYPE,
new RawSource(`module.exports = ${JSON.stringify(this.url)};`)

@@ -121,0 +124,0 @@ );

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

/** @type {Map<string, ChunkGroupInfo>} */
/** @typedef {Map<string, ChunkGroupInfo>} NamedChunkGroup */
/** @type {NamedChunkGroup} */
const namedChunkGroups = new Map();
/** @type {Map<string, ChunkGroupInfo>} */
/** @type {NamedChunkGroup} */
const namedAsyncEntrypoints = new Map();

@@ -361,0 +363,0 @@

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

/** @typedef {import("../../declarations/WebpackOptions").SnapshotOptions} SnapshotOptions */
/** @typedef {import("../Compilation").FileSystemDependencies} FileSystemDependencies */
/** @typedef {import("../Cache").Data} Data */

@@ -55,3 +56,3 @@ /** @typedef {import("../Cache").Etag} Etag */

) {
/** @type {Pack | (() => Pack) } */
/** @type {Pack | (() => Pack)} */
this.data = data;

@@ -400,3 +401,3 @@ /** @type {string} */

/** @type {PackContent[] } */
/** @type {PackContent[]} */
const mergedContent = [];

@@ -1115,3 +1116,3 @@

}) {
/** @type {import("../serialization/Serializer")<PackContainer, null, {}>} */
/** @type {import("../serialization/Serializer")<PackContainer, null, EXPECTED_OBJECT>} */
this.fileSerializer = createFileSerializer(

@@ -1147,3 +1148,3 @@ fs,

this.buildDependencies = new Set();
/** @type {LazySet<string>} */
/** @type {FileSystemDependencies} */
this.newBuildDependencies = new LazySet();

@@ -1372,3 +1373,3 @@ /** @type {Snapshot | undefined} */

/**
* @param {LazySet<string> | Iterable<string>} dependencies dependencies to store
* @param {FileSystemDependencies | Iterable<string>} dependencies dependencies to store
*/

@@ -1375,0 +1376,0 @@ storeBuildDependencies(dependencies) {

@@ -210,3 +210,3 @@ /*

* @param {Chunk} otherChunk the chunk to compare with
* @returns {-1|0|1} the comparison result
* @returns {-1 | 0 | 1} the comparison result
*/

@@ -213,0 +213,0 @@ compareTo(otherChunk) {

@@ -38,4 +38,5 @@ /*

/** @typedef {import("./ChunkGroup")} ChunkGroup */
/** @typedef {import("./Generator").SourceTypes} SourceTypes */
/** @typedef {import("./Module")} Module */
/** @typedef {import("./Module").SourceType} SourceType */
/** @typedef {import("./Module").SourceTypes} SourceTypes */
/** @typedef {import("./Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */

@@ -101,3 +102,3 @@ /** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */

const modulesBySourceType = (sourceTypesByModule) => (set) => {
/** @type {Map<string, SortableSet<Module>>} */
/** @type {Map<SourceType, SortableSet<Module>>} */
const map = new Map();

@@ -225,3 +226,3 @@ for (const module of set) {

/** @typedef {WeakMap<Module, Set<string>>} SourceTypesByModule */
/** @typedef {WeakMap<Module, SourceTypes>} SourceTypesByModule */
/** @typedef {Map<Module, Entrypoint>} EntryModules */

@@ -637,3 +638,3 @@

* @param {Module} module chunk module
* @param {Set<string>} sourceTypes source types
* @param {SourceTypes} sourceTypes source types
*/

@@ -675,6 +676,7 @@ setChunkModuleSourceTypes(chunk, module, sourceTypes) {

* @param {Module} module module
* @returns {Set<string> | undefined} source types
* @returns {SourceTypes | undefined} source types
*/
_getOverwrittenModuleSourceTypes(module) {
let newSet = false;
/** @type {Set<SourceType> | undefined} */
let sourceTypes;

@@ -687,3 +689,3 @@ for (const chunk of this.getModuleChunksIterable(module)) {

if (!sourceTypes) {
sourceTypes = st;
sourceTypes = /** @type {Set<SourceType>} */ (st);
} else if (!newSet) {

@@ -880,3 +882,3 @@ for (const type of st) {

* @param {Chunk} chunkB second chunk
* @returns {-1|0|1} this is a comparator function like sort and returns -1, 0, or 1 based on sort order
* @returns {-1 | 0 | 1} this is a comparator function like sort and returns -1, 0, or 1 based on sort order
*/

@@ -883,0 +885,0 @@ compareChunks(chunkA, chunkB) {

@@ -48,3 +48,3 @@ /*

* @param {ChunkGroup} b second sorting comparator
* @returns {1|0|-1} a sorting index to determine order
* @returns {1 | 0 | -1} a sorting index to determine order
*/

@@ -60,3 +60,3 @@ const sortById = (a, b) => {

* @param {OriginRecord} b the second comparator in sort
* @returns {1|-1|0} returns sorting order as index
* @returns {1 | -1| 0} returns sorting order as index
*/

@@ -96,6 +96,9 @@ const sortOrigin = (a, b) => {

this.origins = [];
/** @typedef {Map<Module, number>} OrderIndices */
/** Indices in top-down order */
/**
* @private
* @type {Map<Module, number>}
* @type {OrderIndices}
*/

@@ -106,3 +109,3 @@ this._modulePreOrderIndices = new Map();

* @private
* @type {Map<Module, number>}
* @type {OrderIndices}
*/

@@ -492,3 +495,3 @@ this._modulePostOrderIndices = new Map();

* @param {ChunkGroup} otherGroup the chunkGroup to compare this against
* @returns {-1|0|1} sort position for comparison
* @returns {-1 | 0 | 1} sort position for comparison
*/

@@ -495,0 +498,0 @@ compareTo(chunkGraph, otherGroup) {

@@ -66,4 +66,6 @@ /*

/** @typedef {Map<string, number>} CurrentAssets */
/**
* @param {Map<string, number>} assets current assets
* @param {CurrentAssets} assets current assets
* @returns {Set<string>} Set of directory paths

@@ -96,3 +98,3 @@ */

* @param {string} outputPath output path
* @param {Map<string, number>} currentAssets filename of the current assets (must not start with .. or ., must only use / as path separator)
* @param {CurrentAssets} currentAssets filename of the current assets (must not start with .. or ., must only use / as path separator)
* @param {(err?: Error | null, set?: Diff) => void} callback returns the filenames of the assets that shouldn't be there

@@ -103,2 +105,3 @@ * @returns {void}

const directories = getDirectories(currentAssets);
/** @type {Diff} */
const diff = new Set();

@@ -394,3 +397,3 @@ asyncLib.forEachLimit(

// incremental builds
/** @type {undefined|Assets} */
/** @type {undefined | Assets} */
let oldAssets;

@@ -397,0 +400,0 @@

@@ -798,45 +798,4 @@ /*

/**
* @typedef {{
* reset: PrintFunction
* bold: PrintFunction
* dim: PrintFunction
* italic: PrintFunction
* underline: PrintFunction
* inverse: PrintFunction
* hidden: PrintFunction
* strikethrough: PrintFunction
* black: PrintFunction
* red: PrintFunction
* green: PrintFunction
* yellow: PrintFunction
* blue: PrintFunction
* magenta: PrintFunction
* cyan: PrintFunction
* white: PrintFunction
* gray: PrintFunction
* bgBlack: PrintFunction
* bgRed: PrintFunction
* bgGreen: PrintFunction
* bgYellow: PrintFunction
* bgBlue: PrintFunction
* bgMagenta: PrintFunction
* bgCyan: PrintFunction
* bgWhite: PrintFunction
* blackBright: PrintFunction
* redBright: PrintFunction
* greenBright: PrintFunction
* yellowBright: PrintFunction
* blueBright: PrintFunction
* magentaBright: PrintFunction
* cyanBright: PrintFunction
* whiteBright: PrintFunction
* bgBlackBright: PrintFunction
* bgRedBright: PrintFunction
* bgGreenBright: PrintFunction
* bgYellowBright: PrintFunction
* bgBlueBright: PrintFunction
* bgMagentaBright: PrintFunction
* bgCyanBright: PrintFunction
* bgWhiteBright: PrintFunction
}} Colors */
* @typedef {{ reset: PrintFunction, bold: PrintFunction, dim: PrintFunction, italic: PrintFunction, underline: PrintFunction, inverse: PrintFunction, hidden: PrintFunction, strikethrough: PrintFunction, black: PrintFunction, red: PrintFunction, green: PrintFunction, yellow: PrintFunction, blue: PrintFunction, magenta: PrintFunction, cyan: PrintFunction, white: PrintFunction, gray: PrintFunction, bgBlack: PrintFunction, bgRed: PrintFunction, bgGreen: PrintFunction, bgYellow: PrintFunction, bgBlue: PrintFunction, bgMagenta: PrintFunction, bgCyan: PrintFunction, bgWhite: PrintFunction, blackBright: PrintFunction, redBright: PrintFunction, greenBright: PrintFunction, yellowBright: PrintFunction, blueBright: PrintFunction, magentaBright: PrintFunction, cyanBright: PrintFunction, whiteBright: PrintFunction, bgBlackBright: PrintFunction, bgRedBright: PrintFunction, bgGreenBright: PrintFunction, bgYellowBright: PrintFunction, bgBlueBright: PrintFunction, bgMagentaBright: PrintFunction, bgCyanBright: PrintFunction, bgWhiteBright: PrintFunction }} Colors
*/

@@ -843,0 +802,0 @@ /**

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

/** @typedef {import("./Module")} Module */
/** @typedef {import("./Module").SourceType} SourceType */
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */

@@ -100,3 +101,3 @@ /** @typedef {import("./Module").CodeGenerationResultData} CodeGenerationResultData */

* @param {RuntimeSpec} runtime runtime(s)
* @param {string} sourceType the source type
* @param {SourceType} sourceType the source type
* @returns {Source} a source

@@ -103,0 +104,0 @@ */

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

});
if (!parser.scope.topLevelScope) {
return true;
}
});

@@ -152,0 +155,0 @@ parser.hooks.pattern

@@ -722,5 +722,5 @@ /*

let immutable = info.immutable;
const queryStringIdx = targetFile.indexOf("?");
if (queryStringIdx >= 0) {
targetFile = targetFile.slice(0, queryStringIdx);
const queryOrHashStringIdx = targetFile.search(/[?#]/);
if (queryOrHashStringIdx >= 0) {
targetFile = targetFile.slice(0, queryOrHashStringIdx);
// We may remove the hash, which is in the query string

@@ -727,0 +727,0 @@ // So we recheck if the file is immutable

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

}),
methodShorthand: rawChecker({
chrome: 47,
and_chr: 47,
edge: 12,
firefox: 34,
and_ff: 34,
// ie: Not supported,
opera: 34,
op_mob: 34,
safari: 9,
ios_saf: 9,
samsung: 5,
android: 47,
// baidu: Not tracked,
and_qq: [14, 9],
and_uc: [15, 5],
kaios: [2, 5],
node: [4, 9]
}),
arrowFunction: rawChecker({

@@ -123,0 +142,0 @@ chrome: 45,

@@ -57,3 +57,3 @@ /*

* @template T
* @param {T|undefined} value value or not
* @param {T | undefined} value value or not
* @returns {T} result value

@@ -94,3 +94,3 @@ */

* @template R
* @param {Record<string, T>|undefined} value value or not
* @param {Record<string, T> | undefined} value value or not
* @param {(value: T) => R} fn nested handler

@@ -97,0 +97,0 @@ * @param {Record<string, (value: T) => R>=} customKeys custom nested handler for some keys

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

* @property {boolean | null} const const and let variable declarations are available
* @property {boolean | null} methodShorthand object method shorthand is available
* @property {boolean | null} arrowFunction arrow functions are available

@@ -196,2 +197,3 @@ * @property {boolean | null} forOf for of iteration is available

optionalChaining: v(14),
methodShorthand: v(4),
arrowFunction: v(6),

@@ -245,2 +247,3 @@ asyncFunction: v(7, 6),

optionalChaining: v(8),
methodShorthand: v(1, 1),
arrowFunction: v(1, 1),

@@ -284,2 +287,3 @@ asyncFunction: v(1, 7),

optionalChaining: v(0, 44),
methodShorthand: v(0, 15),
arrowFunction: v(0, 15),

@@ -307,2 +311,3 @@ asyncFunction: v(0, 21),

optionalChaining: v >= 2020,
methodShorthand: v >= 2015,
arrowFunction: v >= 2015,

@@ -309,0 +314,0 @@ forOf: v >= 2015,

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

const Module = require("../Module");
const { JS_TYPES } = require("../ModuleSourceTypesConstants");
const {
JAVASCRIPT_TYPE,
JAVASCRIPT_TYPES
} = require("../ModuleSourceTypeConstants");
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("../ModuleTypeConstants");

@@ -61,3 +64,3 @@ const RuntimeGlobals = require("../RuntimeGlobals");

getSourceTypes() {
return JS_TYPES;
return JAVASCRIPT_TYPES;
}

@@ -247,3 +250,3 @@

sources.set(
"javascript",
JAVASCRIPT_TYPE,
this.useSourceMap || this.useSimpleSourceMap

@@ -250,0 +253,0 @@ ? new OriginalSource(source, "webpack/container-entry")

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

const Module = require("../Module");
const { JS_TYPES } = require("../ModuleSourceTypesConstants");
const {
JAVASCRIPT_TYPE,
JAVASCRIPT_TYPES
} = require("../ModuleSourceTypeConstants");
const { WEBPACK_MODULE_TYPE_FALLBACK } = require("../ModuleTypeConstants");

@@ -126,3 +129,3 @@ const RuntimeGlobals = require("../RuntimeGlobals");

getSourceTypes() {
return JS_TYPES;
return JAVASCRIPT_TYPES;
}

@@ -161,3 +164,3 @@

const sources = new Map();
sources.set("javascript", new RawSource(code));
sources.set(JAVASCRIPT_TYPE, new RawSource(code));
return { sources, runtimeRequirements: RUNTIME_REQUIREMENTS };

@@ -164,0 +167,0 @@ }

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

const Module = require("../Module");
const {
REMOTE_AND_SHARE_INIT_TYPES
} = require("../ModuleSourceTypesConstants");
const { REMOTE_AND_SHARE_INIT_TYPES } = require("../ModuleSourceTypeConstants");
const { WEBPACK_MODULE_TYPE_REMOTE } = require("../ModuleTypeConstants");

@@ -15,0 +13,0 @@ const RuntimeGlobals = require("../RuntimeGlobals");

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

const Module = require("./Module");
const { JS_TYPES } = require("./ModuleSourceTypesConstants");
const {
JAVASCRIPT_TYPE,
JAVASCRIPT_TYPES
} = require("./ModuleSourceTypeConstants");
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");

@@ -166,3 +169,3 @@ const RuntimeGlobals = require("./RuntimeGlobals");

getSourceTypes() {
return JS_TYPES;
return JAVASCRIPT_TYPES;
}

@@ -1189,3 +1192,3 @@

sources.set(
"javascript",
JAVASCRIPT_TYPE,
this.getSource(

@@ -1192,0 +1195,0 @@ this.getSourceString(this.options.mode, context),

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

/** @typedef {import("enhanced-resolve").ResolveRequest} ResolveRequest */
/** @typedef {import("./Compilation").FileSystemDependencies} FileSystemDependencies */
/** @typedef {import("./ContextModule").ContextModuleOptions} ContextModuleOptions */

@@ -26,3 +28,3 @@ /** @typedef {import("./ContextModule").ResolveDependenciesCallback} ResolveDependenciesCallback */

/** @typedef {import("./dependencies/ContextDependency").ContextOptions} ContextOptions */
/** @typedef {import("enhanced-resolve").ResolveRequest} ResolveRequest */
/**

@@ -41,5 +43,5 @@ * @template T

* @property {ModuleFactoryCreateData["resolveOptions"]} resolveOptions
* @property {LazySet<string>} fileDependencies
* @property {LazySet<string>} missingDependencies
* @property {LazySet<string>} contextDependencies
* @property {FileSystemDependencies} fileDependencies
* @property {FileSystemDependencies} missingDependencies
* @property {FileSystemDependencies} contextDependencies
* @property {ContextDependency[]} dependencies

@@ -46,0 +48,0 @@ */

@@ -15,6 +15,6 @@ /*

CSS_TYPES,
JS_AND_CSS_TYPES,
JS_TYPE,
JS_TYPES
} = require("../ModuleSourceTypesConstants");
JAVASCRIPT_AND_CSS_TYPES,
JAVASCRIPT_TYPE,
JAVASCRIPT_TYPES
} = require("../ModuleSourceTypeConstants");
const RuntimeGlobals = require("../RuntimeGlobals");

@@ -27,4 +27,2 @@ const Template = require("../Template");

/** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../../declarations/WebpackOptions").CssAutoGeneratorOptions} CssAutoGeneratorOptions */
/** @typedef {import("../../declarations/WebpackOptions").CssGlobalGeneratorOptions} CssGlobalGeneratorOptions */
/** @typedef {import("../../declarations/WebpackOptions").CssModuleGeneratorOptions} CssModuleGeneratorOptions */

@@ -41,2 +39,3 @@ /** @typedef {import("../Compilation").DependencyConstructor} DependencyConstructor */

/** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
/** @typedef {import("../Module").SourceType} SourceType */
/** @typedef {import("../Module").SourceTypes} SourceTypes */

@@ -57,3 +56,3 @@ /** @typedef {import("../ModuleGraph")} ModuleGraph */

/**
* @param {CssAutoGeneratorOptions | CssGlobalGeneratorOptions | CssModuleGeneratorOptions} options options
* @param {CssModuleGeneratorOptions} options options
* @param {ModuleGraph} moduleGraph the module graph

@@ -63,4 +62,3 @@ */

super();
this.convention = options.exportsConvention;
this.localIdentName = options.localIdentName;
this.options = options;
this._exportsOnly = options.exportsOnly;

@@ -135,3 +133,3 @@ this._esModule = options.esModule;

...generateContext,
type: "css"
type: CSS_TYPE
})

@@ -275,3 +273,3 @@ );

const source =
generateContext.type === "javascript"
generateContext.type === JAVASCRIPT_TYPE
? exportType === "link"

@@ -340,3 +338,3 @@ ? new ReplaceSource(new RawSource(""))

switch (generateContext.type) {
case "javascript": {
case JAVASCRIPT_TYPE: {
const isCSSModule = /** @type {BuildMeta} */ (module.buildMeta)

@@ -385,10 +383,11 @@ .isCSSModule;

}
let identifier = Template.toIdentifier(usedName);
if (RESERVED_IDENTIFIER.has(identifier)) {
identifier = `_${identifier}`;
}
const i = 0;
let i = 0;
while (usedIdentifiers.has(identifier)) {
identifier = Template.toIdentifier(name + i);
i += 1;
}

@@ -440,3 +439,3 @@ usedIdentifiers.add(identifier);

}
case "css": {
case CSS_TYPE: {
if (!this._generatesJsOnly(module)) {

@@ -461,3 +460,3 @@ generateContext.runtimeRequirements.add(RuntimeGlobals.hasCssModules);

switch (generateContext.type) {
case "javascript": {
case JAVASCRIPT_TYPE: {
return new RawSource(

@@ -467,3 +466,3 @@ `throw new Error(${JSON.stringify(error.message)});`

}
case "css": {
case CSS_TYPE: {
return new RawSource(`/**\n ${error.message} \n**/`);

@@ -482,3 +481,3 @@ }

if (this._generatesJsOnly(module)) {
return JS_TYPES;
return JAVASCRIPT_TYPES;
}

@@ -488,2 +487,5 @@ const sourceTypes = new Set();

for (const connection of connections) {
if (connection.dependency instanceof CssImportDependency) {
continue;
}
if (!connection.originModule) {

@@ -493,7 +495,7 @@ continue;

if (connection.originModule.type.split("/")[0] !== CSS_TYPE) {
sourceTypes.add(JS_TYPE);
sourceTypes.add(JAVASCRIPT_TYPE);
}
}
if (sourceTypes.has(JS_TYPE)) {
return JS_AND_CSS_TYPES;
if (sourceTypes.has(JAVASCRIPT_TYPE)) {
return JAVASCRIPT_AND_CSS_TYPES;
}

@@ -505,3 +507,3 @@ return CSS_TYPES;

* @param {NormalModule} module the module
* @param {string=} type source type
* @param {SourceType=} type source type
* @returns {number} estimate size of the module

@@ -511,3 +513,3 @@ */

switch (type) {
case "javascript": {
case JAVASCRIPT_TYPE: {
const cssData = /** @type {BuildInfo} */ (module.buildInfo).cssData;

@@ -533,3 +535,3 @@ if (!cssData) {

}
case "css": {
case CSS_TYPE: {
const originalSource = module.originalSource();

@@ -536,0 +538,0 @@

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

const Compilation = require("../Compilation");
const { CSS_TYPE } = require("../ModuleSourceTypeConstants");
const RuntimeGlobals = require("../RuntimeGlobals");

@@ -90,3 +91,3 @@ const RuntimeModule = require("../RuntimeModule");

(chunk, chunkGraph) =>
Boolean(chunkGraph.getChunkModulesIterableBySourceType(chunk, "css"))
Boolean(chunkGraph.getChunkModulesIterableBySourceType(chunk, CSS_TYPE))
);

@@ -434,3 +435,3 @@ const hasCssMatcher = compileBooleanMatcher(conditionMap);

"var oldTag = oldTags.pop();",
"if(oldTag.parentNode) oldTag.parentNode.removeChild(oldTag);"
"if(oldTag && oldTag.parentNode) oldTag.parentNode.removeChild(oldTag);"
]),

@@ -457,3 +458,3 @@ "}"

}.css = ${runtimeTemplate.basicFunction(
"chunkIds, removedChunks, removedModules, promises, applyHandlers, updatedModulesList",
"chunkIds, removedChunks, removedModules, promises, applyHandlers, updatedModulesList, css",
[

@@ -464,2 +465,4 @@ isNeutralPlatform

"applyHandlers.push(applyHandler);",
"// Read CSS removed chunks from update manifest",
"var cssRemovedChunks = css && css.r;",
`chunkIds.forEach(${runtimeTemplate.basicFunction("chunkId", [

@@ -469,3 +472,8 @@ `var filename = ${RuntimeGlobals.getChunkCssFilename}(chunkId);`,

"var oldTag = loadStylesheet(chunkId, url);",
"if(!oldTag) return;",
`if(!oldTag && !${withHmr} ) return;`,
"// Skip if CSS was removed",
"if(cssRemovedChunks && cssRemovedChunks.indexOf(chunkId) >= 0) {",
Template.indent(["oldTags.push(oldTag);", "return;"]),
"}",
"",
"// create error before stack unwound to get useful stacktrace later",

@@ -472,0 +480,0 @@ "var error = new Error();",

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

const HotUpdateChunk = require("../HotUpdateChunk");
const { CSS_IMPORT_TYPE, CSS_TYPE } = require("../ModuleSourceTypeConstants");
const {

@@ -29,11 +30,6 @@ CSS_MODULE_TYPE,

const RuntimeGlobals = require("../RuntimeGlobals");
const SelfModuleFactory = require("../SelfModuleFactory");
const Template = require("../Template");
const WebpackError = require("../WebpackError");
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");

@@ -135,4 +131,4 @@ const CssImportDependency = require("../dependencies/CssImportDependency");

"css/auto": createSchemaValidation(
require("../../schemas/plugins/css/CssAutoGeneratorOptions.check"),
() => getSchema("CssAutoGeneratorOptions"),
require("../../schemas/plugins/css/CssModuleGeneratorOptions.check"),
() => getSchema("CssModuleGeneratorOptions"),
generatorValidationOptions

@@ -146,4 +142,4 @@ ),

"css/global": createSchemaValidation(
require("../../schemas/plugins/css/CssGlobalGeneratorOptions.check"),
() => getSchema("CssGlobalGeneratorOptions"),
require("../../schemas/plugins/css/CssModuleGeneratorOptions.check"),
() => getSchema("CssModuleGeneratorOptions"),
generatorValidationOptions

@@ -164,4 +160,4 @@ )

"css/auto": createSchemaValidation(
require("../../schemas/plugins/css/CssAutoParserOptions.check"),
() => getSchema("CssAutoParserOptions"),
require("../../schemas/plugins/css/CssModuleParserOptions.check"),
() => getSchema("CssModuleParserOptions"),
parserValidationOptions

@@ -175,4 +171,4 @@ ),

"css/global": createSchemaValidation(
require("../../schemas/plugins/css/CssGlobalParserOptions.check"),
() => getSchema("CssGlobalParserOptions"),
require("../../schemas/plugins/css/CssModuleParserOptions.check"),
() => getSchema("CssModuleParserOptions"),
parserValidationOptions

@@ -228,3 +224,2 @@ )

const hooks = CssModulesPlugin.getCompilationHooks(compilation);
const selfFactory = new SelfModuleFactory(compilation.moduleGraph);
compilation.dependencyFactories.set(

@@ -246,15 +241,3 @@ CssImportDependency,

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

@@ -267,19 +250,3 @@ normalModuleFactory

);
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,

@@ -305,41 +272,27 @@ new CssIcssExportDependency.Template()

.tap(PLUGIN_NAME, (parserOptions) => {
validateParserOptions[type](parserOptions);
const {
url,
import: importOption,
namedExports,
exportType
} = parserOptions;
switch (type) {
case CSS_MODULE_TYPE:
return new CssParser({
importOption,
url,
namedExports,
exportType
});
validateParserOptions[type](parserOptions);
return new CssParser(parserOptions);
case CSS_MODULE_TYPE_GLOBAL:
validateParserOptions[type](parserOptions);
return new CssParser({
defaultMode: "global",
importOption,
url,
namedExports,
exportType
...parserOptions
});
case CSS_MODULE_TYPE_MODULE:
validateParserOptions[type](parserOptions);
return new CssParser({
defaultMode: "local",
importOption,
url,
namedExports,
exportType
...parserOptions
});
case CSS_MODULE_TYPE_AUTO:
validateParserOptions[type](parserOptions);
return new CssParser({
defaultMode: "auto",
importOption,
url,
namedExports,
exportType
...parserOptions
});

@@ -791,3 +744,3 @@ }

chunk,
"css-import",
CSS_IMPORT_TYPE,
compareModulesByIdOrIdentifier(chunkGraph)

@@ -804,3 +757,3 @@ )

chunk,
"css",
CSS_TYPE,
compareModulesByIdOrIdentifier(chunkGraph)

@@ -935,4 +888,4 @@ )

(
codeGenResult.sources.get("css") ||
codeGenResult.sources.get("css-import")
codeGenResult.sources.get(CSS_TYPE) ||
codeGenResult.sources.get(CSS_IMPORT_TYPE)
);

@@ -986,5 +939,7 @@ const moduleSource = CssModulesPlugin.renderModule(

return (
Boolean(chunkGraph.getChunkModulesIterableBySourceType(chunk, "css")) ||
Boolean(
chunkGraph.getChunkModulesIterableBySourceType(chunk, "css-import")
chunkGraph.getChunkModulesIterableBySourceType(chunk, CSS_TYPE)
) ||
Boolean(
chunkGraph.getChunkModulesIterableBySourceType(chunk, CSS_IMPORT_TYPE)
)

@@ -991,0 +946,0 @@ );

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

* @property {((input: string, start: number, end: number) => number)=} string
* @property {((input: string, start: number, end: number) => number)=} leftCurlyBracket
* @property {((input: string, start: number, end: number) => number)=} rightCurlyBracket
* @property {((input: string, start: number, end: number) => number)=} leftParenthesis
* @property {((input: string, start: number, end: number) => number)=} rightParenthesis
* @property {((input: string, start: number, end: number) => number)=} leftSquareBracket
* @property {((input: string, start: number, end: number) => number)=} rightSquareBracket
* @property {((input: string, start: number, end: number) => number)=} function

@@ -22,4 +26,2 @@ * @property {((input: string, start: number, end: number) => number)=} colon

* @property {((input: string, start: number, end: number, isId: boolean) => number)=} hash
* @property {((input: string, start: number, end: number) => number)=} leftCurlyBracket
* @property {((input: string, start: number, end: number) => number)=} rightCurlyBracket
* @property {((input: string, start: number, end: number) => number)=} semicolon

@@ -722,10 +724,18 @@ * @property {((input: string, start: number, end: number) => number)=} comma

/** @type {CharHandler} */
const consumeLeftSquareBracket = (input, pos, _callbacks) =>
const consumeLeftSquareBracket = (input, pos, callbacks) => {
// Return a <]-token>.
pos;
if (callbacks.leftSquareBracket !== undefined) {
return callbacks.leftSquareBracket(input, pos - 1, pos);
}
return pos;
};
/** @type {CharHandler} */
const consumeRightSquareBracket = (input, pos, _callbacks) =>
const consumeRightSquareBracket = (input, pos, callbacks) => {
// Return a <]-token>.
pos;
if (callbacks.rightSquareBracket !== undefined) {
return callbacks.rightSquareBracket(input, pos - 1, pos);
}
return pos;
};

@@ -1207,3 +1217,3 @@ /** @type {CharHandler} */

* @param {CssTokenCallbacks} callbacks callbacks
* @param {CssTokenCallbacks} additional additional callbacks
* @param {CssTokenCallbacks=} additional additional callbacks
* @param {{ onlyTopLevel?: boolean, declarationValue?: boolean, atRulePrelude?: boolean, functionValue?: boolean }=} options options

@@ -1228,3 +1238,3 @@ * @returns {number} pos

if (additional.function !== undefined) {
if (additional && additional.function !== undefined) {
return additional.function(input, start, end);

@@ -1273,2 +1283,6 @@ }

};
servicedCallbacks.semicolon = (_input, _start, end) => {
needTerminate = true;
return end;
};
}

@@ -1335,5 +1349,7 @@

* @param {number} pos position
* @returns {number} position after whitespace and comments
* @returns {[number, boolean]} position after whitespace and comments
*/
const eatWhitespaceAndComments = (input, pos) => {
let foundWhitespace = false;
for (;;) {

@@ -1343,2 +1359,5 @@ const originalPos = pos;

while (_isWhiteSpace(input.charCodeAt(pos))) {
if (!foundWhitespace) {
foundWhitespace = true;
}
pos++;

@@ -1351,3 +1370,3 @@ }

return pos;
return [pos, foundWhitespace];
};

@@ -1406,3 +1425,3 @@

const eatString = (input, pos) => {
pos = eatWhitespaceAndComments(input, pos);
pos = eatWhitespaceAndComments(input, pos)[0];

@@ -1640,3 +1659,3 @@ const start = pos;

const eatIdentSequence = (input, pos) => {
pos = eatWhitespaceAndComments(input, pos);
pos = eatWhitespaceAndComments(input, pos)[0];

@@ -1666,3 +1685,3 @@ const start = pos;

const eatIdentSequenceOrString = (input, pos) => {
pos = eatWhitespaceAndComments(input, pos);
pos = eatWhitespaceAndComments(input, pos)[0];

@@ -1731,3 +1750,4 @@ const start = pos;

module.exports.isIdentStartCodePoint = isIdentStartCodePoint;
module.exports.isWhiteSpace = _isWhiteSpace;
module.exports.skipCommentsAndEatIdentSequence =
skipCommentsAndEatIdentSequence;

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

const { SyncWaterfallHook } = require("tapable");
const {

@@ -36,2 +37,3 @@ JAVASCRIPT_MODULE_TYPE_AUTO,

/** @typedef {import("./logging/Logger").Logger} Logger */
/** @typedef {import("./Compilation")} Compilation */

@@ -47,3 +49,3 @@ /** @typedef {null | undefined | RegExp | EXPECTED_FUNCTION | string | number | boolean | bigint | undefined} CodeValuePrimitive */

* @property {string[]=} buildDependencies
* @property {string| (() => string)=} version
* @property {string | (() => string)=} version
*/

@@ -186,3 +188,3 @@

const code = obj[key];
return `${JSON.stringify(key)}:${toCode(
return `${key === "__proto__" ? '["__proto__"]' : JSON.stringify(key)}:${toCode(
code,

@@ -337,4 +339,27 @@ parser,

/**
* @typedef {object} DefinePluginHooks
* @property {SyncWaterfallHook<[Record<string, CodeValue>]>} definitions
*/
/** @type {WeakMap<Compilation, DefinePluginHooks>} */
const compilationHooksMap = new WeakMap();
class DefinePlugin {
/**
* @param {Compilation} compilation the compilation
* @returns {DefinePluginHooks} the attached hooks
*/
static getCompilationHooks(compilation) {
let hooks = compilationHooksMap.get(compilation);
if (hooks === undefined) {
hooks = {
definitions: new SyncWaterfallHook(["definitions"])
};
compilationHooksMap.set(compilation, hooks);
}
return hooks;
}
/**
* Create a new define plugin

@@ -366,3 +391,9 @@ * @param {Record<string, CodeValue>} definitions A map of global object definitions

const definitions = this.definitions;
const hooks = DefinePlugin.getCompilationHooks(compilation);
hooks.definitions.tap(PLUGIN_NAME, (previousDefinitions) => ({
...previousDefinitions,
...definitions
}));
/**

@@ -514,3 +545,3 @@ * @type {Map<string, Set<string>>}

/** @type {Record<string, CodeValue>} */
const obj = {};
const obj = Object.create(null);
const finalSet = finalByNestedKey.get(nested);

@@ -517,0 +548,0 @@ for (const { id } of destructed) {

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

const Module = require("./Module");
const { JS_TYPES } = require("./ModuleSourceTypesConstants");
const {
JAVASCRIPT_TYPE,
JAVASCRIPT_TYPES
} = require("./ModuleSourceTypeConstants");
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");

@@ -84,3 +87,3 @@ const RuntimeGlobals = require("./RuntimeGlobals");

getSourceTypes() {
return JS_TYPES;
return JAVASCRIPT_TYPES;
}

@@ -182,5 +185,5 @@

if (this.useSourceMap || this.useSimpleSourceMap) {
sources.set("javascript", new OriginalSource(str, this.identifier()));
sources.set(JAVASCRIPT_TYPE, new OriginalSource(str, this.identifier()));
} else {
sources.set("javascript", new RawSource(str));
sources.set(JAVASCRIPT_TYPE, new RawSource(str));
}

@@ -187,0 +190,0 @@

@@ -25,6 +25,12 @@ /*

* @param {string} expression expression
* @param {Range} range range
* @param {Range | null} range range
* @param {string} identifier identifier
* @param {number=} place place where we inject the expression
*/
constructor(expression, range, identifier) {
constructor(
expression,
range,
identifier,
place = CachedConstDependency.PLACE_MODULE
) {
super();

@@ -35,2 +41,3 @@

this.identifier = identifier;
this.place = place;
this._hashUpdate = undefined;

@@ -43,3 +50,3 @@ }

_createHashUpdate() {
return `${this.identifier}${this.range}${this.expression}`;
return `${this.place}${this.identifier}${this.range}${this.expression}`;
}

@@ -69,2 +76,3 @@

write(this.identifier);
write(this.place);

@@ -83,2 +91,3 @@ super.serialize(context);

this.identifier = read();
this.place = read();

@@ -89,2 +98,5 @@ super.deserialize(context);

CachedConstDependency.PLACE_MODULE = 10;
CachedConstDependency.PLACE_CHUNK = 20;
makeSerializable(

@@ -104,10 +116,14 @@ CachedConstDependency,

*/
apply(dependency, source, { initFragments }) {
apply(dependency, source, { initFragments, chunkInitFragments }) {
const dep = /** @type {CachedConstDependency} */ (dependency);
initFragments.push(
(dep.place === CachedConstDependency.PLACE_MODULE
? initFragments
: chunkInitFragments
).push(
new InitFragment(
`var ${dep.identifier} = ${dep.expression};\n`,
InitFragment.STAGE_CONSTANTS,
0,
// For a chunk we inject expression after imports
dep.place === CachedConstDependency.PLACE_MODULE ? 0 : 10,
`const ${dep.identifier}`

@@ -119,7 +135,5 @@ )

source.insert(dep.range, dep.identifier);
return;
} else if (dep.range !== null) {
source.replace(dep.range[0], dep.range[1] - 1, dep.identifier);
}
source.replace(dep.range[0], dep.range[1] - 1, dep.identifier);
}

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

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

* @param {Range | undefined} valueRange location of the require call
* @param {boolean | string } inShorthand true or name
* @param {boolean | string} inShorthand true or name
* @param {string=} context context

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

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

/** @typedef {Partial<Omit<ContextDependencyOptions, "resource">>} PartialContextDependencyOptions */
/** @typedef {{ new(options: ContextDependencyOptions, range: Range, valueRange: Range, ...args: any[]): ContextDependency }} ContextDependencyConstructor */
/** @typedef {{ new(options: ContextDependencyOptions, range: Range, valueRange: Range, ...args: EXPECTED_ANY[]): ContextDependency }} ContextDependencyConstructor */

@@ -53,3 +53,3 @@ /**

* @param {Expression} expr expr
* @param {Pick<JavascriptParserOptions, `${"expr"|"wrapped"}Context${"Critical"|"Recursive"|"RegExp"}` | "exprContextRequest">} options options for context creation
* @param {Pick<JavascriptParserOptions, `${"expr" | "wrapped"}Context${"Critical" | "Recursive" | "RegExp"}` | "exprContextRequest">} options options for context creation
* @param {PartialContextDependencyOptions} contextOptions options for the ContextModule

@@ -56,0 +56,0 @@ * @param {JavascriptParser} parser the parser

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

class ContextDependencyTemplateAsRequireCall extends ContextDependency.Template {
class ContextDependencyTemplateAsRequireCall
extends ContextDependency.Template
{
/**

@@ -18,0 +20,0 @@ * @param {Dependency} dependency the dependency for which the template should be applied

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

const { CSS_TYPE, JAVASCRIPT_TYPE } = require("../ModuleSourceTypeConstants");
const WebpackError = require("../WebpackError");
const { cssExportConvention } = require("../util/conventions");

@@ -14,2 +16,3 @@ const createHash = require("../util/createHash");

const memoize = require("../util/memoize");
const nonNumericOnlyHash = require("../util/nonNumericOnlyHash");
const CssIcssImportDependency = require("./CssIcssImportDependency");

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

/** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */
/** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */

@@ -34,2 +38,3 @@ /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */

/** @typedef {import("../util/Hash")} Hash */
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
/** @typedef {import("../ChunkGraph")} ChunkGraph */

@@ -50,3 +55,3 @@ /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */

/** @type {CssGeneratorLocalIdentName} */
(generator.localIdentName);
(generator.options.localIdentName);
const relativeResourcePath = makePathsRelative(

@@ -59,35 +64,89 @@ /** @type {string} */

);
const { hashFunction, hashDigest, hashDigestLength, hashSalt, uniqueName } =
runtimeTemplate.outputOptions;
const hash = createHash(hashFunction);
const { uniqueName } = runtimeTemplate.outputOptions;
if (hashSalt) {
hash.update(hashSalt);
}
let localIdentHash = "";
hash.update(relativeResourcePath);
if (/\[(fullhash|hash)\]/.test(localIdentName)) {
const hashSalt = generator.options.localIdentHashSalt;
const hashDigest =
/** @type {string} */
(generator.options.localIdentHashDigest);
const hashDigestLength = generator.options.localIdentHashDigestLength;
const { hashFunction } = runtimeTemplate.outputOptions;
if (!/\[local\]/.test(localIdentName)) {
const hash = createHash(hashFunction);
if (hashSalt) {
hash.update(hashSalt);
}
if (uniqueName) {
hash.update(uniqueName);
}
hash.update(relativeResourcePath);
hash.update(local);
localIdentHash = hash.digest(hashDigest).slice(0, hashDigestLength);
}
const localIdentHash = hash.digest(hashDigest).slice(0, hashDigestLength);
let contentHash = "";
return runtimeTemplate.compilation
.getPath(localIdentName, {
filename: relativeResourcePath,
hash: localIdentHash,
contentHash: localIdentHash,
chunkGraph,
module
})
.replace(/\[local\]/g, local)
.replace(/\[uniqueName\]/g, /** @type {string} */ (uniqueName))
.replace(/^((-?[0-9])|--)/, "_$1");
if (/\[contenthash\]/.test(localIdentName)) {
const hash = createHash(runtimeTemplate.outputOptions.hashFunction);
const source = module.originalSource();
if (source) {
hash.update(source.buffer());
}
if (module.error) {
hash.update(module.error.toString());
}
const fullContentHash = hash.digest(
runtimeTemplate.outputOptions.hashDigest
);
contentHash = nonNumericOnlyHash(
fullContentHash,
runtimeTemplate.outputOptions.hashDigestLength
);
}
let localIdent = runtimeTemplate.compilation.getPath(localIdentName, {
prepareId: (id) => {
if (typeof id !== "string") return id;
return id
.replace(/^([.-]|[^a-zA-Z0-9_-])+/, "")
.replace(/[^a-zA-Z0-9_-]+/g, "_");
},
filename: relativeResourcePath,
hash: localIdentHash,
contentHash,
chunkGraph,
module
});
if (/\[local\]/.test(localIdentName)) {
localIdent = localIdent.replace(/\[local\]/g, local);
}
if (/\[uniqueName\]/.test(localIdentName)) {
localIdent = localIdent.replace(
/\[uniqueName\]/g,
/** @type {string} */ (uniqueName)
);
}
// Protect the first character from unsupported values
return localIdent.replace(/^((-?[0-9])|--)/, "_$1");
};
// 0 - replace, 1 - append, 2 - once
/** @typedef {0 | 1 | 2} ExportMode */
// 0 - none, 1 - name, 1 - value
/** @typedef {0 | 1 | 2} InterpolationMode */
// 0 - replace, 1 - replace, 2 - append, 2 - once
/** @typedef {0 | 1 | 2 | 3 | 4} ExportMode */
// 0 - normal, 1 - custom css variable, 2 - grid custom ident
/** @typedef {0 | 1 | 2} ExportType */
class CssIcssExportDependency extends NullDependency {

@@ -99,16 +158,23 @@ /**

* @param {string} name export name
* @param {string} value export value or true when we need interpolate name as a value
* @param {string=} reexport reexport name
* @param {string | [string, string, boolean]} value export value or true when we need interpolate name as a value
* @param {Range=} range range
* @param {boolean=} interpolate true when value need to be interpolated, otherwise false
* @param {ExportMode=} exportMode export mode
* @param {ExportType=} exportType export type
*/
constructor(name, value, reexport, range) {
constructor(
name,
value,
range,
interpolate = false,
exportMode = CssIcssExportDependency.EXPORT_MODE.REPLACE,
exportType = CssIcssExportDependency.EXPORT_TYPE.NORMAL
) {
super();
this.name = name;
this.value = value;
this.reexport = reexport;
this.range = range;
/** @type {undefined | InterpolationMode} */
this.interpolationMode = undefined;
/** @type {ExportMode} */
this.exportMode = CssIcssExportDependency.EXPORT_MODE.REPLACE;
this.interpolate = interpolate;
this.exportMode = exportMode;
this.exportType = exportType;
this._hashUpdate = undefined;

@@ -135,2 +201,23 @@ }

/**
* Returns list of exports referenced by this dependency
* @param {ModuleGraph} moduleGraph module graph
* @param {RuntimeSpec} runtime the runtime for which the module is analysed
* @returns {ReferencedExports} referenced exports
*/
getReferencedExports(moduleGraph, runtime) {
if (
this.exportMode === CssIcssExportDependency.EXPORT_MODE.SELF_REFERENCE
) {
return [
{
name: [this.name],
canMangle: true
}
];
}
return super.getReferencedExports(moduleGraph, runtime);
}
/**
* Returns the exported names

@@ -141,2 +228,9 @@ * @param {ModuleGraph} moduleGraph module graph

getExports(moduleGraph) {
if (
this.exportMode === CssIcssExportDependency.EXPORT_MODE.NONE ||
this.exportMode === CssIcssExportDependency.EXPORT_MODE.SELF_REFERENCE
) {
return;
}
const module = /** @type {CssModule} */ (moduleGraph.getParentModule(this));

@@ -147,6 +241,9 @@ const generator = /** @type {CssGenerator} */ (module.generator);

/** @type {CssGeneratorExportsConvention} */
(generator.convention)
(generator.options.exportsConvention)
);
return {
exports: names.map((name) => ({
exports: [
...names,
...(Array.isArray(this.value) ? [this.value[1]] : [])
].map((name) => ({
name,

@@ -160,2 +257,30 @@ canMangle: true

/**
* Returns warnings
* @param {ModuleGraph} moduleGraph module graph
* @returns {WebpackError[] | null | undefined} warnings
*/
getWarnings(moduleGraph) {
if (
this.exportMode === CssIcssExportDependency.EXPORT_MODE.SELF_REFERENCE &&
!Array.isArray(this.value)
) {
const module = moduleGraph.getParentModule(this);
if (
module &&
!moduleGraph.getExportsInfo(module).isExportProvided(this.value)
) {
const error = new WebpackError(
`Self-referencing name "${this.value}" not found`
);
error.module = module;
return [error];
}
}
return null;
}
/**
* Update the hash

@@ -175,5 +300,5 @@ * @param {Hash} hash hash to be updated

/** @type {CssGeneratorExportsConvention} */
(generator.convention)
(generator.options.exportsConvention)
);
this._hashUpdate = `exportsConvention|${JSON.stringify(names)}|localIdentName|${JSON.stringify(generator.localIdentName)}`;
this._hashUpdate = `exportsConvention|${JSON.stringify(names)}|localIdentName|${JSON.stringify(generator.options.localIdentName)}`;
}

@@ -190,6 +315,6 @@ hash.update(this._hashUpdate);

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

@@ -205,6 +330,6 @@ }

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

@@ -239,4 +364,4 @@ }

) {
if (nestedDep.reexport) {
return this.findReference(nestedDep.reexport, {
if (Array.isArray(nestedDep.value)) {
return this.findReference(nestedDep.value[1], {
...templateContext,

@@ -247,6 +372,10 @@ module

return CssIcssExportDependency.Template.getIdentifier(nestedDep, {
...templateContext,
module
});
return CssIcssExportDependency.Template.getIdentifier(
nestedDep.value,
nestedDep,
{
...templateContext,
module
}
);
}

@@ -259,2 +388,3 @@ }

/**
* @param {string} value value to identifier
* @param {Dependency} dependency the dependency for which the template should be applied

@@ -264,37 +394,21 @@ * @param {DependencyTemplateContext} templateContext the context object

*/
static getIdentifier(dependency, templateContext) {
static getIdentifier(value, dependency, templateContext) {
const dep = /** @type {CssIcssExportDependency} */ (dependency);
if (
dep.interpolationMode ===
CssIcssExportDependency.INTERPOLATION_MODE.NAME ||
dep.interpolationMode === CssIcssExportDependency.INTERPOLATION_MODE.VALUE
) {
const { module: m, moduleGraph, runtime } = templateContext;
if (dep.interpolate) {
const { module: m } = templateContext;
const module = /** @type {CssModule} */ (m);
const generator = /** @type {CssGenerator} */ (module.generator);
const names = dep.getExportsConventionNames(
dep.interpolationMode ===
CssIcssExportDependency.INTERPOLATION_MODE.NAME
? dep.name
: dep.value,
const local = cssExportConvention(
value,
/** @type {CssGeneratorExportsConvention} */
(generator.convention)
);
const usedNames =
/** @type {string[]} */
(
names
.map((name) =>
moduleGraph.getExportInfo(module, name).getUsedName(name, runtime)
)
.filter(Boolean)
);
const local = usedNames.length === 0 ? names[0] : usedNames[0];
(generator.options.exportsConvention)
)[0];
const prefix =
/** @type {CssIcssExportDependency & { prefix: string }} */
(dependency).prefix;
dep.exportType === CssIcssExportDependency.EXPORT_TYPE.CUSTOM_VARIABLE
? "--"
: "";
return (
(prefix || "") +
prefix +
getCssParser().escapeIdentifier(

@@ -323,3 +437,3 @@ getLocalIdent(

const dep = /** @type {CssIcssExportDependency} */ (dependency);
if (!dep.range && templateContext.type !== "javascript") return;
if (!dep.range && templateContext.type !== JAVASCRIPT_TYPE) return;
const { cssData } = templateContext;

@@ -332,3 +446,3 @@ const { module: m, moduleGraph, runtime } = templateContext;

/** @type {CssGeneratorExportsConvention} */
(generator.convention)
(generator.options.exportsConvention)
);

@@ -346,2 +460,3 @@ const usedNames =

const allNames = new Set([...usedNames, ...names]);
const isReference = Array.isArray(dep.value);

@@ -351,35 +466,55 @@ /** @type {string} */

if (dep.reexport) {
if (isReference && dep.value[2] === true) {
const resolved = CssIcssExportDependencyTemplate.findReference(
dep.reexport,
dep.value[1],
templateContext
);
if (resolved) {
dep.value = resolved;
}
// Fallback to the original name if not found
value = resolved || dep.value[0];
} else {
value = isReference ? dep.value[1] : /** @type {string} */ (dep.value);
}
if (typeof dep.interpolationMode !== "undefined") {
if (dep.interpolate) {
value = CssIcssExportDependencyTemplate.getIdentifier(
value,
dep,
templateContext
);
} else {
value = dep.value;
}
if (templateContext.type === "javascript") {
if (
dep.exportType ===
CssIcssExportDependency.EXPORT_TYPE.GRID_CUSTOM_IDENTIFIER
) {
value += `-${dep.name}`;
}
if (
templateContext.type === JAVASCRIPT_TYPE &&
dep.exportMode !== CssIcssExportDependency.EXPORT_MODE.NONE
) {
for (const used of allNames) {
if (dep.exportMode === 2) {
if (dep.exportMode === CssIcssExportDependency.EXPORT_MODE.ONCE) {
const newValue = getCssParser().unescapeIdentifier(value);
if (isReference) {
cssData.exports.set(dep.value[1], newValue);
}
if (cssData.exports.has(used)) return;
cssData.exports.set(
used,
`${getCssParser().unescapeIdentifier(value)}`
);
cssData.exports.set(used, newValue);
} else {
const originalValue =
dep.exportMode === 0 ? undefined : cssData.exports.get(used);
const newValue = getCssParser().unescapeIdentifier(value);
dep.exportMode === CssIcssExportDependency.EXPORT_MODE.REPLACE
? undefined
: cssData.exports.get(used);
const newValue =
dep.exportMode ===
CssIcssExportDependency.EXPORT_MODE.SELF_REFERENCE
? cssData.exports.get(
isReference ? dep.value[0] : /** @type {string} */ (dep.value)
) || value
: getCssParser().unescapeIdentifier(value);
cssData.exports.set(

@@ -393,4 +528,5 @@ used,

dep.range &&
templateContext.type === "css" &&
dep.exportMode !== 1
templateContext.type === CSS_TYPE &&
dep.exportMode !== CssIcssExportDependency.EXPORT_MODE.APPEND &&
dep.exportMode !== CssIcssExportDependency.EXPORT_MODE.SELF_REFERENCE
) {

@@ -402,14 +538,16 @@ source.replace(dep.range[0], dep.range[1] - 1, value);

/** @type {Record<"REPLACE" | "APPEND" | "ONCE", ExportMode>} */
/** @type {Record<"NONE" | "REPLACE" | "APPEND" | "ONCE" | "SELF_REFERENCE", ExportMode>} */
CssIcssExportDependency.EXPORT_MODE = {
REPLACE: 0,
APPEND: 1,
ONCE: 2
NONE: 0,
REPLACE: 1,
APPEND: 2,
ONCE: 3,
SELF_REFERENCE: 4
};
/** @type {Record<"NONE" | "NAME" | "VALUE", InterpolationMode>} */
CssIcssExportDependency.INTERPOLATION_MODE = {
NONE: 0,
NAME: 1,
VALUE: 2
/** @type {Record<"NORMAL" | "CUSTOM_VARIABLE" | "GRID_CUSTOM_IDENTIFIER", ExportType>} */
CssIcssExportDependency.EXPORT_TYPE = {
NORMAL: 0,
CUSTOM_VARIABLE: 1,
GRID_CUSTOM_IDENTIFIER: 2
};

@@ -416,0 +554,0 @@

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

const WebpackError = require("../WebpackError");
const { cssExportConvention } = require("../util/conventions");
const makeSerializable = require("../util/makeSerializable");
const memoize = require("../util/memoize");
const CssImportDependency = require("./CssImportDependency");

@@ -17,2 +19,3 @@

/** @typedef {import("../Module")} Module */
/** @typedef {import("../CssModule")} CssModule */
/** @typedef {import("../ModuleGraph")} ModuleGraph */

@@ -25,3 +28,9 @@ /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */

/** @typedef {import("../../declarations/WebpackOptions").CssGeneratorExportsConvention} CssGeneratorExportsConvention */
/** @typedef {import("./CssIcssExportDependency").ExportMode} ExportMode */
/** @typedef {import("./CssIcssExportDependency").ExportType} ExportType */
const getCssIcssExportDependency = memoize(() =>
require("./CssIcssExportDependency")
);
class CssIcssImportDependency extends CssImportDependency {

@@ -31,11 +40,26 @@ /**

*
* :import('./style.css') { IMPORTED_NAME: v-primary }
* :import('./style.css') { value: name }
* @param {string} request request request path which needs resolving
* @param {Range} range the range of dependency
* @param {"local" | "global"} mode mode of the parsed CSS
* @param {string} name importName name
* @param {string} name name
* @param {string=} exportName export value
* @param {ExportMode=} exportMode export mode
* @param {ExportType=} exportType export type
*/
constructor(request, range, mode, name) {
constructor(
request,
range,
mode,
name,
exportName = undefined,
exportMode = getCssIcssExportDependency().EXPORT_MODE.NONE,
exportType = getCssIcssExportDependency().EXPORT_TYPE.NORMAL
) {
super(request, range, mode);
this.name = name;
this.value = exportName;
this.interpolate = true;
this.exportMode = exportMode;
this.exportType = exportType;
}

@@ -55,2 +79,11 @@

/**
* @param {string} name export name
* @param {CssGeneratorExportsConvention} convention convention of the export name
* @returns {string[]} convention results
*/
getExportsConventionNames(name, convention) {
return cssExportConvention(name, convention);
}
/**
* Returns list of exports referenced by this dependency

@@ -99,2 +132,6 @@ * @param {ModuleGraph} moduleGraph module graph

write(this.name);
write(this.value);
write(this.interpolate);
write(this.exportMode);
write(this.exportType);
super.serialize(context);

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

this.name = read();
this.value = read();
this.interpolate = read();
this.exportMode = read();
this.exportType = read();
super.deserialize(context);

@@ -124,3 +165,19 @@ }

apply(dependency, source, templateContext) {
// We remove everything in CSS parser
const dep = /** @type {CssIcssImportDependency} */ (dependency);
if (dep.value) {
const { moduleGraph } = templateContext;
const module =
/** @type {CssModule} */
(moduleGraph.getModule(dep));
const CssIcssExportDependency = getCssIcssExportDependency();
const template = new CssIcssExportDependency.Template();
const originalName = dep.name;
const originalExportName = dep.value;
dep.value = originalName;
dep.name = originalExportName;
template.apply(dep, source, { ...templateContext, module });
dep.name = originalName;
dep.value = originalExportName;
}
}

@@ -127,0 +184,0 @@ };

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

const { CSS_TYPE } = require("../ModuleSourceTypeConstants");
const makeSerializable = require("../util/makeSerializable");

@@ -46,6 +47,2 @@ const CssIcssExportDependency = require("./CssIcssExportDependency");

get category() {
return "self";
}
/**

@@ -111,3 +108,3 @@ * Update the hash

apply(dependency, source, templateContext) {
if (templateContext.type === "css") {
if (templateContext.type === CSS_TYPE) {
const dep = /** @type {CssIcssSymbolDependency} */ (dependency);

@@ -123,3 +120,2 @@ /** @type {string | undefined} */

if (!value) {
// TODO generate warning
return;

@@ -126,0 +122,0 @@ }

@@ -13,3 +13,3 @@ /*

/** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
/** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
/** @typedef {import("../css/CssParser").Range} Range */

@@ -109,2 +109,3 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */

apply(dependency, source, templateContext) {
if (templateContext.type === "javascript") return;
const dep = /** @type {CssImportDependency} */ (dependency);

@@ -111,0 +112,0 @@

@@ -16,3 +16,3 @@ /*

/** @typedef {import("../Dependency")} Dependency */
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
/** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */
/** @typedef {import("../Module")} Module */

@@ -122,4 +122,5 @@ /** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */

source,
{ moduleGraph, runtimeTemplate, codeGenerationResults }
{ type, moduleGraph, runtimeTemplate, codeGenerationResults }
) {
if (type === "javascript") return;
const dep = /** @type {CssUrlDependency} */ (dependency);

@@ -126,0 +127,0 @@ const module = /** @type {Module} */ (moduleGraph.getModule(dep));

@@ -9,9 +9,9 @@ /*

/** @typedef {import("../Module").BuildMeta} BuildMeta */
/** @typedef {import("../Parser").ParserState} ParserState */
/** @typedef {import("../javascript/JavascriptParser").JavascriptParserState} JavascriptParserState */
/** @type {WeakMap<ParserState, boolean>} */
/** @type {WeakMap<JavascriptParserState, boolean>} */
const parserStateExportsState = new WeakMap();
/**
* @param {ParserState} parserState parser state
* @param {JavascriptParserState} parserState parser state
* @returns {void}

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

/**
* @param {ParserState} parserState parser state
* @param {JavascriptParserState} parserState parser state
* @returns {void}

@@ -46,3 +46,3 @@ */

/**
* @param {ParserState} parserState parser state
* @param {JavascriptParserState} parserState parser state
* @returns {boolean} true, when enabled

@@ -56,3 +56,3 @@ */

/**
* @param {ParserState} parserState parser state
* @param {JavascriptParserState} parserState parser state
* @returns {void}

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

/**
* @param {ParserState} parserState parser state
* @param {JavascriptParserState} parserState parser state
* @returns {void}

@@ -71,0 +71,0 @@ */

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

/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/** @typedef {import("../dependencies/ExternalModuleInitFragment").ArrayImportSpecifiers} ArrayImportSpecifiers */
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */

@@ -23,7 +24,8 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */

* @param {string} module module
* @param {{ name: string, value: string }[]} importSpecifiers import specifiers
* @param {ArrayImportSpecifiers} importSpecifiers import specifiers
* @param {string | undefined} defaultImport default import
* @param {string} expression expression
* @param {Range} range range
* @param {Range | null} range range
* @param {string} identifier identifier
* @param {number=} place place where we inject the expression
*/

@@ -36,5 +38,6 @@ constructor(

range,
identifier
identifier,
place = CachedConstDependency.PLACE_MODULE
) {
super(expression, range, identifier);
super(expression, range, identifier, place);

@@ -41,0 +44,0 @@ this.importedModule = module;

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

/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
/** @typedef {{ name: string, value?: string }[]} ArrayImportSpecifiers */
/** @typedef {Map<string, Set<string>>} ImportSpecifiers */

@@ -24,3 +25,3 @@

* @param {string} importedModule imported module
* @param {{ name: string, value?: string }[] | ImportSpecifiers} specifiers import specifiers
* @param {ArrayImportSpecifiers | ImportSpecifiers} specifiers import specifiers
* @param {string=} defaultImport default import

@@ -27,0 +28,0 @@ */

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

/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/** @typedef {import("../dependencies/ExternalModuleInitFragment").ArrayImportSpecifiers} ArrayImportSpecifiers */
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */

@@ -24,3 +25,3 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */

* @param {string} module module
* @param {{ name: string, value: string }[]} importSpecifiers import specifiers
* @param {ArrayImportSpecifiers} importSpecifiers import specifiers
* @param {string | undefined} defaultImport default import

@@ -27,0 +28,0 @@ */

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

* @param {Expression | SpreadElement} expr expressions
* @returns {{fn: FunctionExpression | ArrowFunctionExpression, expressions: (Expression | SpreadElement)[], needThis: boolean | undefined } | undefined} function expression with additional information
* @returns {{ fn: FunctionExpression | ArrowFunctionExpression, expressions: (Expression | SpreadElement)[], needThis: boolean | undefined } | undefined} function expression with additional information
*/

@@ -18,0 +18,0 @@ module.exports = (expr) => {

@@ -126,3 +126,3 @@ /*

node.type.endsWith("Declaration") &&
/** @type {FunctionDeclaration | ClassDeclaration} */ (node).id
/** @type {FunctionDeclaration | ClassDeclaration} */ (node).id
? /** @type {FunctionDeclaration | ClassDeclaration} */

@@ -228,3 +228,4 @@ (node).id.name

(source),
parser.state.lastHarmonyImportOrder,
/** @type {number} */
(parser.state.lastHarmonyImportOrder),
id ? [id] : [],

@@ -231,0 +232,0 @@ name,

@@ -63,3 +63,3 @@ /*

/** @typedef {"missing"|"unused"|"empty-star"|"reexport-dynamic-default"|"reexport-named-default"|"reexport-namespace-object"|"reexport-fake-namespace-object"|"reexport-undefined"|"normal-reexport"|"dynamic-reexport"} ExportModeType */
/** @typedef {"missing" | "unused" | "empty-star" | "reexport-dynamic-default" | "reexport-named-default" | "reexport-namespace-object" | "reexport-fake-namespace-object" | "reexport-undefined" | "normal-reexport" | "dynamic-reexport"} ExportModeType */

@@ -66,0 +66,0 @@ const { ExportPresenceModes } = HarmonyImportDependency;

@@ -12,9 +12,9 @@ /*

/** @typedef {import("../Module").BuildMeta} BuildMeta */
/** @typedef {import("../Parser").ParserState} ParserState */
/** @typedef {import("../javascript/JavascriptParser").JavascriptParserState} JavascriptParserState */
/** @type {WeakMap<ParserState, boolean>} */
/** @type {WeakMap<JavascriptParserState, boolean>} */
const parserStateExportsState = new WeakMap();
/**
* @param {ParserState} parserState parser state
* @param {JavascriptParserState} parserState parser state
* @param {boolean} isStrictHarmony strict harmony mode should be enabled

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

/**
* @param {ParserState} parserState parser state
* @param {JavascriptParserState} parserState parser state
* @returns {boolean} true, when enabled

@@ -44,0 +44,0 @@ */

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

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

@@ -66,6 +66,11 @@

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

@@ -72,0 +77,0 @@ this.phase = phase;

@@ -28,3 +28,3 @@ /*

/** @typedef {Pick<ContextModuleOptions, 'mode' | 'recursive' | 'regExp' | 'include' | 'exclude' | 'chunkName'> & { groupOptions: RawChunkGroupOptions, exports?: RawReferencedExports }} ImportMetaContextOptions */
/** @typedef {Pick<ContextModuleOptions, "mode" | "recursive" | "regExp" | "include" | "exclude" | "chunkName"> & { groupOptions: RawChunkGroupOptions, exports?: RawReferencedExports }} ImportMetaContextOptions */

@@ -31,0 +31,0 @@ /**

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

const Compilation = require("../Compilation");
const DefinePlugin = require("../DefinePlugin");
const ModuleDependencyWarning = require("../ModuleDependencyWarning");

@@ -48,2 +49,27 @@ const {

/**
* Collect import.meta.env definitions from DefinePlugin and build JSON string
* @param {Compilation} compilation the compilation
* @returns {string} env object as JSON string
*/
const collectImportMetaEnvDefinitions = (compilation) => {
const definePluginHooks = DefinePlugin.getCompilationHooks(compilation);
const definitions = definePluginHooks.definitions.call({});
if (!definitions) {
return "{}";
}
/** @type {string[]} */
const pairs = [];
for (const key of Object.keys(definitions)) {
if (key.startsWith("import.meta.env.")) {
const envKey = key.slice("import.meta.env.".length);
const value = definitions[key];
pairs.push(`${JSON.stringify(envKey)}:${value}`);
}
}
return `{${pairs.join(",")}}`;
};
/**
* @typedef {object} ImportMetaPluginHooks

@@ -299,2 +325,33 @@ * @property {SyncBailHook<[DestructuringAssignmentProperty], string | void>} propertyInDestructuring

// import.meta.env
parser.hooks.typeof
.for("import.meta.env")
.tap(
PLUGIN_NAME,
toConstantDependency(parser, JSON.stringify("object"))
);
parser.hooks.expression
.for("import.meta.env")
.tap(PLUGIN_NAME, (expr) => {
const envCode = collectImportMetaEnvDefinitions(compilation);
const dep = new ConstDependency(
envCode,
/** @type {Range} */ (expr.range)
);
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
parser.state.module.addPresentationalDependency(dep);
return true;
});
parser.hooks.evaluateTypeof
.for("import.meta.env")
.tap(PLUGIN_NAME, evaluateToString("object"));
parser.hooks.evaluateIdentifier
.for("import.meta.env")
.tap(PLUGIN_NAME, (expr) =>
new BasicEvaluatedExpression()
.setTruthy()
.setSideEffects(false)
.setRange(/** @type {Range} */ (expr.range))
);
// Unknown properties

@@ -301,0 +358,0 @@ parser.hooks.unhandledExpressionMemberChain

@@ -32,3 +32,3 @@ /*

/** @typedef {import("../javascript/JavascriptParser").Range} Range */
/** @typedef {import("../javascript/JavascriptParser").ParserState} ParserState */
/** @typedef {import("../javascript/JavascriptParser").JavascriptParserState} JavascriptParserState */
/** @typedef {import("../javascript/JavascriptParser").Members} Members */

@@ -45,3 +45,3 @@ /** @typedef {import("../javascript/JavascriptParser").MembersOptionals} MembersOptionals */

/** @type {WeakMap<ParserState, State>} */
/** @type {WeakMap<JavascriptParserState, State>} */
const parserStateMap = new WeakMap();

@@ -48,0 +48,0 @@ const dynamicImportTag = Symbol("import()");

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

/** @typedef {import("../javascript/JavascriptParser").ParserState} ParserState */
/** @typedef {import("../javascript/JavascriptParser").JavascriptParserState} JavascriptParserState */

@@ -38,3 +38,3 @@ /**

/**
* @param {ParserState} state parser state
* @param {JavascriptParserState} state parser state
* @param {string} name name

@@ -53,3 +53,3 @@ * @returns {LocalModule} local module

/**
* @param {ParserState} state parser state
* @param {JavascriptParserState} state parser state
* @param {string} name name

@@ -56,0 +56,0 @@ * @param {string=} namedModule named module

@@ -44,5 +44,5 @@ /*

/** @typedef {import("../NormalModule")} NormalModule */
/** @typedef {import("../Parser").ParserState} ParserState */
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
/** @typedef {import("../javascript/JavascriptParser")} Parser */
/** @typedef {import("../javascript/JavascriptParser").JavascriptParserState} JavascriptParserState */
/** @typedef {import("../javascript/JavascriptParser").Range} Range */

@@ -66,3 +66,3 @@ /** @typedef {import("./HarmonyImportDependencyParserPlugin").HarmonySettings} HarmonySettings */

/** @type {WeakMap<ParserState, number>} */
/** @type {WeakMap<JavascriptParserState, number>} */
const workerIndexMap = new WeakMap();

@@ -69,0 +69,0 @@

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

const Module = require("./Module");
const { JS_TYPES } = require("./ModuleSourceTypesConstants");
const {
JAVASCRIPT_TYPE,
JAVASCRIPT_TYPES
} = require("./ModuleSourceTypeConstants");
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");

@@ -57,3 +60,3 @@ const RuntimeGlobals = require("./RuntimeGlobals");

getSourceTypes() {
return JS_TYPES;
return JAVASCRIPT_TYPES;
}

@@ -97,3 +100,3 @@

sources.set(
"javascript",
JAVASCRIPT_TYPE,
new RawSource(`module.exports = ${RuntimeGlobals.require};`)

@@ -100,0 +103,0 @@ );

@@ -57,3 +57,3 @@ /*

function parse(src) {
const obj = /** @type {Env} */ ({});
const obj = /** @type {Env} */ (Object.create(null));

@@ -178,3 +178,3 @@ // Convert buffer to string

// for use with progressive expansion
const runningParsed = /** @type {Env} */ ({});
const runningParsed = /** @type {Env} */ (Object.create(null));
const processEnv = options.processEnv;

@@ -188,3 +188,4 @@

value =
processEnv[key] && processEnv[key] !== value
Object.prototype.hasOwnProperty.call(processEnv, key) &&
processEnv[key] !== value
? /** @type {string} */ (processEnv[key])

@@ -338,3 +339,3 @@ : expandValue(value, processEnv, runningParsed);

// Similar to Vite's implementation
const parsed = /** @type {Env} */ ({});
const parsed = /** @type {Env} */ (Object.create(null));

@@ -429,3 +430,3 @@ for (const content of contents) {

expand({ parsed, processEnv });
const env = /** @type {Env} */ ({});
const env = /** @type {Env} */ (Object.create(null));

@@ -438,3 +439,7 @@ // Get all keys from parser and process.env

if (prefixes.some((prefix) => key.startsWith(prefix))) {
env[key] = process.env[key] ? process.env[key] : parsed[key];
env[key] =
Object.prototype.hasOwnProperty.call(process.env, key) &&
process.env[key]
? process.env[key]
: parsed[key];
}

@@ -441,0 +446,0 @@ }

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

const { HotUpdateChunk, RuntimeGlobals } = require("..");
const { JAVASCRIPT_TYPE } = require("../ModuleSourceTypeConstants");
const Template = require("../Template");

@@ -114,6 +115,6 @@ const {

/**
* @param {Set<Chunk>} chunks the chunks to render
* @param {Iterable<Chunk>} chunks the chunks to render
* @param {ChunkGraph} chunkGraph the chunk graph
* @param {Chunk=} runtimeChunk the runtime chunk
* @returns {Source|undefined} the source
* @returns {Source | undefined} the source
*/

@@ -158,3 +159,3 @@ const withDependentChunks = (chunks, chunkGraph, runtimeChunk) => {

const sourceWithDependentChunks = withDependentChunks(
/** @type {Set<Chunk>} */ (entryDependentChunks),
entryDependentChunks,
chunkGraph,

@@ -220,3 +221,3 @@ chunk

const [module, entrypoint] = entries[i];
if (!chunkGraph.getModuleSourceTypes(module).has("javascript")) {
if (!chunkGraph.getModuleSourceTypes(module).has(JAVASCRIPT_TYPE)) {
continue;

@@ -223,0 +224,0 @@ }

@@ -1349,7 +1349,7 @@ /*

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

@@ -1356,0 +1356,0 @@ };

@@ -17,4 +17,5 @@ /*

CSS_URL_TYPES,
JS_TYPES
} = require("./ModuleSourceTypesConstants");
JAVASCRIPT_TYPE,
JAVASCRIPT_TYPES
} = require("./ModuleSourceTypeConstants");
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");

@@ -90,3 +91,3 @@ const RuntimeGlobals = require("./RuntimeGlobals");

]);
const EMPTY_RUNTIME_REQUIREMENTS = new Set([]);
const EMPTY_RUNTIME_REQUIREMENTS = new Set();

@@ -660,3 +661,3 @@ /**

return JS_TYPES;
return JAVASCRIPT_TYPES;
}

@@ -985,3 +986,3 @@

sources.set(
"javascript",
JAVASCRIPT_TYPE,
new RawSource(`module.exports = ${JSON.stringify(request)};`)

@@ -1071,7 +1072,7 @@ );

sources.set(
"javascript",
JAVASCRIPT_TYPE,
new OriginalSource(sourceString, this.identifier())
);
} else {
sources.set("javascript", new RawSource(sourceString));
sources.set(JAVASCRIPT_TYPE, new RawSource(sourceString));
}

@@ -1078,0 +1079,0 @@

@@ -29,3 +29,3 @@ /*

/** @typedef {((context: string, request: string, callback: (err?: Error | null, result?: string | false, resolveRequest?: import('enhanced-resolve').ResolveRequest) => void) => void)} ExternalItemFunctionDataGetResolveCallbackResult */
/** @typedef {((context: string, request: string, callback: (err?: Error | null, result?: string | false, resolveRequest?: import("enhanced-resolve").ResolveRequest) => void) => void)} ExternalItemFunctionDataGetResolveCallbackResult */
/** @typedef {((context: string, request: string) => Promise<string>)} ExternalItemFunctionDataGetResolveResult */

@@ -32,0 +32,0 @@ /** @typedef {(options?: ResolveOptions) => ExternalItemFunctionDataGetResolveCallbackResult | ExternalItemFunctionDataGetResolveResult} ExternalItemFunctionDataGetResolve */

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

const { JAVASCRIPT_TYPE } = require("./ModuleSourceTypeConstants");
/** @typedef {import("webpack-sources").Source} Source */

@@ -17,2 +19,3 @@ /** @typedef {import("./ChunkGraph")} ChunkGraph */

/** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */
/** @typedef {import("./Module").SourceType} SourceType */
/** @typedef {import("./Module").SourceTypes} SourceTypes */

@@ -35,3 +38,3 @@ /** @typedef {import("./ModuleGraph")} ModuleGraph */

* @property {CodeGenerationResults=} codeGenerationResults code generation results of other modules (need to have a codeGenerationDependency to use that)
* @property {string} type which kind of code should be generated
* @property {SourceType} type which kind of code should be generated
* @property {() => CodeGenerationResultData=} getData get access to the code generation data

@@ -58,3 +61,3 @@ */

/**
* @param {Record<string, Generator>} map map of types
* @param {{ [key in SourceType]?: Generator }} map map of types
* @returns {ByTypeGenerator} generator by type

@@ -82,3 +85,3 @@ */

* @param {NormalModule} module the module
* @param {string=} type source type
* @param {SourceType=} type source type
* @returns {number} estimate size of the module

@@ -146,3 +149,3 @@ */

/**
* @param {Record<string, Generator>} map map of types
* @param {{ [key in SourceType]?: Generator }} map map of types
*/

@@ -152,3 +155,3 @@ constructor(map) {

this.map = map;
this._types = new Set(Object.keys(map));
this._types = /** @type {SourceTypes} */ (new Set(Object.keys(map)));
/** @type {GenerateErrorFn | undefined} */

@@ -168,6 +171,6 @@ this.generateError = generateError.bind(this);

* @param {NormalModule} module the module
* @param {string=} type source type
* @param {SourceType=} type source type
* @returns {number} estimate size of the module
*/
getSize(module, type = "javascript") {
getSize(module, type = JAVASCRIPT_TYPE) {
const t = type;

@@ -174,0 +177,0 @@ const generator = this.map[t];

@@ -288,3 +288,4 @@ // @ts-nocheck

currentUpdateApplyHandlers,
updatedModules
updatedModules,
update.css
);

@@ -291,0 +292,0 @@ return promises;

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

const ModuleFactory = require("../ModuleFactory");
const { JS_TYPES } = require("../ModuleSourceTypesConstants");
const { JAVASCRIPT_TYPES } = require("../ModuleSourceTypeConstants");
const { JAVASCRIPT_TYPE } = require("../ModuleSourceTypeConstants");
const {

@@ -212,3 +213,3 @@ WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY

getSourceTypes() {
return JS_TYPES;
return JAVASCRIPT_TYPES;
}

@@ -295,3 +296,3 @@

}
sources.set("javascript", new RawSource(source));
sources.set(JAVASCRIPT_TYPE, new RawSource(source));
return {

@@ -298,0 +299,0 @@ sources,

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

const WebpackError = require("./WebpackError");
const makeSerializable = require("./util/makeSerializable");
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
/**

@@ -26,14 +30,39 @@ * @template T

constructor(error, hook) {
super(error.message);
super(error ? error.message : undefined, error ? { cause: error } : {});
this.name = "HookWebpackError";
this.hook = hook;
this.error = error;
this.name = "HookWebpackError";
this.hideStack = true;
this.details = `caused by plugins in ${hook}\n${error.stack}`;
this.stack += `\n-- inner error --\n${error ? error.stack : ""}`;
this.details = `caused by plugins in ${hook}\n${error ? error.stack : ""}`;
}
this.stack += `\n-- inner error --\n${error.stack}`;
/**
* @param {ObjectSerializerContext} context context
*/
serialize(context) {
const { write } = context;
write(this.error);
write(this.hook);
super.serialize(context);
}
/**
* @param {ObjectDeserializerContext} context context
*/
deserialize(context) {
const { read } = context;
this.error = read();
this.hook = read();
super.deserialize(context);
}
}
makeSerializable(HookWebpackError, "webpack/lib/HookWebpackError");
module.exports = HookWebpackError;

@@ -40,0 +69,0 @@

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

const WebpackError = require("./WebpackError");
const { chunkHasCss } = require("./css/CssModulesPlugin");
const ConstDependency = require("./dependencies/ConstDependency");

@@ -821,2 +822,3 @@ const ImportMetaHotAcceptDependency = require("./dependencies/ImportMetaHotAcceptDependency");

] of hotUpdateMainContentByFilename) {
/** @type {{c: ChunkId[], r: ChunkId[], m: ModuleId[], css?: {r: ChunkId[]}}} */
const hotUpdateMainJson = {

@@ -838,2 +840,22 @@ c: [...updatedChunkIds],

// Build CSS removed chunks list (chunks in updatedChunkIds that no longer have CSS)
/** @type {ChunkId[]} */
const cssRemovedChunkIds = [];
if (compilation.options.experiments.css) {
for (const chunkId of updatedChunkIds) {
for (const /** @type {Chunk} */ chunk of compilation.chunks) {
if (chunk.id === chunkId) {
if (!chunkHasCss(chunk, chunkGraph)) {
cssRemovedChunkIds.push(chunkId);
}
break;
}
}
}
}
if (cssRemovedChunkIds.length > 0) {
hotUpdateMainJson.css = { r: cssRemovedChunkIds };
}
const source = new RawSource(

@@ -840,0 +862,0 @@ (filename.endsWith(".json") ? "" : "export default ") +

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

/** @typedef {Set<string>} UsedModuleIds */
/**
* @param {Compilation} compilation the compilation
* @param {((module: Module) => boolean)=} filter filter modules
* @returns {[Set<string>, Module[]]} used module ids as strings and modules without id matching the filter
* @returns {[UsedModuleIds, Module[]]} used module ids as strings and modules without id matching the filter
*/

@@ -236,3 +238,3 @@ const getUsedModuleIdsAndModules = (compilation, filter) => {

/** @type {Set<string>} */
/** @type {UsedModuleIds} */
const usedIds = new Set();

@@ -263,8 +265,10 @@ if (compilation.usedModuleIds) {

/** @typedef {Set<string>} UsedChunkIds */
/**
* @param {Compilation} compilation the compilation
* @returns {Set<string>} used chunk ids as strings
* @returns {UsedChunkIds} used chunk ids as strings
*/
const getUsedChunkIds = (compilation) => {
/** @type {Set<string>} */
/** @type {UsedChunkIds} */
const usedIds = new Set();

@@ -305,3 +309,8 @@ if (compilation.usedChunkIds) {

) => {
/** @type {Map<string, T[]>} */
/**
* @template T
* @typedef {Map<string, T[]>} MapToItem
*/
/** @type {MapToItem<T>} */
const nameToItems = new Map();

@@ -314,3 +323,3 @@

/** @type {Map<string, T[]>} */
/** @type {MapToItem<T>} */
const nameToItems2 = new Map();

@@ -410,3 +419,3 @@

/**
* @param {Set<string>} usedIds used ids
* @param {UsedModuleIds} usedIds used ids
* @param {Iterable<Module>} modules the modules

@@ -413,0 +422,0 @@ * @param {Compilation} compilation the compilation

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

/** @type {Set<Entrypoint>} */
const groups = new Set([]);
const groups = new Set();
for (const group of queue) {

@@ -25,0 +25,0 @@ if (group !== entrypoint) {

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

const InitFragment = require("../InitFragment");
const { JS_TYPES } = require("../ModuleSourceTypesConstants");
const { JAVASCRIPT_TYPES } = require("../ModuleSourceTypeConstants");
const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibilityDependency");

@@ -25,2 +25,3 @@

/** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
/** @typedef {import("../Module").SourceType} SourceType */
/** @typedef {import("../Module").SourceTypes} SourceTypes */

@@ -64,3 +65,3 @@ /** @typedef {import("../NormalModule")} NormalModule */

getTypes(module) {
return JS_TYPES;
return JAVASCRIPT_TYPES;
}

@@ -70,3 +71,3 @@

* @param {NormalModule} module the module
* @param {string=} type source type
* @param {SourceType=} type source type
* @returns {number} estimate size of the module

@@ -73,0 +74,0 @@ */

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

const InitFragment = require("../InitFragment");
const { JAVASCRIPT_TYPE } = require("../ModuleSourceTypeConstants");
const {

@@ -83,3 +84,3 @@ JAVASCRIPT_MODULE_TYPE_AUTO,

return Boolean(
chunkGraph.getChunkModulesIterableBySourceType(chunk, "javascript")
chunkGraph.getChunkModulesIterableBySourceType(chunk, JAVASCRIPT_TYPE)
);

@@ -104,3 +105,3 @@ };

return Boolean(
chunkGraph.getChunkModulesIterableBySourceType(chunk, "javascript")
chunkGraph.getChunkModulesIterableBySourceType(chunk, JAVASCRIPT_TYPE)
);

@@ -187,3 +188,3 @@ };

* @property {boolean | undefined} strictMode rendering in strict context
* @property {boolean } inlined inlined
* @property {boolean} inlined inlined
* @property {boolean=} inlinedInIIFE the inlined entry module is wrapped in an IIFE

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

* @property {boolean=} inlinedInIIFE the inlined entry module is wrapped in an IIFE, existing only when `factory` is set to false
* @property {boolean=} renderInObject render module in object container
*/

@@ -284,3 +286,3 @@

this.options = options;
/** @type {WeakMap<Source, { source: Source, needModule:boolean, needExports: boolean, needRequire: boolean, needThisAsExports: boolean, needStrict: boolean | undefined }>} */
/** @type {WeakMap<Source, { source: Source, needModule:boolean, needExports: boolean, needRequire: boolean, needThisAsExports: boolean, needStrict: boolean | undefined, renderShorthand: boolean }>} */
this._moduleFactoryCache = new WeakMap();

@@ -496,3 +498,3 @@ }

chunk,
"javascript"
JAVASCRIPT_TYPE
);

@@ -537,3 +539,4 @@ if (modules) {

compilation.hooks.executeModule.tap(PLUGIN_NAME, (options, context) => {
const source = options.codeGenerationResult.sources.get("javascript");
const source =
options.codeGenerationResult.sources.get(JAVASCRIPT_TYPE);
if (source === undefined) return;

@@ -626,7 +629,8 @@ const { module } = options;

strictMode,
factory
factory,
renderInObject
} = renderContext;
try {
const codeGenResult = codeGenerationResults.get(module, chunk.runtime);
const moduleSource = codeGenResult.sources.get("javascript");
const moduleSource = codeGenResult.sources.get(JAVASCRIPT_TYPE);
if (!moduleSource) return null;

@@ -666,2 +670,4 @@ if (codeGenResult.data !== undefined) {

);
const renderShorthand =
renderInObject === true && runtimeTemplate.supportsMethodShorthand();
let source;

@@ -674,3 +680,4 @@ if (

cacheEntry.needThisAsExports === needThisAsExports &&
cacheEntry.needStrict === needStrict
cacheEntry.needStrict === needStrict &&
cacheEntry.renderShorthand === renderShorthand
) {

@@ -696,3 +703,10 @@ source = cacheEntry.source;

if (needRequire) args.push(RuntimeGlobals.require);
if (!needThisAsExports && runtimeTemplate.supportsArrowFunction()) {
if (renderShorthand) {
// we can optimize function to methodShorthand if render module factory in object
factorySource.add(`(${args.join(", ")}) {\n\n`);
} else if (
!needThisAsExports &&
runtimeTemplate.supportsArrowFunction()
) {
factorySource.add(`/***/ ((${args.join(", ")}) => {\n\n`);

@@ -702,2 +716,3 @@ } else {

}
if (needStrict) {

@@ -707,3 +722,3 @@ factorySource.add('"use strict";\n');

factorySource.add(moduleSourcePostContent);
factorySource.add("\n\n/***/ })");
factorySource.add(`\n\n/***/ }${renderShorthand ? "" : ")"}`);
source = new CachedSource(factorySource);

@@ -716,3 +731,4 @@ this._moduleFactoryCache.set(moduleSourcePostContent, {

needThisAsExports,
needStrict
needStrict,
renderShorthand
});

@@ -752,3 +768,3 @@ }

chunk,
"javascript",
JAVASCRIPT_TYPE,
compareModulesByIdOrIdentifier(chunkGraph)

@@ -776,8 +792,11 @@ );

const moduleSources =
Template.renderChunkModules(chunkRenderContext, allModules, (module) =>
this.renderModule(
module,
{ ...chunkRenderContext, factory: true },
hooks
)
Template.renderChunkModules(
chunkRenderContext,
allModules,
(module, renderInObject) =>
this.renderModule(
module,
{ ...chunkRenderContext, factory: true, renderInObject },
hooks
)
) || new RawSource("{}");

@@ -838,3 +857,3 @@ let source = tryRunOrWebpackError(

chunk,
"javascript",
JAVASCRIPT_TYPE,
compareModulesByIdOrIdentifier(chunkGraph)

@@ -895,6 +914,6 @@ ) || [])

: allModules,
(module) =>
(module, renderInObject) =>
this.renderModule(
module,
{ ...chunkRenderContext, factory: true },
{ ...chunkRenderContext, factory: true, renderInObject },
hooks

@@ -1302,3 +1321,5 @@ ),

] of chunkGraph.getChunkEntryModulesWithChunkGroupIterable(chunk)) {
if (!chunkGraph.getModuleSourceTypes(entryModule).has("javascript")) {
if (
!chunkGraph.getModuleSourceTypes(entryModule).has(JAVASCRIPT_TYPE)
) {
i--;

@@ -1563,2 +1584,15 @@ continue;

"}",
// Add helpful error message in development mode when module is not found
...(outputOptions.pathinfo
? [
"// Check if module exists (development only)",
"if (__webpack_modules__[moduleId] === undefined) {",
Template.indent([
'var e = new Error("Cannot find module \'" + moduleId + "\'");',
"e.code = 'MODULE_NOT_FOUND';",
"throw e;"
]),
"}"
]
: []),
"// Create a new module (and put it into the cache)",

@@ -1676,3 +1710,2 @@ "var module = __webpack_module_cache__[moduleId] = {",

const nonInlinedModuleThroughIdentifiers = new Set();
/** @type {Map<Module, Source>} */

@@ -1679,0 +1712,0 @@ for (const m of allModules) {

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

const Generator = require("../Generator");
const { JS_TYPES } = require("../ModuleSourceTypesConstants");
const { JAVASCRIPT_TYPES } = require("../ModuleSourceTypeConstants");
const RuntimeGlobals = require("../RuntimeGlobals");

@@ -21,2 +21,3 @@

/** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
/** @typedef {import("../Module").SourceType} SourceType */
/** @typedef {import("../Module").SourceTypes} SourceTypes */

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

* @param {JsonValue} data Raw JSON data
* @returns {undefined|string} stringified data
* @returns {undefined | string} stringified data
*/

@@ -138,3 +139,3 @@ const stringifySafe = (data) => {

getTypes(module) {
return JS_TYPES;
return JAVASCRIPT_TYPES;
}

@@ -144,3 +145,3 @@

* @param {NormalModule} module the module
* @param {string=} type source type
* @param {SourceType=} type source type
* @returns {number} estimate size of the module

@@ -147,0 +148,0 @@ */

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

throw new Error(
`Cannot parse JSON: ${/** @type {Error} */ (err).message}`
`Cannot parse JSON: ${/** @type {Error} */ (err).message}`,
{ cause: err }
);

@@ -60,0 +61,0 @@ }

@@ -311,3 +311,3 @@ /*

* @param {ModuleRenderContext} renderContext render context
* @param {Omit<LibraryContext<T>, 'options'>} libraryContext context
* @param {Omit<LibraryContext<T>, "options">} libraryContext context
* @returns {Source} source with library export

@@ -314,0 +314,0 @@ */

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

/** @typedef {import("../util/Hash")} Hash */
/** @template T @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T> */
/**
* @template T
* @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T>
*/

@@ -23,0 +26,0 @@ /**

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

/** @typedef {import("../javascript/JavascriptModulesPlugin").StartupRenderContext} StartupRenderContext */
/** @template T @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T> */
/**
* @template T
* @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T>
*/

@@ -26,0 +29,0 @@ /**

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

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

@@ -73,3 +74,24 @@ /** @typedef {import("../javascript/JavascriptModulesPlugin").StartupRenderContext} StartupRenderContext */

ConcatenatedModule.getCompilationHooks(compilation);
onDemandExportsGeneration.tap(PLUGIN_NAME, (_module) => true);
onDemandExportsGeneration.tap(
PLUGIN_NAME,
(module, runtimes, source, finalName) => {
/** @type {BuildMeta} */
const buildMeta = module.buildMeta || (module.buildMeta = {});
const exportsSourceByRuntime =
buildMeta.exportsSourceByRuntime ||
(buildMeta.exportsSourceByRuntime = new Map());
const exportsFinalNameByRuntime =
buildMeta.exportsFinalNameByRuntime ||
(buildMeta.exportsFinalNameByRuntime = new Map());
for (const runtime of runtimes) {
exportsSourceByRuntime.set(runtime, source);
exportsFinalNameByRuntime.set(runtime, finalName);
}
return true;
}
);
});

@@ -157,6 +179,12 @@ }

: moduleGraph.getExportsInfo(module).orderedExports;
const exportsFinalNameByRuntime =
(module.buildMeta &&
module.buildMeta.exportsFinalNameByRuntime &&
module.buildMeta.exportsFinalNameByRuntime.get(chunk.runtime)) ||
{};
const definitions =
inlined && !inlinedInIIFE
? (module.buildMeta && module.buildMeta.exportsFinalName) || {}
: {};
inlined && !inlinedInIIFE ? exportsFinalNameByRuntime : {};
/** @type {string[]} */

@@ -274,3 +302,3 @@ const shortHandedExports = [];

* @param {ModuleRenderContext} renderContext render context
* @param {Omit<LibraryContext<T>, 'options'>} libraryContext context
* @param {Omit<LibraryContext<T>, "options">} libraryContext context
* @returns {Source} source with library export

@@ -281,13 +309,13 @@ */

module,
{ factory, inlinedInIIFE },
{ factory, inlinedInIIFE, chunk },
libraryContext
) {
// Re-add `factoryExportsBinding` to the source
// when the module is rendered as a factory or treated as an inlined (startup) module but wrapped in an IIFE
if (
(inlinedInIIFE || factory) &&
const exportsSource =
module.buildMeta &&
module.buildMeta.factoryExportsBinding
) {
return new ConcatSource(module.buildMeta.factoryExportsBinding, source);
module.buildMeta.exportsSourceByRuntime &&
module.buildMeta.exportsSourceByRuntime.get(chunk.runtime);
// Re-add the module's exports source when rendered in factory or as an inlined startup module wrapped in an IIFE
if ((inlinedInIIFE || factory) && exportsSource) {
return new ConcatSource(exportsSource, source);
}

@@ -294,0 +322,0 @@ return source;

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

/** @typedef {import("../util/Hash")} Hash */
/** @template T @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T> */
/**
* @template T
* @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T>
*/

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

@@ -37,3 +37,3 @@ /*

/**
* @param {string|undefined} base the path prefix
* @param {string | undefined} base the path prefix
* @param {Accessor} accessor the accessor

@@ -40,0 +40,0 @@ * @param {string=} joinWith the element separator

@@ -38,4 +38,4 @@ /*

* @typedef {object} LoggerOptions
* @property {false|true|"none"|"error"|"warn"|"info"|"log"|"verbose"} level loglevel
* @property {FilterTypes|boolean} debug filter for debug logging
* @property {false | true | "none" | "error" | "warn" | "info" | "log" | "verbose"} level loglevel
* @property {FilterTypes | boolean} debug filter for debug logging
* @property {LoggerConsole} console the console to log to

@@ -42,0 +42,0 @@ */

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

/** @typedef {typeof LogType[keyof typeof LogType]} LogTypeEnum */
/** @typedef {Map<string | undefined, [number, number]>} TimersMap */

@@ -147,3 +148,3 @@ const LOG_SYMBOL = Symbol("webpack logger raw log method");

time(label) {
/** @type {Map<string | undefined, [number, number]>} */
/** @type {TimersMap} */
this[TIMERS_SYMBOL] = this[TIMERS_SYMBOL] || new Map();

@@ -174,3 +175,3 @@ this[TIMERS_SYMBOL].set(label, process.hrtime());

const time = process.hrtime(prev);
/** @type {Map<string | undefined, [number, number]>} */
/** @type {TimersMap} */
(this[TIMERS_SYMBOL]).delete(label);

@@ -191,5 +192,5 @@ this[LOG_SYMBOL](LogType.time, [label, ...time]);

const time = process.hrtime(prev);
/** @type {Map<string | undefined, [number, number]>} */
/** @type {TimersMap} */
(this[TIMERS_SYMBOL]).delete(label);
/** @type {Map<string | undefined, [number, number]>} */
/** @type {TimersMap} */
this[TIMERS_AGGREGATES_SYMBOL] =

@@ -196,0 +197,0 @@ this[TIMERS_AGGREGATES_SYMBOL] || new Map();

@@ -55,3 +55,3 @@ /*

/** @type {ManifestPluginOptions & Required<Omit<ManifestPluginOptions, "filter" | "generate">>} */
/** @type {ManifestPluginOptions & Required<Omit<ManifestPluginOptions, "filter" | "generate">>} */
this.options = {

@@ -58,0 +58,0 @@ filename: "manifest.json",

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

const ModuleGraph = require("./ModuleGraph");
const { JS_TYPES } = require("./ModuleSourceTypesConstants");
const {
JAVASCRIPT_TYPE,
UNKNOWN_TYPE
} = require("./ModuleSourceTypeConstants");
const { JAVASCRIPT_TYPES } = require("./ModuleSourceTypeConstants");
const RuntimeGlobals = require("./RuntimeGlobals");

@@ -28,2 +32,3 @@ const { first } = require("./util/SetHelpers");

/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
/** @typedef {import("./Compilation").FileSystemDependencies} FileSystemDependencies */
/** @typedef {import("./Compilation").UnsafeCacheData} UnsafeCacheData */

@@ -35,2 +40,3 @@ /** @typedef {import("./ConcatenationScope")} ConcatenationScope */

/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
/** @typedef {import("./ModuleSourceTypeConstants").AllTypes} AllTypes */
/** @typedef {import("./FileSystemInfo")} FileSystemInfo */

@@ -76,3 +82,5 @@ /** @typedef {import("./FileSystemInfo").Snapshot} Snapshot */

/** @typedef {ReadonlySet<string>} SourceTypes */
/** @typedef {AllTypes} KnownSourceType */
/** @typedef {KnownSourceType | string} SourceType */
/** @typedef {ReadonlySet<SourceType>} SourceTypes */

@@ -87,2 +95,3 @@ // TODO webpack 6: compilation will be required in CodeGenerationContext

* @property {RuntimeSpec} runtime the runtimes code should be generated for
* @property {RuntimeSpec[]} runtimes all runtimes code should be generated for
* @property {ConcatenationScope=} concatenationScope when in concatenated module, information about other concatenated modules

@@ -111,3 +120,3 @@ * @property {CodeGenerationResults | undefined} codeGenerationResults code generation results of other modules (need to have a codeGenerationDependency to use that)

* @typedef {object} CodeGenerationResult
* @property {Map<string, Source>} sources the resulting sources for all source types
* @property {Map<SourceType, Source>} sources the resulting sources for all source types
* @property {CodeGenerationResultData=} data the resulting data for all source types

@@ -135,8 +144,6 @@ * @property {ReadOnlyRuntimeRequirements | null} runtimeRequirements the runtime requirements

* @property {Record<string, string>=} jsIncompatibleExports
* @property {Record<string, string>=} exportsFinalName
* @property {string=} factoryExportsBinding
* @property {Map<RuntimeSpec, Record<string, string>>=} exportsFinalNameByRuntime
* @property {Map<RuntimeSpec, string>=} exportsSourceByRuntime
*/
/** @typedef {LazySet<string>} FileSystemDependencies */
/**

@@ -198,3 +205,4 @@ * @typedef {object} KnownBuildInfo

const DEFAULT_TYPES_UNKNOWN = new Set(["unknown"]);
/** @type {SourceTypes} */
const DEFAULT_TYPES_UNKNOWN = new Set([UNKNOWN_TYPE]);

@@ -850,4 +858,4 @@ const deprecatedNeedRebuild = util.deprecate(

* @deprecated Use needBuild instead
* @param {Map<string, number|null>} fileTimestamps timestamps of files
* @param {Map<string, number|null>} contextTimestamps timestamps of directories
* @param {Map<string, number | null>} fileTimestamps timestamps of files
* @param {Map<string, number | null>} contextTimestamps timestamps of directories
* @returns {boolean} true, if the module needs a rebuild

@@ -940,3 +948,3 @@ */

}
return JS_TYPES;
return JAVASCRIPT_TYPES;
}

@@ -949,6 +957,6 @@

* @param {RuntimeTemplate} runtimeTemplate the runtime template
* @param {string=} type the type of source that should be generated
* @param {SourceType=} type the type of source that should be generated
* @returns {Source} generated source
*/
source(dependencyTemplates, runtimeTemplate, type = "javascript") {
source(dependencyTemplates, runtimeTemplate, type = JAVASCRIPT_TYPE) {
if (this.codeGeneration === Module.prototype.codeGeneration) {

@@ -971,2 +979,3 @@ const AbstractMethodError = require("./AbstractMethodError");

runtime: undefined,
runtimes: [],
codeGenerationResults: undefined

@@ -979,3 +988,3 @@ };

? sources.get(type)
: sources.get(/** @type {string} */ (first(this.getSourceTypes())))
: sources.get(/** @type {SourceType} */ (first(this.getSourceTypes())))
);

@@ -1035,3 +1044,3 @@ }

for (const type of this.getSourceTypes()) {
if (type !== "unknown") {
if (type !== UNKNOWN_TYPE) {
sources.set(

@@ -1038,0 +1047,0 @@ type,

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

* @param {string | ErrorWithHideStack} err error thrown
* @param {{from?: string|null}} info additional info
* @param {{from?: string | null}} info additional info
*/

@@ -23,0 +23,0 @@ constructor(err, { from = null } = {}) {

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

* @param {Error} err error thrown
* @param {{from?: string|null}} info additional info
* @param {{from?: string | null}} info additional info
*/

@@ -21,0 +21,0 @@ constructor(err, { from = null } = {}) {

@@ -284,3 +284,3 @@ /*

* @param {(duplicateItem: T, duplicateItemIndex: number, numberOfTimesReplaced: number) => T} fn callback function to generate new values for the duplicate items
* @param {(firstElement:T, nextElement:T) => -1 | 0 | 1=} comparator optional comparator function to sort the duplicate items
* @param {(firstElement: T, nextElement: T) => -1 | 0 | 1=} comparator optional comparator function to sort the duplicate items
* @returns {T[]} the array with duplicates replaced

@@ -287,0 +287,0 @@ * @example

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

this._dependencySourceOrderMap = new WeakMap();
/**
* @type {Set<Module>}
* @private
*/
this._modulesNeedingSort = new Set();
}

@@ -309,5 +315,4 @@

const currentSourceOrder =
/** @type { HarmonyImportSideEffectDependency | HarmonyImportSpecifierDependency} */ (
dependency
).sourceOrder;
/** @type {HarmonyImportSideEffectDependency | HarmonyImportSpecifierDependency} */
(dependency).sourceOrder;

@@ -318,5 +323,4 @@ // lib/index.js (reexport)

const originSourceOrder =
/** @type { HarmonyImportSideEffectDependency | HarmonyImportSpecifierDependency} */ (
originDependency
).sourceOrder;
/** @type {HarmonyImportSideEffectDependency | HarmonyImportSpecifierDependency} */
(originDependency).sourceOrder;
if (

@@ -336,13 +340,24 @@ typeof currentSourceOrder === "number" &&

// Save for later batch sorting
this._modulesNeedingSort.add(parentModule);
}
}
/**
* @returns {void}
*/
finishUpdateParent() {
if (this._modulesNeedingSort.size === 0) {
return;
}
for (const mod of this._modulesNeedingSort) {
// If dependencies like HarmonyImportSideEffectDependency and HarmonyImportSpecifierDependency have a SourceOrder,
// we sort based on it; otherwise, we preserve the original order.
sortWithSourceOrder(
parentModule.dependencies,
this._dependencySourceOrderMap
mod.dependencies,
this._dependencySourceOrderMap,
(dep, index) => this.setParentDependenciesBlockIndex(dep, index)
);
for (const [index, dep] of parentModule.dependencies.entries()) {
this.setParentDependenciesBlockIndex(dep, index);
}
}
this._modulesNeedingSort.clear();
}

@@ -349,0 +364,0 @@

@@ -55,4 +55,4 @@ /*

/**
* @param {Module|null} originModule the referencing module
* @param {Dependency|null} dependency the referencing dependency
* @param {Module | null} originModule the referencing module
* @param {Dependency | null} dependency the referencing dependency
* @param {Module} module the referenced module

@@ -59,0 +59,0 @@ * @param {string=} explanation some extra detail

@@ -100,3 +100,3 @@ /*

* @type {Readonly<"asset/raw-data-url">}
* TODO: Document what this asset type is for. See css-loader tests for its usage.
* This is the module type used for the ignored asset module.
*/

@@ -114,3 +114,2 @@ const ASSET_MODULE_TYPE_RAW_DATA_URL = "asset/raw-data-url";

* This is the module type used for the ModuleFederation feature's FallbackModule class.
* TODO: Document this better.
*/

@@ -122,3 +121,2 @@ const WEBPACK_MODULE_TYPE_FALLBACK = "fallback-module";

* This is the module type used for the ModuleFederation feature's RemoteModule class.
* TODO: Document this better.
*/

@@ -130,3 +128,2 @@ const WEBPACK_MODULE_TYPE_REMOTE = "remote-module";

* This is the module type used for the ModuleFederation feature's ProvideModule class.
* TODO: Document this better.
*/

@@ -133,0 +130,0 @@ const WEBPACK_MODULE_TYPE_PROVIDE = "provide-module";

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

* @param {Error} warning error thrown
* @param {{from?: string|null}} info additional info
* @param {{from?: string | null}} info additional info
*/

@@ -21,0 +21,0 @@ constructor(warning, { from = null } = {}) {

@@ -248,19 +248,10 @@ /*

.tap(PLUGIN_NAME, (expr) => {
// We use `CachedConstDependency` because of `eval` devtool, there is no `import.meta` inside `eval()`
const { importMetaName, environment, module } =
compilation.outputOptions;
if (
module &&
importMetaName === "import.meta" &&
(expressionName === "import.meta.filename" ||
expressionName === "import.meta.dirname") &&
environment.importMetaDirnameAndFilename
) {
return true;
}
// 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 =
if (
environment.importMetaDirnameAndFilename ||

@@ -270,20 +261,30 @@ (compiler.platform.web === 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}__`
);
) {
const dep = new CachedConstDependency(
`${importMetaName}.${property}`,
/** @type {Range} */
(expr.range),
`__webpack_${property}__`,
CachedConstDependency.PLACE_CHUNK
);
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
parser.state.module.addPresentationalDependency(dep);
return;
}
const dep = new ExternalModuleDependency(
"url",
[
{
name: "fileURLToPath",
value: URL_MODULE_CONSTANT_FUNCTION_NAME
}
],
undefined,
`${URL_MODULE_CONSTANT_FUNCTION_NAME}(${value()})`,
/** @type {Range} */ (expr.range),
`__webpack_${property}__`,
ExternalModuleDependency.PLACE_CHUNK
);
dep.loc = /** @type {DependencyLocation} */ (expr.loc);

@@ -305,16 +306,21 @@ parser.state.module.addPresentationalDependency(dep);

if (
module &&
importMetaName === "import.meta" &&
(expressionName === "import.meta.filename" ||
expressionName === "import.meta.dirname") &&
environment.importMetaDirnameAndFilename
environment.importMetaDirnameAndFilename ||
(compiler.platform.web === null &&
compiler.platform.node === null &&
module)
) {
return `${property}: ${importMetaName}.${property},`;
const dep = new CachedConstDependency(
`${importMetaName}.${property}`,
null,
`__webpack_${property}__`,
CachedConstDependency.PLACE_CHUNK
);
dep.loc = /** @type {DependencyLocation} */ (
usingProperty.loc
);
parser.state.module.addPresentationalDependency(dep);
return `${property}: __webpack_${property}__,`;
}
if (environment.importMetaDirnameAndFilename) {
return `${property}: ${importMetaName}.${property},`;
}
const dep = new ExternalModuleInitFragmentDependency(
const dep = new ExternalModuleDependency(
"url",

@@ -327,3 +333,7 @@ [

],
undefined
undefined,
`${URL_MODULE_CONSTANT_FUNCTION_NAME}(${value()})`,
null,
`__webpack_${property}__`,
ExternalModuleDependency.PLACE_CHUNK
);

@@ -334,3 +344,3 @@

return `${property}: ${URL_MODULE_CONSTANT_FUNCTION_NAME}(${value()}),`;
return `${property}: __webpack_${property}__,`;
}

@@ -337,0 +347,0 @@ });

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

/** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */
/** @typedef {import("./Generator").SourceTypes} SourceTypes */
/** @typedef {import("./Module").SourceType} SourceType */
/** @typedef {import("./Module").SourceTypes} SourceTypes */
/** @typedef {import("./Module").UnsafeCacheData} UnsafeCacheData */

@@ -398,3 +399,3 @@ /** @typedef {import("./ModuleGraph")} ModuleGraph */

* @private
* @type {Map<string | undefined, number> | undefined}
* @type {Map<undefined | SourceType, number> | undefined}
*/

@@ -704,3 +705,4 @@ this._sourceSizes = undefined;

throw new Error(
`Cannot parse string options: ${/** @type {Error} */ (err).message}`
`Cannot parse string options: ${/** @type {Error} */ (err).message}`,
{ cause: err }
);

@@ -1313,3 +1315,3 @@ }

/**
* @param {LazySet<string>} deps deps
* @param {FileSystemDependencies} deps deps
*/

@@ -1316,0 +1318,0 @@ const checkDependencies = (deps) => {

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

/** @typedef {import("../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
/** @typedef {import("./Compilation").FileSystemDependencies} FileSystemDependencies */
/** @typedef {import("./Generator")} Generator */

@@ -65,3 +66,3 @@ /** @typedef {import("./ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */

/** @typedef {Pick<RuleSetRule, 'type' | 'sideEffects' | 'parser' | 'generator' | 'resolve' | 'layer' | 'extractSourceMap'>} ModuleSettings */
/** @typedef {Pick<RuleSetRule, "type" | "sideEffects" | "parser" | "generator" | "resolve" | "layer" | "extractSourceMap">} ModuleSettings */
/** @typedef {Partial<NormalModuleCreateData & { settings: ModuleSettings }>} CreateData */

@@ -79,5 +80,5 @@

* @property {CreateData} createData
* @property {LazySet<string>} fileDependencies
* @property {LazySet<string>} missingDependencies
* @property {LazySet<string>} contextDependencies
* @property {FileSystemDependencies} fileDependencies
* @property {FileSystemDependencies} missingDependencies
* @property {FileSystemDependencies} contextDependencies
* @property {Module=} ignoredModule

@@ -302,10 +303,6 @@ * @property {boolean} cacheable allow to use the unsafe cache

/** @typedef {import("../declarations/WebpackOptions").CssParserOptions} CssParserOptions */
/** @typedef {import("../declarations/WebpackOptions").CssAutoParserOptions} CssAutoParserOptions */
/** @typedef {import("../declarations/WebpackOptions").CssGlobalParserOptions} CssGlobalParserOptions */
/** @typedef {import("../declarations/WebpackOptions").CssModuleParserOptions} CssModuleParserOptions */
/** @typedef {import("./css/CssGenerator")} CssGenerator */
/** @typedef {import("../declarations/WebpackOptions").CssGeneratorOptions} CssGeneratorOptions */
/** @typedef {import("../declarations/WebpackOptions").CssGlobalGeneratorOptions} CssGlobalGeneratorOptions */
/** @typedef {import("../declarations/WebpackOptions").CssModuleGeneratorOptions} CssModuleGeneratorOptions */
/** @typedef {import("../declarations/WebpackOptions").CssAutoGeneratorOptions} CssAutoGeneratorOptions */

@@ -326,5 +323,5 @@ /**

* [CSS_MODULE_TYPE, CssParser, CssParserOptions, CssGenerator, CssGeneratorOptions],
* [CSS_MODULE_TYPE_AUTO, CssParser, CssAutoParserOptions, CssGenerator, CssAutoGeneratorOptions],
* [CSS_MODULE_TYPE_AUTO, CssParser, CssModuleParserOptions, CssGenerator, CssModuleGeneratorOptions],
* [CSS_MODULE_TYPE_MODULE, CssParser, CssModuleParserOptions, CssGenerator, CssModuleGeneratorOptions],
* [CSS_MODULE_TYPE_GLOBAL, CssParser, CssGlobalParserOptions, CssGenerator, CssGlobalGeneratorOptions],
* [CSS_MODULE_TYPE_GLOBAL, CssParser, CssModuleParserOptions, CssGenerator, CssModuleGeneratorOptions],
* [string, Parser, ParserOptions, Generator, GeneratorOptions],

@@ -331,0 +328,0 @@ * ]} ParsersAndGeneratorsByTypes

@@ -11,3 +11,3 @@ /*

const ModuleGraph = require("../ModuleGraph");
const { JS_TYPE } = require("../ModuleSourceTypesConstants");
const { JAVASCRIPT_TYPE } = require("../ModuleSourceTypeConstants");
const { STAGE_DEFAULT } = require("../OptimizationStages");

@@ -464,3 +464,3 @@ const HarmonyImportDependency = require("../dependencies/HarmonyImportDependency");

const newSourceTypes = new Set(sourceTypes);
newSourceTypes.delete(JS_TYPE);
newSourceTypes.delete(JAVASCRIPT_TYPE);
chunkGraph.setChunkModuleSourceTypes(

@@ -870,2 +870,3 @@ chunk,

/** @typedef {Module | ((requestShortener: RequestShortener) => string)} Problem */
/** @typedef {Map<Module, Problem>} Warnings */

@@ -883,3 +884,3 @@ class ConcatConfiguration {

this.modules.add(rootModule);
/** @type {Map<Module, Problem>} */
/** @type {Warnings} */
this.warnings = new Map();

@@ -916,3 +917,3 @@ }

/**
* @returns {Map<Module, Problem>} warnings
* @returns {Warnings} warnings
*/

@@ -919,0 +920,0 @@ getWarningsSorted() {

@@ -48,3 +48,3 @@ /*

* @param {string} glob the pattern
* @param {Map<string, RegExp>} cache the glob to RegExp cache
* @param {CacheItem} cache the glob to RegExp cache
* @returns {RegExp} a regular expression

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

}
moduleGraph.finishUpdateParent();
logger.timeEnd("update dependencies");

@@ -396,3 +397,3 @@ }

* @param {SideEffectsFlagValue} flagValue the flag value
* @param {Map<string, RegExp>} cache cache for glob to regexp
* @param {CacheItem} cache cache for glob to regexp
* @returns {boolean | undefined} true, when the module has side effects, undefined or false when not

@@ -399,0 +400,0 @@ */

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

/** @typedef {import("../Module")} Module */
/** @typedef {import("../Module").SourceType} SourceType */
/** @typedef {import("../ModuleGraph")} ModuleGraph */

@@ -46,13 +47,17 @@ /** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */

/** @typedef {number} Priority */
/** @typedef {number} Size */
/** @typedef {number} CountOfChunk */
/** @typedef {number} CountOfRequest */
/**
* @callback CombineSizeFunction
* @param {number} a
* @param {number} b
* @returns {number}
* @param {Size} a
* @param {Size} b
* @returns {Size}
*/
/** @typedef {string} SourceType */
/** @typedef {SourceType[]} SourceTypes */
/** @typedef {SourceType[]} DefaultSizeTypes */
/** @typedef {Record<SourceType, number>} SplitChunksSizes */
/** @typedef {Record<SourceType, Size>} SplitChunksSizes */

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

* @property {string} key
* @property {number=} priority
* @property {Priority=} priority
* @property {GetNameFn=} getName

@@ -73,5 +78,5 @@ * @property {ChunkFilterFn=} chunksFilter

* @property {SplitChunksSizes} maxInitialSize
* @property {number=} minChunks
* @property {number=} maxAsyncRequests
* @property {number=} maxInitialRequests
* @property {CountOfChunk=} minChunks
* @property {CountOfRequest=} maxAsyncRequests
* @property {CountOfRequest=} maxInitialRequests
* @property {TemplatePath=} filename

@@ -87,3 +92,3 @@ * @property {string=} idHint

* @property {string} key
* @property {number} priority
* @property {Priority} priority
* @property {GetNameFn=} getName

@@ -97,5 +102,5 @@ * @property {ChunkFilterFn} chunksFilter

* @property {SplitChunksSizes} maxInitialSize
* @property {number} minChunks
* @property {number} maxAsyncRequests
* @property {number} maxInitialRequests
* @property {CountOfChunk} minChunks
* @property {CountOfRequest} maxAsyncRequests
* @property {CountOfRequest} maxInitialRequests
* @property {TemplatePath=} filename

@@ -152,5 +157,5 @@ * @property {string} idHint

* @property {SplitChunksSizes} maxAsyncSize
* @property {number} minChunks
* @property {number} maxAsyncRequests
* @property {number} maxInitialRequests
* @property {CountOfChunk} minChunks
* @property {CountOfRequest} maxAsyncRequests
* @property {CountOfRequest} maxInitialRequests
* @property {boolean} hidePathInfo

@@ -165,2 +170,4 @@ * @property {TemplatePath=} filename

/** @typedef {Set<Chunk>} ChunkSet */
/**

@@ -172,5 +179,5 @@ * @typedef {object} ChunksInfoItem

* @property {string=} name
* @property {Record<SourceType, number>} sizes
* @property {Set<Chunk>} chunks
* @property {Set<Chunk>} reusableChunks
* @property {SplitChunksSizes} sizes
* @property {ChunkSet} chunks
* @property {ChunkSet} reusableChunks
* @property {Set<bigint | Chunk>} chunksKeys

@@ -207,3 +214,3 @@ */

* @param {Chunk} chunk the chunk
* @returns {number} the number of requests
* @returns {CountOfRequest} the number of requests
*/

@@ -222,3 +229,3 @@ const getRequests = (chunk) => {

* @param {T} obj obj an object
* @param {function(T[keyof T], keyof T): T[keyof T]} fn fn
* @param {(obj: T[keyof T], key: keyof T) => T[keyof T]} fn fn
* @returns {T} result

@@ -307,3 +314,3 @@ */

if (typeof value === "number") {
/** @type {Record<string, number>} */
/** @type {SplitChunksSizes} */
const o = {};

@@ -336,3 +343,3 @@ for (const sizeType of defaultSizeTypes) o[sizeType] = value;

const hasNonZeroSizes = (sizes) => {
for (const key of Object.keys(sizes)) {
for (const key of /** @type {SourceType[]} */ (Object.keys(sizes))) {
if (sizes[key] > 0) return true;

@@ -350,4 +357,4 @@ }

const combineSizes = (a, b, combine) => {
const aKeys = new Set(Object.keys(a));
const bKeys = new Set(Object.keys(b));
const aKeys = /** @type {Set<SourceType>} */ (new Set(Object.keys(a)));
const bKeys = /** @type {Set<SourceType>} */ (new Set(Object.keys(b)));
/** @type {SplitChunksSizes} */

@@ -372,3 +379,3 @@ const result = {};

const checkMinSize = (sizes, minSize) => {
for (const key of Object.keys(minSize)) {
for (const key of /** @type {SourceType[]} */ (Object.keys(minSize))) {
const size = sizes[key];

@@ -384,7 +391,9 @@ if (size === undefined || size === 0) continue;

* @param {SplitChunksSizes} minSizeReduction the min sizes
* @param {number} chunkCount number of chunks
* @param {CountOfChunk} chunkCount number of chunks
* @returns {boolean} true if there are sizes and all existing sizes are at least `minSizeReduction`
*/
const checkMinSizeReduction = (sizes, minSizeReduction, chunkCount) => {
for (const key of Object.keys(minSizeReduction)) {
for (const key of /** @type {SourceType[]} */ (
Object.keys(minSizeReduction)
)) {
const size = sizes[key];

@@ -403,4 +412,5 @@ if (size === undefined || size === 0) continue;

const getViolatingMinSizes = (sizes, minSize) => {
/** @type {SourceTypes | undefined} */
let list;
for (const key of Object.keys(minSize)) {
for (const key of /** @type {SourceType[]} */ (Object.keys(minSize))) {
const size = sizes[key];

@@ -418,7 +428,7 @@ if (size === undefined || size === 0) continue;

* @param {SplitChunksSizes} sizes the sizes
* @returns {number} the total size
* @returns {Size} the total size
*/
const totalSize = (sizes) => {
let size = 0;
for (const key of Object.keys(sizes)) {
for (const key of /** @type {SourceType[]} */ (Object.keys(sizes))) {
size += sizes[key];

@@ -908,5 +918,5 @@ }

const getChunkSetsInGraph = memoize(() => {
/** @type {Map<bigint, Set<Chunk>>} */
/** @type {Map<bigint, ChunkSet>} */
const chunkSetsInGraph = new Map();
/** @type {Set<Chunk>} */
/** @type {ChunkSet} */
const singleChunkSets = new Set();

@@ -949,6 +959,8 @@ for (const module of compilation.modules) {

/** @typedef {Map<bigint | Chunk, ChunkSet>} ChunkSetsInGraph */
const getExportsChunkSetsInGraph = memoize(() => {
/** @type {Map<bigint | Chunk, Set<Chunk>>} */
/** @type {ChunkSetsInGraph} */
const chunkSetsInGraph = new Map();
/** @type {Set<Chunk>} */
/** @type {ChunkSet} */
const singleChunkSets = new Set();

@@ -972,3 +984,3 @@ for (const module of compilation.modules) {

/** @typedef {Map<number, Set<Chunk>[]>} ChunkSetsByCount */
/** @typedef {Map<CountOfChunk, ChunkSet[]>} ChunkSetsByCount */

@@ -979,3 +991,3 @@ // group these set of chunks by count

/**
* @param {IterableIterator<Set<Chunk>>} chunkSets set of sets of chunks
* @param {IterableIterator<ChunkSet>} chunkSets set of sets of chunks
* @returns {ChunkSetsByCount} map of sets of chunks by count

@@ -1008,9 +1020,9 @@ */

/** @typedef {(Set<Chunk> | Chunk)[]} Combinations */
/** @typedef {(ChunkSet | Chunk)[]} Combinations */
// Create a list of possible combinations
/**
* @param {Map<bigint | Chunk, Set<Chunk>>} chunkSets chunk sets
* @param {Set<Chunk>} singleChunkSets single chunks sets
* @param {Map<number, Set<Chunk>[]>} chunkSetsByCount chunk sets by count
* @param {ChunkSetsInGraph} chunkSets chunk sets
* @param {ChunkSet} singleChunkSets single chunks sets
* @param {ChunkSetsByCount} chunkSetsByCount chunk sets by count
* @returns {(key: bigint | Chunk) => Combinations} combinations

@@ -1035,3 +1047,3 @@ */

const chunksSet =
/** @type {Set<Chunk>} */
/** @type {ChunkSet} */
(chunkSets.get(key));

@@ -1097,3 +1109,3 @@ /** @type {Combinations} */

/** @type {WeakMap<Set<Chunk> | Chunk, WeakMap<ChunkFilterFn, SelectedChunksResult>>} */
/** @type {WeakMap<ChunkSet | Chunk, WeakMap<ChunkFilterFn, SelectedChunksResult>>} */
const selectedChunksCacheByChunksSet = new WeakMap();

@@ -1104,3 +1116,3 @@

* It is cached for performance reasons
* @param {Set<Chunk> | Chunk} chunks list of chunks
* @param {ChunkSet | Chunk} chunks list of chunks
* @param {ChunkFilterFn} chunkFilter filter function for chunks

@@ -1298,3 +1310,3 @@ * @returns {SelectedChunksResult} list and key

getExportsChunkSetsInGraph();
/** @type {Set<Set<Chunk> | Chunk>} */
/** @type {Set<ChunkSet | Chunk>} */
const set = new Set();

@@ -1733,3 +1745,5 @@ const groupedByUsedExports =

}
for (const key of Object.keys(maxSize)) {
for (const key of /** @type {SourceType[]} */ (
Object.keys(maxSize)
)) {
const maxSizeValue = maxSize[key];

@@ -1736,0 +1750,0 @@ const minSizeValue = minSize[key];

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

/** @typedef {Record<string, EXPECTED_ANY> & ParserStateBase} ParserState */
/** @typedef {ParserStateBase & Record<string, EXPECTED_ANY>} ParserState */

@@ -26,0 +26,0 @@ class Parser {

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

const Module = require("./Module");
const { JS_TYPES } = require("./ModuleSourceTypesConstants");
const {
JAVASCRIPT_TYPE,
JAVASCRIPT_TYPES
} = require("./ModuleSourceTypeConstants");
const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");

@@ -53,3 +56,3 @@ const makeSerializable = require("./util/makeSerializable");

getSourceTypes() {
return JS_TYPES;
return JAVASCRIPT_TYPES;
}

@@ -127,7 +130,7 @@

sources.set(
"javascript",
JAVASCRIPT_TYPE,
new OriginalSource(this.sourceStr, this.identifier())
);
} else {
sources.set("javascript", new RawSource(this.sourceStr));
sources.set(JAVASCRIPT_TYPE, new RawSource(this.sourceStr));
}

@@ -134,0 +137,0 @@ return { sources, runtimeRequirements: this.runtimeRequirements };

@@ -85,3 +85,3 @@ /*

* @template {T[keyof T]} V
* @typedef {({ [P in keyof Required<T>]: Required<T>[P] extends V ? P : never })[keyof T]} KeysOfTypes
* @typedef {({ [key in keyof Required<T>]: Required<T>[key] extends V ? key : never })[keyof T]} KeysOfTypes
*/

@@ -88,0 +88,0 @@

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

/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Compilation").HashWithLengthFunction} HashWithLengthFunction */
/** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */

@@ -142,3 +143,3 @@

* @param {string} value string
* @returns {(length: number) => string} string to put in quotes with length
* @returns {HashWithLengthFunction} string to put in quotes with length
*/

@@ -235,3 +236,3 @@ const unquotedStringifyWithLength = (value) => (length) =>

* @param {(chunk: Chunk) => string | number} fn function from chunk to value
* @returns {(length: number) => string} function which generates code with static mapping of results of fn for including in quoted string for specific length
* @returns {HashWithLengthFunction} function which generates code with static mapping of results of fn for including in quoted string for specific length
*/

@@ -238,0 +239,0 @@ const mapExprWithLength = (fn) => (length) =>

@@ -11,3 +11,3 @@ /*

const Module = require("./Module");
const { RUNTIME_TYPES } = require("./ModuleSourceTypesConstants");
const { RUNTIME_TYPES } = require("./ModuleSourceTypeConstants");
const { WEBPACK_MODULE_TYPE_RUNTIME } = require("./ModuleTypeConstants");

@@ -14,0 +14,0 @@

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

supportsMethodShorthand() {
return this.outputOptions.environment.methodShorthand;
}
supportsArrowFunction() {

@@ -960,3 +964,3 @@ return this.outputOptions.environment.arrowFunction;

* @param {Module} options.originModule the origin module
* @param {boolean|undefined} options.asiSafe true, if location is safe for ASI, a bracket can be emitted
* @param {boolean | undefined} options.asiSafe true, if location is safe for ASI, a bracket can be emitted
* @param {boolean} options.isCall true, if expression will be called

@@ -963,0 +967,0 @@ * @param {boolean | null} options.callContext when false, call context will not be preserved

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

const MAX_REDIRECTS = 5;
/**

@@ -204,2 +206,18 @@ * @param {typeof import("http") | typeof import("https")} request request

/**
* Sanitize URL for inclusion in error messages
* @param {string} href URL string to sanitize
* @returns {string} sanitized URL text for logs/errors
*/
const sanitizeUrlForError = (href) => {
try {
const u = new URL(href);
return `${u.protocol}//${u.host}`;
} catch (_err) {
return String(href)
.slice(0, 200)
.replace(/[\r\n]/g, "");
}
};
class Lockfile {

@@ -322,3 +340,3 @@ constructor() {

* @param {FnWithKey<T, R>=} forceFn function for the second try
* @returns {(FnWithKey<T, R>) & { force: FnWithKey<T, R> }} cached function
* @returns {FnWithKey<T, R> & { force: FnWithKey<T, R> }} cached function
*/

@@ -643,7 +661,42 @@ const cachedWithKey = (fn, forceFn = fn) => {

/**
* @param {string} location Location header value (relative or absolute)
* @param {string} base current absolute URL
* @returns {string} absolute, validated redirect target
*/
const validateRedirectLocation = (location, base) => {
let nextUrl;
try {
nextUrl = new URL(location, base);
} catch (err) {
throw new Error(
`Invalid redirect URL: ${sanitizeUrlForError(location)}`,
{ cause: err }
);
}
if (nextUrl.protocol !== "http:" && nextUrl.protocol !== "https:") {
throw new Error(
`Redirected URL uses disallowed protocol: ${sanitizeUrlForError(nextUrl.href)}`
);
}
if (!isAllowed(nextUrl.href)) {
throw new Error(
`${nextUrl.href} doesn't match the allowedUris policy after redirect. These URIs are allowed:\n${allowedUris
.map((uri) => ` - ${uri}`)
.join("\n")}`
);
}
return nextUrl.href;
};
/**
* @param {string} url URL
* @param {string | null} integrity integrity
* @param {(err: Error | null, resolveContentResult?: ResolveContentResult) => void} callback callback
* @param {number=} redirectCount number of followed redirects
*/
const resolveContent = (url, integrity, callback) => {
const resolveContent = (
url,
integrity,
callback,
redirectCount = 0
) => {
/**

@@ -660,4 +713,14 @@ * @param {Error | null} err error

if ("location" in result) {
// Validate redirect target before following
let absolute;
try {
absolute = validateRedirectLocation(result.location, url);
} catch (err_) {
return callback(/** @type {Error} */ (err_));
}
if (redirectCount >= MAX_REDIRECTS) {
return callback(new Error("Too many redirects"));
}
return resolveContent(
result.location,
absolute,
integrity,

@@ -673,3 +736,4 @@ (err, innerResult) => {

});
}
},
redirectCount + 1
);

@@ -790,5 +854,12 @@ }

) {
const result = {
location: new URL(location, url).href
};
let absolute;
try {
absolute = validateRedirectLocation(location, url);
} catch (err) {
logger.log(
`GET ${url} [${res.statusCode}] -> ${String(location)} (rejected: ${/** @type {Error} */ (err).message})`
);
return callback(/** @type {Error} */ (err));
}
const result = { location: absolute };
if (

@@ -795,0 +866,0 @@ !cachedResult ||

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

/** @typedef {Error & { cause: unknown, errors: EXPECTED_ANY[] }} AggregateError */
/** @typedef {Error & { cause?: unknown, errors: EXPECTED_ANY[] }} AggregateError */

@@ -31,3 +31,2 @@ class AggregateErrorSerializer {

const errors = context.read();
// @ts-expect-error ES2018 doesn't `AggregateError`, but it can be used by developers
// eslint-disable-next-line n/no-unsupported-features/es-builtins, n/no-unsupported-features/es-syntax, unicorn/error-message

@@ -34,0 +33,0 @@ const err = new AggregateError(errors);

@@ -160,7 +160,5 @@ /*

// @ts-expect-error ES2018 doesn't `AggregateError`, but it can be used by developers
// eslint-disable-next-line n/no-unsupported-features/es-builtins, n/no-unsupported-features/es-syntax
if (typeof AggregateError !== "undefined") {
jsTypes.set(
// @ts-expect-error ES2018 doesn't `AggregateError`, but it can be used by developers
// eslint-disable-next-line n/no-unsupported-features/es-builtins, n/no-unsupported-features/es-syntax

@@ -167,0 +165,0 @@ AggregateError,

@@ -11,3 +11,3 @@ /*

/** @typedef {EXPECTED_ANY[]} SerializedType */
/** @typedef {{}} Context */
/** @typedef {EXPECTED_OBJECT} Context */

@@ -14,0 +14,0 @@ /**

@@ -11,3 +11,3 @@ /*

const Module = require("../Module");
const { CONSUME_SHARED_TYPES } = require("../ModuleSourceTypesConstants");
const { CONSUME_SHARED_TYPES } = require("../ModuleSourceTypeConstants");
const {

@@ -14,0 +14,0 @@ WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE

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

/** @type {Map<string, ConsumeOptions>} */
/** @typedef {Map<string, ConsumeOptions>} Consumes */
/** @type {Consumes} */
let unresolvedConsumes;
/** @type {Map<string, ConsumeOptions>} */
/** @type {Consumes} */
let resolvedConsumes;
/** @type {Map<string, ConsumeOptions>} */
/** @type {Consumes} */
let prefixedConsumes;

@@ -129,0 +131,0 @@ const promise = resolveMatchedConfigs(compilation, this._consumes).then(

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

const Module = require("../Module");
const { SHARED_INIT_TYPES } = require("../ModuleSourceTypesConstants");
const { SHARED_INIT_TYPES } = require("../ModuleSourceTypeConstants");
const { WEBPACK_MODULE_TYPE_PROVIDE } = require("../ModuleTypeConstants");

@@ -13,0 +13,0 @@ const RuntimeGlobals = require("../RuntimeGlobals");

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

/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../Compilation").FileSystemDependencies} FileSystemDependencies */
/** @typedef {import("../ResolverFactory").ResolveOptionsWithDependencyType} ResolveOptionsWithDependencyType */

@@ -18,6 +19,11 @@

* @template T
* @typedef {Map<string, T>} MatchedConfigsItem
*/
/**
* @template T
* @typedef {object} MatchedConfigs
* @property {Map<string, T>} resolved
* @property {Map<string, T>} unresolved
* @property {Map<string, T>} prefixed
* @property {MatchedConfigsItem<T>} resolved
* @property {MatchedConfigsItem<T>} unresolved
* @property {MatchedConfigsItem<T>} prefixed
*/

@@ -35,7 +41,7 @@

module.exports.resolveMatchedConfigs = (compilation, configs) => {
/** @type {Map<string, T>} */
/** @type {MatchedConfigsItem<T>} */
const resolved = new Map();
/** @type {Map<string, T>} */
/** @type {MatchedConfigsItem<T>} */
const unresolved = new Map();
/** @type {Map<string, T>} */
/** @type {MatchedConfigsItem<T>} */
const prefixed = new Map();

@@ -90,11 +96,11 @@ /** @type {ResolveContext} */

compilation.contextDependencies.addAll(
/** @type {LazySet<string>} */
/** @type {FileSystemDependencies} */
(resolveContext.contextDependencies)
);
compilation.fileDependencies.addAll(
/** @type {LazySet<string>} */
/** @type {FileSystemDependencies} */
(resolveContext.fileDependencies)
);
compilation.missingDependencies.addAll(
/** @type {LazySet<string>} */
/** @type {FileSystemDependencies} */
(resolveContext.missingDependencies)

@@ -101,0 +107,0 @@ );

@@ -382,3 +382,3 @@ /*

return normalizeVersion(
/** @type {Exclude<JsonPrimitive, null | boolean| number>} */ (
/** @type {Exclude<JsonPrimitive, null | boolean | number>} */ (
dependency[packageName]

@@ -385,0 +385,0 @@ )

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

sourceMap.debugId = debugId;
currentSourceMappingURLComment = `\n//# debugId=${debugId}${currentSourceMappingURLComment}`;
const debugIdComment = `\n//# debugId=${debugId}`;
currentSourceMappingURLComment =
currentSourceMappingURLComment
? `${debugIdComment}${currentSourceMappingURLComment}`
: debugIdComment;
}

@@ -502,0 +507,0 @@

@@ -33,3 +33,3 @@ /*

/** @typedef {{ [Key in Exclude<StatsValue, boolean | object | "normal">]: StatsOptions }} NamedPresets */
/** @typedef {{ [Key in Exclude<StatsValue, boolean | EXPECTED_OBJECT | "normal">]: StatsOptions }} NamedPresets */

@@ -36,0 +36,0 @@ /** @type {NamedPresets} */

@@ -79,3 +79,3 @@ /*

* @param {string} name module name
* @returns {[string,string]} prefix and module name
* @returns {[string, string]} prefix and module name
*/

@@ -82,0 +82,0 @@ const getModuleName = (name) => {

@@ -283,3 +283,3 @@ /*

* @param {Module[]} modules modules to render (should be ordered by identifier)
* @param {(module: Module) => Source | null} renderModule function to render a module
* @param {(module: Module, renderInArray?: boolean) => Source | null} renderModule function to render a module
* @param {string=} prefix applying prefix strings

@@ -294,8 +294,16 @@ * @returns {Source | null} rendered chunk modules in a Source object or null if no modules

}
/** @type {{ id: ModuleId, module: Module }[]} */
const modulesWithId = modules.map((m) => ({
id: /** @type {ModuleId} */ (chunkGraph.getModuleId(m)),
module: m
}));
const bounds = Template.getModulesArrayBounds(modulesWithId);
const renderInObject = bounds === false;
/** @type {{ id: ModuleId, source: Source | "false" }[]} */
const allModules = modules.map((module) => ({
id: /** @type {ModuleId} */ (chunkGraph.getModuleId(module)),
source: renderModule(module) || "false"
const allModules = modulesWithId.map(({ id, module }) => ({
id,
source: renderModule(module, renderInObject) || "false"
}));
const bounds = Template.getModulesArrayBounds(allModules);
if (bounds) {

@@ -337,3 +345,5 @@ // Render a spare array

}
source.add(`\n/***/ ${JSON.stringify(module.id)}:\n`);
source.add(
`\n/***/ ${JSON.stringify(module.id)}${renderContext.runtimeTemplate.supportsMethodShorthand() && module.source !== "false" ? "" : ":"}\n`
);
source.add(module.source);

@@ -369,2 +379,3 @@ }

runtime: renderContext.chunk.runtime,
runtimes: [renderContext.chunk.runtime],
codeGenerationResults

@@ -371,0 +382,0 @@ });

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

/**
* @param {string | number} id id
* @returns {string | number} result
*/
/** @type {PathData["prepareId"]} */
const prepareId = (id) => {

@@ -307,3 +304,3 @@ if (typeof id !== "string") return id;

const idReplacer = replacer(() =>
prepareId(
(data.prepareId || prepareId)(
module instanceof Module

@@ -358,3 +355,5 @@ ? /** @type {ModuleId} */

"runtime",
replacer(() => prepareId(/** @type {string} */ (data.runtime)))
replacer(() =>
(data.prepareId || prepareId)(/** @type {string} */ (data.runtime))
)
);

@@ -361,0 +360,0 @@ } else {

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

/** @typedef {">=" | "<=" | "<" | ">" | "-" } BinarySearchPredicate */
/** @typedef {"GE" | "GT" | "LT" | "LE" | "EQ" } SearchPredicateSuffix */
/** @typedef {">=" | "<=" | "<" | ">" | "-"} BinarySearchPredicate */
/** @typedef {"GE" | "GT" | "LT" | "LE" | "EQ"} SearchPredicateSuffix */

@@ -15,0 +15,0 @@ /**

@@ -60,3 +60,3 @@ /*

* @param {T} b second item
* @returns {-1|0|1} compare result
* @returns {-1 | 0 | 1} compare result
*/

@@ -94,3 +94,3 @@ const result = fn.bind(null, arg);

* @param {Iterable<T>} b second value
* @returns {-1|0|1} compare result
* @returns {-1 | 0 | 1} compare result
*/

@@ -120,3 +120,3 @@ const result = (a, b) => {

* @param {DependencyLocation} b A location node
* @returns {-1|0|1} sorting comparator value
* @returns {-1 | 0 | 1} sorting comparator value
*/

@@ -184,3 +184,3 @@ const compareLocations = (a, b) => {

* @param {Module} b module
* @returns {-1|0|1} compare result
* @returns {-1 | 0 | 1} compare result
*/

@@ -196,3 +196,3 @@ const compareModulesById = (chunkGraph, a, b) =>

* @param {number} b number
* @returns {-1|0|1} compare result
* @returns {-1 | 0 | 1} compare result
*/

@@ -211,3 +211,3 @@ const compareNumbers = (a, b) => {

* @param {string} b string
* @returns {-1|0|1} compare result
* @returns {-1 | 0 | 1} compare result
*/

@@ -284,3 +284,3 @@ const compareStringsNumeric = (a, b) => {

* @param {Module} b module
* @returns {-1|0|1} compare result
* @returns {-1 | 0 | 1} compare result
*/

@@ -300,3 +300,3 @@ const compareModulesByPostOrderIndexOrIdentifier = (moduleGraph, a, b) => {

* @param {Module} b module
* @returns {-1|0|1} compare result
* @returns {-1 | 0 | 1} compare result
*/

@@ -316,3 +316,3 @@ const compareModulesByPreOrderIndexOrIdentifier = (moduleGraph, a, b) => {

* @param {Module} b module
* @returns {-1|0|1} compare result
* @returns {-1 | 0 | 1} compare result
*/

@@ -339,3 +339,3 @@ const compareModulesByIdOrIdentifier = (chunkGraph, a, b) => {

* @param {string} b second string
* @returns {-1|0|1} compare result
* @returns {-1 | 0 | 1} compare result
*/

@@ -421,3 +421,3 @@ const compareStrings = (a, b) => {

* @param {T} b second value
* @returns {-1|0|1} compare result
* @returns {-1 | 0 | 1} compare result
*/

@@ -454,3 +454,3 @@ const result = (a, b) => {

* @param {T} b second value
* @returns {-1|0|1} compare result
* @returns {-1 | 0 | 1} compare result
*/

@@ -526,43 +526,38 @@ const result = (a, b) => {

* @param {WeakMap<Dependency, DependencySourceOrder>} dependencySourceOrderMap dependency source order map
* @param {((dep: Dependency, index: number) => void)=} onDependencyReSort optional callback to set index for each dependency
* @returns {void}
*/
const sortWithSourceOrder = (dependencies, dependencySourceOrderMap) => {
/**
* @param {Dependency} dep dependency
* @returns {number} source order
*/
const getSourceOrder = (dep) => {
if (dependencySourceOrderMap.has(dep)) {
const { main } = /** @type {DependencySourceOrder} */ (
dependencySourceOrderMap.get(dep)
);
return main;
}
return /** @type {number} */ (
/** @type {ModuleDependency} */ (dep).sourceOrder
);
};
/**
* If the sourceOrder is a number, it means the dependency needs to be sorted.
* @param {number | undefined} sourceOrder sourceOrder
* @returns {boolean} needReSort
*/
const needReSort = (sourceOrder) => {
if (typeof sourceOrder === "number") {
return true;
}
return false;
};
// Extract dependencies with sourceOrder and sort them
const sortWithSourceOrder = (
dependencies,
dependencySourceOrderMap,
onDependencyReSort
) => {
/** @type {{dep: Dependency, main: number, sub: number}[]} */
const withSourceOrder = [];
/** @type {number[]} */
const positions = [];
// First pass: collect dependencies with sourceOrder
for (let i = 0; i < dependencies.length; i++) {
const dep = dependencies[i];
const sourceOrder = getSourceOrder(dep);
const cached = dependencySourceOrderMap.get(dep);
if (needReSort(sourceOrder)) {
withSourceOrder.push({ dep, sourceOrder, originalIndex: i });
if (cached) {
positions.push(i);
withSourceOrder.push({
dep,
main: cached.main,
sub: cached.sub
});
} else {
const sourceOrder = /** @type {number | undefined} */ (
/** @type {ModuleDependency} */ (dep).sourceOrder
);
if (typeof sourceOrder === "number") {
positions.push(i);
withSourceOrder.push({
dep,
main: sourceOrder,
sub: 0
});
}
}

@@ -575,33 +570,15 @@ }

// Sort dependencies with sourceOrder
withSourceOrder.sort((a, b) => {
// Handle both dependencies in map case
if (
dependencySourceOrderMap.has(a.dep) &&
dependencySourceOrderMap.has(b.dep)
) {
const { main: mainA, sub: subA } = /** @type {DependencySourceOrder} */ (
dependencySourceOrderMap.get(a.dep)
);
const { main: mainB, sub: subB } = /** @type {DependencySourceOrder} */ (
dependencySourceOrderMap.get(b.dep)
);
if (mainA === mainB) {
return compareNumbers(subA, subB);
}
return compareNumbers(mainA, mainB);
if (a.main !== b.main) {
return compareNumbers(a.main, b.main);
}
return compareNumbers(a.sourceOrder, b.sourceOrder);
return compareNumbers(a.sub, b.sub);
});
// Second pass: build result array
let sortedIndex = 0;
for (let i = 0; i < dependencies.length; i++) {
const dep = dependencies[i];
const sourceOrder = getSourceOrder(dep);
if (needReSort(sourceOrder)) {
dependencies[i] = withSourceOrder[sortedIndex].dep;
sortedIndex++;
// Second pass: place sorted deps back to original positions
for (let i = 0; i < positions.length; i++) {
const depIndex = positions[i];
dependencies[depIndex] = withSourceOrder[i].dep;
if (onDependencyReSort) {
onDependencyReSort(dependencies[depIndex], depIndex);
}

@@ -618,3 +595,3 @@ }

* @param {Chunk} b chunk
* @returns {-1|0|1} compare result
* @returns {-1 | 0 | 1} compare result
*/

@@ -640,3 +617,3 @@ module.exports.compareChunksById = (a, b) =>

* @param {Module} b module
* @returns {-1|0|1} compare result
* @returns {-1 | 0 | 1} compare result
*/

@@ -643,0 +620,0 @@ module.exports.compareModulesByIdentifier = (a, b) =>

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

/**
* @param {string} char character to escape for use in character class
* @returns {string} escaped character
*/
const quoteMetaInCharClass = (char) => {
// In character class, only these need escaping: ] \ ^ -
if (char === "]" || char === "\\" || char === "^" || char === "-") {
return `\\${char}`;
}
return char;
};
/**
* Converts an array of single characters into an optimized character class string
* using ranges where possible. E.g., ["1","2","3","4","a"] => "1-4a"
* @param {string[]} chars array of single characters (should be sorted)
* @returns {string} optimized character class content (without the brackets)
*/
const charsToCharClassContent = (chars) => {
if (chars.length === 0) return "";
if (chars.length === 1) return quoteMetaInCharClass(chars[0]);
// Sort by char code
const sorted = [...chars].sort((a, b) => a.charCodeAt(0) - b.charCodeAt(0));
/** @type {string[]} */
const parts = [];
let rangeStart = sorted[0];
let rangeEnd = sorted[0];
for (let i = 1; i < sorted.length; i++) {
const char = sorted[i];
const prevCode = rangeEnd.charCodeAt(0);
const currCode = char.charCodeAt(0);
if (currCode === prevCode + 1) {
// Extend the range
rangeEnd = char;
} else {
// Flush the current range
parts.push(formatRange(rangeStart, rangeEnd));
rangeStart = char;
rangeEnd = char;
}
}
// Flush the last range
parts.push(formatRange(rangeStart, rangeEnd));
return parts.join("");
};
/**
* Formats a range of characters for use in a character class
* @param {string} start start character
* @param {string} end end character
* @returns {string} formatted range
*/
const formatRange = (start, end) => {
const startCode = start.charCodeAt(0);
const endCode = end.charCodeAt(0);
const length = endCode - startCode + 1;
if (length === 1) {
return quoteMetaInCharClass(start);
}
if (length === 2) {
// For 2 chars, just list them (e.g., "ab" instead of "a-b")
return quoteMetaInCharClass(start) + quoteMetaInCharClass(end);
}
// For 3+ chars, use range notation
return `${quoteMetaInCharClass(start)}-${quoteMetaInCharClass(end)}`;
};
/**
* @param {string} str string

@@ -152,3 +225,3 @@ * @returns {string} string

if (countOfSingleCharItems === itemsArr.length) {
return `[${quoteMeta(itemsArr.sort().join(""))}]`;
return `[${charsToCharClassContent(itemsArr)}]`;
}

@@ -158,10 +231,11 @@ /** @type {Set<string>} */

if (countOfSingleCharItems > 2) {
let singleCharItems = "";
/** @type {string[]} */
const singleCharItems = [];
for (const item of items) {
if (item.length === 1) {
singleCharItems += item;
singleCharItems.push(item);
items.delete(item);
}
}
finishedItems.push(`[${quoteMeta(singleCharItems)}]`);
finishedItems.push(`[${charsToCharClassContent(singleCharItems)}]`);
}

@@ -233,4 +307,2 @@

// TODO further optimize regexp, i. e.
// use ranges: (1|2|3|4|a) => [1-4a]
/** @type {string[]} */

@@ -237,0 +309,0 @@ const conditional = [...finishedItems, ...Array.from(items, quoteMeta)];

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

const Hash = require("./Hash");
/** @typedef {import("../../declarations/WebpackOptions").HashDigest} Encoding */
/** @typedef {import("./Hash")} Hash */
/** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */
const BULK_SIZE = 3;
// We are using an object instead of a Map as this will stay static during the runtime
// so access to it can be optimized by v8
/** @type {{[key: string]: Map<string, string>}} */
const digestCaches = {};
/** @typedef {() => Hash} HashFactory */
class BulkUpdateDecorator extends Hash {
/**
* @param {Hash | HashFactory} hashOrFactory function to create a hash
* @param {string=} hashKey key for caching
*/
constructor(hashOrFactory, hashKey) {
super();
this.hashKey = hashKey;
if (typeof hashOrFactory === "function") {
this.hashFactory = hashOrFactory;
this.hash = undefined;
} else {
this.hashFactory = undefined;
this.hash = hashOrFactory;
}
this.buffer = "";
}
/**
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
* @overload
* @param {string | Buffer} data data
* @returns {Hash} updated hash
*/
/**
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
* @overload
* @param {string} data data
* @param {Encoding} inputEncoding data encoding
* @returns {Hash} updated hash
*/
/**
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
* @param {string | Buffer} data data
* @param {Encoding=} inputEncoding data encoding
* @returns {Hash} updated hash
*/
update(data, inputEncoding) {
if (
inputEncoding !== undefined ||
typeof data !== "string" ||
data.length > BULK_SIZE
) {
if (this.hash === undefined) {
this.hash = /** @type {HashFactory} */ (this.hashFactory)();
}
if (this.buffer.length > 0) {
this.hash.update(this.buffer);
this.buffer = "";
}
if (typeof data === "string" && inputEncoding) {
this.hash.update(data, inputEncoding);
} else {
this.hash.update(data);
}
} else {
this.buffer += data;
if (this.buffer.length > BULK_SIZE) {
if (this.hash === undefined) {
this.hash = /** @type {HashFactory} */ (this.hashFactory)();
}
this.hash.update(this.buffer);
this.buffer = "";
}
}
return this;
}
/**
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
* @overload
* @returns {Buffer} digest
*/
/**
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
* @overload
* @param {Encoding} encoding encoding of the return value
* @returns {string} digest
*/
/**
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
* @param {Encoding=} encoding encoding of the return value
* @returns {string | Buffer} digest
*/
digest(encoding) {
let digestCache;
const buffer = this.buffer;
if (this.hash === undefined) {
// short data for hash, we can use caching
const cacheKey = `${this.hashKey}-${encoding}`;
digestCache = digestCaches[cacheKey];
if (digestCache === undefined) {
digestCache = digestCaches[cacheKey] = new Map();
}
const cacheEntry = digestCache.get(buffer);
if (cacheEntry !== undefined) return cacheEntry;
this.hash = /** @type {HashFactory} */ (this.hashFactory)();
}
if (buffer.length > 0) {
this.hash.update(buffer);
}
if (!encoding) {
const result = this.hash.digest();
if (digestCache !== undefined) {
digestCache.set(buffer, result);
}
return result;
}
const digestResult = this.hash.digest(encoding);
// Compatibility with the old hash library
const result =
typeof digestResult === "string"
? digestResult
: /** @type {NodeJS.TypedArray} */ (digestResult).toString();
if (digestCache !== undefined) {
digestCache.set(buffer, result);
}
return result;
}
}
/* istanbul ignore next */
class DebugHash extends Hash {
constructor() {
super();
this.string = "";
}
/**
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
* @overload
* @param {string | Buffer} data data
* @returns {Hash} updated hash
*/
/**
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
* @overload
* @param {string} data data
* @param {Encoding} inputEncoding data encoding
* @returns {Hash} updated hash
*/
/**
* Update hash {@link https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding}
* @param {string | Buffer} data data
* @param {Encoding=} inputEncoding data encoding
* @returns {Hash} updated hash
*/
update(data, inputEncoding) {
if (typeof data !== "string") data = data.toString("utf8");
const prefix = Buffer.from("@webpack-debug-digest@").toString("hex");
if (data.startsWith(prefix)) {
data = Buffer.from(data.slice(prefix.length), "hex").toString();
}
this.string += `[${data}](${
/** @type {string} */
(
// eslint-disable-next-line unicorn/error-message
new Error().stack
).split("\n", 3)[2]
})\n`;
return this;
}
/**
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
* @overload
* @returns {Buffer} digest
*/
/**
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
* @overload
* @param {Encoding} encoding encoding of the return value
* @returns {string} digest
*/
/**
* Calculates the digest {@link https://nodejs.org/api/crypto.html#crypto_hash_digest_encoding}
* @param {Encoding=} encoding encoding of the return value
* @returns {string | Buffer} digest
*/
digest(encoding) {
return Buffer.from(`@webpack-debug-digest@${this.string}`).toString("hex");
}
}
/** @type {typeof import("crypto") | undefined} */

@@ -213,4 +18,8 @@ let crypto;

let createMd4;
/** @type {typeof import("./hash/DebugHash") | undefined} */
let DebugHash;
/** @type {typeof import("./hash/BatchedHash") | undefined} */
let BatchedHash;
/** @type {typeof import("./hash/BulkUpdateHash") | undefined} */
let BulkUpdateHash;

@@ -224,4 +33,7 @@ /**

if (typeof algorithm === "function") {
if (BulkUpdateHash === undefined) {
BulkUpdateHash = require("./hash/BulkUpdateHash");
}
// eslint-disable-next-line new-cap
return new BulkUpdateDecorator(() => new algorithm());
return new BulkUpdateHash(() => new algorithm());
}

@@ -231,2 +43,5 @@ switch (algorithm) {

case "debug":
if (DebugHash === undefined) {
DebugHash = require("./hash/DebugHash");
}
return new DebugHash();

@@ -255,3 +70,6 @@ case "xxhash64":

if (crypto === undefined) crypto = require("crypto");
return new BulkUpdateDecorator(
if (BulkUpdateHash === undefined) {
BulkUpdateHash = require("./hash/BulkUpdateHash");
}
return new BulkUpdateHash(
() =>

@@ -266,3 +84,6 @@ /** @type {Hash} */ (

if (crypto === undefined) crypto = require("crypto");
return new BulkUpdateDecorator(
if (BulkUpdateHash === undefined) {
BulkUpdateHash = require("./hash/BulkUpdateHash");
}
return new BulkUpdateHash(
() =>

@@ -269,0 +90,0 @@ /** @type {Hash} */ (

@@ -197,3 +197,3 @@ /*

* @param {string} name name
* @returns {{ new <T = any>(values?: ReadonlyArray<T> | null): SetDeprecatedArray<T> }} SetDeprecatedArray
* @returns {{ new <T = EXPECTED_ANY>(values?: ReadonlyArray<T> | null): SetDeprecatedArray<T> }} SetDeprecatedArray
*/

@@ -200,0 +200,0 @@ module.exports.createArrayToSetDeprecationSet = (name) => {

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

/** @typedef {Set<string>} Types */
/**
* @param {Sizes} size size
* @param {Sizes} minSize minimum size
* @returns {Set<string>} set of types that are too small
* @returns {Types} set of types that are too small
*/
const getTooSmallTypes = (size, minSize) => {
/** @typedef {Types} */
const types = new Set();

@@ -160,3 +163,3 @@ for (const key of Object.keys(size)) {

* @param {T} size size
* @param {Set<string>} types types
* @param {Types} types types
* @returns {number} number of matching size types

@@ -174,3 +177,3 @@ */

* @param {Sizes} size size
* @param {Set<string>} types types
* @param {Types} types types
* @returns {number} selective size sum

@@ -177,0 +180,0 @@ */

@@ -48,3 +48,3 @@ /*

/**
* @typedef {IStatsBase<bigint> & { atimeNs: bigint, mtimeNs: bigint, ctimeNs: bigint, birthtimeNs: bigint }} IBigIntStats
* @typedef {IStatsBase<bigint> & { atimeNs: bigint, mtimeNs: bigint, ctimeNs: bigint, birthtimeNs: bigint }} IBigIntStats
*/

@@ -141,6 +141,6 @@

* @typedef {{
* (path: PathOrFileDescriptor, options: ({ encoding?: null | undefined, flag?: string | undefined } & import("events").Abortable) | undefined | null, callback: BufferCallback): void;
* (path: PathOrFileDescriptor, options: ({ encoding: BufferEncoding, flag?: string | undefined } & import("events").Abortable) | BufferEncoding, callback: StringCallback): void;
* (path: PathOrFileDescriptor, options: (ObjectEncodingOptions & { flag?: string | undefined } & import("events").Abortable) | BufferEncoding | undefined | null, callback: StringOrBufferCallback): void;
* (path: PathOrFileDescriptor, callback: BufferCallback): void;
* (path: PathOrFileDescriptor, options: ({ encoding?: null | undefined, flag?: string | undefined } & import("events").Abortable) | undefined | null, callback: BufferCallback): void,
* (path: PathOrFileDescriptor, options: ({ encoding: BufferEncoding, flag?: string | undefined } & import("events").Abortable) | BufferEncoding, callback: StringCallback): void,
* (path: PathOrFileDescriptor, options: (ObjectEncodingOptions & { flag?: string | undefined } & import("events").Abortable) | BufferEncoding | undefined | null, callback: StringOrBufferCallback): void,
* (path: PathOrFileDescriptor, callback: BufferCallback): void,
* }} ReadFile

@@ -151,5 +151,5 @@ */

* @typedef {{
* (path: PathOrFileDescriptor, options?: { encoding?: null | undefined, flag?: string | undefined } | null): Buffer;
* (path: PathOrFileDescriptor, options: { encoding: BufferEncoding, flag?: string | undefined } | BufferEncoding): string;
* (path: PathOrFileDescriptor, options?: (ObjectEncodingOptions & { flag?: string | undefined }) | BufferEncoding | null): string | Buffer;
* (path: PathOrFileDescriptor, options?: { encoding?: null | undefined, flag?: string | undefined } | null): Buffer,
* (path: PathOrFileDescriptor, options: { encoding: BufferEncoding, flag?: string | undefined } | BufferEncoding): string,
* (path: PathOrFileDescriptor, options?: (ObjectEncodingOptions & { flag?: string | undefined }) | BufferEncoding | null): string | Buffer,
* }} ReadFileSync

@@ -163,3 +163,3 @@ */

/**
* @typedef {'buffer'| { encoding: 'buffer' }} BufferEncodingOption
* @typedef {"buffer" | { encoding: "buffer" }} BufferEncodingOption
*/

@@ -180,6 +180,6 @@

* @typedef {{
* (path: PathLike, options: EncodingOption, callback: StringCallback): void;
* (path: PathLike, options: BufferEncodingOption, callback: BufferCallback): void;
* (path: PathLike, options: EncodingOption, callback: StringOrBufferCallback): void;
* (path: PathLike, callback: StringCallback): void;
* (path: PathLike, options: EncodingOption, callback: StringCallback): void,
* (path: PathLike, options: BufferEncodingOption, callback: BufferCallback): void,
* (path: PathLike, options: EncodingOption, callback: StringOrBufferCallback): void,
* (path: PathLike, callback: StringCallback): void,
* }} Readlink

@@ -190,5 +190,5 @@ */

* @typedef {{
* (path: PathLike, options?: EncodingOption): string;
* (path: PathLike, options: BufferEncodingOption): Buffer;
* (path: PathLike, options?: EncodingOption): string | Buffer;
* (path: PathLike, options?: EncodingOption): string,
* (path: PathLike, options: BufferEncodingOption): Buffer,
* (path: PathLike, options?: EncodingOption): string | Buffer,
* }} ReadlinkSync

@@ -199,8 +199,8 @@ */

* @typedef {{
* (path: PathLike, options: { encoding: BufferEncoding | null, withFileTypes?: false | undefined, recursive?: boolean | undefined } | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException | null, files?: string[]) => void): void;
* (path: PathLike, options: { encoding: 'buffer', withFileTypes?: false | undefined, recursive?: boolean | undefined } | 'buffer', callback: (err: NodeJS.ErrnoException | null, files?: Buffer[]) => void): void;
* (path: PathLike, options: (ObjectEncodingOptions & { withFileTypes?: false | undefined, recursive?: boolean | undefined }) | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException | null, files?: string[] | Buffer[]) => void): void;
* (path: PathLike, callback: (err: NodeJS.ErrnoException | null, files?: string[]) => void): void;
* (path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true, recursive?: boolean | undefined }, callback: (err: NodeJS.ErrnoException | null, files?: Dirent<string>[]) => void): void;
* (path: PathLike, options: { encoding: 'buffer', withFileTypes: true, recursive?: boolean | undefined }, callback: (err: NodeJS.ErrnoException | null, files: Dirent<Buffer>[]) => void): void;
* (path: PathLike, options: { encoding: BufferEncoding | null, withFileTypes?: false | undefined, recursive?: boolean | undefined } | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException | null, files?: string[]) => void): void,
* (path: PathLike, options: { encoding: "buffer", withFileTypes?: false | undefined, recursive?: boolean | undefined } | "buffer", callback: (err: NodeJS.ErrnoException | null, files?: Buffer[]) => void): void,
* (path: PathLike, options: (ObjectEncodingOptions & { withFileTypes?: false | undefined, recursive?: boolean | undefined }) | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException | null, files?: string[] | Buffer[]) => void): void,
* (path: PathLike, callback: (err: NodeJS.ErrnoException | null, files?: string[]) => void): void,
* (path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true, recursive?: boolean | undefined }, callback: (err: NodeJS.ErrnoException | null, files?: Dirent<string>[]) => void): void,
* (path: PathLike, options: { encoding: "buffer", withFileTypes: true, recursive?: boolean | undefined }, callback: (err: NodeJS.ErrnoException | null, files: Dirent<Buffer>[]) => void): void,
* }} Readdir

@@ -211,7 +211,7 @@ */

* @typedef {{
* (path: PathLike, options?: { encoding: BufferEncoding | null, withFileTypes?: false | undefined, recursive?: boolean | undefined; } | BufferEncoding | null): string[];
* (path: PathLike, options: { encoding: 'buffer', withFileTypes?: false | undefined, recursive?: boolean | undefined } | 'buffer'): Buffer[];
* (path: PathLike, options?: (ObjectEncodingOptions & { withFileTypes?: false | undefined, recursive?: boolean | undefined }) | BufferEncoding | null): string[] | Buffer[];
* (path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true, recursive?: boolean | undefined }): Dirent[];
* (path: PathLike, options: { encoding: "buffer", withFileTypes: true, recursive?: boolean | undefined }): Dirent<Buffer>[];
* (path: PathLike, options?: { encoding: BufferEncoding | null, withFileTypes?: false | undefined, recursive?: boolean | undefined; } | BufferEncoding | null): string[],
* (path: PathLike, options: { encoding: "buffer", withFileTypes?: false | undefined, recursive?: boolean | undefined } | "buffer"): Buffer[],
* (path: PathLike, options?: (ObjectEncodingOptions & { withFileTypes?: false | undefined, recursive?: boolean | undefined }) | BufferEncoding | null): string[] | Buffer[],
* (path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true, recursive?: boolean | undefined }): Dirent[],
* (path: PathLike, options: { encoding: "buffer", withFileTypes: true, recursive?: boolean | undefined }): Dirent<Buffer>[],
* }} ReaddirSync

@@ -222,6 +222,6 @@ */

* @typedef {{
* (path: PathLike, callback: StatsCallback): void;
* (path: PathLike, options: (StatOptions & { bigint?: false | undefined }) | undefined, callback: StatsCallback): void;
* (path: PathLike, options: StatOptions & { bigint: true }, callback: BigIntStatsCallback): void;
* (path: PathLike, options: StatOptions | undefined, callback: StatsOrBigIntStatsCallback): void;
* (path: PathLike, callback: StatsCallback): void,
* (path: PathLike, options: (StatOptions & { bigint?: false | undefined }) | undefined, callback: StatsCallback): void,
* (path: PathLike, options: StatOptions & { bigint: true }, callback: BigIntStatsCallback): void,
* (path: PathLike, options: StatOptions | undefined, callback: StatsOrBigIntStatsCallback): void,
* }} Stat

@@ -232,9 +232,9 @@ */

* @typedef {{
* (path: PathLike, options?: undefined): IStats;
* (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined, throwIfNoEntry: false }): IStats | undefined;
* (path: PathLike, options: StatSyncOptions & { bigint: true, throwIfNoEntry: false }): IBigIntStats | undefined;
* (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined }): IStats;
* (path: PathLike, options: StatSyncOptions & { bigint: true }): IBigIntStats;
* (path: PathLike, options: StatSyncOptions & { bigint: boolean, throwIfNoEntry?: false | undefined }): IStats | IBigIntStats;
* (path: PathLike, options?: StatSyncOptions): IStats | IBigIntStats | undefined;
* (path: PathLike, options?: undefined): IStats,
* (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined, throwIfNoEntry: false }): IStats | undefined,
* (path: PathLike, options: StatSyncOptions & { bigint: true, throwIfNoEntry: false }): IBigIntStats | undefined,
* (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined }): IStats,
* (path: PathLike, options: StatSyncOptions & { bigint: true }): IBigIntStats,
* (path: PathLike, options: StatSyncOptions & { bigint: boolean, throwIfNoEntry?: false | undefined }): IStats | IBigIntStats,
* (path: PathLike, options?: StatSyncOptions): IStats | IBigIntStats | undefined,
* }} StatSync

@@ -245,6 +245,6 @@ */

* @typedef {{
* (path: PathLike, callback: StatsCallback): void;
* (path: PathLike, options: (StatOptions & { bigint?: false | undefined }) | undefined, callback: StatsCallback): void;
* (path: PathLike, options: StatOptions & { bigint: true }, callback: BigIntStatsCallback): void;
* (path: PathLike, options: StatOptions | undefined, callback: StatsOrBigIntStatsCallback): void;
* (path: PathLike, callback: StatsCallback): void,
* (path: PathLike, options: (StatOptions & { bigint?: false | undefined }) | undefined, callback: StatsCallback): void,
* (path: PathLike, options: StatOptions & { bigint: true }, callback: BigIntStatsCallback): void,
* (path: PathLike, options: StatOptions | undefined, callback: StatsOrBigIntStatsCallback): void,
* }} LStat

@@ -255,9 +255,9 @@ */

* @typedef {{
* (path: PathLike, options?: undefined): IStats;
* (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined, throwIfNoEntry: false }): IStats | undefined;
* (path: PathLike, options: StatSyncOptions & { bigint: true, throwIfNoEntry: false }): IBigIntStats | undefined;
* (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined }): IStats;
* (path: PathLike, options: StatSyncOptions & { bigint: true }): IBigIntStats;
* (path: PathLike, options: StatSyncOptions & { bigint: boolean, throwIfNoEntry?: false | undefined }): IStats | IBigIntStats;
* (path: PathLike, options?: StatSyncOptions): IStats | IBigIntStats | undefined;
* (path: PathLike, options?: undefined): IStats,
* (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined, throwIfNoEntry: false }): IStats | undefined,
* (path: PathLike, options: StatSyncOptions & { bigint: true, throwIfNoEntry: false }): IBigIntStats | undefined,
* (path: PathLike, options?: StatSyncOptions & { bigint?: false | undefined }): IStats,
* (path: PathLike, options: StatSyncOptions & { bigint: true }): IBigIntStats,
* (path: PathLike, options: StatSyncOptions & { bigint: boolean, throwIfNoEntry?: false | undefined }): IStats | IBigIntStats,
* (path: PathLike, options?: StatSyncOptions): IStats | IBigIntStats | undefined,
* }} LStatSync

@@ -268,5 +268,5 @@ */

* @typedef {{
* (path: PathLike, options: EncodingOption, callback: StringCallback): void;
* (path: PathLike, options: BufferEncodingOption, callback: BufferCallback): void;
* (path: PathLike, options: EncodingOption, callback: StringOrBufferCallback): void;
* (path: PathLike, options: EncodingOption, callback: StringCallback): void,
* (path: PathLike, options: BufferEncodingOption, callback: BufferCallback): void,
* (path: PathLike, options: EncodingOption, callback: StringOrBufferCallback): void,
* (path: PathLike, callback: StringCallback): void;

@@ -278,5 +278,5 @@ * }} RealPath

* @typedef {{
* (path: PathLike, options?: EncodingOption): string;
* (path: PathLike, options: BufferEncodingOption): Buffer;
* (path: PathLike, options?: EncodingOption): string | Buffer;
* (path: PathLike, options?: EncodingOption): string,
* (path: PathLike, options: BufferEncodingOption): Buffer,
* (path: PathLike, options?: EncodingOption): string | Buffer,
* }} RealPathSync

@@ -329,4 +329,4 @@ */

* @typedef {{
* (file: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options: WriteFileOptions, callback: NoParamCallback): void;
* (file: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, callback: NoParamCallback): void;
* (file: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, options: WriteFileOptions, callback: NoParamCallback): void,
* (file: PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView, callback: NoParamCallback): void,
* }} WriteFile

@@ -341,6 +341,6 @@ */

* @typedef {{
* (file: PathLike, options: MakeDirectoryOptions & { recursive: true }, callback: StringCallback): void;
* (file: PathLike, options: Mode | (MakeDirectoryOptions & { recursive?: false | undefined; }) | null | undefined, callback: NoParamCallback): void;
* (file: PathLike, options: Mode | MakeDirectoryOptions | null | undefined, callback: StringCallback): void;
* (file: PathLike, callback: NoParamCallback): void;
* (file: PathLike, options: MakeDirectoryOptions & { recursive: true }, callback: StringCallback): void,
* (file: PathLike, options: Mode | (MakeDirectoryOptions & { recursive?: false | undefined; }) | null | undefined, callback: NoParamCallback): void,
* (file: PathLike, options: Mode | MakeDirectoryOptions | null | undefined, callback: StringCallback): void,
* (file: PathLike, callback: NoParamCallback): void,
* }} Mkdir

@@ -355,4 +355,4 @@ */

* @typedef {{
* (file: PathLike, callback: NoParamCallback): void;
* (file: PathLike, options: RmDirOptions, callback: NoParamCallback): void;
* (file: PathLike, callback: NoParamCallback): void,
* (file: PathLike, options: RmDirOptions, callback: NoParamCallback): void,
* }} Rmdir

@@ -400,5 +400,5 @@ */

* @typedef {{
* (path: PathLike, options: MakeDirectoryOptions & { recursive: true }): string | undefined;
* (path: PathLike, options?: Mode | (MakeDirectoryOptions & { recursive?: false | undefined }) | null): void;
* (path: PathLike, options?: Mode | MakeDirectoryOptions | null): string | undefined;
* (path: PathLike, options: MakeDirectoryOptions & { recursive: true }): string | undefined,
* (path: PathLike, options?: Mode | (MakeDirectoryOptions & { recursive?: false | undefined }) | null): void,
* (path: PathLike, options?: Mode | MakeDirectoryOptions | null): string | undefined,
* }} MkdirSync

@@ -443,5 +443,5 @@ */

* @typedef {{
* (file: PathLike, flags: OpenMode | undefined, mode: Mode | undefined | null, callback: NumberCallback): void;
* (file: PathLike, flags: OpenMode | undefined, callback: NumberCallback): void;
* (file: PathLike, callback: NumberCallback): void;
* (file: PathLike, flags: OpenMode | undefined, mode: Mode | undefined | null, callback: NumberCallback): void,
* (file: PathLike, flags: OpenMode | undefined, callback: NumberCallback): void,
* (file: PathLike, callback: NumberCallback): void,
* }} Open

@@ -473,5 +473,5 @@ */

* @typedef {{
* (fd: number, buffer: TBuffer, offset: number, length: number, position: ReadPosition | null, callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void): void;
* (fd: number, options: ReadAsyncOptions<TBuffer>, callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void): void;
* (fd: number, callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: NodeJS.ArrayBufferView) => void): void;
* (fd: number, buffer: TBuffer, offset: number, length: number, position: ReadPosition | null, callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void): void,
* (fd: number, options: ReadAsyncOptions<TBuffer>, callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: TBuffer) => void): void,
* (fd: number, callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: NodeJS.ArrayBufferView) => void): void,
* }} Read

@@ -497,3 +497,3 @@ */

/**
* @param {InputFileSystem | OutputFileSystem|undefined} fs a file system
* @param {InputFileSystem | OutputFileSystem | undefined} fs a file system
* @param {string} rootPath the root path

@@ -517,3 +517,3 @@ * @param {string} targetPath the target path

/**
* @param {InputFileSystem|OutputFileSystem|undefined} fs a file system
* @param {InputFileSystem | OutputFileSystem | undefined} fs a file system
* @param {string} rootPath a path

@@ -537,3 +537,3 @@ * @param {string} filename a filename

/**
* @param {InputFileSystem|OutputFileSystem|undefined} fs a file system
* @param {InputFileSystem | OutputFileSystem | undefined} fs a file system
* @param {string} absPath an absolute path

@@ -540,0 +540,0 @@ * @returns {string} the parent directory of the absolute path

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

const Hash = require("../Hash");
const { digest, update } = require("./hash-digest");
const MAX_SHORT_STRING = require("./wasm-hash").MAX_SHORT_STRING;

@@ -55,5 +56,5 @@

if (this.encoding) {
this.hash.update(this.string, this.encoding);
update(this.hash, this.string, this.encoding);
} else {
this.hash.update(this.string);
update(this.hash, this.string);
}

@@ -71,8 +72,8 @@ this.string = undefined;

} else if (inputEncoding) {
this.hash.update(data, inputEncoding);
update(this.hash, data, inputEncoding);
} else {
this.hash.update(data);
update(this.hash, data);
}
} else {
this.hash.update(data);
update(this.hash, data);
}

@@ -101,11 +102,11 @@ return this;

if (this.encoding) {
this.hash.update(this.string, this.encoding);
update(this.hash, this.string, this.encoding);
} else {
this.hash.update(this.string);
update(this.hash, this.string);
}
}
if (!encoding) {
return this.hash.digest();
return digest(this.hash);
}
return this.hash.digest(encoding);
return digest(this.hash, encoding);
}

@@ -112,0 +113,0 @@ }

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

const PATH_QUERY_REGEXP = /^((?:\0.|[^?\0])*)(\?.*)?$/;
const ZERO_ESCAPE_REGEXP = /\0(.)/g;

@@ -334,11 +335,52 @@ /** @typedef {{ resource: string, path: string, query: string, fragment: string }} ParsedResource */

const _parseResource = (str) => {
const match =
/** @type {[string, string, string | undefined, string | undefined]} */
(/** @type {unknown} */ (PATH_QUERY_FRAGMENT_REGEXP.exec(str)));
return {
resource: str,
path: match[1].replace(/\0(.)/g, "$1"),
query: match[2] ? match[2].replace(/\0(.)/g, "$1") : "",
fragment: match[3] || ""
};
const firstEscape = str.indexOf("\0");
// Handle `\0`
if (firstEscape !== -1) {
const match =
/** @type {[string, string, string | undefined, string | undefined]} */
(/** @type {unknown} */ (PATH_QUERY_FRAGMENT_REGEXP.exec(str)));
return {
resource: str,
path: match[1].replace(ZERO_ESCAPE_REGEXP, "$1"),
query: match[2] ? match[2].replace(ZERO_ESCAPE_REGEXP, "$1") : "",
fragment: match[3] || ""
};
}
/** @type {ParsedResource} */
const result = { resource: str, path: "", query: "", fragment: "" };
const queryStart = str.indexOf("?");
const fragmentStart = str.indexOf("#");
if (fragmentStart < 0) {
if (queryStart < 0) {
result.path = result.resource;
// No fragment, no query
return result;
}
result.path = str.slice(0, queryStart);
result.query = str.slice(queryStart);
// Query, no fragment
return result;
}
if (queryStart < 0 || fragmentStart < queryStart) {
result.path = str.slice(0, fragmentStart);
result.fragment = str.slice(fragmentStart);
// Fragment, no query
return result;
}
result.path = str.slice(0, queryStart);
result.query = str.slice(queryStart, fragmentStart);
result.fragment = str.slice(fragmentStart);
// Query and fragment
return result;
};

@@ -352,10 +394,33 @@

const _parseResourceWithoutFragment = (str) => {
const match =
/** @type {[string, string, string | undefined]} */
(/** @type {unknown} */ (PATH_QUERY_REGEXP.exec(str)));
return {
resource: str,
path: match[1].replace(/\0(.)/g, "$1"),
query: match[2] ? match[2].replace(/\0(.)/g, "$1") : ""
};
const firstEscape = str.indexOf("\0");
// Handle `\0`
if (firstEscape !== -1) {
const match =
/** @type {[string, string, string | undefined]} */
(/** @type {unknown} */ (PATH_QUERY_REGEXP.exec(str)));
return {
resource: str,
path: match[1].replace(ZERO_ESCAPE_REGEXP, "$1"),
query: match[2] ? match[2].replace(ZERO_ESCAPE_REGEXP, "$1") : ""
};
}
/** @type {ParsedResourceWithoutFragment} */
const result = { resource: str, path: "", query: "" };
const queryStart = str.indexOf("?");
if (queryStart < 0) {
result.path = result.resource;
// No query
return result;
}
result.path = str.slice(0, queryStart);
result.query = str.slice(queryStart);
// Query
return result;
};

@@ -362,0 +427,0 @@

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

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

@@ -85,4 +83,2 @@ require("../dependencies/CssIcssImportDependency"),

require("../dependencies/CssIcssExportDependency"),
"dependencies/CssUrlDependency": () =>
require("../dependencies/CssUrlDependency"),
"dependencies/CssIcssSymbolDependency": () =>

@@ -89,0 +85,0 @@ require("../dependencies/CssIcssSymbolDependency"),

@@ -74,3 +74,3 @@ /*

* @template T
* @param {SortableSet<T>} set set
* @param {Exclude<RuntimeSpec, undefined | string>} set set
* @returns {string} runtime key

@@ -106,3 +106,3 @@ */

* @template T
* @param {SortableSet<T>} set set
* @param {Exclude<RuntimeSpec, undefined | string>} set set
* @returns {string} runtime string

@@ -168,3 +168,3 @@ */

* @param {RuntimeSpec} b second
* @returns {-1|0|1} compare
* @returns {-1 | 0 | 1} compare
*/

@@ -171,0 +171,0 @@ const compareRuntime = (a, b) => {

@@ -20,5 +20,5 @@ /*

// prefer .buffer(), it's called anyway during emit
/** @type {Buffer|string} */
/** @type {Buffer | string} */
let aSource = typeof a.buffer === "function" ? a.buffer() : a.source();
/** @type {Buffer|string} */
/** @type {Buffer | string} */
let bSource = typeof b.buffer === "function" ? b.buffer() : b.source();

@@ -25,0 +25,0 @@ if (aSource === bSource) return true;

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

constructor() {
/** @type {Buffer|undefined} */
/** @type {Buffer | undefined} */
this._value = undefined;

@@ -42,0 +42,0 @@ }

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

/** @typedef {(error: Error|null, result?: Buffer) => void} ErrorFirstCallback */
/** @typedef {(error: Error | null, result?: Buffer) => void} ErrorFirstCallback */

@@ -29,3 +29,3 @@ const backSlashCharCode = "\\".charCodeAt(0);

* @param {string} specifier specifier
* @returns {string|undefined} scheme if absolute URL specifier provided
* @returns {string | undefined} scheme if absolute URL specifier provided
*/

@@ -32,0 +32,0 @@ function getScheme(specifier) {

@@ -10,6 +10,7 @@ /*

const Generator = require("../Generator");
const { WEBASSEMBLY_TYPES } = require("../ModuleSourceTypesConstants");
const { WEBASSEMBLY_TYPES } = require("../ModuleSourceTypeConstants");
/** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
/** @typedef {import("../Module").SourceType} SourceType */
/** @typedef {import("../Module").SourceTypes} SourceTypes */

@@ -42,3 +43,3 @@ /** @typedef {import("../NormalModule")} NormalModule */

* @param {NormalModule} module the module
* @param {string=} type source type
* @param {SourceType=} type source type
* @returns {number} estimate size of the module

@@ -45,0 +46,0 @@ */

@@ -11,3 +11,3 @@ /*

const InitFragment = require("../InitFragment");
const { WEBASSEMBLY_TYPES } = require("../ModuleSourceTypesConstants");
const { WEBASSEMBLY_TYPES } = require("../ModuleSourceTypeConstants");
const RuntimeGlobals = require("../RuntimeGlobals");

@@ -20,2 +20,3 @@ const Template = require("../Template");

/** @typedef {import("../Module")} Module */
/** @typedef {import("../Module").SourceType} SourceType */
/** @typedef {import("../Module").SourceTypes} SourceTypes */

@@ -39,3 +40,3 @@ /** @typedef {import("../NormalModule")} NormalModule */

* @param {NormalModule} module the module
* @param {string=} type source type
* @param {SourceType=} type source type
* @returns {number} estimate size of the module

@@ -42,0 +43,0 @@ */

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

const Generator = require("../Generator");
const { WEBASSEMBLY_TYPES } = require("../ModuleSourceTypesConstants");
const { WEBASSEMBLY_TYPES } = require("../ModuleSourceTypeConstants");
const WebAssemblyExportImportedDependency = require("../dependencies/WebAssemblyExportImportedDependency");

@@ -22,2 +22,3 @@ const WebAssemblyUtils = require("./WebAssemblyUtils");

/** @typedef {import("../Module")} Module */
/** @typedef {import("../Module").SourceType} SourceType */
/** @typedef {import("../Module").SourceTypes} SourceTypes */

@@ -275,2 +276,4 @@ /** @typedef {import("../ModuleGraph")} ModuleGraph */

/** @typedef {Map<string, UsedWasmDependency>} Mapping */
/**

@@ -280,3 +283,3 @@ * Mangle import names and modules

* @param {AST} state.ast Module's ast
* @param {Map<string, UsedWasmDependency>} state.usedDependencyMap mappings to mangle names
* @param {Mapping} state.usedDependencyMap mappings to mangle names
* @returns {ArrayBufferTransform} transform

@@ -390,7 +393,7 @@ */

* @param {Module} module current module
* @param {boolean | undefined} mangle mangle imports
* @returns {Map<string, UsedWasmDependency>} mappings to mangled names
* @param {boolean=} mangle mangle imports
* @returns {Mapping} mappings to mangled names
*/
const getUsedDependencyMap = (moduleGraph, module, mangle) => {
/** @type {Map<string, UsedWasmDependency>} */
/** @type {Mapping} */
const map = new Map();

@@ -434,3 +437,3 @@ for (const usedDep of WebAssemblyUtils.getUsedDependencies(

* @param {NormalModule} module the module
* @param {string=} type source type
* @param {SourceType=} type source type
* @returns {number} estimate size of the module

@@ -437,0 +440,0 @@ */

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

const InitFragment = require("../InitFragment");
const { WEBASSEMBLY_TYPES } = require("../ModuleSourceTypesConstants");
const { WEBASSEMBLY_TYPES } = require("../ModuleSourceTypeConstants");
const RuntimeGlobals = require("../RuntimeGlobals");

@@ -23,2 +23,3 @@ const Template = require("../Template");

/** @typedef {import("../Module")} Module */
/** @typedef {import("../Module").SourceType} SourceType */
/** @typedef {import("../Module").SourceTypes} SourceTypes */

@@ -38,3 +39,3 @@ /** @typedef {import("../NormalModule")} NormalModule */

* @param {NormalModule} module the module
* @param {string=} type source type
* @param {SourceType=} type source type
* @returns {number} estimate size of the module

@@ -41,0 +42,0 @@ */

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

const Generator = require("../Generator");
const {
JAVASCRIPT_TYPE,
WEBASSEMBLY_TYPE
} = require("../ModuleSourceTypeConstants");
const { WEBASSEMBLY_MODULE_TYPE_SYNC } = require("../ModuleTypeConstants");

@@ -78,4 +82,4 @@ const WebAssemblyExportImportedDependency = require("../dependencies/WebAssemblyExportImportedDependency");

return Generator.byType({
javascript: new WebAssemblyJavascriptGenerator(),
webassembly: new WebAssemblyGenerator(this.options)
[JAVASCRIPT_TYPE]: new WebAssemblyJavascriptGenerator(),
[WEBASSEMBLY_TYPE]: new WebAssemblyGenerator(this.options)
});

@@ -82,0 +86,0 @@ });

@@ -157,3 +157,3 @@ /*

}
/** @type {MultiCompiler|Compiler} */
/** @type {MultiCompiler | Compiler} */
let compiler;

@@ -160,0 +160,0 @@ /** @type {boolean | undefined} */

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

constructor(message, options = {}) {
// @ts-expect-error ES2018 doesn't `Error.cause`, but it can be used by developers
super(message, options);

@@ -27,0 +26,0 @@

@@ -114,7 +114,7 @@ /*

// 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
// but it 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
compiler.platform.node === null &&
compiler.platform.web === null
? "module-import"

@@ -412,2 +412,35 @@ : "node-commonjs"

: {};
const isUniversalTarget =
options.output.module &&
compiler.platform.node === null &&
compiler.platform.web === null;
if (isUniversalTarget) {
const emitter = require.resolve("../hot/emitter-event-target.js");
const NormalModuleReplacementPlugin = require("./NormalModuleReplacementPlugin");
// Override emitter that using `EventEmitter` to `EventTarget`
// TODO webpack6 - migrate to `EventTarget` by default
new NormalModuleReplacementPlugin(/emitter(\.js)?$/, (result) => {
if (
/webpack[/\\]hot|webpack-dev-server[/\\]client|webpack-hot-middleware[/\\]client/.test(
result.context
)
) {
result.request = emitter;
}
return result;
}).apply(compiler);
}
const backend = require.resolve(
isUniversalTarget
? "../hot/lazy-compilation-universal.js"
: `../hot/lazy-compilation-${
options.externalsPresets.node ? "node" : "web"
}.js`
);
new LazyCompilationPlugin({

@@ -420,8 +453,3 @@ backend:

client:
(lazyOptions.backend && lazyOptions.backend.client) ||
require.resolve(
`../hot/lazy-compilation-${
options.externalsPresets.node ? "node" : "web"
}.js`
)
(lazyOptions.backend && lazyOptions.backend.client) || backend
}),

@@ -428,0 +456,0 @@ entries: !lazyOptions || lazyOptions.entries !== false,

{
"name": "webpack",
"version": "5.103.0",
"version": "5.104.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.",

@@ -35,3 +35,3 @@ "homepage": "https://github.com/webpack/webpack",

"prelint": "yarn setup",
"lint": "yarn lint:code && yarn lint:special && yarn lint:types && yarn lint:types-test && yarn lint:types-module-test && yarn lint:yarn && yarn fmt:check && yarn lint:spellcheck",
"lint": "yarn lint:code && yarn lint:special && yarn lint:types && yarn lint:types-test && yarn lint:types-module-test && yarn lint:types-hot && yarn lint:yarn && yarn fmt:check && yarn lint:spellcheck",
"lint:code": "node node_modules/eslint/bin/eslint.js --cache .",

@@ -41,2 +41,3 @@ "lint:special": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/schemas-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-schemas && node tooling/generate-runtime-code.js && node tooling/generate-wasm-code.js && node node_modules/tooling/compile-to-definitions && node node_modules/tooling/precompile-schemas && node node_modules/tooling/generate-types --no-template-literals",

"lint:types-test": "tsc -p tsconfig.types.test.json",
"lint:types-hot": "tsc -p tsconfig.hot.json",
"lint:types-module-test": "tsc -p tsconfig.module.test.json",

@@ -60,4 +61,6 @@ "lint:yarn": "yarn-deduplicate --fail --list -s highest yarn.lock",

"test:basic": "yarn test:base --testMatch \"<rootDir>/test/*.basictest.js\"",
"test:basic:deno": "yarn test:base:deno --testMatch \"<rootDir>/test/*.basictest.js\"",
"test:unit": "yarn test:base --testMatch \"<rootDir>/test/*.unittest.js\"",
"test:integration": "yarn test:base --testMatch \"<rootDir>/test/*.{basictest,longtest,test}.js\"",
"test:base:deno": "deno --allow-read --allow-env --allow-sys --allow-ffi --allow-write --allow-run --v8-flags='--max-old-space-size=4096' ./node_modules/jest-cli/bin/jest.js --logHeapUsage",
"test:base": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --logHeapUsage",

@@ -95,6 +98,6 @@ "cover": "yarn cover:all && yarn cover:report",

"acorn-import-phases": "^1.0.3",
"browserslist": "^4.26.3",
"browserslist": "^4.28.1",
"chrome-trace-event": "^1.0.2",
"enhanced-resolve": "^5.17.3",
"es-module-lexer": "^1.2.1",
"enhanced-resolve": "^5.17.4",
"es-module-lexer": "^2.0.0",
"eslint-scope": "5.1.1",

@@ -110,3 +113,3 @@ "events": "^3.2.0",

"tapable": "^2.3.0",
"terser-webpack-plugin": "^5.3.11",
"terser-webpack-plugin": "^5.3.16",
"watchpack": "^2.4.4",

@@ -118,6 +121,7 @@ "webpack-sources": "^3.3.3"

"@babel/preset-react": "^7.27.1",
"@changesets/cli": "^2.29.8",
"@codspeed/core": "^5.0.1",
"@eslint/js": "^9.37.0",
"@eslint/js": "^9.39.0",
"@eslint/markdown": "^7.4.0",
"@stylistic/eslint-plugin": "^5.4.0",
"@stylistic/eslint-plugin": "^5.6.0",
"@types/glob-to-regexp": "^0.4.4",

@@ -127,3 +131,3 @@ "@types/graceful-fs": "^4.1.9",

"@types/mime-types": "^2.1.4",
"@types/node": "^24.9.1",
"@types/node": "^24.10.1",
"@types/xxhashjs": "^0.2.4",

@@ -135,4 +139,4 @@ "assemblyscript": "^0.28.9",

"coffeescript": "^2.5.1",
"core-js": "^3.43.0",
"cspell": "^9.1.1",
"core-js": "^3.47.0",
"cspell": "^9.4.0",
"css-loader": "^7.1.2",

@@ -142,8 +146,8 @@ "date-fns": "^4.0.0",

"es6-promise-polyfill": "^1.2.0",
"eslint": "^9.37.0",
"eslint": "^9.39.2",
"eslint-config-prettier": "^10.1.1",
"eslint-config-webpack": "^4.5.1",
"eslint-config-webpack": "^4.7.3",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-jest": "^29.0.1",
"eslint-plugin-jsdoc": "^51.2.3",
"eslint-plugin-jest": "^29.5.0",
"eslint-plugin-jsdoc": "^61.5.0",
"eslint-plugin-n": "^17.23.1",

@@ -166,3 +170,3 @@ "eslint-plugin-prettier": "^5.5.0",

"json5": "^2.1.3",
"less": "^4.4.2",
"less": "^4.5.1",
"less-loader": "^12.2.0",

@@ -172,11 +176,11 @@ "lint-staged": "^16.2.3",

"lodash-es": "^4.17.15",
"memfs": "^4.49.0",
"meriyah": "^6.1.4",
"memfs": "^4.51.1",
"meriyah": "^7.0.0",
"mini-css-extract-plugin": "^2.9.0",
"mini-svg-data-uri": "^1.2.3",
"node-gyp": "^11.2.0",
"node-gyp": "^12.1.0",
"nyc": "^17.1.0",
"open-cli": "^8.0.0",
"pkg-pr-new": "^0.0.60",
"prettier": "^3.6.0",
"pkg-pr-new": "^0.0.62",
"prettier": "^3.7.4",
"prettier-2": "npm:prettier@^2",

@@ -187,4 +191,4 @@ "pretty-format": "^30.0.5",

"raw-loader": "^4.0.1",
"react": "^19.2.0",
"react-dom": "^19.2.0",
"react": "^19.2.3",
"react-dom": "^19.2.3",
"rimraf": "^3.0.2",

@@ -196,7 +200,7 @@ "script-loader": "^0.7.2",

"terser": "^5.43.1",
"three": "^0.181.0",
"three": "^0.182.0",
"tinybench": "^5.0.0",
"toml": "^3.0.0",
"tooling": "webpack/tooling#v1.24.3",
"ts-loader": "^9.5.1",
"ts-loader": "^9.5.4",
"typescript": "^5.9.3",

@@ -203,0 +207,0 @@ "url-loader": "^4.1.0",

@@ -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&&"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;
"use strict";function e(t,{instancePath:r="",parentData:o,parentDataProperty:s,rootData:a=t}={}){let n=null,l=0;if(0===l){if(!t||"object"!=typeof t||Array.isArray(t))return e.errors=[{params:{type:"object"}}],!1;{const r=l;for(const r in t)if("esModule"!==r&&"exportType"!==r&&"exportsConvention"!==r&&"exportsOnly"!==r&&"localIdentHashDigest"!==r&&"localIdentHashDigestLength"!==r&&"localIdentHashSalt"!==r&&"localIdentName"!==r)return e.errors=[{params:{additionalProperty:r}}],!1;if(r===l){if(void 0!==t.esModule){const r=l;if("boolean"!=typeof t.esModule)return e.errors=[{params:{type:"boolean"}}],!1;var i=r===l}else i=!0;if(i){if(void 0!==t.exportType){let r=t.exportType;const o=l;if("link"!==r&&"text"!==r&&"css-style-sheet"!==r)return e.errors=[{params:{}}],!1;i=o===l}else i=!0;if(i){if(void 0!==t.exportsConvention){let r=t.exportsConvention;const o=l,s=l;let a=!1;const f=l;if("as-is"!==r&&"camel-case"!==r&&"camel-case-only"!==r&&"dashes"!==r&&"dashes-only"!==r){const e={params:{}};null===n?n=[e]:n.push(e),l++}var p=f===l;if(a=a||p,!a){const e=l;if(!(r instanceof Function)){const e={params:{}};null===n?n=[e]:n.push(e),l++}p=e===l,a=a||p}if(!a){const t={params:{}};return null===n?n=[t]:n.push(t),l++,e.errors=n,!1}l=s,null!==n&&(s?n.length=s:n=null),i=o===l}else i=!0;if(i){if(void 0!==t.exportsOnly){const r=l;if("boolean"!=typeof t.exportsOnly)return e.errors=[{params:{type:"boolean"}}],!1;i=r===l}else i=!0;if(i){if(void 0!==t.localIdentHashDigest){const r=l;if("string"!=typeof t.localIdentHashDigest)return e.errors=[{params:{type:"string"}}],!1;i=r===l}else i=!0;if(i){if(void 0!==t.localIdentHashDigestLength){let r=t.localIdentHashDigestLength;const o=l;if(l==l){if("number"!=typeof r)return e.errors=[{params:{type:"number"}}],!1;if(r<1||isNaN(r))return e.errors=[{params:{comparison:">=",limit:1}}],!1}i=o===l}else i=!0;if(i){if(void 0!==t.localIdentHashSalt){let r=t.localIdentHashSalt;const o=l;if(l==l){if("string"!=typeof r)return e.errors=[{params:{type:"string"}}],!1;if(r.length<1)return e.errors=[{params:{}}],!1}i=o===l}else i=!0;if(i)if(void 0!==t.localIdentName){const r=l;if("string"!=typeof t.localIdentName)return e.errors=[{params:{type:"string"}}],!1;i=r===l}else i=!0}}}}}}}}}return e.errors=n,0===l}function t(r,{instancePath:o="",parentData:s,parentDataProperty:a,rootData:n=r}={}){let l=null,i=0;return e(r,{instancePath:o,parentData:s,parentDataProperty:a,rootData:n})||(l=null===l?e.errors:l.concat(e.errors),i=l.length),t.errors=l,0===i}module.exports=t,module.exports.default=t;

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

*/
"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;
"use strict";module.exports=t,module.exports.default=t;const e={type:"object",additionalProperties:!1,properties:{animation:{$ref:"#/definitions/CssParserAnimation"},container:{$ref:"#/definitions/CssParserContainer"},customIdents:{$ref:"#/definitions/CssParserCustomIdents"},dashedIdents:{$ref:"#/definitions/CssParserDashedIdents"},exportType:{$ref:"#/definitions/CssParserExportType"},function:{$ref:"#/definitions/CssParserFunction"},grid:{$ref:"#/definitions/CssParserGrid"},import:{$ref:"#/definitions/CssParserImport"},namedExports:{$ref:"#/definitions/CssParserNamedExports"},url:{$ref:"#/definitions/CssParserUrl"}}},r=Object.prototype.hasOwnProperty;function o(t,{instancePath:s="",parentData:n,parentDataProperty:a,rootData:i=t}={}){if(!t||"object"!=typeof t||Array.isArray(t))return o.errors=[{params:{type:"object"}}],!1;{const s=0;for(const s in t)if(!r.call(e.properties,s))return o.errors=[{params:{additionalProperty:s}}],!1;if(0===s){if(void 0!==t.animation){const e=0;if("boolean"!=typeof t.animation)return o.errors=[{params:{type:"boolean"}}],!1;var f=0===e}else f=!0;if(f){if(void 0!==t.container){const e=0;if("boolean"!=typeof t.container)return o.errors=[{params:{type:"boolean"}}],!1;f=0===e}else f=!0;if(f){if(void 0!==t.customIdents){const e=0;if("boolean"!=typeof t.customIdents)return o.errors=[{params:{type:"boolean"}}],!1;f=0===e}else f=!0;if(f){if(void 0!==t.dashedIdents){const e=0;if("boolean"!=typeof t.dashedIdents)return o.errors=[{params:{type:"boolean"}}],!1;f=0===e}else f=!0;if(f){if(void 0!==t.exportType){let e=t.exportType;const r=0;if("link"!==e&&"text"!==e&&"css-style-sheet"!==e)return o.errors=[{params:{}}],!1;f=0===r}else f=!0;if(f){if(void 0!==t.function){const e=0;if("boolean"!=typeof t.function)return o.errors=[{params:{type:"boolean"}}],!1;f=0===e}else f=!0;if(f){if(void 0!==t.grid){const e=0;if("boolean"!=typeof t.grid)return o.errors=[{params:{type:"boolean"}}],!1;f=0===e}else f=!0;if(f){if(void 0!==t.import){const e=0;if("boolean"!=typeof t.import)return o.errors=[{params:{type:"boolean"}}],!1;f=0===e}else f=!0;if(f){if(void 0!==t.namedExports){const e=0;if("boolean"!=typeof t.namedExports)return o.errors=[{params:{type:"boolean"}}],!1;f=0===e}else f=!0;if(f)if(void 0!==t.url){const e=0;if("boolean"!=typeof t.url)return o.errors=[{params:{type:"boolean"}}],!1;f=0===e}else f=!0}}}}}}}}}}return o.errors=null,!0}function t(e,{instancePath:r="",parentData:s,parentDataProperty:n,rootData:a=e}={}){let i=null,f=0;return o(e,{instancePath:r,parentData:s,parentDataProperty:n,rootData:a})||(i=null===i?o.errors:i.concat(o.errors),f=i.length),t.errors=i,0===f}
/*
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";
/**
* @type {ReadonlySet<never>}
*/
const NO_TYPES = new Set();
/**
* @type {ReadonlySet<"asset">}
*/
const ASSET_TYPES = new Set(["asset"]);
/**
* @type {ReadonlySet<"asset" | "javascript" | "asset">}
*/
const ASSET_AND_JS_TYPES = new Set(["asset", "javascript"]);
/**
* @type {ReadonlySet<"css-url" | "asset">}
*/
const ASSET_AND_CSS_URL_TYPES = new Set(["asset", "css-url"]);
/**
* @type {ReadonlySet<"javascript" | "css-url" | "asset">}
*/
const ASSET_AND_JS_AND_CSS_URL_TYPES = new Set([
"asset",
"javascript",
"css-url"
]);
/**
* @type {"javascript"}
*/
const JS_TYPE = "javascript";
/**
* @type {ReadonlySet<"javascript">}
*/
const JS_TYPES = new Set(["javascript"]);
/**
* @type {ReadonlySet<"javascript" | "css-url">}
*/
const JS_AND_CSS_URL_TYPES = new Set(["javascript", "css-url"]);
/**
* @type {ReadonlySet<"javascript" | "css">}
*/
const JS_AND_CSS_TYPES = new Set(["javascript", "css"]);
/**
* @type {"css"}
*/
const CSS_TYPE = "css";
/**
* @type {ReadonlySet<"css">}
*/
const CSS_TYPES = new Set(["css"]);
/**
* @type {ReadonlySet<"css-url">}
*/
const CSS_URL_TYPES = new Set(["css-url"]);
/**
* @type {ReadonlySet<"css-import">}
*/
const CSS_IMPORT_TYPES = new Set(["css-import"]);
/**
* @type {ReadonlySet<"webassembly">}
*/
const WEBASSEMBLY_TYPES = new Set(["webassembly"]);
/**
* @type {ReadonlySet<"runtime">}
*/
const RUNTIME_TYPES = new Set(["runtime"]);
/**
* @type {ReadonlySet<"remote" | "share-init">}
*/
const REMOTE_AND_SHARE_INIT_TYPES = new Set(["remote", "share-init"]);
/**
* @type {ReadonlySet<"consume-shared">}
*/
const CONSUME_SHARED_TYPES = new Set(["consume-shared"]);
/**
* @type {ReadonlySet<"share-init">}
*/
const SHARED_INIT_TYPES = new Set(["share-init"]);
module.exports.ASSET_AND_CSS_URL_TYPES = ASSET_AND_CSS_URL_TYPES;
module.exports.ASSET_AND_JS_AND_CSS_URL_TYPES = ASSET_AND_JS_AND_CSS_URL_TYPES;
module.exports.ASSET_AND_JS_TYPES = ASSET_AND_JS_TYPES;
module.exports.ASSET_TYPES = ASSET_TYPES;
module.exports.CONSUME_SHARED_TYPES = CONSUME_SHARED_TYPES;
module.exports.CSS_IMPORT_TYPES = CSS_IMPORT_TYPES;
module.exports.CSS_TYPE = CSS_TYPE;
module.exports.CSS_TYPES = CSS_TYPES;
module.exports.CSS_URL_TYPES = CSS_URL_TYPES;
module.exports.JS_AND_CSS_TYPES = JS_AND_CSS_TYPES;
module.exports.JS_AND_CSS_URL_TYPES = JS_AND_CSS_URL_TYPES;
module.exports.JS_TYPE = JS_TYPE;
module.exports.JS_TYPES = JS_TYPES;
module.exports.NO_TYPES = NO_TYPES;
module.exports.REMOTE_AND_SHARE_INIT_TYPES = REMOTE_AND_SHARE_INIT_TYPES;
module.exports.RUNTIME_TYPES = RUNTIME_TYPES;
module.exports.SHARED_INIT_TYPES = SHARED_INIT_TYPES;
module.exports.WEBASSEMBLY_TYPES = WEBASSEMBLY_TYPES;
/*
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: any) => boolean;
export = check;
/*
* This file was automatically generated.
* DO NOT MODIFY BY HAND.
* Run `yarn fix:special` to update
*/
"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;
{
"$ref": "../../WebpackOptions.json#/definitions/CssAutoGeneratorOptions"
}
/*
* This file was automatically generated.
* DO NOT MODIFY BY HAND.
* Run `yarn fix:special` to update
*/
declare const check: (options: any) => boolean;
export = check;
/*
* This file was automatically generated.
* DO NOT MODIFY BY HAND.
* Run `yarn fix:special` to update
*/
"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;
{
"$ref": "../../WebpackOptions.json#/definitions/CssAutoParserOptions"
}
/*
* This file was automatically generated.
* DO NOT MODIFY BY HAND.
* Run `yarn fix:special` to update
*/
declare const check: (options: any) => boolean;
export = check;
/*
* This file was automatically generated.
* DO NOT MODIFY BY HAND.
* Run `yarn fix:special` to update
*/
"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;
{
"$ref": "../../WebpackOptions.json#/definitions/CssGlobalGeneratorOptions"
}
/*
* This file was automatically generated.
* DO NOT MODIFY BY HAND.
* Run `yarn fix:special` to update
*/
declare const check: (options: any) => boolean;
export = check;
/*
* This file was automatically generated.
* DO NOT MODIFY BY HAND.
* Run `yarn fix:special` to update
*/
"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;
{
"$ref": "../../WebpackOptions.json#/definitions/CssGlobalParserOptions"
}

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

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