mirror of https://github.com/webpack/webpack.git
fix: types
This commit is contained in:
parent
c109f97b1b
commit
24c0ededd2
|
@ -15,6 +15,24 @@ declare namespace NodeJS {
|
|||
}
|
||||
}
|
||||
|
||||
declare module "typescript-iterable" {
|
||||
// New iterator interfaces from `lib.es2015.iterable.d.ts` for compatibility with old typescript versions and `dispose`
|
||||
interface Disposable {
|
||||
[Symbol.dispose](): void;
|
||||
}
|
||||
|
||||
export interface IteratorObject<T, TReturn = unknown, TNext = unknown>
|
||||
extends Iterator<T, TReturn, TNext>,
|
||||
Disposable {
|
||||
[Symbol.iterator](): IteratorObject<T, TReturn, TNext>;
|
||||
}
|
||||
|
||||
export interface SetIterator<T>
|
||||
extends IteratorObject<T, BuiltinIteratorReturn, unknown> {
|
||||
[Symbol.iterator](): SetIterator<T>;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "neo-async" {
|
||||
interface QueueObject<T, E> {
|
||||
push(item: T): void;
|
||||
|
|
|
@ -140,6 +140,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|||
* @property {Map<string, AssetInfo | undefined>=} assetsInfo for assets modules
|
||||
* @property {boolean=} dataUrl for assets modules
|
||||
* @property {CssData=} cssData for css modules
|
||||
* @property {Set<string>=} topLevelDeclarations top level declaration names
|
||||
*/
|
||||
|
||||
/** @typedef {Map<string, string | Set<string>>} ValueCacheVersions */
|
||||
|
|
|
@ -762,9 +762,13 @@ class ConcatenatedModule extends Module {
|
|||
cacheable: true,
|
||||
moduleArgument,
|
||||
exportsArgument,
|
||||
/** @type {LazySet<string>} */
|
||||
fileDependencies: new LazySet(),
|
||||
/** @type {LazySet<string>} */
|
||||
contextDependencies: new LazySet(),
|
||||
/** @type {LazySet<string>} */
|
||||
missingDependencies: new LazySet(),
|
||||
/** @type {Set<string>} */
|
||||
topLevelDeclarations: new Set(),
|
||||
assets: undefined
|
||||
};
|
||||
|
@ -775,7 +779,8 @@ class ConcatenatedModule extends Module {
|
|||
for (const m of this._modules) {
|
||||
// populate cacheable
|
||||
if (!(/** @type {BuildInfo} */ (m.buildInfo).cacheable)) {
|
||||
this.buildInfo.cacheable = false;
|
||||
/** @type {BuildInfo} */
|
||||
(this.buildInfo).cacheable = false;
|
||||
}
|
||||
|
||||
// populate dependencies
|
||||
|
@ -783,7 +788,8 @@ class ConcatenatedModule extends Module {
|
|||
dep =>
|
||||
!(dep instanceof HarmonyImportDependency) ||
|
||||
!this._modules.has(
|
||||
/** @type {Module} */ (compilation.moduleGraph.getModule(dep))
|
||||
/** @type {Module} */
|
||||
(compilation.moduleGraph.getModule(dep))
|
||||
)
|
||||
)) {
|
||||
this.dependencies.push(d);
|
||||
|
@ -812,38 +818,37 @@ class ConcatenatedModule extends Module {
|
|||
const { assets, assetsInfo, topLevelDeclarations } =
|
||||
/** @type {BuildInfo} */ (m.buildInfo);
|
||||
|
||||
const buildInfo = /** @type {BuildInfo} */ (this.buildInfo);
|
||||
|
||||
// populate topLevelDeclarations
|
||||
if (topLevelDeclarations) {
|
||||
const topLevelDeclarations = this.buildInfo.topLevelDeclarations;
|
||||
const topLevelDeclarations = buildInfo.topLevelDeclarations;
|
||||
if (topLevelDeclarations !== undefined) {
|
||||
for (const decl of topLevelDeclarations) {
|
||||
topLevelDeclarations.add(decl);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.buildInfo.topLevelDeclarations = undefined;
|
||||
buildInfo.topLevelDeclarations = undefined;
|
||||
}
|
||||
|
||||
// populate assets
|
||||
if (assets) {
|
||||
if (this.buildInfo.assets === undefined) {
|
||||
this.buildInfo.assets = Object.create(null);
|
||||
if (buildInfo.assets === undefined) {
|
||||
buildInfo.assets = Object.create(null);
|
||||
}
|
||||
Object.assign(
|
||||
/** @type {NonNullable<BuildInfo["assets"]>} */
|
||||
(
|
||||
/** @type {BuildInfo} */
|
||||
(this.buildInfo).assets
|
||||
),
|
||||
(buildInfo.assets),
|
||||
assets
|
||||
);
|
||||
}
|
||||
if (assetsInfo) {
|
||||
if (this.buildInfo.assetsInfo === undefined) {
|
||||
this.buildInfo.assetsInfo = new Map();
|
||||
if (buildInfo.assetsInfo === undefined) {
|
||||
buildInfo.assetsInfo = new Map();
|
||||
}
|
||||
for (const [key, value] of assetsInfo) {
|
||||
this.buildInfo.assetsInfo.set(key, value);
|
||||
buildInfo.assetsInfo.set(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1136,6 +1141,7 @@ class ConcatenatedModule extends Module {
|
|||
// List of all used names to avoid conflicts
|
||||
const allUsedNames = new Set(RESERVED_NAMES);
|
||||
// Updated Top level declarations are created by renaming
|
||||
/** @type {Set<string>} */
|
||||
const topLevelDeclarations = new Set();
|
||||
|
||||
// List of additional names in scope for module references
|
||||
|
@ -1326,7 +1332,10 @@ class ConcatenatedModule extends Module {
|
|||
info.namespaceObjectName =
|
||||
/** @type {string} */
|
||||
(namespaceObjectName);
|
||||
topLevelDeclarations.add(namespaceObjectName);
|
||||
topLevelDeclarations.add(
|
||||
/** @type {string} */
|
||||
(namespaceObjectName)
|
||||
);
|
||||
break;
|
||||
}
|
||||
case "external": {
|
||||
|
|
|
@ -39,6 +39,11 @@ const flatten = (targetSet, toDeepMerge) => {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @typedef {import("typescript-iterable").SetIterator<T>} SetIterator
|
||||
*/
|
||||
|
||||
/**
|
||||
* Like Set but with an addAll method to eventually add items from another iterable.
|
||||
* Access methods make sure that all delayed operations are executed.
|
||||
|
@ -139,7 +144,7 @@ class LazySet {
|
|||
}
|
||||
|
||||
/**
|
||||
* @returns {IterableIterator<[T, T]>} entries
|
||||
* @returns {SetIterator<[T, T]>} entries
|
||||
*/
|
||||
entries() {
|
||||
this._deopt = true;
|
||||
|
@ -170,7 +175,7 @@ class LazySet {
|
|||
}
|
||||
|
||||
/**
|
||||
* @returns {IterableIterator<T>} keys
|
||||
* @returns {SetIterator<T>} keys
|
||||
*/
|
||||
keys() {
|
||||
this._deopt = true;
|
||||
|
@ -179,7 +184,7 @@ class LazySet {
|
|||
}
|
||||
|
||||
/**
|
||||
* @returns {IterableIterator<T>} values
|
||||
* @returns {SetIterator<T>} values
|
||||
*/
|
||||
values() {
|
||||
this._deopt = true;
|
||||
|
@ -188,7 +193,7 @@ class LazySet {
|
|||
}
|
||||
|
||||
/**
|
||||
* @returns {IterableIterator<T>} iterable iterator
|
||||
* @returns {SetIterator<T>} iterable iterator
|
||||
*/
|
||||
[Symbol.iterator]() {
|
||||
this._deopt = true;
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
new Map().entries();
|
||||
|
||||
/**
|
||||
* The StackedCacheMap is a data structure designed as an alternative to a Map
|
||||
* in situations where you need to handle multiple item additions and
|
||||
|
@ -128,7 +130,7 @@ class StackedCacheMap {
|
|||
next() {
|
||||
let result = current.next();
|
||||
while (result.done && iterators.length > 0) {
|
||||
current = /** @type {IterableIterator<[K, V]>} */ (iterators.pop());
|
||||
current = /** @type {MapIterator<[K, V]>} */ (iterators.pop());
|
||||
result = current.next();
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -48,18 +48,22 @@ const path = require("path");
|
|||
* @typedef {IStatsBase<bigint> & { atimeNs: bigint, mtimeNs: bigint, ctimeNs: bigint, birthtimeNs: bigint }} IBigIntStats
|
||||
*/
|
||||
|
||||
/* eslint-disable jsdoc/require-template */
|
||||
/**
|
||||
* @template {string | Buffer} [T=string]
|
||||
* @typedef {object} Dirent
|
||||
* @property {() => boolean} isFile
|
||||
* @property {() => boolean} isDirectory
|
||||
* @property {() => boolean} isBlockDevice
|
||||
* @property {() => boolean} isCharacterDevice
|
||||
* @property {() => boolean} isSymbolicLink
|
||||
* @property {() => boolean} isFIFO
|
||||
* @property {() => boolean} isSocket
|
||||
* @property {string} name
|
||||
* @property {string} path
|
||||
* @property {() => boolean} isFile true when is file, otherwise false
|
||||
* @property {() => boolean} isDirectory true when is directory, otherwise false
|
||||
* @property {() => boolean} isBlockDevice true when is block device, otherwise false
|
||||
* @property {() => boolean} isCharacterDevice true when is character device, otherwise false
|
||||
* @property {() => boolean} isSymbolicLink true when is symbolic link, otherwise false
|
||||
* @property {() => boolean} isFIFO true when is FIFO, otherwise false
|
||||
* @property {() => boolean} isSocket true when is socket, otherwise false
|
||||
* @property {T} name name
|
||||
* @property {string} parentPath path
|
||||
* @property {string=} path path
|
||||
*/
|
||||
/* eslint-enable jsdoc/require-template */
|
||||
|
||||
/** @typedef {string | number | boolean | null} JsonPrimitive */
|
||||
/** @typedef {JsonValue[]} JsonArray */
|
||||
|
@ -74,6 +78,7 @@ const path = require("path");
|
|||
/** @typedef {(err: NodeJS.ErrnoException | null, result?: Buffer[]) => void} ReaddirBufferCallback */
|
||||
/** @typedef {(err: NodeJS.ErrnoException | null, result?: string[] | Buffer[]) => void} ReaddirStringOrBufferCallback */
|
||||
/** @typedef {(err: NodeJS.ErrnoException | null, result?: Dirent[]) => void} ReaddirDirentCallback */
|
||||
/** @typedef {(err: NodeJS.ErrnoException | null, result?: Dirent<Buffer>[]) => void} ReaddirDirentBufferCallback */
|
||||
/** @typedef {(err: NodeJS.ErrnoException | null, result?: IStats) => void} StatsCallback */
|
||||
/** @typedef {(err: NodeJS.ErrnoException | null, result?: IBigIntStats) => void} BigIntStatsCallback */
|
||||
/** @typedef {(err: NodeJS.ErrnoException | null, result?: IStats | IBigIntStats) => void} StatsOrBigIntStatsCallback */
|
||||
|
@ -187,20 +192,22 @@ const path = require("path");
|
|||
|
||||
/**
|
||||
* @typedef {{
|
||||
* (path: PathLike, options: { encoding: BufferEncoding | null, withFileTypes?: false | undefined, recursive?: boolean | undefined } | BufferEncoding | undefined | null, callback: ReaddirStringCallback): void;
|
||||
* (path: PathLike, options: { encoding: 'buffer', withFileTypes?: false | undefined, recursive?: boolean | undefined } | 'buffer', callback: ReaddirBufferCallback): void;
|
||||
* (path: PathLike, callback: ReaddirStringCallback): void;
|
||||
* (path: PathLike, options: (ObjectEncodingOptions & { withFileTypes?: false | undefined, recursive?: boolean | undefined }) | BufferEncoding | undefined | null, callback: ReaddirStringOrBufferCallback): void;
|
||||
* (path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true, recursive?: boolean | undefined }, callback: ReaddirDirentCallback): void;
|
||||
* (path: PathLike, options: { encoding: BufferEncoding | null, withFileTypes?: false | undefined, recursive?: boolean | undefined } | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException | null, files?: string[]) => void): void;
|
||||
* (path: PathLike, options: { encoding: 'buffer', withFileTypes?: false | undefined, recursive?: boolean | undefined } | 'buffer', callback: (err: NodeJS.ErrnoException | null, files?: Buffer[]) => void): void;
|
||||
* (path: PathLike, options: (ObjectEncodingOptions & { withFileTypes?: false | undefined, recursive?: boolean | undefined }) | BufferEncoding | undefined | null, callback: (err: NodeJS.ErrnoException | null, files?: string[] | Buffer[]) => void): void;
|
||||
* (path: PathLike, callback: (err: NodeJS.ErrnoException | null, files?: string[]) => void): void;
|
||||
* (path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true, recursive?: boolean | undefined }, callback: (err: NodeJS.ErrnoException | null, files?: Dirent<string>[]) => void): void;
|
||||
* (path: PathLike, options: { encoding: 'buffer', withFileTypes: true, recursive?: boolean | undefined }, callback: (err: NodeJS.ErrnoException | null, files: Dirent<Buffer>[]) => void): void;
|
||||
* }} Readdir
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* (path: PathLike, options?: { encoding: BufferEncoding | null, withFileTypes?: false | undefined, recursive?: boolean | undefined } | BufferEncoding | null): string[];
|
||||
* (path: PathLike, options?: { encoding: BufferEncoding | null, withFileTypes?: false | undefined, recursive?: boolean | undefined; } | BufferEncoding | null): string[];
|
||||
* (path: PathLike, options: { encoding: 'buffer', withFileTypes?: false | undefined, recursive?: boolean | undefined } | 'buffer'): Buffer[];
|
||||
* (path: PathLike, options?: (ObjectEncodingOptions & { withFileTypes?: false | undefined, recursive?: boolean | undefined }) | BufferEncoding | null): string[] | Buffer[];
|
||||
* (path: PathLike, options: ObjectEncodingOptions & { withFileTypes: true, recursive?: boolean | undefined }): Dirent[];
|
||||
* (path: PathLike, options: { encoding: "buffer", withFileTypes: true, recursive?: boolean | undefined }): Dirent<Buffer>[];
|
||||
* }} ReaddirSync
|
||||
*/
|
||||
|
||||
|
|
|
@ -561,7 +561,7 @@ module.exports.stringifyHoley = json => {
|
|||
exports.parseVersionRuntimeCode = runtimeTemplate =>
|
||||
`var parseVersion = ${runtimeTemplate.basicFunction("str", [
|
||||
"// see webpack/lib/util/semver.js for original code",
|
||||
`var p=${runtimeTemplate.supportsArrowFunction() ? "p=>" : "function(p)"}{return p.split(".").map((${runtimeTemplate.supportsArrowFunction() ? "p=>" : "function(p)"}{return+p==p?+p:p}))},n=/^([^-+]+)?(?:-([^+]+))?(?:\\+(.+))?$/.exec(str),r=n[1]?p(n[1]):[];return n[2]&&(r.length++,r.push.apply(r,p(n[2]))),n[3]&&(r.push([]),r.push.apply(r,p(n[3]))),r;`
|
||||
`var p=${runtimeTemplate.supportsArrowFunction() ? "p=>" : "function(p)"}{return p.split(".").map(${runtimeTemplate.supportsArrowFunction() ? "p=>" : "function(p)"}{return+p==p?+p:p})},n=/^([^-+]+)?(?:-([^+]+))?(?:\\+(.+))?$/.exec(str),r=n[1]?p(n[1]):[];return n[2]&&(r.length++,r.push.apply(r,p(n[2]))),n[3]&&(r.push([]),r.push.apply(r,p(n[3]))),r;`
|
||||
])}`;
|
||||
//#endregion
|
||||
|
||||
|
|
50
package.json
50
package.json
|
@ -6,7 +6,7 @@
|
|||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/eslint-scope": "^3.7.7",
|
||||
"@types/estree": "^1.0.6",
|
||||
"@types/estree": "^1.0.8",
|
||||
"@types/json-schema": "^7.0.15",
|
||||
"@webassemblyjs/ast": "^1.14.1",
|
||||
"@webassemblyjs/wasm-edit": "^1.14.1",
|
||||
|
@ -14,7 +14,7 @@
|
|||
"acorn": "^8.14.0",
|
||||
"browserslist": "^4.24.0",
|
||||
"chrome-trace-event": "^1.0.2",
|
||||
"enhanced-resolve": "^5.17.1",
|
||||
"enhanced-resolve": "^5.17.2",
|
||||
"es-module-lexer": "^1.2.1",
|
||||
"eslint-scope": "5.1.1",
|
||||
"events": "^3.2.0",
|
||||
|
@ -28,7 +28,7 @@
|
|||
"tapable": "^2.1.1",
|
||||
"terser-webpack-plugin": "^5.3.11",
|
||||
"watchpack": "^2.4.1",
|
||||
"webpack-sources": "^3.3.2"
|
||||
"webpack-sources": "^3.3.3"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"webpack-cli": {
|
||||
|
@ -39,31 +39,31 @@
|
|||
"@babel/core": "^7.27.1",
|
||||
"@babel/preset-react": "^7.27.1",
|
||||
"@codspeed/tinybench-plugin": "^4.0.1",
|
||||
"@eslint/js": "^9.21.0",
|
||||
"@stylistic/eslint-plugin": "^4.2.0",
|
||||
"@eslint/js": "^9.29.0",
|
||||
"@stylistic/eslint-plugin": "^5.0.0",
|
||||
"@types/glob-to-regexp": "^0.4.4",
|
||||
"@types/graceful-fs": "^4.1.9",
|
||||
"@types/jest": "^29.5.11",
|
||||
"@types/jest": "^30.0.0",
|
||||
"@types/mime-types": "^2.1.4",
|
||||
"@types/node": "^22.15.11",
|
||||
"@types/node": "^24.0.3",
|
||||
"@types/xxhashjs": "^0.2.4",
|
||||
"assemblyscript": "^0.28.2",
|
||||
"babel-loader": "^10.0.0",
|
||||
"bundle-loader": "^0.5.6",
|
||||
"coffee-loader": "^5.0.0",
|
||||
"coffeescript": "^2.5.1",
|
||||
"core-js": "^3.6.5",
|
||||
"cspell": "^9.0.1",
|
||||
"core-js": "^3.43.0",
|
||||
"cspell": "^9.1.1",
|
||||
"css-loader": "^7.1.2",
|
||||
"date-fns": "^4.0.0",
|
||||
"es5-ext": "^0.10.53",
|
||||
"es6-promise-polyfill": "^1.2.0",
|
||||
"eslint": "^9.21.0",
|
||||
"eslint": "^9.29.0",
|
||||
"eslint-config-prettier": "^10.1.1",
|
||||
"eslint-plugin-jest": "^28.6.0",
|
||||
"eslint-plugin-jsdoc": "^50.6.3",
|
||||
"eslint-plugin-n": "^17.16.2",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"eslint-plugin-jest": "^29.0.1",
|
||||
"eslint-plugin-jsdoc": "^51.2.2",
|
||||
"eslint-plugin-n": "^17.20.0",
|
||||
"eslint-plugin-prettier": "^5.5.0",
|
||||
"eslint-plugin-unicorn": "^59.0.0",
|
||||
"file-loader": "^6.0.0",
|
||||
"fork-ts-checker-webpack-plugin": "^9.0.2",
|
||||
|
@ -71,17 +71,17 @@
|
|||
"hash-wasm": "^4.9.0",
|
||||
"husky": "^9.0.11",
|
||||
"istanbul": "^0.4.5",
|
||||
"jest": "^30.0.0",
|
||||
"jest-circus": "^30.0.0",
|
||||
"jest-cli": "^30.0.0",
|
||||
"jest-diff": "^30.0.0",
|
||||
"jest-environment-node": "^30.0.0",
|
||||
"jest": "^30.0.2",
|
||||
"jest-circus": "^30.0.2",
|
||||
"jest-cli": "^30.0.2",
|
||||
"jest-diff": "^30.0.2",
|
||||
"jest-environment-node": "^30.0.2",
|
||||
"jest-junit": "^16.0.0",
|
||||
"json-loader": "^0.5.7",
|
||||
"json5": "^2.1.3",
|
||||
"less": "^4.0.0",
|
||||
"less-loader": "^12.2.0",
|
||||
"lint-staged": "^16.0.0",
|
||||
"lint-staged": "^16.1.2",
|
||||
"lodash": "^4.17.19",
|
||||
"lodash-es": "^4.17.15",
|
||||
"memfs": "^4.14.0",
|
||||
|
@ -90,9 +90,9 @@
|
|||
"node-gyp": "^11.2.0",
|
||||
"nyc": "^17.1.0",
|
||||
"open-cli": "^8.0.0",
|
||||
"prettier": "^3.5.1",
|
||||
"prettier": "^3.6.0",
|
||||
"prettier-2": "npm:prettier@^2",
|
||||
"pretty-format": "^29.5.0",
|
||||
"pretty-format": "^30.0.2",
|
||||
"pug": "^3.0.3",
|
||||
"pug-loader": "^2.4.0",
|
||||
"raw-loader": "^4.0.1",
|
||||
|
@ -100,14 +100,14 @@
|
|||
"react-dom": "^19.0.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"script-loader": "^0.7.2",
|
||||
"simple-git": "^3.27.0",
|
||||
"simple-git": "^3.28.0",
|
||||
"strip-ansi": "^6.0.0",
|
||||
"style-loader": "^4.0.0",
|
||||
"terser": "^5.38.1",
|
||||
"terser": "^5.43.1",
|
||||
"three": "^0.177.0",
|
||||
"tinybench": "^4.0.1",
|
||||
"toml": "^3.0.0",
|
||||
"tooling": "webpack/tooling#v1.23.9",
|
||||
"tooling": "webpack/tooling#v1.24.0",
|
||||
"ts-loader": "^9.5.1",
|
||||
"typescript": "^5.8.2",
|
||||
"url-loader": "^4.1.0",
|
||||
|
|
|
@ -190,10 +190,10 @@ describe("Stats", () => {
|
|||
"assets": Array [
|
||||
Object {
|
||||
"name": "entryB.js",
|
||||
"size": 3105,
|
||||
"size": 3093,
|
||||
},
|
||||
],
|
||||
"assetsSize": 3105,
|
||||
"assetsSize": 3093,
|
||||
"auxiliaryAssets": undefined,
|
||||
"auxiliaryAssetsSize": 0,
|
||||
"childAssets": undefined,
|
||||
|
@ -238,10 +238,10 @@ describe("Stats", () => {
|
|||
"info": Object {
|
||||
"javascriptModule": false,
|
||||
"minimized": true,
|
||||
"size": 3105,
|
||||
"size": 3093,
|
||||
},
|
||||
"name": "entryB.js",
|
||||
"size": 3105,
|
||||
"size": 3093,
|
||||
"type": "asset",
|
||||
},
|
||||
Object {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue