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