mirror of https://github.com/webpack/webpack.git
chore: fix `any` types
Github Actions / lint (push) Waiting to run
Details
Github Actions / basic (push) Waiting to run
Details
Github Actions / validate-legacy-node (push) Waiting to run
Details
Github Actions / unit (push) Waiting to run
Details
Github Actions / integration (10.x, macos-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (10.x, macos-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (10.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (10.x, ubuntu-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (10.x, windows-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (10.x, windows-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (12.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (14.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (16.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (18.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (18.x, ubuntu-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, macos-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, macos-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, ubuntu-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, windows-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, windows-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, macos-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, macos-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, ubuntu-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, windows-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, windows-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (23.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (23.x, ubuntu-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (lts/*, ubuntu-latest, a, 1) (push) Blocked by required conditions
Details
Github Actions / integration (lts/*, ubuntu-latest, b, 1) (push) Blocked by required conditions
Details
Github Actions / lint (push) Waiting to run
Details
Github Actions / basic (push) Waiting to run
Details
Github Actions / validate-legacy-node (push) Waiting to run
Details
Github Actions / unit (push) Waiting to run
Details
Github Actions / integration (10.x, macos-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (10.x, macos-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (10.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (10.x, ubuntu-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (10.x, windows-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (10.x, windows-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (12.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (14.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (16.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (18.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (18.x, ubuntu-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, macos-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, macos-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, ubuntu-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, windows-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (20.x, windows-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, macos-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, macos-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, ubuntu-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, windows-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (22.x, windows-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (23.x, ubuntu-latest, a) (push) Blocked by required conditions
Details
Github Actions / integration (23.x, ubuntu-latest, b) (push) Blocked by required conditions
Details
Github Actions / integration (lts/*, ubuntu-latest, a, 1) (push) Blocked by required conditions
Details
Github Actions / integration (lts/*, ubuntu-latest, b, 1) (push) Blocked by required conditions
Details
This commit is contained in:
commit
79c5575cfc
|
@ -8,7 +8,7 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- task: UseNode@1
|
- task: UseNode@1
|
||||||
inputs:
|
inputs:
|
||||||
version: "18.x"
|
version: "22.x"
|
||||||
displayName: "Install Node.js"
|
displayName: "Install Node.js"
|
||||||
- script: |
|
- script: |
|
||||||
node -v
|
node -v
|
||||||
|
|
|
@ -333,32 +333,31 @@ export default [
|
||||||
// No `*` type
|
// No `*` type
|
||||||
{
|
{
|
||||||
comment: "JsdocBlock:has(JsdocTypeAny)",
|
comment: "JsdocBlock:has(JsdocTypeAny)",
|
||||||
message: "Please use `any`."
|
message: "Please use `any` or `EXPECTED_ANY` type."
|
||||||
},
|
},
|
||||||
// No `?` type
|
// No `?` type
|
||||||
{
|
{
|
||||||
comment: "JsdocBlock:has(JsdocTypeUnknown)",
|
comment: "JsdocBlock:has(JsdocTypeUnknown)",
|
||||||
message: "Please use `unknown` or `any`"
|
message: "Please use `unknown` or `any` (or `EXPECTED_ANY`) type"
|
||||||
},
|
},
|
||||||
|
// No `any` type
|
||||||
|
// {
|
||||||
|
// comment: "JsdocBlock:has(JsdocTypeName[value=/^any$/])",
|
||||||
|
// message: "Please use provide types instead `any`"
|
||||||
|
// },
|
||||||
// No `Function` type
|
// No `Function` type
|
||||||
{
|
{
|
||||||
comment:
|
comment:
|
||||||
"JsdocBlock:has(JsdocTypeName[value=/^(function|Function)$/])",
|
"JsdocBlock:has(JsdocTypeName[value=/^(function|Function)$/])",
|
||||||
message:
|
message:
|
||||||
"Please use provide types for function - `(a: number, b: number) -> number` instead `Function`"
|
"Please use provide types for function - `(a: number, b: number) -> number` instead `Function` or use `EXPECTED_FUNCTION` type"
|
||||||
}
|
}
|
||||||
// No `Object` type
|
// No `Object` type
|
||||||
// {
|
// {
|
||||||
// comment:
|
// comment:
|
||||||
// "JsdocBlock:has(JsdocTag[tag!=typedef]:has(JsdocTypeName[value=/^(object|Object)$/]))",
|
// "JsdocBlock:has(JsdocTag[tag!=/^(typedef|template)$/]:has(JsdocTypeName[value=/^(object|Object)$/]))",
|
||||||
// message:
|
// message:
|
||||||
// "Please use provide types for object - `{ property: number:, result: () => number}` instead `Object`"
|
// "Please use provide types for object - `{ property: number:, result: () => number}` instead `Object` or use `EXPECTED_OBJECT` type"
|
||||||
// },
|
|
||||||
// No `any` type
|
|
||||||
// {
|
|
||||||
// comment: "JsdocBlock:has(JsdocTypeName[value=/^any$/])",
|
|
||||||
// message:
|
|
||||||
// "Please use provide types instead `any`"
|
|
||||||
// },
|
// },
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,9 +26,11 @@ const {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {TODO} Data */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @callback GotHandler
|
* @callback GotHandler
|
||||||
* @param {any} result
|
* @param {TODO} result
|
||||||
* @param {(err?: Error) => void} callback
|
* @param {(err?: Error) => void} callback
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
|
@ -51,9 +53,9 @@ const needCalls = (times, callback) => err => {
|
||||||
class Cache {
|
class Cache {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.hooks = {
|
this.hooks = {
|
||||||
/** @type {AsyncSeriesBailHook<[string, Etag | null, GotHandler[]], any>} */
|
/** @type {AsyncSeriesBailHook<[string, Etag | null, GotHandler[]], Data>} */
|
||||||
get: new AsyncSeriesBailHook(["identifier", "etag", "gotHandlers"]),
|
get: new AsyncSeriesBailHook(["identifier", "etag", "gotHandlers"]),
|
||||||
/** @type {AsyncParallelHook<[string, Etag | null, any]>} */
|
/** @type {AsyncParallelHook<[string, Etag | null, Data]>} */
|
||||||
store: new AsyncParallelHook(["identifier", "etag", "data"]),
|
store: new AsyncParallelHook(["identifier", "etag", "data"]),
|
||||||
/** @type {AsyncParallelHook<[Iterable<string>]>} */
|
/** @type {AsyncParallelHook<[Iterable<string>]>} */
|
||||||
storeBuildDependencies: new AsyncParallelHook(["dependencies"]),
|
storeBuildDependencies: new AsyncParallelHook(["dependencies"]),
|
||||||
|
|
|
@ -39,7 +39,7 @@ class MultiItemCache {
|
||||||
constructor(items) {
|
constructor(items) {
|
||||||
this._items = items;
|
this._items = items;
|
||||||
// eslint-disable-next-line no-constructor-return
|
// eslint-disable-next-line no-constructor-return
|
||||||
if (items.length === 1) return /** @type {any} */ (items[0]);
|
if (items.length === 1) return /** @type {TODO} */ (items[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -117,7 +117,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
||||||
* @param {Module} module the module
|
* @param {Module} module the module
|
||||||
* @param {RuntimeSpec} runtime runtime(s)
|
* @param {RuntimeSpec} runtime runtime(s)
|
||||||
* @param {string} key data key
|
* @param {string} key data key
|
||||||
* @returns {any} data generated by code generation
|
* @returns {TODO | undefined} data generated by code generation
|
||||||
*/
|
*/
|
||||||
getData(module, runtime, key) {
|
getData(module, runtime, key) {
|
||||||
const data = this.get(module, runtime).data;
|
const data = this.get(module, runtime).data;
|
||||||
|
@ -127,7 +127,7 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
||||||
/**
|
/**
|
||||||
* @param {Module} module the module
|
* @param {Module} module the module
|
||||||
* @param {RuntimeSpec} runtime runtime(s)
|
* @param {RuntimeSpec} runtime runtime(s)
|
||||||
* @returns {any} hash of the code generation
|
* @returns {string} hash of the code generation
|
||||||
*/
|
*/
|
||||||
getHash(module, runtime) {
|
getHash(module, runtime) {
|
||||||
const info = this.get(module, runtime);
|
const info = this.get(module, runtime);
|
||||||
|
|
|
@ -369,7 +369,7 @@ const { isSourceEqual } = require("./util/source");
|
||||||
* @property {number} modulesSpace
|
* @property {number} modulesSpace
|
||||||
* @property {number} chunkModulesSpace
|
* @property {number} chunkModulesSpace
|
||||||
* @property {number} nestedModulesSpace
|
* @property {number} nestedModulesSpace
|
||||||
* @property {false|"none"|"error"|"warn"|"info"|"log"|"verbose"} logging
|
* @property {false | "none" | "error" | "warn" | "info" | "log" | "verbose"} logging
|
||||||
* @property {((value: string) => boolean)[]} loggingDebug
|
* @property {((value: string) => boolean)[]} loggingDebug
|
||||||
* @property {boolean} loggingTrace
|
* @property {boolean} loggingTrace
|
||||||
* @property {any} _env
|
* @property {any} _env
|
||||||
|
@ -816,7 +816,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||||
/** @type {SyncHook<[RuntimeModule, Chunk]>} */
|
/** @type {SyncHook<[RuntimeModule, Chunk]>} */
|
||||||
runtimeModule: new SyncHook(["module", "chunk"]),
|
runtimeModule: new SyncHook(["module", "chunk"]),
|
||||||
|
|
||||||
/** @type {SyncHook<[Iterable<Module>, any]>} */
|
/** @type {SyncHook<[Iterable<Module>, Records]>} */
|
||||||
reviveModules: new SyncHook(["modules", "records"]),
|
reviveModules: new SyncHook(["modules", "records"]),
|
||||||
/** @type {SyncHook<[Iterable<Module>]>} */
|
/** @type {SyncHook<[Iterable<Module>]>} */
|
||||||
beforeModuleIds: new SyncHook(["modules"]),
|
beforeModuleIds: new SyncHook(["modules"]),
|
||||||
|
@ -827,7 +827,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||||
/** @type {SyncHook<[Iterable<Module>]>} */
|
/** @type {SyncHook<[Iterable<Module>]>} */
|
||||||
afterOptimizeModuleIds: new SyncHook(["modules"]),
|
afterOptimizeModuleIds: new SyncHook(["modules"]),
|
||||||
|
|
||||||
/** @type {SyncHook<[Iterable<Chunk>, any]>} */
|
/** @type {SyncHook<[Iterable<Chunk>, Records]>} */
|
||||||
reviveChunks: new SyncHook(["chunks", "records"]),
|
reviveChunks: new SyncHook(["chunks", "records"]),
|
||||||
/** @type {SyncHook<[Iterable<Chunk>]>} */
|
/** @type {SyncHook<[Iterable<Chunk>]>} */
|
||||||
beforeChunkIds: new SyncHook(["chunks"]),
|
beforeChunkIds: new SyncHook(["chunks"]),
|
||||||
|
@ -838,9 +838,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||||
/** @type {SyncHook<[Iterable<Chunk>]>} */
|
/** @type {SyncHook<[Iterable<Chunk>]>} */
|
||||||
afterOptimizeChunkIds: new SyncHook(["chunks"]),
|
afterOptimizeChunkIds: new SyncHook(["chunks"]),
|
||||||
|
|
||||||
/** @type {SyncHook<[Iterable<Module>, any]>} */
|
/** @type {SyncHook<[Iterable<Module>, Records]>} */
|
||||||
recordModules: new SyncHook(["modules", "records"]),
|
recordModules: new SyncHook(["modules", "records"]),
|
||||||
/** @type {SyncHook<[Iterable<Chunk>, any]>} */
|
/** @type {SyncHook<[Iterable<Chunk>, Records]>} */
|
||||||
recordChunks: new SyncHook(["chunks", "records"]),
|
recordChunks: new SyncHook(["chunks", "records"]),
|
||||||
|
|
||||||
/** @type {SyncHook<[Iterable<Module>]>} */
|
/** @type {SyncHook<[Iterable<Module>]>} */
|
||||||
|
@ -867,9 +867,9 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
||||||
contentHash: new SyncHook(["chunk"]),
|
contentHash: new SyncHook(["chunk"]),
|
||||||
/** @type {SyncHook<[]>} */
|
/** @type {SyncHook<[]>} */
|
||||||
afterHash: new SyncHook([]),
|
afterHash: new SyncHook([]),
|
||||||
/** @type {SyncHook<[any]>} */
|
/** @type {SyncHook<[Records]>} */
|
||||||
recordHash: new SyncHook(["records"]),
|
recordHash: new SyncHook(["records"]),
|
||||||
/** @type {SyncHook<[Compilation, any]>} */
|
/** @type {SyncHook<[Compilation, Records]>} */
|
||||||
record: new SyncHook(["compilation", "records"]),
|
record: new SyncHook(["compilation", "records"]),
|
||||||
|
|
||||||
/** @type {SyncHook<[]>} */
|
/** @type {SyncHook<[]>} */
|
||||||
|
@ -3232,13 +3232,21 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
||||||
|
|
||||||
const shouldRecord = this.hooks.shouldRecord.call() !== false;
|
const shouldRecord = this.hooks.shouldRecord.call() !== false;
|
||||||
|
|
||||||
this.hooks.reviveModules.call(this.modules, this.records);
|
this.hooks.reviveModules.call(
|
||||||
|
this.modules,
|
||||||
|
/** @type {Records} */
|
||||||
|
(this.records)
|
||||||
|
);
|
||||||
this.hooks.beforeModuleIds.call(this.modules);
|
this.hooks.beforeModuleIds.call(this.modules);
|
||||||
this.hooks.moduleIds.call(this.modules);
|
this.hooks.moduleIds.call(this.modules);
|
||||||
this.hooks.optimizeModuleIds.call(this.modules);
|
this.hooks.optimizeModuleIds.call(this.modules);
|
||||||
this.hooks.afterOptimizeModuleIds.call(this.modules);
|
this.hooks.afterOptimizeModuleIds.call(this.modules);
|
||||||
|
|
||||||
this.hooks.reviveChunks.call(this.chunks, this.records);
|
this.hooks.reviveChunks.call(
|
||||||
|
this.chunks,
|
||||||
|
/** @type {Records} */
|
||||||
|
(this.records)
|
||||||
|
);
|
||||||
this.hooks.beforeChunkIds.call(this.chunks);
|
this.hooks.beforeChunkIds.call(this.chunks);
|
||||||
this.hooks.chunkIds.call(this.chunks);
|
this.hooks.chunkIds.call(this.chunks);
|
||||||
this.hooks.optimizeChunkIds.call(this.chunks);
|
this.hooks.optimizeChunkIds.call(this.chunks);
|
||||||
|
@ -3253,8 +3261,16 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
||||||
this.sortItemsWithChunkIds();
|
this.sortItemsWithChunkIds();
|
||||||
|
|
||||||
if (shouldRecord) {
|
if (shouldRecord) {
|
||||||
this.hooks.recordModules.call(this.modules, this.records);
|
this.hooks.recordModules.call(
|
||||||
this.hooks.recordChunks.call(this.chunks, this.records);
|
this.modules,
|
||||||
|
/** @type {Records} */
|
||||||
|
(this.records)
|
||||||
|
);
|
||||||
|
this.hooks.recordChunks.call(
|
||||||
|
this.chunks,
|
||||||
|
/** @type {Records} */
|
||||||
|
(this.records)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.hooks.optimizeCodeGeneration.call(this.modules);
|
this.hooks.optimizeCodeGeneration.call(this.modules);
|
||||||
|
@ -3294,7 +3310,10 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
||||||
|
|
||||||
if (shouldRecord) {
|
if (shouldRecord) {
|
||||||
this.logger.time("record hash");
|
this.logger.time("record hash");
|
||||||
this.hooks.recordHash.call(this.records);
|
this.hooks.recordHash.call(
|
||||||
|
/** @type {Records} */
|
||||||
|
(this.records)
|
||||||
|
);
|
||||||
this.logger.timeEnd("record hash");
|
this.logger.timeEnd("record hash");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3332,7 +3351,11 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
||||||
|
|
||||||
this.summarizeDependencies();
|
this.summarizeDependencies();
|
||||||
if (shouldRecord) {
|
if (shouldRecord) {
|
||||||
this.hooks.record.call(this, this.records);
|
this.hooks.record.call(
|
||||||
|
this,
|
||||||
|
/** @type {Records} */
|
||||||
|
(this.records)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hooks.needAdditionalSeal.call()) {
|
if (this.hooks.needAdditionalSeal.call()) {
|
||||||
|
|
|
@ -96,6 +96,7 @@ const { isSourceEqual } = require("./util/source");
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @typedef {{ sizeOnlySource: SizeOnlySource | undefined, writtenTo: Map<string, number> }} CacheEntry */
|
/** @typedef {{ sizeOnlySource: SizeOnlySource | undefined, writtenTo: Map<string, number> }} CacheEntry */
|
||||||
|
|
||||||
/** @typedef {{ path: string, source: Source, size: number | undefined, waiting: ({ cacheEntry: any, file: string }[] | undefined) }} SimilarEntry */
|
/** @typedef {{ path: string, source: Source, size: number | undefined, waiting: ({ cacheEntry: any, file: string }[] | undefined) }} SimilarEntry */
|
||||||
|
|
||||||
/** @typedef {{ buildInfo: BuildInfo, references: References | undefined, memCache: WeakTupleMap<any, any> }} ModuleMemCachesItem */
|
/** @typedef {{ buildInfo: BuildInfo, references: References | undefined, memCache: WeakTupleMap<any, any> }} ModuleMemCachesItem */
|
||||||
|
@ -112,13 +113,13 @@ const isSorted = array => {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {{[key: string]: any}} obj an object
|
* @template {object} T
|
||||||
* @param {string[]} keys the keys of the object
|
* @param {T} obj an object
|
||||||
* @returns {{[key: string]: any}} the object with properties sorted by property name
|
* @param {(keyof T)[]} keys the keys of the object
|
||||||
|
* @returns {T} the object with properties sorted by property name
|
||||||
*/
|
*/
|
||||||
const sortObject = (obj, keys) => {
|
const sortObject = (obj, keys) => {
|
||||||
/** @type {{[key: string]: any}} */
|
const o = /** @type {T} */ ({});
|
||||||
const o = {};
|
|
||||||
for (const k of keys.sort()) {
|
for (const k of keys.sort()) {
|
||||||
o[k] = obj[k];
|
o[k] = obj[k];
|
||||||
}
|
}
|
||||||
|
@ -203,7 +204,7 @@ class Compiler {
|
||||||
/** @type {AsyncSeriesHook<[]>} */
|
/** @type {AsyncSeriesHook<[]>} */
|
||||||
shutdown: new AsyncSeriesHook([]),
|
shutdown: new AsyncSeriesHook([]),
|
||||||
|
|
||||||
/** @type {SyncBailHook<[string, string, any[] | undefined], true | void>} */
|
/** @type {SyncBailHook<[string, string, EXPECTED_ANY[] | undefined], true | void>} */
|
||||||
infrastructureLog: new SyncBailHook(["origin", "type", "args"]),
|
infrastructureLog: new SyncBailHook(["origin", "type", "args"]),
|
||||||
|
|
||||||
// TODO the following hooks are weirdly located here
|
// TODO the following hooks are weirdly located here
|
||||||
|
|
|
@ -78,7 +78,7 @@ class ConditionalInitFragment extends InitFragment {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {GenerateContext} context context
|
* @param {GenerateContext} context context
|
||||||
* @returns {string|Source=} the source code that will be included at the end of the module
|
* @returns {string | Source=} the source code that will be included at the end of the module
|
||||||
*/
|
*/
|
||||||
getEndContent(context) {
|
getEndContent(context) {
|
||||||
if (this.runtimeCondition === false || !this.endContent) return "";
|
if (this.runtimeCondition === false || !this.endContent) return "";
|
||||||
|
|
|
@ -137,7 +137,7 @@ function getObjKeys(properties) {
|
||||||
/** @typedef {boolean | undefined | null} AsiSafe */
|
/** @typedef {boolean | undefined | null} AsiSafe */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {any[] | {[k: string]: any}} obj obj
|
* @param {EXPECTED_ANY[] | {[k: string]: EXPECTED_ANY}} obj obj
|
||||||
* @param {JavascriptParser} parser Parser
|
* @param {JavascriptParser} parser Parser
|
||||||
* @param {ValueCacheVersions} valueCacheVersions valueCacheVersions
|
* @param {ValueCacheVersions} valueCacheVersions valueCacheVersions
|
||||||
* @param {string} key the defined key
|
* @param {string} key the defined key
|
||||||
|
@ -160,21 +160,19 @@ const stringifyObj = (
|
||||||
let code;
|
let code;
|
||||||
const arr = Array.isArray(obj);
|
const arr = Array.isArray(obj);
|
||||||
if (arr) {
|
if (arr) {
|
||||||
code = `[${
|
code = `[${obj
|
||||||
/** @type {any[]} */ (obj)
|
.map(code =>
|
||||||
.map(code =>
|
toCode(
|
||||||
toCode(
|
code,
|
||||||
code,
|
parser,
|
||||||
parser,
|
valueCacheVersions,
|
||||||
valueCacheVersions,
|
key,
|
||||||
key,
|
runtimeTemplate,
|
||||||
runtimeTemplate,
|
logger,
|
||||||
logger,
|
null
|
||||||
null
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
.join(",")
|
)
|
||||||
}]`;
|
.join(",")}]`;
|
||||||
} else {
|
} else {
|
||||||
let keys = Object.keys(obj);
|
let keys = Object.keys(obj);
|
||||||
if (objKeys) {
|
if (objKeys) {
|
||||||
|
@ -182,7 +180,7 @@ const stringifyObj = (
|
||||||
}
|
}
|
||||||
code = `{${keys
|
code = `{${keys
|
||||||
.map(key => {
|
.map(key => {
|
||||||
const code = /** @type {{[k: string]: any}} */ (obj)[key];
|
const code = obj[key];
|
||||||
return `${JSON.stringify(key)}:${toCode(
|
return `${JSON.stringify(key)}:${toCode(
|
||||||
code,
|
code,
|
||||||
parser,
|
parser,
|
||||||
|
@ -310,7 +308,10 @@ const toCacheVersion = code => {
|
||||||
if (typeof code === "object") {
|
if (typeof code === "object") {
|
||||||
const items = Object.keys(code).map(key => ({
|
const items = Object.keys(code).map(key => ({
|
||||||
key,
|
key,
|
||||||
value: toCacheVersion(/** @type {Record<string, any>} */ (code)[key])
|
value: toCacheVersion(
|
||||||
|
/** @type {Record<string, EXPECTED_ANY>} */
|
||||||
|
(code)[key]
|
||||||
|
)
|
||||||
}));
|
}));
|
||||||
if (items.some(({ value }) => value === undefined)) return;
|
if (items.some(({ value }) => value === undefined)) return;
|
||||||
return `{${items.map(({ key, value }) => `${key}: ${value}`).join(", ")}}`;
|
return `{${items.map(({ key, value }) => `${key}: ${value}`).join(", ")}}`;
|
||||||
|
|
|
@ -216,7 +216,7 @@ const getSourceForImportExternal = (
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} key key
|
* @param {string} key key
|
||||||
* @param {any | undefined} value value
|
* @param {TODO | undefined} value value
|
||||||
* @returns {undefined | string} replaced value
|
* @returns {undefined | string} replaced value
|
||||||
*/
|
*/
|
||||||
const importAssertionReplacer = (key, value) => {
|
const importAssertionReplacer = (key, value) => {
|
||||||
|
|
|
@ -64,7 +64,7 @@ class InitFragment {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {GenerateContext} context context
|
* @param {GenerateContext} context context
|
||||||
* @returns {string|Source=} the source code that will be included at the end of the module
|
* @returns {string | Source=} the source code that will be included at the end of the module
|
||||||
*/
|
*/
|
||||||
getEndContent(context) {
|
getEndContent(context) {
|
||||||
return this.endContent;
|
return this.endContent;
|
||||||
|
|
|
@ -70,7 +70,7 @@ class LoaderOptionsPlugin {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @type {any} */
|
/** @type {TODO} */
|
||||||
(context)[key] = options[key];
|
(context)[key] = options[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ const makeSerializable = require("./util/makeSerializable");
|
||||||
/**
|
/**
|
||||||
* @typedef {object} CodeGenerationResult
|
* @typedef {object} CodeGenerationResult
|
||||||
* @property {Map<string, Source>} sources the resulting sources for all source types
|
* @property {Map<string, Source>} sources the resulting sources for all source types
|
||||||
* @property {Map<string, any>=} data the resulting data for all source types
|
* @property {Map<string, TODO>=} data the resulting data for all source types
|
||||||
* @property {ReadOnlyRuntimeRequirements | null} runtimeRequirements the runtime requirements
|
* @property {ReadOnlyRuntimeRequirements | null} runtimeRequirements the runtime requirements
|
||||||
* @property {string=} hash a hash of the code generation result (will be automatically calculated from sources and runtimeRequirements if not provided)
|
* @property {string=} hash a hash of the code generation result (will be automatically calculated from sources and runtimeRequirements if not provided)
|
||||||
*/
|
*/
|
||||||
|
@ -138,8 +138,8 @@ const makeSerializable = require("./util/makeSerializable");
|
||||||
|
|
||||||
/** @typedef {(err?: WebpackError) => void} BuildCallback */
|
/** @typedef {(err?: WebpackError) => void} BuildCallback */
|
||||||
|
|
||||||
/** @typedef {KnownBuildMeta & Record<string, any>} BuildMeta */
|
/** @typedef {KnownBuildMeta & Record<string, EXPECTED_ANY>} BuildMeta */
|
||||||
/** @typedef {KnownBuildInfo & Record<string, any>} BuildInfo */
|
/** @typedef {KnownBuildInfo & Record<string, EXPECTED_ANY>} BuildInfo */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {object} FactoryMeta
|
* @typedef {object} FactoryMeta
|
||||||
|
|
|
@ -12,9 +12,11 @@ const makeSerializable = require("./util/makeSerializable");
|
||||||
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||||
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
||||||
|
|
||||||
|
/** @typedef {Error & { hideStack?: boolean }} ErrorWithHideStack */
|
||||||
|
|
||||||
class ModuleBuildError extends WebpackError {
|
class ModuleBuildError extends WebpackError {
|
||||||
/**
|
/**
|
||||||
* @param {string | Error&any} err error thrown
|
* @param {string | ErrorWithHideStack} err error thrown
|
||||||
* @param {{from?: string|null}} info additional info
|
* @param {{from?: string|null}} info additional info
|
||||||
*/
|
*/
|
||||||
constructor(err, { from = null } = {}) {
|
constructor(err, { from = null } = {}) {
|
||||||
|
|
|
@ -9,12 +9,13 @@ const WebpackError = require("./WebpackError");
|
||||||
|
|
||||||
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
||||||
/** @typedef {import("./Module")} Module */
|
/** @typedef {import("./Module")} Module */
|
||||||
|
/** @typedef {import("./ModuleBuildError").ErrorWithHideStack} ErrorWithHideStack */
|
||||||
|
|
||||||
class ModuleDependencyError extends WebpackError {
|
class ModuleDependencyError extends WebpackError {
|
||||||
/**
|
/**
|
||||||
* Creates an instance of ModuleDependencyError.
|
* Creates an instance of ModuleDependencyError.
|
||||||
* @param {Module} module module tied to dependency
|
* @param {Module} module module tied to dependency
|
||||||
* @param {Error} err error thrown
|
* @param {ErrorWithHideStack} err error thrown
|
||||||
* @param {DependencyLocation} loc location of dependency
|
* @param {DependencyLocation} loc location of dependency
|
||||||
*/
|
*/
|
||||||
constructor(module, err, loc) {
|
constructor(module, err, loc) {
|
||||||
|
@ -22,7 +23,7 @@ class ModuleDependencyError extends WebpackError {
|
||||||
|
|
||||||
this.name = "ModuleDependencyError";
|
this.name = "ModuleDependencyError";
|
||||||
this.details =
|
this.details =
|
||||||
err && !(/** @type {any} */ (err).hideStack)
|
err && !err.hideStack
|
||||||
? /** @type {string} */ (err.stack).split("\n").slice(1).join("\n")
|
? /** @type {string} */ (err.stack).split("\n").slice(1).join("\n")
|
||||||
: undefined;
|
: undefined;
|
||||||
this.module = module;
|
this.module = module;
|
||||||
|
@ -30,7 +31,7 @@ class ModuleDependencyError extends WebpackError {
|
||||||
/** error is not (de)serialized, so it might be undefined after deserialization */
|
/** error is not (de)serialized, so it might be undefined after deserialization */
|
||||||
this.error = err;
|
this.error = err;
|
||||||
|
|
||||||
if (err && /** @type {any} */ (err).hideStack && err.stack) {
|
if (err && err.hideStack && err.stack) {
|
||||||
this.stack = /** @type {string} */ `${err.stack
|
this.stack = /** @type {string} */ `${err.stack
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.slice(1)
|
.slice(1)
|
||||||
|
|
|
@ -10,11 +10,12 @@ const makeSerializable = require("./util/makeSerializable");
|
||||||
|
|
||||||
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
|
||||||
/** @typedef {import("./Module")} Module */
|
/** @typedef {import("./Module")} Module */
|
||||||
|
/** @typedef {import("./ModuleDependencyError").ErrorWithHideStack} ErrorWithHideStack */
|
||||||
|
|
||||||
class ModuleDependencyWarning extends WebpackError {
|
class ModuleDependencyWarning extends WebpackError {
|
||||||
/**
|
/**
|
||||||
* @param {Module} module module tied to dependency
|
* @param {Module} module module tied to dependency
|
||||||
* @param {Error} err error thrown
|
* @param {ErrorWithHideStack} err error thrown
|
||||||
* @param {DependencyLocation} loc location of dependency
|
* @param {DependencyLocation} loc location of dependency
|
||||||
*/
|
*/
|
||||||
constructor(module, err, loc) {
|
constructor(module, err, loc) {
|
||||||
|
@ -22,7 +23,7 @@ class ModuleDependencyWarning extends WebpackError {
|
||||||
|
|
||||||
this.name = "ModuleDependencyWarning";
|
this.name = "ModuleDependencyWarning";
|
||||||
this.details =
|
this.details =
|
||||||
err && !(/** @type {any} */ (err).hideStack)
|
err && !err.hideStack
|
||||||
? /** @type {string} */ (err.stack).split("\n").slice(1).join("\n")
|
? /** @type {string} */ (err.stack).split("\n").slice(1).join("\n")
|
||||||
: undefined;
|
: undefined;
|
||||||
this.module = module;
|
this.module = module;
|
||||||
|
@ -30,7 +31,7 @@ class ModuleDependencyWarning extends WebpackError {
|
||||||
/** error is not (de)serialized, so it might be undefined after deserialization */
|
/** error is not (de)serialized, so it might be undefined after deserialization */
|
||||||
this.error = err;
|
this.error = err;
|
||||||
|
|
||||||
if (err && /** @type {any} */ (err).hideStack && err.stack) {
|
if (err && err.hideStack && err.stack) {
|
||||||
this.stack = /** @type {string} */ `${err.stack
|
this.stack = /** @type {string} */ `${err.stack
|
||||||
.split("\n")
|
.split("\n")
|
||||||
.slice(1)
|
.slice(1)
|
||||||
|
|
|
@ -121,6 +121,8 @@ class ModuleGraphModule {
|
||||||
|
|
||||||
/** @typedef {(moduleGraphConnection: ModuleGraphConnection) => boolean} FilterConnection */
|
/** @typedef {(moduleGraphConnection: ModuleGraphConnection) => boolean} FilterConnection */
|
||||||
|
|
||||||
|
/** @typedef {Map<Module, WeakTupleMap<any, any>>} ModuleMemCaches */
|
||||||
|
|
||||||
class ModuleGraph {
|
class ModuleGraph {
|
||||||
constructor() {
|
constructor() {
|
||||||
/**
|
/**
|
||||||
|
@ -134,7 +136,7 @@ class ModuleGraph {
|
||||||
*/
|
*/
|
||||||
this._moduleMap = new Map();
|
this._moduleMap = new Map();
|
||||||
/**
|
/**
|
||||||
* @type {WeakMap<any, object>}
|
* @type {WeakMap<TODO, object>}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this._metaMap = new WeakMap();
|
this._metaMap = new WeakMap();
|
||||||
|
@ -144,7 +146,7 @@ class ModuleGraph {
|
||||||
*/
|
*/
|
||||||
this._cache = undefined;
|
this._cache = undefined;
|
||||||
/**
|
/**
|
||||||
* @type {Map<Module, WeakTupleMap<any, any>> | undefined}
|
* @type {ModuleMemCaches | undefined}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this._moduleMemCaches = undefined;
|
this._moduleMemCaches = undefined;
|
||||||
|
@ -758,7 +760,7 @@ class ModuleGraph {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {any} thing any thing
|
* @param {TODO} thing any thing
|
||||||
* @returns {object} metadata
|
* @returns {object} metadata
|
||||||
*/
|
*/
|
||||||
getMeta(thing) {
|
getMeta(thing) {
|
||||||
|
@ -771,7 +773,7 @@ class ModuleGraph {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {any} thing any thing
|
* @param {TODO} thing any thing
|
||||||
* @returns {object | undefined} metadata
|
* @returns {object | undefined} metadata
|
||||||
*/
|
*/
|
||||||
getMetaIfExisting(thing) {
|
getMetaIfExisting(thing) {
|
||||||
|
@ -804,7 +806,7 @@ class ModuleGraph {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Map<Module, WeakTupleMap<any, any>>} moduleMemCaches mem caches for modules for better caching
|
* @param {ModuleMemCaches} moduleMemCaches mem caches for modules for better caching
|
||||||
*/
|
*/
|
||||||
setModuleMemCaches(moduleMemCaches) {
|
setModuleMemCaches(moduleMemCaches) {
|
||||||
this._moduleMemCaches = moduleMemCaches;
|
this._moduleMemCaches = moduleMemCaches;
|
||||||
|
|
|
@ -44,7 +44,7 @@ const previouslyPolyfilledBuiltinModules = {
|
||||||
class ModuleNotFoundError extends WebpackError {
|
class ModuleNotFoundError extends WebpackError {
|
||||||
/**
|
/**
|
||||||
* @param {Module | null} module module tied to dependency
|
* @param {Module | null} module module tied to dependency
|
||||||
* @param {Error&any} err error thrown
|
* @param {Error & { details?: string }} err error thrown
|
||||||
* @param {DependencyLocation} loc location of dependency
|
* @param {DependencyLocation} loc location of dependency
|
||||||
*/
|
*/
|
||||||
constructor(module, err, loc) {
|
constructor(module, err, loc) {
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
const WebpackError = require("./WebpackError");
|
const WebpackError = require("./WebpackError");
|
||||||
const makeSerializable = require("./util/makeSerializable");
|
const makeSerializable = require("./util/makeSerializable");
|
||||||
|
|
||||||
|
/** @typedef {import("./Dependency").SourcePosition} SourcePosition */
|
||||||
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||||
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
||||||
|
|
||||||
|
@ -16,7 +17,7 @@ const WASM_HEADER = Buffer.from([0x00, 0x61, 0x73, 0x6d]);
|
||||||
class ModuleParseError extends WebpackError {
|
class ModuleParseError extends WebpackError {
|
||||||
/**
|
/**
|
||||||
* @param {string | Buffer} source source code
|
* @param {string | Buffer} source source code
|
||||||
* @param {Error & any} err the parse error
|
* @param {Error & { loc?: SourcePosition }} err the parse error
|
||||||
* @param {string[]} loaders the loaders used
|
* @param {string[]} loaders the loaders used
|
||||||
* @param {string} type module type
|
* @param {string} type module type
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -51,6 +51,7 @@ const {
|
||||||
/** @typedef {import("./ResolverFactory").ResolveRequest} ResolveRequest */
|
/** @typedef {import("./ResolverFactory").ResolveRequest} ResolveRequest */
|
||||||
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
||||||
/** @typedef {import("./dependencies/ModuleDependency")} ModuleDependency */
|
/** @typedef {import("./dependencies/ModuleDependency")} ModuleDependency */
|
||||||
|
/** @typedef {import("./rules/RuleSetCompiler").RuleSetRules} RuleSetRules */
|
||||||
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
||||||
|
|
||||||
/** @typedef {Pick<RuleSetRule, 'type' | 'sideEffects' | 'parser' | 'generator' | 'resolve' | 'layer'>} ModuleSettings */
|
/** @typedef {Pick<RuleSetRule, 'type' | 'sideEffects' | 'parser' | 'generator' | 'resolve' | 'layer'>} ModuleSettings */
|
||||||
|
@ -299,10 +300,10 @@ class NormalModuleFactory extends ModuleFactory {
|
||||||
this.resolverFactory = resolverFactory;
|
this.resolverFactory = resolverFactory;
|
||||||
this.ruleSet = ruleSetCompiler.compile([
|
this.ruleSet = ruleSetCompiler.compile([
|
||||||
{
|
{
|
||||||
rules: options.defaultRules
|
rules: /** @type {RuleSetRules} */ (options.defaultRules)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
rules: options.rules
|
rules: /** @type {RuleSetRules} */ (options.rules)
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
this.context = context || "";
|
this.context = context || "";
|
||||||
|
|
|
@ -853,6 +853,7 @@ class RuntimeTemplate {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @template GenerateContext
|
||||||
* @param {object} options options
|
* @param {object} options options
|
||||||
* @param {ModuleGraph} options.moduleGraph the module graph
|
* @param {ModuleGraph} options.moduleGraph the module graph
|
||||||
* @param {Module} options.module the module
|
* @param {Module} options.module the module
|
||||||
|
@ -864,7 +865,7 @@ class RuntimeTemplate {
|
||||||
* @param {boolean | null} options.callContext when false, call context will not be preserved
|
* @param {boolean | null} options.callContext when false, call context will not be preserved
|
||||||
* @param {boolean} options.defaultInterop when true and accessing the default exports, interop code will be generated
|
* @param {boolean} options.defaultInterop when true and accessing the default exports, interop code will be generated
|
||||||
* @param {string} options.importVar the identifier name of the import variable
|
* @param {string} options.importVar the identifier name of the import variable
|
||||||
* @param {InitFragment<TODO>[]} options.initFragments init fragments will be added here
|
* @param {InitFragment<GenerateContext>[]} options.initFragments init fragments will be added here
|
||||||
* @param {RuntimeSpec} options.runtime runtime for which this code will be generated
|
* @param {RuntimeSpec} options.runtime runtime for which this code will be generated
|
||||||
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
|
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||||
* @returns {string} expression
|
* @returns {string} expression
|
||||||
|
|
|
@ -96,11 +96,14 @@ const MIN_ITEMS_IN_FRESH_PACK = 100;
|
||||||
const MAX_ITEMS_IN_FRESH_PACK = 50000;
|
const MAX_ITEMS_IN_FRESH_PACK = 50000;
|
||||||
const MAX_TIME_IN_FRESH_PACK = 1 * 60 * 1000; // 1 min
|
const MAX_TIME_IN_FRESH_PACK = 1 * 60 * 1000; // 1 min
|
||||||
|
|
||||||
|
/** @typedef {TODO | undefined} Value */
|
||||||
|
/** @typedef {TODO | undefined} LazyValue */
|
||||||
|
|
||||||
class PackItemInfo {
|
class PackItemInfo {
|
||||||
/**
|
/**
|
||||||
* @param {string} identifier identifier of item
|
* @param {string} identifier identifier of item
|
||||||
* @param {string | null | undefined} etag etag of item
|
* @param {string | null | undefined} etag etag of item
|
||||||
* @param {any} value fresh value of item
|
* @param {Value} value fresh value of item
|
||||||
*/
|
*/
|
||||||
constructor(identifier, etag, value) {
|
constructor(identifier, etag, value) {
|
||||||
this.identifier = identifier;
|
this.identifier = identifier;
|
||||||
|
@ -155,7 +158,7 @@ class Pack {
|
||||||
/**
|
/**
|
||||||
* @param {string} identifier unique name for the resource
|
* @param {string} identifier unique name for the resource
|
||||||
* @param {string | null} etag etag of the resource
|
* @param {string | null} etag etag of the resource
|
||||||
* @returns {any} cached content
|
* @returns {Value} cached content
|
||||||
*/
|
*/
|
||||||
get(identifier, etag) {
|
get(identifier, etag) {
|
||||||
const info = this.itemInfo.get(identifier);
|
const info = this.itemInfo.get(identifier);
|
||||||
|
@ -178,7 +181,7 @@ class Pack {
|
||||||
/**
|
/**
|
||||||
* @param {string} identifier unique name for the resource
|
* @param {string} identifier unique name for the resource
|
||||||
* @param {string | null} etag etag of the resource
|
* @param {string | null} etag etag of the resource
|
||||||
* @param {any} data cached content
|
* @param {Value} data cached content
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
set(identifier, etag, data) {
|
set(identifier, etag, data) {
|
||||||
|
@ -269,7 +272,7 @@ class Pack {
|
||||||
}
|
}
|
||||||
|
|
||||||
_persistFreshContent() {
|
_persistFreshContent() {
|
||||||
/** @typedef {{ items: Items, map: Map<string, any>, loc: number }} PackItem */
|
/** @typedef {{ items: Items, map: Content, loc: number }} PackItem */
|
||||||
const itemsCount = this.freshContent.size;
|
const itemsCount = this.freshContent.size;
|
||||||
if (itemsCount > 0) {
|
if (itemsCount > 0) {
|
||||||
const packCount = Math.ceil(itemsCount / MAX_ITEMS_IN_FRESH_PACK);
|
const packCount = Math.ceil(itemsCount / MAX_ITEMS_IN_FRESH_PACK);
|
||||||
|
@ -394,7 +397,7 @@ class Pack {
|
||||||
const mergedItems = new Set();
|
const mergedItems = new Set();
|
||||||
/** @type {Items} */
|
/** @type {Items} */
|
||||||
const mergedUsedItems = new Set();
|
const mergedUsedItems = new Set();
|
||||||
/** @type {((map: Map<string, any>) => Promise<void>)[]} */
|
/** @type {((map: Content) => Promise<void>)[]} */
|
||||||
const addToMergedMap = [];
|
const addToMergedMap = [];
|
||||||
for (const content of mergedContent) {
|
for (const content of mergedContent) {
|
||||||
for (const identifier of content.items) {
|
for (const identifier of content.items) {
|
||||||
|
@ -473,6 +476,7 @@ class Pack {
|
||||||
await content.unpack(
|
await content.unpack(
|
||||||
"it should be splitted into used and unused items"
|
"it should be splitted into used and unused items"
|
||||||
);
|
);
|
||||||
|
/** @type {Content} */
|
||||||
const map = new Map();
|
const map = new Map();
|
||||||
for (const identifier of usedItems) {
|
for (const identifier of usedItems) {
|
||||||
map.set(
|
map.set(
|
||||||
|
@ -663,7 +667,7 @@ class Pack {
|
||||||
|
|
||||||
makeSerializable(Pack, "webpack/lib/cache/PackFileCacheStrategy", "Pack");
|
makeSerializable(Pack, "webpack/lib/cache/PackFileCacheStrategy", "Pack");
|
||||||
|
|
||||||
/** @typedef {Map<string, any>} Content */
|
/** @typedef {Map<string, Value>} Content */
|
||||||
|
|
||||||
class PackContentItems {
|
class PackContentItems {
|
||||||
/**
|
/**
|
||||||
|
@ -826,7 +830,7 @@ class PackContent {
|
||||||
*/
|
*/
|
||||||
constructor(items, usedItems, dataOrFn, logger, lazyName) {
|
constructor(items, usedItems, dataOrFn, logger, lazyName) {
|
||||||
this.items = items;
|
this.items = items;
|
||||||
/** @type {TODO | undefined} */
|
/** @type {LazyValue} */
|
||||||
this.lazy = typeof dataOrFn === "function" ? dataOrFn : undefined;
|
this.lazy = typeof dataOrFn === "function" ? dataOrFn : undefined;
|
||||||
/** @type {Content | undefined} */
|
/** @type {Content | undefined} */
|
||||||
this.content = typeof dataOrFn === "function" ? undefined : dataOrFn.map;
|
this.content = typeof dataOrFn === "function" ? undefined : dataOrFn.map;
|
||||||
|
@ -943,7 +947,9 @@ class PackContent {
|
||||||
*/
|
*/
|
||||||
getSize() {
|
getSize() {
|
||||||
if (!this.lazy) return -1;
|
if (!this.lazy) return -1;
|
||||||
const options = /** @type {any} */ (this.lazy).options;
|
const options =
|
||||||
|
/** @type {{ options: { size?: number } }} */
|
||||||
|
(this.lazy).options;
|
||||||
if (!options) return -1;
|
if (!options) return -1;
|
||||||
const size = options.size;
|
const size = options.size;
|
||||||
if (typeof size !== "number") return -1;
|
if (typeof size !== "number") return -1;
|
||||||
|
@ -961,7 +967,7 @@ class PackContent {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @template T
|
* @template T
|
||||||
* @param {(item: any) => (() => Promise<PackContentItems> | PackContentItems)} write write function
|
* @param {(item?: LazyValue) => (() => Promise<PackContentItems> | PackContentItems)} write write function
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
writeLazy(write) {
|
writeLazy(write) {
|
||||||
|
@ -1030,10 +1036,7 @@ class PackContent {
|
||||||
}
|
}
|
||||||
// Move to state C1 (or maybe C2)
|
// Move to state C1 (or maybe C2)
|
||||||
this.content = map;
|
this.content = map;
|
||||||
this.lazy = SerializerMiddleware.unMemoizeLazy(
|
this.lazy = SerializerMiddleware.unMemoizeLazy(this.lazy);
|
||||||
/** @type {LazyFunction} */
|
|
||||||
(this.lazy)
|
|
||||||
);
|
|
||||||
|
|
||||||
return new PackContentItems(map);
|
return new PackContentItems(map);
|
||||||
})
|
})
|
||||||
|
@ -1316,7 +1319,7 @@ class PackFileCacheStrategy {
|
||||||
/**
|
/**
|
||||||
* @param {string} identifier unique name for the resource
|
* @param {string} identifier unique name for the resource
|
||||||
* @param {Etag | null} etag etag of the resource
|
* @param {Etag | null} etag etag of the resource
|
||||||
* @param {any} data cached content
|
* @param {Value} data cached content
|
||||||
* @returns {Promise<void>} promise
|
* @returns {Promise<void>} promise
|
||||||
*/
|
*/
|
||||||
store(identifier, etag, data) {
|
store(identifier, etag, data) {
|
||||||
|
@ -1330,7 +1333,7 @@ class PackFileCacheStrategy {
|
||||||
/**
|
/**
|
||||||
* @param {string} identifier unique name for the resource
|
* @param {string} identifier unique name for the resource
|
||||||
* @param {Etag | null} etag etag of the resource
|
* @param {Etag | null} etag etag of the resource
|
||||||
* @returns {Promise<any>} promise to the cached content
|
* @returns {Promise<Value>} promise to the cached content
|
||||||
*/
|
*/
|
||||||
restore(identifier, etag) {
|
restore(identifier, etag) {
|
||||||
return this._getPack()
|
return this._getPack()
|
||||||
|
|
|
@ -32,6 +32,7 @@ const ConstDependency = require("./ConstDependency");
|
||||||
const LocalModuleDependency = require("./LocalModuleDependency");
|
const LocalModuleDependency = require("./LocalModuleDependency");
|
||||||
const UnsupportedDependency = require("./UnsupportedDependency");
|
const UnsupportedDependency = require("./UnsupportedDependency");
|
||||||
|
|
||||||
|
/** @typedef {import("../../declarations/WebpackOptions").Amd} Amd */
|
||||||
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
||||||
/** @typedef {import("../../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptions */
|
/** @typedef {import("../../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptions */
|
||||||
/** @typedef {import("../Compiler")} Compiler */
|
/** @typedef {import("../Compiler")} Compiler */
|
||||||
|
@ -41,9 +42,11 @@ const UnsupportedDependency = require("./UnsupportedDependency");
|
||||||
|
|
||||||
const PLUGIN_NAME = "AMDPlugin";
|
const PLUGIN_NAME = "AMDPlugin";
|
||||||
|
|
||||||
|
/** @typedef {Record<string, TODO>} AmdOptions */
|
||||||
|
|
||||||
class AMDPlugin {
|
class AMDPlugin {
|
||||||
/**
|
/**
|
||||||
* @param {Record<string, any>} amdOptions the AMD options
|
* @param {AmdOptions} amdOptions the AMD options
|
||||||
*/
|
*/
|
||||||
constructor(amdOptions) {
|
constructor(amdOptions) {
|
||||||
this.amdOptions = amdOptions;
|
this.amdOptions = amdOptions;
|
||||||
|
|
|
@ -8,6 +8,8 @@ const RuntimeGlobals = require("../RuntimeGlobals");
|
||||||
const RuntimeModule = require("../RuntimeModule");
|
const RuntimeModule = require("../RuntimeModule");
|
||||||
const Template = require("../Template");
|
const Template = require("../Template");
|
||||||
|
|
||||||
|
/** @typedef {import("./AMDPlugin").AmdOptions} AmdOptions */
|
||||||
|
|
||||||
class AMDDefineRuntimeModule extends RuntimeModule {
|
class AMDDefineRuntimeModule extends RuntimeModule {
|
||||||
constructor() {
|
constructor() {
|
||||||
super("amd define");
|
super("amd define");
|
||||||
|
@ -27,7 +29,7 @@ class AMDDefineRuntimeModule extends RuntimeModule {
|
||||||
|
|
||||||
class AMDOptionsRuntimeModule extends RuntimeModule {
|
class AMDOptionsRuntimeModule extends RuntimeModule {
|
||||||
/**
|
/**
|
||||||
* @param {Record<string, boolean | number | string>} options the AMD options
|
* @param {AmdOptions} options the AMD options
|
||||||
*/
|
*/
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
super("amd options");
|
super("amd options");
|
||||||
|
|
|
@ -50,6 +50,7 @@ const JavascriptParser = require("./JavascriptParser");
|
||||||
/** @typedef {import("eslint-scope").Reference} Reference */
|
/** @typedef {import("eslint-scope").Reference} Reference */
|
||||||
/** @typedef {import("eslint-scope").Scope} Scope */
|
/** @typedef {import("eslint-scope").Scope} Scope */
|
||||||
/** @typedef {import("eslint-scope").Variable} Variable */
|
/** @typedef {import("eslint-scope").Variable} Variable */
|
||||||
|
/** @typedef {import("estree").Program} Program */
|
||||||
/** @typedef {import("webpack-sources").Source} Source */
|
/** @typedef {import("webpack-sources").Source} Source */
|
||||||
/** @typedef {import("../../declarations/WebpackOptions").Output} OutputOptions */
|
/** @typedef {import("../../declarations/WebpackOptions").Output} OutputOptions */
|
||||||
/** @typedef {import("../Chunk")} Chunk */
|
/** @typedef {import("../Chunk")} Chunk */
|
||||||
|
@ -1529,7 +1530,7 @@ class JavascriptModulesPlugin {
|
||||||
const renamedInlinedModules = new Map();
|
const renamedInlinedModules = new Map();
|
||||||
const { runtimeTemplate } = renderContext;
|
const { runtimeTemplate } = renderContext;
|
||||||
|
|
||||||
/** @typedef {{ source: Source, module: Module, ast: any, variables: Set<Variable>, through: Set<Reference>, usedInNonInlined: Set<Variable>, moduleScope: Scope }} Info */
|
/** @typedef {{ source: Source, module: Module, ast: Program, variables: Set<Variable>, through: Set<Reference>, usedInNonInlined: Set<Variable>, moduleScope: Scope }} Info */
|
||||||
/** @type {Map<Module, Info>} */
|
/** @type {Map<Module, Info>} */
|
||||||
const inlinedModulesToInfo = new Map();
|
const inlinedModulesToInfo = new Map();
|
||||||
/** @type {Set<string>} */
|
/** @type {Set<string>} */
|
||||||
|
|
|
@ -4858,7 +4858,7 @@ class JavascriptParser extends Parser {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Range} range range of the comment
|
* @param {Range} range range of the comment
|
||||||
* @returns {{ options: Record<string, any> | null, errors: (Error & { comment: Comment })[] | null }} result
|
* @returns {{ options: Record<string, EXPECTED_ANY> | null, errors: (Error & { comment: Comment })[] | null }} result
|
||||||
*/
|
*/
|
||||||
parseCommentOptions(range) {
|
parseCommentOptions(range) {
|
||||||
const comments = this.getComments(range);
|
const comments = this.getComments(range);
|
||||||
|
|
|
@ -89,25 +89,44 @@ class LimitChunkCountPlugin {
|
||||||
// this is large. Size = chunks * (chunks - 1) / 2
|
// this is large. Size = chunks * (chunks - 1) / 2
|
||||||
// It uses a multi layer bucket sort plus normal sort in the last layer
|
// It uses a multi layer bucket sort plus normal sort in the last layer
|
||||||
// It's also lazy so only accessed buckets are sorted
|
// It's also lazy so only accessed buckets are sorted
|
||||||
|
/** @type {LazyBucketSortedSet<ChunkCombination, number>} */
|
||||||
const combinations = new LazyBucketSortedSet(
|
const combinations = new LazyBucketSortedSet(
|
||||||
// Layer 1: ordered by largest size benefit
|
// Layer 1: ordered by largest size benefit
|
||||||
c => c.sizeDiff,
|
c => c.sizeDiff,
|
||||||
(a, b) => b - a,
|
(a, b) => b - a,
|
||||||
|
|
||||||
// Layer 2: ordered by smallest combined size
|
// Layer 2: ordered by smallest combined size
|
||||||
/**
|
/**
|
||||||
* @param {ChunkCombination} c combination
|
* @param {ChunkCombination} c combination
|
||||||
* @returns {number} integrated size
|
* @returns {number} integrated size
|
||||||
*/
|
*/
|
||||||
c => c.integratedSize,
|
c => c.integratedSize,
|
||||||
|
/**
|
||||||
|
* @param {number} a a
|
||||||
|
* @param {number} b b
|
||||||
|
* @returns {number} result
|
||||||
|
*/
|
||||||
(a, b) => a - b,
|
(a, b) => a - b,
|
||||||
|
|
||||||
// Layer 3: ordered by position difference in orderedChunk (-> to be deterministic)
|
// Layer 3: ordered by position difference in orderedChunk (-> to be deterministic)
|
||||||
/**
|
/**
|
||||||
* @param {ChunkCombination} c combination
|
* @param {ChunkCombination} c combination
|
||||||
* @returns {number} position difference
|
* @returns {number} position difference
|
||||||
*/
|
*/
|
||||||
c => c.bIdx - c.aIdx,
|
c => c.bIdx - c.aIdx,
|
||||||
|
/**
|
||||||
|
* @param {number} a a
|
||||||
|
* @param {number} b b
|
||||||
|
* @returns {number} result
|
||||||
|
*/
|
||||||
(a, b) => a - b,
|
(a, b) => a - b,
|
||||||
|
|
||||||
// Layer 4: ordered by position in orderedChunk (-> to be deterministic)
|
// Layer 4: ordered by position in orderedChunk (-> to be deterministic)
|
||||||
|
/**
|
||||||
|
* @param {ChunkCombination} a a
|
||||||
|
* @param {ChunkCombination} b b
|
||||||
|
* @returns {number} result
|
||||||
|
*/
|
||||||
(a, b) => a.bIdx - b.bIdx
|
(a, b) => a.bIdx - b.bIdx
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -132,6 +151,7 @@ class LimitChunkCountPlugin {
|
||||||
|
|
||||||
const aSize = chunkGraph.getChunkSize(a, options);
|
const aSize = chunkGraph.getChunkSize(a, options);
|
||||||
const bSize = chunkGraph.getChunkSize(b, options);
|
const bSize = chunkGraph.getChunkSize(b, options);
|
||||||
|
/** @type {ChunkCombination} */
|
||||||
const c = {
|
const c = {
|
||||||
deleted: false,
|
deleted: false,
|
||||||
sizeDiff: aSize + bSize - integratedSize,
|
sizeDiff: aSize + bSize - integratedSize,
|
||||||
|
|
|
@ -8,9 +8,17 @@
|
||||||
/** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
|
||||||
/** @typedef {import("./RuleSetCompiler")} RuleSetCompiler */
|
/** @typedef {import("./RuleSetCompiler")} RuleSetCompiler */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template T
|
||||||
|
* @template {T[keyof T]} V
|
||||||
|
* @typedef {import("./RuleSetCompiler").KeysOfTypes<T, V>} KeysOfTypes
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @typedef {KeysOfTypes<RuleSetRule, string | boolean | { [k: string]: EXPECTED_ANY }>} BasicEffectRuleKeys */
|
||||||
|
|
||||||
class BasicEffectRulePlugin {
|
class BasicEffectRulePlugin {
|
||||||
/**
|
/**
|
||||||
* @param {string} ruleProperty the rule property
|
* @param {BasicEffectRuleKeys} ruleProperty the rule property
|
||||||
* @param {string=} effectType the effect type
|
* @param {string=} effectType the effect type
|
||||||
*/
|
*/
|
||||||
constructor(ruleProperty, effectType) {
|
constructor(ruleProperty, effectType) {
|
||||||
|
|
|
@ -5,13 +5,24 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetConditionOrConditions} RuleSetConditionOrConditions */
|
||||||
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetConditionOrConditionsAbsolute} RuleSetConditionOrConditionsAbsolute */
|
||||||
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetLoaderOptions} RuleSetLoaderOptions */
|
||||||
/** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
|
||||||
/** @typedef {import("./RuleSetCompiler")} RuleSetCompiler */
|
/** @typedef {import("./RuleSetCompiler")} RuleSetCompiler */
|
||||||
/** @typedef {import("./RuleSetCompiler").RuleCondition} RuleCondition */
|
/** @typedef {import("./RuleSetCompiler").RuleCondition} RuleCondition */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template T
|
||||||
|
* @template {T[keyof T]} V
|
||||||
|
* @typedef {import("./RuleSetCompiler").KeysOfTypes<T, V>} KeysOfTypes
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @typedef {KeysOfTypes<RuleSetRule, RuleSetConditionOrConditions | RuleSetConditionOrConditionsAbsolute>} BasicMatcherRuleKeys */
|
||||||
|
|
||||||
class BasicMatcherRulePlugin {
|
class BasicMatcherRulePlugin {
|
||||||
/**
|
/**
|
||||||
* @param {string} ruleProperty the rule property
|
* @param {BasicMatcherRuleKeys} ruleProperty the rule property
|
||||||
* @param {string=} dataProperty the data property
|
* @param {string=} dataProperty the data property
|
||||||
* @param {boolean=} invert if true, inverts the condition
|
* @param {boolean=} invert if true, inverts the condition
|
||||||
*/
|
*/
|
||||||
|
@ -31,11 +42,11 @@ class BasicMatcherRulePlugin {
|
||||||
(path, rule, unhandledProperties, result) => {
|
(path, rule, unhandledProperties, result) => {
|
||||||
if (unhandledProperties.has(this.ruleProperty)) {
|
if (unhandledProperties.has(this.ruleProperty)) {
|
||||||
unhandledProperties.delete(this.ruleProperty);
|
unhandledProperties.delete(this.ruleProperty);
|
||||||
const value =
|
const value = rule[this.ruleProperty];
|
||||||
rule[/** @type {keyof RuleSetRule} */ (this.ruleProperty)];
|
|
||||||
const condition = ruleSetCompiler.compileCondition(
|
const condition = ruleSetCompiler.compileCondition(
|
||||||
`${path}.${this.ruleProperty}`,
|
`${path}.${this.ruleProperty}`,
|
||||||
value
|
/** @type {RuleSetConditionOrConditions | RuleSetConditionOrConditionsAbsolute} */
|
||||||
|
(value)
|
||||||
);
|
);
|
||||||
const fn = condition.fn;
|
const fn = condition.fn;
|
||||||
result.conditions.push({
|
result.conditions.push({
|
||||||
|
|
|
@ -5,14 +5,23 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetConditionOrConditions} RuleSetConditionOrConditions */
|
||||||
/** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
|
||||||
/** @typedef {import("./RuleSetCompiler")} RuleSetCompiler */
|
/** @typedef {import("./RuleSetCompiler")} RuleSetCompiler */
|
||||||
/** @typedef {import("./RuleSetCompiler").RuleCondition} RuleCondition */
|
/** @typedef {import("./RuleSetCompiler").RuleCondition} RuleCondition */
|
||||||
/** @typedef {import("./RuleSetCompiler").RuleConditionFunction} RuleConditionFunction */
|
/** @typedef {import("./RuleSetCompiler").RuleConditionFunction} RuleConditionFunction */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template T
|
||||||
|
* @template {T[keyof T]} V
|
||||||
|
* @typedef {import("./RuleSetCompiler").KeysOfTypes<T, V>} KeysOfTypes
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @typedef {KeysOfTypes<RuleSetRule, { [k: string]: RuleSetConditionOrConditions }>} ObjectMatcherRuleKeys */
|
||||||
|
|
||||||
class ObjectMatcherRulePlugin {
|
class ObjectMatcherRulePlugin {
|
||||||
/**
|
/**
|
||||||
* @param {string} ruleProperty the rule property
|
* @param {ObjectMatcherRuleKeys} ruleProperty the rule property
|
||||||
* @param {string=} dataProperty the data property
|
* @param {string=} dataProperty the data property
|
||||||
* @param {RuleConditionFunction=} additionalConditionFunction need to check
|
* @param {RuleConditionFunction=} additionalConditionFunction need to check
|
||||||
*/
|
*/
|
||||||
|
@ -34,8 +43,8 @@ class ObjectMatcherRulePlugin {
|
||||||
if (unhandledProperties.has(ruleProperty)) {
|
if (unhandledProperties.has(ruleProperty)) {
|
||||||
unhandledProperties.delete(ruleProperty);
|
unhandledProperties.delete(ruleProperty);
|
||||||
const value =
|
const value =
|
||||||
/** @type {Record<string, any>} */
|
/** @type {Record<string, RuleSetConditionOrConditions>} */
|
||||||
(rule[/** @type {keyof RuleSetRule} */ (ruleProperty)]);
|
(rule[ruleProperty]);
|
||||||
for (const property of Object.keys(value)) {
|
for (const property of Object.keys(value)) {
|
||||||
const nestedDataProperties = property.split(".");
|
const nestedDataProperties = property.split(".");
|
||||||
const condition = ruleSetCompiler.compileCondition(
|
const condition = ruleSetCompiler.compileCondition(
|
||||||
|
|
|
@ -7,8 +7,11 @@
|
||||||
|
|
||||||
const { SyncHook } = require("tapable");
|
const { SyncHook } = require("tapable");
|
||||||
|
|
||||||
|
/** @typedef {import("../../declarations/WebpackOptions").Falsy} Falsy */
|
||||||
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetLoaderOptions} RuleSetLoaderOptions */
|
||||||
/** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
|
||||||
/** @typedef {import("../../declarations/WebpackOptions").RuleSetRules} RuleSetRules */
|
|
||||||
|
/** @typedef {(Falsy | RuleSetRule)[]} RuleSetRules */
|
||||||
|
|
||||||
/** @typedef {(value: string | EffectData) => boolean} RuleConditionFunction */
|
/** @typedef {(value: string | EffectData) => boolean} RuleConditionFunction */
|
||||||
|
|
||||||
|
@ -40,15 +43,23 @@ const { SyncHook } = require("tapable");
|
||||||
/**
|
/**
|
||||||
* @typedef {object} Effect
|
* @typedef {object} Effect
|
||||||
* @property {string} type
|
* @property {string} type
|
||||||
* @property {any} value
|
* @property {TODO} value
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/** @typedef {Map<string, RuleSetLoaderOptions>} References */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {object} RuleSet
|
* @typedef {object} RuleSet
|
||||||
* @property {Map<string, any>} references map of references in the rule set (may grow over time)
|
* @property {References} references map of references in the rule set (may grow over time)
|
||||||
* @property {(effectData: EffectData) => Effect[]} exec execute the rule set
|
* @property {(effectData: EffectData) => Effect[]} exec execute the rule set
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template T
|
||||||
|
* @template {T[keyof T]} V
|
||||||
|
* @typedef {({ [P in keyof Required<T>]: Required<T>[P] extends V ? P : never })[keyof T]} KeysOfTypes
|
||||||
|
*/
|
||||||
|
|
||||||
/** @typedef {{ apply: (ruleSetCompiler: RuleSetCompiler) => void }} RuleSetPlugin */
|
/** @typedef {{ apply: (ruleSetCompiler: RuleSetCompiler) => void }} RuleSetPlugin */
|
||||||
|
|
||||||
class RuleSetCompiler {
|
class RuleSetCompiler {
|
||||||
|
@ -57,7 +68,7 @@ class RuleSetCompiler {
|
||||||
*/
|
*/
|
||||||
constructor(plugins) {
|
constructor(plugins) {
|
||||||
this.hooks = Object.freeze({
|
this.hooks = Object.freeze({
|
||||||
/** @type {SyncHook<[string, RuleSetRule, Set<string>, CompiledRule, Map<string | undefined, any>]>} */
|
/** @type {SyncHook<[string, RuleSetRule, Set<string>, CompiledRule, References]>} */
|
||||||
rule: new SyncHook([
|
rule: new SyncHook([
|
||||||
"path",
|
"path",
|
||||||
"rule",
|
"rule",
|
||||||
|
@ -74,7 +85,7 @@ class RuleSetCompiler {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {TODO[]} ruleSet raw user provided rules
|
* @param {RuleSetRules} ruleSet raw user provided rules
|
||||||
* @returns {RuleSet} compiled RuleSet
|
* @returns {RuleSet} compiled RuleSet
|
||||||
*/
|
*/
|
||||||
compile(ruleSet) {
|
compile(ruleSet) {
|
||||||
|
@ -161,7 +172,7 @@ class RuleSetCompiler {
|
||||||
/**
|
/**
|
||||||
* @param {string} path current path
|
* @param {string} path current path
|
||||||
* @param {RuleSetRules} rules the raw rules provided by user
|
* @param {RuleSetRules} rules the raw rules provided by user
|
||||||
* @param {Map<string, any>} refs references
|
* @param {References} refs references
|
||||||
* @returns {CompiledRule[]} rules
|
* @returns {CompiledRule[]} rules
|
||||||
*/
|
*/
|
||||||
compileRules(path, rules, refs) {
|
compileRules(path, rules, refs) {
|
||||||
|
@ -179,7 +190,7 @@ class RuleSetCompiler {
|
||||||
/**
|
/**
|
||||||
* @param {string} path current path
|
* @param {string} path current path
|
||||||
* @param {RuleSetRule} rule the raw rule provided by user
|
* @param {RuleSetRule} rule the raw rule provided by user
|
||||||
* @param {Map<string, any>} refs references
|
* @param {References} refs references
|
||||||
* @returns {CompiledRule} normalized and compiled rule for processing
|
* @returns {CompiledRule} normalized and compiled rule for processing
|
||||||
*/
|
*/
|
||||||
compileRule(path, rule, refs) {
|
compileRule(path, rule, refs) {
|
||||||
|
@ -228,7 +239,7 @@ class RuleSetCompiler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} path current path
|
* @param {string} path current path
|
||||||
* @param {any} condition user provided condition value
|
* @param {RuleSetLoaderOptions} condition user provided condition value
|
||||||
* @returns {Condition} compiled condition
|
* @returns {Condition} compiled condition
|
||||||
*/
|
*/
|
||||||
compileCondition(path, condition) {
|
compileCondition(path, condition) {
|
||||||
|
@ -255,7 +266,7 @@ class RuleSetCompiler {
|
||||||
try {
|
try {
|
||||||
return {
|
return {
|
||||||
matchWhenEmpty: condition(""),
|
matchWhenEmpty: condition(""),
|
||||||
fn: condition
|
fn: /** @type {RuleConditionFunction} */ (condition)
|
||||||
};
|
};
|
||||||
} catch (_err) {
|
} catch (_err) {
|
||||||
throw this.error(
|
throw this.error(
|
||||||
|
@ -386,7 +397,7 @@ class RuleSetCompiler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} path current path
|
* @param {string} path current path
|
||||||
* @param {any} value value at the error location
|
* @param {EXPECTED_ANY} value value at the error location
|
||||||
* @param {string} message message explaining the problem
|
* @param {string} message message explaining the problem
|
||||||
* @returns {Error} an error object
|
* @returns {Error} an error object
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -7,9 +7,12 @@
|
||||||
|
|
||||||
const util = require("util");
|
const util = require("util");
|
||||||
|
|
||||||
|
/** @typedef {import("../../declarations/WebpackOptions").Falsy} Falsy */
|
||||||
/** @typedef {import("../../declarations/WebpackOptions").RuleSetLoader} RuleSetLoader */
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetLoader} RuleSetLoader */
|
||||||
/** @typedef {import("../../declarations/WebpackOptions").RuleSetLoaderOptions} RuleSetLoaderOptions */
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetLoaderOptions} RuleSetLoaderOptions */
|
||||||
/** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */
|
||||||
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetUse} RuleSetUse */
|
||||||
|
/** @typedef {import("../../declarations/WebpackOptions").RuleSetUseItem} RuleSetUseItem */
|
||||||
/** @typedef {import("./RuleSetCompiler")} RuleSetCompiler */
|
/** @typedef {import("./RuleSetCompiler")} RuleSetCompiler */
|
||||||
/** @typedef {import("./RuleSetCompiler").Effect} Effect */
|
/** @typedef {import("./RuleSetCompiler").Effect} Effect */
|
||||||
|
|
||||||
|
@ -43,7 +46,7 @@ class UseEffectRulePlugin {
|
||||||
conflictWith("loader", "use");
|
conflictWith("loader", "use");
|
||||||
conflictWith("options", "use");
|
conflictWith("options", "use");
|
||||||
|
|
||||||
const use = rule.use;
|
const use = /** @type {RuleSetUse} */ (rule.use);
|
||||||
const enforce = rule.enforce;
|
const enforce = rule.enforce;
|
||||||
|
|
||||||
const type = enforce ? `use-${enforce}` : "use";
|
const type = enforce ? `use-${enforce}` : "use";
|
||||||
|
@ -51,12 +54,17 @@ class UseEffectRulePlugin {
|
||||||
/**
|
/**
|
||||||
* @param {string} path options path
|
* @param {string} path options path
|
||||||
* @param {string} defaultIdent default ident when none is provided
|
* @param {string} defaultIdent default ident when none is provided
|
||||||
* @param {object} item user provided use value
|
* @param {RuleSetUseItem} item user provided use value
|
||||||
* @returns {Effect | ((value: TODO) => Effect[])} effect
|
* @returns {Effect | ((value: TODO) => Effect[])} effect
|
||||||
*/
|
*/
|
||||||
const useToEffect = (path, defaultIdent, item) => {
|
const useToEffect = (path, defaultIdent, item) => {
|
||||||
if (typeof item === "function") {
|
if (typeof item === "function") {
|
||||||
return data => useToEffectsWithoutIdent(path, item(data));
|
return data =>
|
||||||
|
useToEffectsWithoutIdent(
|
||||||
|
path,
|
||||||
|
/** @type {RuleSetUseItem | RuleSetUseItem[]} */
|
||||||
|
(item(data))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return useToEffectRaw(path, defaultIdent, item);
|
return useToEffectRaw(path, defaultIdent, item);
|
||||||
};
|
};
|
||||||
|
@ -64,7 +72,7 @@ class UseEffectRulePlugin {
|
||||||
/**
|
/**
|
||||||
* @param {string} path options path
|
* @param {string} path options path
|
||||||
* @param {string} defaultIdent default ident when none is provided
|
* @param {string} defaultIdent default ident when none is provided
|
||||||
* @param {{ ident?: string, loader?: RuleSetLoader, options?: RuleSetLoaderOptions }} item user provided use value
|
* @param {Exclude<NonNullable<RuleSetUseItem>, EXPECTED_FUNCTION>} item user provided use value
|
||||||
* @returns {Effect} effect
|
* @returns {Effect} effect
|
||||||
*/
|
*/
|
||||||
const useToEffectRaw = (path, defaultIdent, item) => {
|
const useToEffectRaw = (path, defaultIdent, item) => {
|
||||||
|
@ -104,33 +112,50 @@ class UseEffectRulePlugin {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} path options path
|
* @param {string} path options path
|
||||||
* @param {TODO} items user provided use value
|
* @param {RuleSetUseItem | (Falsy | RuleSetUseItem)[]} items user provided use value
|
||||||
* @returns {Effect[]} effects
|
* @returns {Effect[]} effects
|
||||||
*/
|
*/
|
||||||
const useToEffectsWithoutIdent = (path, items) => {
|
const useToEffectsWithoutIdent = (path, items) => {
|
||||||
if (Array.isArray(items)) {
|
if (Array.isArray(items)) {
|
||||||
return items
|
return items.filter(Boolean).map((item, idx) =>
|
||||||
.filter(Boolean)
|
useToEffectRaw(
|
||||||
.map((item, idx) =>
|
`${path}[${idx}]`,
|
||||||
useToEffectRaw(`${path}[${idx}]`, "[[missing ident]]", item)
|
"[[missing ident]]",
|
||||||
);
|
/** @type {Exclude<RuleSetUseItem, EXPECTED_FUNCTION>} */
|
||||||
|
(item)
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return [useToEffectRaw(path, "[[missing ident]]", items)];
|
return [
|
||||||
|
useToEffectRaw(
|
||||||
|
path,
|
||||||
|
"[[missing ident]]",
|
||||||
|
/** @type {Exclude<RuleSetUseItem, EXPECTED_FUNCTION>} */
|
||||||
|
(items)
|
||||||
|
)
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} path current path
|
* @param {string} path current path
|
||||||
* @param {TODO} items user provided use value
|
* @param {RuleSetUse} items user provided use value
|
||||||
* @returns {(Effect | ((value: TODO) => Effect[]))[]} effects
|
* @returns {(Effect | ((value: TODO) => Effect[]))[]} effects
|
||||||
*/
|
*/
|
||||||
const useToEffects = (path, items) => {
|
const useToEffects = (path, items) => {
|
||||||
if (Array.isArray(items)) {
|
if (Array.isArray(items)) {
|
||||||
return items.filter(Boolean).map((item, idx) => {
|
return items.filter(Boolean).map((item, idx) => {
|
||||||
const subPath = `${path}[${idx}]`;
|
const subPath = `${path}[${idx}]`;
|
||||||
return useToEffect(subPath, subPath, item);
|
return useToEffect(
|
||||||
|
subPath,
|
||||||
|
subPath,
|
||||||
|
/** @type {RuleSetUseItem} */
|
||||||
|
(item)
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return [useToEffect(path, path, items)];
|
return [
|
||||||
|
useToEffect(path, path, /** @type {RuleSetUseItem} */ (items))
|
||||||
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof use === "function") {
|
if (typeof use === "function") {
|
||||||
|
@ -182,7 +207,12 @@ class UseEffectRulePlugin {
|
||||||
|
|
||||||
const ident =
|
const ident =
|
||||||
options && typeof options === "object" ? path : undefined;
|
options && typeof options === "object" ? path : undefined;
|
||||||
references.set(ident, options);
|
references.set(
|
||||||
|
/** @type {TODO} */
|
||||||
|
(ident),
|
||||||
|
/** @type {RuleSetLoaderOptions} */
|
||||||
|
(options)
|
||||||
|
);
|
||||||
result.effects.push({
|
result.effects.push({
|
||||||
type: enforce ? `use-${enforce}` : "use",
|
type: enforce ? `use-${enforce}` : "use",
|
||||||
value: {
|
value: {
|
||||||
|
|
|
@ -59,7 +59,7 @@ const getResourceName = resource => {
|
||||||
*/
|
*/
|
||||||
const getModuleName = name => {
|
const getModuleName = name => {
|
||||||
const [, prefix, resource] =
|
const [, prefix, resource] =
|
||||||
/** @type {[any, string, string]} */
|
/** @type {[string, string, string]} */
|
||||||
(/** @type {unknown} */ (/^(.*!)?([^!]*)$/.exec(name)));
|
(/** @type {unknown} */ (/^(.*!)?([^!]*)$/.exec(name)));
|
||||||
|
|
||||||
if (resource.length > MAX_MODULE_IDENTIFIER_LENGTH) {
|
if (resource.length > MAX_MODULE_IDENTIFIER_LENGTH) {
|
||||||
|
|
|
@ -68,7 +68,7 @@ const { HookMap, SyncWaterfallHook, SyncBailHook } = require("tapable");
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @typedef {Record<string, EXPECTED_ANY> & KnownStatsPrinterColorFn & KnownStatsPrinterFormatters & KnownStatsPrinterContext} StatsPrinterContext */
|
/** @typedef {Record<string, EXPECTED_ANY> & KnownStatsPrinterColorFn & KnownStatsPrinterFormatters & KnownStatsPrinterContext} StatsPrinterContext */
|
||||||
/** @typedef {any} PrintObject */
|
/** @typedef {TODO} PrintObject */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {object} StatsPrintHooks
|
* @typedef {object} StatsPrintHooks
|
||||||
|
|
|
@ -85,13 +85,13 @@ class AsyncQueue {
|
||||||
this._entries = new Map();
|
this._entries = new Map();
|
||||||
/** @type {ArrayQueue<AsyncQueueEntry<T, K, R>>} */
|
/** @type {ArrayQueue<AsyncQueueEntry<T, K, R>>} */
|
||||||
this._queued = new ArrayQueue();
|
this._queued = new ArrayQueue();
|
||||||
/** @type {AsyncQueue<any, any, any>[] | undefined} */
|
/** @type {AsyncQueue<T, K, R>[] | undefined} */
|
||||||
this._children = undefined;
|
this._children = undefined;
|
||||||
this._activeTasks = 0;
|
this._activeTasks = 0;
|
||||||
this._willEnsureProcessing = false;
|
this._willEnsureProcessing = false;
|
||||||
this._needProcessing = false;
|
this._needProcessing = false;
|
||||||
this._stopped = false;
|
this._stopped = false;
|
||||||
/** @type {AsyncQueue<any, any, any>} */
|
/** @type {AsyncQueue<T, K, R>} */
|
||||||
this._root = parent ? parent._root : this;
|
this._root = parent ? parent._root : this;
|
||||||
if (parent) {
|
if (parent) {
|
||||||
if (this._root._children === undefined) {
|
if (this._root._children === undefined) {
|
||||||
|
|
|
@ -10,12 +10,25 @@ const SortableSet = require("./SortableSet");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @template T
|
* @template T
|
||||||
* @typedef {LazyBucketSortedSet<T, any> | SortableSet<T>} Entry
|
* @template K
|
||||||
|
* @typedef {(item: T) => K} GetKey
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @template T
|
* @template T
|
||||||
* @typedef {((value: T) => any) | ((value: any, value1: any) => number)} Arg
|
* @typedef {(a: T, n: T) => number} Comparator
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template T
|
||||||
|
* @template K
|
||||||
|
* @typedef {LazyBucketSortedSet<T, K> | SortableSet<T>} Entry
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template T
|
||||||
|
* @template K
|
||||||
|
* @typedef {GetKey<T, K> | Comparator<K> | Comparator<T>} Arg
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,17 +45,16 @@ const SortableSet = require("./SortableSet");
|
||||||
*/
|
*/
|
||||||
class LazyBucketSortedSet {
|
class LazyBucketSortedSet {
|
||||||
/**
|
/**
|
||||||
* @param {(item: T) => K} getKey function to get key from item
|
* @param {GetKey<T, K>} getKey function to get key from item
|
||||||
* @param {(a: K, b: K) => number} comparator comparator to sort keys
|
* @param {Comparator<K>=} comparator comparator to sort keys
|
||||||
* @param {...Arg<T>} args more pairs of getKey and comparator plus optional final comparator for the last layer
|
* @param {...Arg<T, K>} args more pairs of getKey and comparator plus optional final comparator for the last layer
|
||||||
*/
|
*/
|
||||||
constructor(getKey, comparator, ...args) {
|
constructor(getKey, comparator, ...args) {
|
||||||
this._getKey = getKey;
|
this._getKey = getKey;
|
||||||
/** @type {Arg<T>[]} */
|
|
||||||
this._innerArgs = args;
|
this._innerArgs = args;
|
||||||
this._leaf = args.length <= 1;
|
this._leaf = args.length <= 1;
|
||||||
this._keys = new SortableSet(undefined, comparator);
|
this._keys = new SortableSet(undefined, comparator);
|
||||||
/** @type {Map<K, Entry<T>>} */
|
/** @type {Map<K, Entry<T, K>>} */
|
||||||
this._map = new Map();
|
this._map = new Map();
|
||||||
this._unsortedItems = new Set();
|
this._unsortedItems = new Set();
|
||||||
this.size = 0;
|
this.size = 0;
|
||||||
|
@ -65,18 +77,20 @@ class LazyBucketSortedSet {
|
||||||
_addInternal(key, item) {
|
_addInternal(key, item) {
|
||||||
let entry = this._map.get(key);
|
let entry = this._map.get(key);
|
||||||
if (entry === undefined) {
|
if (entry === undefined) {
|
||||||
entry =
|
entry = this._leaf
|
||||||
/** @type {Entry<T>} */
|
? new SortableSet(
|
||||||
(
|
undefined,
|
||||||
this._leaf
|
/** @type {Comparator<T>} */
|
||||||
? new SortableSet(undefined, this._innerArgs[0])
|
(this._innerArgs[0])
|
||||||
: new /** @type {TODO} */ (LazyBucketSortedSet)(...this._innerArgs)
|
)
|
||||||
);
|
: new LazyBucketSortedSet(
|
||||||
|
.../** @type {[GetKey<T, K>, Comparator<K>]} */
|
||||||
|
(this._innerArgs)
|
||||||
|
);
|
||||||
this._keys.add(key);
|
this._keys.add(key);
|
||||||
this._map.set(key, entry);
|
this._map.set(key, entry);
|
||||||
}
|
}
|
||||||
/** @type {Entry<T>} */
|
entry.add(item);
|
||||||
(entry).add(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,7 +104,7 @@ class LazyBucketSortedSet {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const key = this._getKey(item);
|
const key = this._getKey(item);
|
||||||
const entry = /** @type {Entry<T>} */ (this._map.get(key));
|
const entry = /** @type {Entry<T, K>} */ (this._map.get(key));
|
||||||
entry.delete(item);
|
entry.delete(item);
|
||||||
if (entry.size === 0) {
|
if (entry.size === 0) {
|
||||||
this._deleteKey(key);
|
this._deleteKey(key);
|
||||||
|
@ -132,7 +146,9 @@ class LazyBucketSortedSet {
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
const nodeEntry = /** @type {LazyBucketSortedSet<T, any>} */ (entry);
|
const nodeEntry =
|
||||||
|
/** @type {LazyBucketSortedSet<T, K>} */
|
||||||
|
(entry);
|
||||||
const item = nodeEntry.popFirst();
|
const item = nodeEntry.popFirst();
|
||||||
if (nodeEntry.size === 0) {
|
if (nodeEntry.size === 0) {
|
||||||
this._deleteKey(key);
|
this._deleteKey(key);
|
||||||
|
@ -178,9 +194,9 @@ class LazyBucketSortedSet {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const oldEntry = /** @type {LazyBucketSortedSet<T, any>} */ (
|
const oldEntry =
|
||||||
this._map.get(key)
|
/** @type {LazyBucketSortedSet<T, K>} */
|
||||||
);
|
(this._map.get(key));
|
||||||
const finishUpdate = oldEntry.startUpdate(item);
|
const finishUpdate = oldEntry.startUpdate(item);
|
||||||
return remove => {
|
return remove => {
|
||||||
if (remove) {
|
if (remove) {
|
||||||
|
@ -218,7 +234,9 @@ class LazyBucketSortedSet {
|
||||||
const iterator = leafEntry[Symbol.iterator]();
|
const iterator = leafEntry[Symbol.iterator]();
|
||||||
iterators.push(iterator);
|
iterators.push(iterator);
|
||||||
} else {
|
} else {
|
||||||
const nodeEntry = /** @type {LazyBucketSortedSet<T, any>} */ (entry);
|
const nodeEntry =
|
||||||
|
/** @type {LazyBucketSortedSet<T, K>} */
|
||||||
|
(entry);
|
||||||
nodeEntry._appendIterators(iterators);
|
nodeEntry._appendIterators(iterators);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -279,15 +279,15 @@ const compareChunkGroupsByIndex = (a, b) =>
|
||||||
module.exports.compareChunkGroupsByIndex = compareChunkGroupsByIndex;
|
module.exports.compareChunkGroupsByIndex = compareChunkGroupsByIndex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @template K1 {Object}
|
* @template {object} K1
|
||||||
* @template K2
|
* @template {object} K2
|
||||||
* @template T
|
* @template T
|
||||||
*/
|
*/
|
||||||
class TwoKeyWeakMap {
|
class TwoKeyWeakMap {
|
||||||
constructor() {
|
constructor() {
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {WeakMap<any, WeakMap<any, T | undefined>>}
|
* @type {WeakMap<K1, WeakMap<K2, T | undefined>>}
|
||||||
*/
|
*/
|
||||||
this._map = new WeakMap();
|
this._map = new WeakMap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,13 +22,8 @@ const getValidate = memoize(() => require("schema-utils").validate);
|
||||||
const createSchemaValidation = (check, getSchema, options) => {
|
const createSchemaValidation = (check, getSchema, options) => {
|
||||||
getSchema = memoize(getSchema);
|
getSchema = memoize(getSchema);
|
||||||
return value => {
|
return value => {
|
||||||
if (check && !check(/** @type {T} */ (value))) {
|
if (check && value && !check(value)) {
|
||||||
getValidate()(
|
getValidate()(getSchema(), value, options);
|
||||||
getSchema(),
|
|
||||||
/** @type {object | object[]} */
|
|
||||||
(value),
|
|
||||||
options
|
|
||||||
);
|
|
||||||
require("util").deprecate(
|
require("util").deprecate(
|
||||||
() => {},
|
() => {},
|
||||||
"webpack bug: Pre-compiled schema reports error while real schema is happy. This has performance drawbacks.",
|
"webpack bug: Pre-compiled schema reports error while real schema is happy. This has performance drawbacks.",
|
||||||
|
|
|
@ -37,6 +37,9 @@ const createDeprecation = (message, code) => {
|
||||||
return fn;
|
return fn;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** @typedef {"concat" | "entry" | "filter" | "find" | "findIndex" | "includes" | "indexOf" | "join" | "lastIndexOf" | "map" | "reduce" | "reduceRight" | "slice" | "some"} COPY_METHODS_NAMES */
|
||||||
|
|
||||||
|
/** @type {COPY_METHODS_NAMES[]} */
|
||||||
const COPY_METHODS = [
|
const COPY_METHODS = [
|
||||||
"concat",
|
"concat",
|
||||||
"entry",
|
"entry",
|
||||||
|
@ -54,6 +57,9 @@ const COPY_METHODS = [
|
||||||
"some"
|
"some"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/** @typedef {"copyWithin" | "entries" | "fill" | "keys" | "pop" | "reverse" | "shift" | "splice" | "sort" | "unshift"} DISABLED_METHODS_NAMES */
|
||||||
|
|
||||||
|
/** @type {DISABLED_METHODS_NAMES[]} */
|
||||||
const DISABLED_METHODS = [
|
const DISABLED_METHODS = [
|
||||||
"copyWithin",
|
"copyWithin",
|
||||||
"entries",
|
"entries",
|
||||||
|
@ -68,7 +74,13 @@ const DISABLED_METHODS = [
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {any} set new set
|
* @template T
|
||||||
|
* @typedef {Set<T> & {[Symbol.isConcatSpreadable]?: boolean} & { push?: (...items: T[]) => void } & { [P in DISABLED_METHODS_NAMES]?: () => void } & { [P in COPY_METHODS_NAMES]?: () => TODO }} SetWithDeprecatedArrayMethods
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @template T
|
||||||
|
* @param {SetWithDeprecatedArrayMethods<T>} set new set
|
||||||
* @param {string} name property name
|
* @param {string} name property name
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
|
@ -81,7 +93,7 @@ module.exports.arrayToSetDeprecation = (set, name) => {
|
||||||
);
|
);
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
* @this {Set<any>}
|
* @this {Set<T>}
|
||||||
* @returns {number} count
|
* @returns {number} count
|
||||||
*/
|
*/
|
||||||
set[method] = function () {
|
set[method] = function () {
|
||||||
|
@ -108,7 +120,7 @@ module.exports.arrayToSetDeprecation = (set, name) => {
|
||||||
);
|
);
|
||||||
/**
|
/**
|
||||||
* @deprecated
|
* @deprecated
|
||||||
* @this {Set<any>}
|
* @this {Set<T>}
|
||||||
* @returns {number} count
|
* @returns {number} count
|
||||||
*/
|
*/
|
||||||
set.push = function () {
|
set.push = function () {
|
||||||
|
@ -121,6 +133,7 @@ module.exports.arrayToSetDeprecation = (set, name) => {
|
||||||
};
|
};
|
||||||
for (const method of DISABLED_METHODS) {
|
for (const method of DISABLED_METHODS) {
|
||||||
if (set[method]) continue;
|
if (set[method]) continue;
|
||||||
|
|
||||||
set[method] = () => {
|
set[method] = () => {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`${name} was changed from Array to Set (using Array method '${method}' is not possible)`
|
`${name} was changed from Array to Set (using Array method '${method}' is not possible)`
|
||||||
|
@ -129,12 +142,12 @@ module.exports.arrayToSetDeprecation = (set, name) => {
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {number} index index
|
* @param {number} index index
|
||||||
* @returns {any} value
|
* @returns {() => T | undefined} value
|
||||||
*/
|
*/
|
||||||
const createIndexGetter = index => {
|
const createIndexGetter = index => {
|
||||||
/**
|
/**
|
||||||
* @this {Set<any>} a Set
|
* @this {Set<T>} a Set
|
||||||
* @returns {any} the value at this location
|
* @returns {T | undefined} the value at this location
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line func-style
|
// eslint-disable-next-line func-style
|
||||||
const fn = function () {
|
const fn = function () {
|
||||||
|
@ -221,7 +234,7 @@ module.exports.soonFrozenObjectDeprecation = (obj, name, code, note = "") => {
|
||||||
note && `\n${note}`
|
note && `\n${note}`
|
||||||
}`;
|
}`;
|
||||||
return /** @type {Proxy<T>} */ (
|
return /** @type {Proxy<T>} */ (
|
||||||
new Proxy(/** @type {object} */ (obj), {
|
new Proxy(/** @type {T} */ (obj), {
|
||||||
set: util.deprecate(
|
set: util.deprecate(
|
||||||
/**
|
/**
|
||||||
* @param {T} target target
|
* @param {T} target target
|
||||||
|
@ -231,12 +244,7 @@ module.exports.soonFrozenObjectDeprecation = (obj, name, code, note = "") => {
|
||||||
* @returns {boolean} result
|
* @returns {boolean} result
|
||||||
*/
|
*/
|
||||||
(target, property, value, receiver) =>
|
(target, property, value, receiver) =>
|
||||||
Reflect.set(
|
Reflect.set(target, property, value, receiver),
|
||||||
/** @type {object} */ (target),
|
|
||||||
property,
|
|
||||||
value,
|
|
||||||
receiver
|
|
||||||
),
|
|
||||||
message,
|
message,
|
||||||
code
|
code
|
||||||
),
|
),
|
||||||
|
@ -248,11 +256,7 @@ module.exports.soonFrozenObjectDeprecation = (obj, name, code, note = "") => {
|
||||||
* @returns {boolean} result
|
* @returns {boolean} result
|
||||||
*/
|
*/
|
||||||
(target, property, descriptor) =>
|
(target, property, descriptor) =>
|
||||||
Reflect.defineProperty(
|
Reflect.defineProperty(target, property, descriptor),
|
||||||
/** @type {object} */ (target),
|
|
||||||
property,
|
|
||||||
descriptor
|
|
||||||
),
|
|
||||||
message,
|
message,
|
||||||
code
|
code
|
||||||
),
|
),
|
||||||
|
@ -262,19 +266,17 @@ module.exports.soonFrozenObjectDeprecation = (obj, name, code, note = "") => {
|
||||||
* @param {string | symbol} property property
|
* @param {string | symbol} property property
|
||||||
* @returns {boolean} result
|
* @returns {boolean} result
|
||||||
*/
|
*/
|
||||||
(target, property) =>
|
(target, property) => Reflect.deleteProperty(target, property),
|
||||||
Reflect.deleteProperty(/** @type {object} */ (target), property),
|
|
||||||
message,
|
message,
|
||||||
code
|
code
|
||||||
),
|
),
|
||||||
setPrototypeOf: util.deprecate(
|
setPrototypeOf: util.deprecate(
|
||||||
/**
|
/**
|
||||||
* @param {T} target target
|
* @param {T} target target
|
||||||
* @param {object | null} proto proto
|
* @param {EXPECTED_OBJECT | null} proto proto
|
||||||
* @returns {boolean} result
|
* @returns {boolean} result
|
||||||
*/
|
*/
|
||||||
(target, proto) =>
|
(target, proto) => Reflect.setPrototypeOf(target, proto),
|
||||||
Reflect.setPrototypeOf(/** @type {object} */ (target), proto),
|
|
||||||
message,
|
message,
|
||||||
code
|
code
|
||||||
)
|
)
|
||||||
|
|
|
@ -19,7 +19,7 @@ class WasmHash {
|
||||||
* @param {number} digestSize size of digest returned by wasm
|
* @param {number} digestSize size of digest returned by wasm
|
||||||
*/
|
*/
|
||||||
constructor(instance, instancesPool, chunkSize, digestSize) {
|
constructor(instance, instancesPool, chunkSize, digestSize) {
|
||||||
const exports = /** @type {any} */ (instance.exports);
|
const exports = /** @type {EXPECTED_ANY} */ (instance.exports);
|
||||||
exports.init();
|
exports.init();
|
||||||
this.exports = exports;
|
this.exports = exports;
|
||||||
this.mem = Buffer.from(exports.memory.buffer, 0, 65536);
|
this.mem = Buffer.from(exports.memory.buffer, 0, 65536);
|
||||||
|
|
|
@ -6,8 +6,9 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert an object into an ES6 map
|
* Convert an object into an ES6 map
|
||||||
* @param {object} obj any object type that works with Object.entries()
|
* @template {object} T
|
||||||
* @returns {Map<string, any>} an ES6 Map of KV pairs
|
* @param {T} obj any object type that works with Object.entries()
|
||||||
|
* @returns {Map<string, T[keyof T]>} an ES6 Map of KV pairs
|
||||||
*/
|
*/
|
||||||
module.exports = function objectToMap(obj) {
|
module.exports = function objectToMap(obj) {
|
||||||
return new Map(Object.entries(obj));
|
return new Map(Object.entries(obj));
|
||||||
|
|
|
@ -101,7 +101,7 @@
|
||||||
"style-loader": "^4.0.0",
|
"style-loader": "^4.0.0",
|
||||||
"terser": "^5.38.1",
|
"terser": "^5.38.1",
|
||||||
"toml": "^3.0.0",
|
"toml": "^3.0.0",
|
||||||
"tooling": "webpack/tooling#v1.23.6",
|
"tooling": "webpack/tooling#v1.23.7",
|
||||||
"ts-loader": "^9.5.1",
|
"ts-loader": "^9.5.1",
|
||||||
"typescript": "^5.8.2",
|
"typescript": "^5.8.2",
|
||||||
"url-loader": "^4.1.0",
|
"url-loader": "^4.1.0",
|
||||||
|
|
|
@ -1745,7 +1745,7 @@ declare abstract class CodeGenerationResults {
|
||||||
runtime: RuntimeSpec
|
runtime: RuntimeSpec
|
||||||
): null | ReadonlySet<string>;
|
): null | ReadonlySet<string>;
|
||||||
getData(module: Module, runtime: RuntimeSpec, key: string): any;
|
getData(module: Module, runtime: RuntimeSpec, key: string): any;
|
||||||
getHash(module: Module, runtime: RuntimeSpec): any;
|
getHash(module: Module, runtime: RuntimeSpec): string;
|
||||||
add(module: Module, runtime: RuntimeSpec, result: CodeGenerationResult): void;
|
add(module: Module, runtime: RuntimeSpec, result: CodeGenerationResult): void;
|
||||||
}
|
}
|
||||||
type CodeValue =
|
type CodeValue =
|
||||||
|
@ -1867,18 +1867,18 @@ declare class Compilation {
|
||||||
SyncBailHook<[Chunk, Set<string>, RuntimeRequirementsContext], void>
|
SyncBailHook<[Chunk, Set<string>, RuntimeRequirementsContext], void>
|
||||||
>;
|
>;
|
||||||
runtimeModule: SyncHook<[RuntimeModule, Chunk]>;
|
runtimeModule: SyncHook<[RuntimeModule, Chunk]>;
|
||||||
reviveModules: SyncHook<[Iterable<Module>, any]>;
|
reviveModules: SyncHook<[Iterable<Module>, Records]>;
|
||||||
beforeModuleIds: SyncHook<[Iterable<Module>]>;
|
beforeModuleIds: SyncHook<[Iterable<Module>]>;
|
||||||
moduleIds: SyncHook<[Iterable<Module>]>;
|
moduleIds: SyncHook<[Iterable<Module>]>;
|
||||||
optimizeModuleIds: SyncHook<[Iterable<Module>]>;
|
optimizeModuleIds: SyncHook<[Iterable<Module>]>;
|
||||||
afterOptimizeModuleIds: SyncHook<[Iterable<Module>]>;
|
afterOptimizeModuleIds: SyncHook<[Iterable<Module>]>;
|
||||||
reviveChunks: SyncHook<[Iterable<Chunk>, any]>;
|
reviveChunks: SyncHook<[Iterable<Chunk>, Records]>;
|
||||||
beforeChunkIds: SyncHook<[Iterable<Chunk>]>;
|
beforeChunkIds: SyncHook<[Iterable<Chunk>]>;
|
||||||
chunkIds: SyncHook<[Iterable<Chunk>]>;
|
chunkIds: SyncHook<[Iterable<Chunk>]>;
|
||||||
optimizeChunkIds: SyncHook<[Iterable<Chunk>]>;
|
optimizeChunkIds: SyncHook<[Iterable<Chunk>]>;
|
||||||
afterOptimizeChunkIds: SyncHook<[Iterable<Chunk>]>;
|
afterOptimizeChunkIds: SyncHook<[Iterable<Chunk>]>;
|
||||||
recordModules: SyncHook<[Iterable<Module>, any]>;
|
recordModules: SyncHook<[Iterable<Module>, Records]>;
|
||||||
recordChunks: SyncHook<[Iterable<Chunk>, any]>;
|
recordChunks: SyncHook<[Iterable<Chunk>, Records]>;
|
||||||
optimizeCodeGeneration: SyncHook<[Iterable<Module>]>;
|
optimizeCodeGeneration: SyncHook<[Iterable<Module>]>;
|
||||||
beforeModuleHash: SyncHook<[]>;
|
beforeModuleHash: SyncHook<[]>;
|
||||||
afterModuleHash: SyncHook<[]>;
|
afterModuleHash: SyncHook<[]>;
|
||||||
|
@ -1889,8 +1889,8 @@ declare class Compilation {
|
||||||
beforeHash: SyncHook<[]>;
|
beforeHash: SyncHook<[]>;
|
||||||
contentHash: SyncHook<[Chunk]>;
|
contentHash: SyncHook<[Chunk]>;
|
||||||
afterHash: SyncHook<[]>;
|
afterHash: SyncHook<[]>;
|
||||||
recordHash: SyncHook<[any]>;
|
recordHash: SyncHook<[Records]>;
|
||||||
record: SyncHook<[Compilation, any]>;
|
record: SyncHook<[Compilation, Records]>;
|
||||||
beforeModuleAssets: SyncHook<[]>;
|
beforeModuleAssets: SyncHook<[]>;
|
||||||
shouldGenerateChunkAssets: SyncBailHook<[], boolean | void>;
|
shouldGenerateChunkAssets: SyncBailHook<[], boolean | void>;
|
||||||
beforeChunkAssets: SyncHook<[]>;
|
beforeChunkAssets: SyncHook<[]>;
|
||||||
|
@ -13119,7 +13119,7 @@ declare interface RuleSet {
|
||||||
/**
|
/**
|
||||||
* map of references in the rule set (may grow over time)
|
* map of references in the rule set (may grow over time)
|
||||||
*/
|
*/
|
||||||
references: Map<string, any>;
|
references: Map<string, RuleSetLoaderOptions>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* execute the rule set
|
* execute the rule set
|
||||||
|
@ -13144,6 +13144,7 @@ type RuleSetConditionOrConditions =
|
||||||
| ((value: string) => boolean)
|
| ((value: string) => boolean)
|
||||||
| RuleSetLogicalConditions
|
| RuleSetLogicalConditions
|
||||||
| RuleSetCondition[];
|
| RuleSetCondition[];
|
||||||
|
type RuleSetLoaderOptions = string | { [index: string]: any };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logic operators used in a condition matcher.
|
* Logic operators used in a condition matcher.
|
||||||
|
@ -13909,7 +13910,7 @@ declare abstract class RuntimeTemplate {
|
||||||
*/
|
*/
|
||||||
runtimeRequirements: Set<string>;
|
runtimeRequirements: Set<string>;
|
||||||
}): [string, string];
|
}): [string, string];
|
||||||
exportFromImport(__0: {
|
exportFromImport<GenerateContext>(__0: {
|
||||||
/**
|
/**
|
||||||
* the module graph
|
* the module graph
|
||||||
*/
|
*/
|
||||||
|
@ -13953,7 +13954,7 @@ declare abstract class RuntimeTemplate {
|
||||||
/**
|
/**
|
||||||
* init fragments will be added here
|
* init fragments will be added here
|
||||||
*/
|
*/
|
||||||
initFragments: InitFragment<any>[];
|
initFragments: InitFragment<GenerateContext>[];
|
||||||
/**
|
/**
|
||||||
* runtime for which this code will be generated
|
* runtime for which this code will be generated
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -5967,9 +5967,9 @@ toml@^3.0.0:
|
||||||
resolved "https://registry.yarnpkg.com/toml/-/toml-3.0.0.tgz#342160f1af1904ec9d204d03a5d61222d762c5ee"
|
resolved "https://registry.yarnpkg.com/toml/-/toml-3.0.0.tgz#342160f1af1904ec9d204d03a5d61222d762c5ee"
|
||||||
integrity sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==
|
integrity sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==
|
||||||
|
|
||||||
tooling@webpack/tooling#v1.23.6:
|
tooling@webpack/tooling#v1.23.7:
|
||||||
version "1.23.5"
|
version "1.23.7"
|
||||||
resolved "https://codeload.github.com/webpack/tooling/tar.gz/fde1360cf28dfdb938e289d06da01ed83df0a343"
|
resolved "https://codeload.github.com/webpack/tooling/tar.gz/bee59400abb9046078b7ea919ab36b60828e796d"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@yarnpkg/lockfile" "^1.1.0"
|
"@yarnpkg/lockfile" "^1.1.0"
|
||||||
ajv "^8.1.0"
|
ajv "^8.1.0"
|
||||||
|
|
Loading…
Reference in New Issue