mirror of https://github.com/webpack/webpack.git
fix: better types (#19469)
Github Actions / lint (push) Has been cancelled
Details
Github Actions / validate-legacy-node (push) Has been cancelled
Details
Github Actions / benchmark (push) Has been cancelled
Details
Github Actions / basic (push) Has been cancelled
Details
Github Actions / unit (push) Has been cancelled
Details
Github Actions / integration (10.x, macos-latest, a) (push) Has been cancelled
Details
Github Actions / integration (10.x, macos-latest, b) (push) Has been cancelled
Details
Github Actions / integration (10.x, ubuntu-latest, a) (push) Has been cancelled
Details
Github Actions / integration (10.x, ubuntu-latest, b) (push) Has been cancelled
Details
Github Actions / integration (10.x, windows-latest, a) (push) Has been cancelled
Details
Github Actions / integration (10.x, windows-latest, b) (push) Has been cancelled
Details
Github Actions / integration (12.x, ubuntu-latest, a) (push) Has been cancelled
Details
Github Actions / integration (14.x, ubuntu-latest, a) (push) Has been cancelled
Details
Github Actions / integration (16.x, ubuntu-latest, a) (push) Has been cancelled
Details
Github Actions / integration (18.x, ubuntu-latest, a) (push) Has been cancelled
Details
Github Actions / integration (18.x, ubuntu-latest, b) (push) Has been cancelled
Details
Github Actions / integration (20.x, macos-latest, a) (push) Has been cancelled
Details
Github Actions / integration (20.x, macos-latest, b) (push) Has been cancelled
Details
Github Actions / integration (20.x, ubuntu-latest, a) (push) Has been cancelled
Details
Github Actions / integration (20.x, ubuntu-latest, b) (push) Has been cancelled
Details
Github Actions / integration (20.x, windows-latest, a) (push) Has been cancelled
Details
Github Actions / integration (20.x, windows-latest, b) (push) Has been cancelled
Details
Github Actions / integration (22.x, macos-latest, a) (push) Has been cancelled
Details
Github Actions / integration (22.x, macos-latest, b) (push) Has been cancelled
Details
Github Actions / integration (22.x, ubuntu-latest, a) (push) Has been cancelled
Details
Github Actions / integration (22.x, ubuntu-latest, b) (push) Has been cancelled
Details
Github Actions / integration (22.x, windows-latest, a) (push) Has been cancelled
Details
Github Actions / integration (22.x, windows-latest, b) (push) Has been cancelled
Details
Github Actions / integration (23.x, ubuntu-latest, a) (push) Has been cancelled
Details
Github Actions / integration (23.x, ubuntu-latest, b) (push) Has been cancelled
Details
Github Actions / integration (lts/*, ubuntu-latest, a, 1) (push) Has been cancelled
Details
Github Actions / integration (lts/*, ubuntu-latest, b, 1) (push) Has been cancelled
Details
Github Actions / lint (push) Has been cancelled
Details
Github Actions / validate-legacy-node (push) Has been cancelled
Details
Github Actions / benchmark (push) Has been cancelled
Details
Github Actions / basic (push) Has been cancelled
Details
Github Actions / unit (push) Has been cancelled
Details
Github Actions / integration (10.x, macos-latest, a) (push) Has been cancelled
Details
Github Actions / integration (10.x, macos-latest, b) (push) Has been cancelled
Details
Github Actions / integration (10.x, ubuntu-latest, a) (push) Has been cancelled
Details
Github Actions / integration (10.x, ubuntu-latest, b) (push) Has been cancelled
Details
Github Actions / integration (10.x, windows-latest, a) (push) Has been cancelled
Details
Github Actions / integration (10.x, windows-latest, b) (push) Has been cancelled
Details
Github Actions / integration (12.x, ubuntu-latest, a) (push) Has been cancelled
Details
Github Actions / integration (14.x, ubuntu-latest, a) (push) Has been cancelled
Details
Github Actions / integration (16.x, ubuntu-latest, a) (push) Has been cancelled
Details
Github Actions / integration (18.x, ubuntu-latest, a) (push) Has been cancelled
Details
Github Actions / integration (18.x, ubuntu-latest, b) (push) Has been cancelled
Details
Github Actions / integration (20.x, macos-latest, a) (push) Has been cancelled
Details
Github Actions / integration (20.x, macos-latest, b) (push) Has been cancelled
Details
Github Actions / integration (20.x, ubuntu-latest, a) (push) Has been cancelled
Details
Github Actions / integration (20.x, ubuntu-latest, b) (push) Has been cancelled
Details
Github Actions / integration (20.x, windows-latest, a) (push) Has been cancelled
Details
Github Actions / integration (20.x, windows-latest, b) (push) Has been cancelled
Details
Github Actions / integration (22.x, macos-latest, a) (push) Has been cancelled
Details
Github Actions / integration (22.x, macos-latest, b) (push) Has been cancelled
Details
Github Actions / integration (22.x, ubuntu-latest, a) (push) Has been cancelled
Details
Github Actions / integration (22.x, ubuntu-latest, b) (push) Has been cancelled
Details
Github Actions / integration (22.x, windows-latest, a) (push) Has been cancelled
Details
Github Actions / integration (22.x, windows-latest, b) (push) Has been cancelled
Details
Github Actions / integration (23.x, ubuntu-latest, a) (push) Has been cancelled
Details
Github Actions / integration (23.x, ubuntu-latest, b) (push) Has been cancelled
Details
Github Actions / integration (lts/*, ubuntu-latest, a, 1) (push) Has been cancelled
Details
Github Actions / integration (lts/*, ubuntu-latest, b, 1) (push) Has been cancelled
Details
This commit is contained in:
parent
9a0e0ea4ee
commit
9e0339de0f
|
@ -499,7 +499,7 @@ export type DevtoolFallbackModuleFilenameTemplate =
|
|||
*/
|
||||
export type DevtoolModuleFilenameTemplate =
|
||||
| string
|
||||
| ((context: TODO) => string);
|
||||
| import("../lib/ModuleFilenameHelpers").ModuleFilenameTemplateFunction;
|
||||
/**
|
||||
* Module namespace to use when interpolating filename template string for the sources array in a generated SourceMap. Defaults to `output.library` if not set. It's useful for avoiding runtime collisions in sourcemaps from multiple webpack projects built as libraries.
|
||||
*/
|
||||
|
@ -1289,7 +1289,11 @@ export interface InfrastructureLogging {
|
|||
/**
|
||||
* Stream used for logging output. Defaults to process.stderr. This option is only used when no custom console is provided.
|
||||
*/
|
||||
stream?: NodeJS.WritableStream;
|
||||
stream?: NodeJS.WritableStream & {
|
||||
isTTY?: boolean;
|
||||
columns?: number;
|
||||
rows?: number;
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Custom values available in the loader context.
|
||||
|
|
|
@ -39,7 +39,9 @@ export interface SourceMapDevToolPluginOptions {
|
|||
/**
|
||||
* Generator string or function to create identifiers of modules for the 'sources' array in the SourceMap used only if 'moduleFilenameTemplate' would result in a conflict.
|
||||
*/
|
||||
fallbackModuleFilenameTemplate?: string | ((context: any) => string);
|
||||
fallbackModuleFilenameTemplate?:
|
||||
| string
|
||||
| import("../../lib/ModuleFilenameHelpers").ModuleFilenameTemplateFunction;
|
||||
/**
|
||||
* Path prefix to which the [file] placeholder is relative to.
|
||||
*/
|
||||
|
@ -59,7 +61,9 @@ export interface SourceMapDevToolPluginOptions {
|
|||
/**
|
||||
* Generator string or function to create identifiers of modules for the 'sources' array in the SourceMap.
|
||||
*/
|
||||
moduleFilenameTemplate?: string | ((context: any) => string);
|
||||
moduleFilenameTemplate?:
|
||||
| string
|
||||
| import("../../lib/ModuleFilenameHelpers").ModuleFilenameTemplateFunction;
|
||||
/**
|
||||
* Namespace prefix to allow multiple webpack roots in the devtools.
|
||||
*/
|
||||
|
|
|
@ -130,7 +130,7 @@ const { isSourceEqual } = require("./util/source");
|
|||
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsModule} StatsModule */
|
||||
/** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
|
||||
/** @typedef {import("./util/Hash")} Hash */
|
||||
/** @typedef {import("./util/createHash").Algorithm} Algorithm */
|
||||
/** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
|
||||
/**
|
||||
* @template T
|
||||
* @typedef {import("./util/deprecation").FakeHook<T>} FakeHook<T>
|
||||
|
@ -1520,7 +1520,8 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|||
this.options,
|
||||
this,
|
||||
this.resolverFactory.get("normal", module.resolveOptions),
|
||||
/** @type {InputFileSystem} */ (this.inputFileSystem),
|
||||
/** @type {InputFileSystem} */
|
||||
(this.inputFileSystem),
|
||||
err => {
|
||||
if (currentProfile !== undefined) {
|
||||
currentProfile.markBuildingEnd();
|
||||
|
@ -4313,7 +4314,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|||
) {
|
||||
let moduleHashDigest;
|
||||
try {
|
||||
const moduleHash = createHash(/** @type {Algorithm} */ (hashFunction));
|
||||
const moduleHash = createHash(/** @type {HashFunction} */ (hashFunction));
|
||||
module.updateHash(moduleHash, {
|
||||
chunkGraph,
|
||||
runtime,
|
||||
|
@ -4341,7 +4342,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|||
const hashFunction = outputOptions.hashFunction;
|
||||
const hashDigest = outputOptions.hashDigest;
|
||||
const hashDigestLength = outputOptions.hashDigestLength;
|
||||
const hash = createHash(/** @type {Algorithm} */ (hashFunction));
|
||||
const hash = createHash(/** @type {HashFunction} */ (hashFunction));
|
||||
if (outputOptions.hashSalt) {
|
||||
hash.update(outputOptions.hashSalt);
|
||||
}
|
||||
|
@ -4524,7 +4525,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|||
this.logger.timeAggregate("hashing: hash runtime modules");
|
||||
try {
|
||||
this.logger.time("hashing: hash chunks");
|
||||
const chunkHash = createHash(/** @type {Algorithm} */ (hashFunction));
|
||||
const chunkHash = createHash(
|
||||
/** @type {HashFunction} */ (hashFunction)
|
||||
);
|
||||
if (outputOptions.hashSalt) {
|
||||
chunkHash.update(outputOptions.hashSalt);
|
||||
}
|
||||
|
@ -4577,7 +4580,9 @@ This prevents using hashes of each other and should be avoided.`);
|
|||
for (const module of /** @type {Iterable<RuntimeModule>} */ (
|
||||
chunkGraph.getChunkFullHashModulesIterable(chunk)
|
||||
)) {
|
||||
const moduleHash = createHash(/** @type {Algorithm} */ (hashFunction));
|
||||
const moduleHash = createHash(
|
||||
/** @type {HashFunction} */ (hashFunction)
|
||||
);
|
||||
module.updateHash(moduleHash, {
|
||||
chunkGraph,
|
||||
runtime: chunk.runtime,
|
||||
|
@ -4599,7 +4604,7 @@ This prevents using hashes of each other and should be avoided.`);
|
|||
(codeGenerationJobsMap.get(oldHash)).get(module)
|
||||
).hash = moduleHashDigest;
|
||||
}
|
||||
const chunkHash = createHash(/** @type {Algorithm} */ (hashFunction));
|
||||
const chunkHash = createHash(/** @type {HashFunction} */ (hashFunction));
|
||||
chunkHash.update(chunk.hash);
|
||||
chunkHash.update(this.hash);
|
||||
const chunkHashDigest =
|
||||
|
|
|
@ -81,7 +81,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|||
|
||||
/**
|
||||
* @typedef {object} ContextModuleOptionsExtras
|
||||
* @property {false|string|string[]} resource
|
||||
* @property {false | string | string[]} resource
|
||||
* @property {string=} resourceQuery
|
||||
* @property {string=} resourceFragment
|
||||
* @property {ResolveOptions=} resolveOptions
|
||||
|
|
|
@ -397,8 +397,7 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
|
|||
/** @type {string} */
|
||||
(category),
|
||||
referencedExports,
|
||||
/** @type {TODO} */
|
||||
(obj.context),
|
||||
obj.context,
|
||||
attributes
|
||||
);
|
||||
dep.optional = true;
|
||||
|
|
|
@ -190,7 +190,8 @@ const createResolveDependenciesFromContextMap =
|
|||
map[key] + options.resourceQuery + options.resourceFragment,
|
||||
key,
|
||||
options.typePrefix,
|
||||
/** @type {string} */ (options.category),
|
||||
/** @type {string} */
|
||||
(options.category),
|
||||
options.referencedExports
|
||||
)
|
||||
);
|
||||
|
|
|
@ -22,6 +22,7 @@ const {
|
|||
const createHash = require("./util/createHash");
|
||||
|
||||
/** @typedef {import("estree").Expression} Expression */
|
||||
/** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
|
||||
/** @typedef {import("./Compiler")} Compiler */
|
||||
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
||||
/** @typedef {import("./Module").ValueCacheVersions} ValueCacheVersions */
|
||||
|
@ -31,7 +32,6 @@ const createHash = require("./util/createHash");
|
|||
/** @typedef {import("./javascript/JavascriptParser").DestructuringAssignmentProperty} DestructuringAssignmentProperty */
|
||||
/** @typedef {import("./javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {import("./logging/Logger").Logger} Logger */
|
||||
/** @typedef {import("./util/createHash").Algorithm} Algorithm */
|
||||
|
||||
/** @typedef {null | undefined | RegExp | EXPECTED_FUNCTION | string | number | boolean | bigint | undefined} CodeValuePrimitive */
|
||||
/** @typedef {RecursiveArrayOrRecord<CodeValuePrimitive | RuntimeValue>} CodeValue */
|
||||
|
@ -367,7 +367,7 @@ class DefinePlugin {
|
|||
const { runtimeTemplate } = compilation;
|
||||
|
||||
const mainHash = createHash(
|
||||
/** @type {Algorithm} */
|
||||
/** @type {HashFunction} */
|
||||
(compilation.outputOptions.hashFunction)
|
||||
);
|
||||
mainHash.update(
|
||||
|
|
|
@ -16,6 +16,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|||
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
|
||||
/** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptions} DllReferencePluginOptions */
|
||||
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("./Compilation")} Compilation */
|
||||
/** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */
|
||||
|
@ -23,6 +24,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|||
/** @typedef {import("./Generator").SourceTypes} SourceTypes */
|
||||
/** @typedef {import("./LibManifestPlugin").ManifestModuleData} ManifestModuleData */
|
||||
/** @typedef {import("./Module").BuildCallback} BuildCallback */
|
||||
/** @typedef {import("./Module").BuildMeta} BuildMeta */
|
||||
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
|
||||
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
|
||||
/** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */
|
||||
|
@ -39,9 +41,16 @@ const makeSerializable = require("./util/makeSerializable");
|
|||
/** @typedef {import("./util/Hash")} Hash */
|
||||
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
||||
|
||||
/** @typedef {string} SourceRequest */
|
||||
/** @typedef {"require" | "object"} Type */
|
||||
/** @typedef {TODO} Data */
|
||||
/** @typedef {string} DelegatedModuleSourceRequest */
|
||||
|
||||
/** @typedef {NonNullable<DllReferencePluginOptions["type"]>} DelegatedModuleType */
|
||||
|
||||
/**
|
||||
* @typedef {object} DelegatedModuleData
|
||||
* @property {BuildMeta=} buildMeta build meta
|
||||
* @property {true | string[]=} exports exports
|
||||
* @property {number | string} id module id
|
||||
*/
|
||||
|
||||
const RUNTIME_REQUIREMENTS = new Set([
|
||||
RuntimeGlobals.module,
|
||||
|
@ -50,9 +59,9 @@ const RUNTIME_REQUIREMENTS = new Set([
|
|||
|
||||
class DelegatedModule extends Module {
|
||||
/**
|
||||
* @param {SourceRequest} sourceRequest source request
|
||||
* @param {Data} data data
|
||||
* @param {Type} type type
|
||||
* @param {DelegatedModuleSourceRequest} sourceRequest source request
|
||||
* @param {DelegatedModuleData} data data
|
||||
* @param {DelegatedModuleType} type type
|
||||
* @param {string} userRequest user request
|
||||
* @param {string | Module} originalRequest original request
|
||||
*/
|
||||
|
@ -65,7 +74,6 @@ class DelegatedModule extends Module {
|
|||
this.delegationType = type;
|
||||
this.userRequest = userRequest;
|
||||
this.originalRequest = originalRequest;
|
||||
/** @type {ManifestModuleData | undefined} */
|
||||
this.delegateData = data;
|
||||
|
||||
// Build info
|
||||
|
@ -255,7 +263,9 @@ class DelegatedModule extends Module {
|
|||
*/
|
||||
cleanupForCache() {
|
||||
super.cleanupForCache();
|
||||
this.delegateData = undefined;
|
||||
this.delegateData =
|
||||
/** @type {EXPECTED_ANY} */
|
||||
(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,15 +9,14 @@ const DelegatedModule = require("./DelegatedModule");
|
|||
|
||||
/** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptions} DllReferencePluginOptions */
|
||||
/** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptionsContent} DllReferencePluginOptionsContent */
|
||||
/** @typedef {import("./DelegatedModule").Data} Data */
|
||||
/** @typedef {import("./DelegatedModule").SourceRequest} SourceRequest */
|
||||
/** @typedef {import("./DelegatedModule").Type} Type */
|
||||
/** @typedef {import("./DelegatedModule").DelegatedModuleSourceRequest} DelegatedModuleSourceRequest */
|
||||
/** @typedef {import("./DelegatedModule").DelegatedModuleType} DelegatedModuleType */
|
||||
/** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
|
||||
/** @typedef {import("./util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
|
||||
|
||||
/**
|
||||
* @typedef {object} Options
|
||||
* @property {SourceRequest} source source
|
||||
* @property {DelegatedModuleSourceRequest} source source
|
||||
* @property {NonNullable<DllReferencePluginOptions["context"]>} context absolute context path to which lib ident is relative to
|
||||
* @property {DllReferencePluginOptionsContent} content content
|
||||
* @property {DllReferencePluginOptions["type"]} type type
|
||||
|
@ -58,7 +57,8 @@ class DelegatedModuleFactoryPlugin {
|
|||
new DelegatedModule(
|
||||
this.options.source,
|
||||
resolved,
|
||||
/** @type {Type} */ (this.options.type),
|
||||
/** @type {DelegatedModuleType} */
|
||||
(this.options.type),
|
||||
innerRequest,
|
||||
request
|
||||
)
|
||||
|
@ -77,7 +77,8 @@ class DelegatedModuleFactoryPlugin {
|
|||
new DelegatedModule(
|
||||
this.options.source,
|
||||
resolved,
|
||||
/** @type {Type} */ (this.options.type),
|
||||
/** @type {DelegatedModuleType} */
|
||||
(this.options.type),
|
||||
requestPlusExt,
|
||||
request + extension
|
||||
)
|
||||
|
@ -98,7 +99,8 @@ class DelegatedModuleFactoryPlugin {
|
|||
return new DelegatedModule(
|
||||
this.options.source,
|
||||
resolved,
|
||||
/** @type {Type} */ (this.options.type),
|
||||
/** @type {DelegatedModuleType} */
|
||||
(this.options.type),
|
||||
request,
|
||||
module
|
||||
);
|
||||
|
|
|
@ -39,7 +39,7 @@ const PLUGIN_NAME = "EvalSourceMapDevToolPlugin";
|
|||
|
||||
class EvalSourceMapDevToolPlugin {
|
||||
/**
|
||||
* @param {SourceMapDevToolPluginOptions|string} inputOptions Options object
|
||||
* @param {SourceMapDevToolPluginOptions | string} inputOptions Options object
|
||||
*/
|
||||
constructor(inputOptions) {
|
||||
/** @type {SourceMapDevToolPluginOptions} */
|
||||
|
|
|
@ -34,9 +34,18 @@ const RETURNS_TRUE = () => true;
|
|||
|
||||
const CIRCULAR = Symbol("circular target");
|
||||
|
||||
/**
|
||||
* @typedef {object} RestoreProvidedDataExports
|
||||
* @property {ExportInfoName} name
|
||||
* @property {ExportInfo["provided"]} provided
|
||||
* @property {ExportInfo["canMangleProvide"]} canMangleProvide
|
||||
* @property {ExportInfo["terminalBinding"]} terminalBinding
|
||||
* @property {RestoreProvidedData | undefined} exportsInfo
|
||||
*/
|
||||
|
||||
class RestoreProvidedData {
|
||||
/**
|
||||
* @param {TODO[]} exports exports
|
||||
* @param {RestoreProvidedDataExports[]} exports exports
|
||||
* @param {ExportInfo["provided"]} otherProvided other provided
|
||||
* @param {ExportInfo["canMangleProvide"]} otherCanMangleProvide other can mangle provide
|
||||
* @param {ExportInfo["terminalBinding"]} otherTerminalBinding other terminal binding
|
||||
|
@ -78,7 +87,7 @@ makeSerializable(
|
|||
"RestoreProvidedData"
|
||||
);
|
||||
|
||||
/** @typedef {Map<string, ExportInfo>} Exports */
|
||||
/** @typedef {Map<ExportInfoName, ExportInfo>} Exports */
|
||||
/** @typedef {string | string[] | false} UsedName */
|
||||
|
||||
class ExportsInfo {
|
||||
|
@ -131,6 +140,7 @@ class ExportsInfo {
|
|||
this._sortExports();
|
||||
}
|
||||
if (this._redirectTo !== undefined) {
|
||||
/** @type {Exports} */
|
||||
const map = new Map(
|
||||
Array.from(this._redirectTo.orderedExports, item => [item.name, item])
|
||||
);
|
||||
|
@ -160,6 +170,7 @@ class ExportsInfo {
|
|||
*/
|
||||
_sortExportsMap(exports) {
|
||||
if (exports.size > 1) {
|
||||
/** @type {string[]} */
|
||||
const namesInOrder = [];
|
||||
for (const entry of exports.values()) {
|
||||
namesInOrder.push(entry.name);
|
||||
|
@ -229,7 +240,7 @@ class ExportsInfo {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {string} name export name
|
||||
* @param {ExportInfoName} name export name
|
||||
* @returns {ExportInfo} export info for this name
|
||||
*/
|
||||
getOwnExportInfo(name) {
|
||||
|
@ -242,7 +253,7 @@ class ExportsInfo {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {string} name export name
|
||||
* @param {ExportInfoName} name export name
|
||||
* @returns {ExportInfo} export info for this name
|
||||
*/
|
||||
getExportInfo(name) {
|
||||
|
@ -257,7 +268,7 @@ class ExportsInfo {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {string} name export name
|
||||
* @param {ExportInfoName} name export name
|
||||
* @returns {ExportInfo} export info for this name
|
||||
*/
|
||||
getReadOnlyExportInfo(name) {
|
||||
|
@ -269,7 +280,7 @@ class ExportsInfo {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {string[]} name export name
|
||||
* @param {ExportInfoName[]} name export name
|
||||
* @returns {ExportInfo | undefined} export info for this name
|
||||
*/
|
||||
getReadOnlyExportInfoRecursive(name) {
|
||||
|
@ -280,7 +291,7 @@ class ExportsInfo {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {string[]=} name the export name
|
||||
* @param {ExportInfoName[]=} name the export name
|
||||
* @returns {ExportsInfo | undefined} the nested exports info
|
||||
*/
|
||||
getNestedExportsInfo(name) {
|
||||
|
@ -327,7 +338,8 @@ class ExportsInfo {
|
|||
if (targetKey) {
|
||||
exportInfo.setTarget(
|
||||
targetKey,
|
||||
/** @type {ModuleGraphConnection} */ (targetModule),
|
||||
/** @type {ModuleGraphConnection} */
|
||||
(targetModule),
|
||||
[exportInfo.name],
|
||||
-1
|
||||
);
|
||||
|
@ -552,6 +564,7 @@ class ExportsInfo {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
/** @type {string[]} */
|
||||
const array = [];
|
||||
if (!this._exportsAreOrdered) this._sortExports();
|
||||
for (const exportInfo of this._exports.values()) {
|
||||
|
@ -604,7 +617,7 @@ class ExportsInfo {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {string | string[]} name the name of the export
|
||||
* @param {ExportInfoName | ExportInfoName[]} name the name of the export
|
||||
* @returns {boolean | undefined | null} if the export is provided
|
||||
*/
|
||||
isExportProvided(name) {
|
||||
|
@ -665,7 +678,7 @@ class ExportsInfo {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {string | string[]} name export name
|
||||
* @param {ExportInfoName | ExportInfoName[]} name export name
|
||||
* @param {RuntimeSpec} runtime check usage for this runtime only
|
||||
* @returns {UsageStateType} usage status
|
||||
*/
|
||||
|
@ -683,7 +696,7 @@ class ExportsInfo {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {string | string[]} name the export name
|
||||
* @param {ExportInfoName | ExportInfoName[]} name the export name
|
||||
* @param {RuntimeSpec} runtime check usage for this runtime only
|
||||
* @returns {UsedName} the used name
|
||||
*/
|
||||
|
@ -698,7 +711,7 @@ class ExportsInfo {
|
|||
const x = info.getUsedName(name[0], runtime);
|
||||
if (x === false) return false;
|
||||
const arr =
|
||||
/** @type {string[]} */
|
||||
/** @type {ExportInfoName[]} */
|
||||
(x === name[0] && name.length === 1 ? name : [x]);
|
||||
if (name.length === 1) {
|
||||
return arr;
|
||||
|
@ -755,6 +768,7 @@ class ExportsInfo {
|
|||
const otherProvided = this._otherExportsInfo.provided;
|
||||
const otherCanMangleProvide = this._otherExportsInfo.canMangleProvide;
|
||||
const otherTerminalBinding = this._otherExportsInfo.terminalBinding;
|
||||
/** @type {RestoreProvidedDataExports[]} */
|
||||
const exports = [];
|
||||
for (const exportInfo of this.orderedExports) {
|
||||
if (
|
||||
|
@ -827,19 +841,24 @@ class ExportsInfo {
|
|||
/** @typedef {(module: Module) => boolean} ValidTargetModuleFilter */
|
||||
|
||||
/** @typedef {{ connection: ModuleGraphConnection, export: string[], priority: number }} TargetItem */
|
||||
|
||||
/** @typedef {Map<Dependency | undefined, TargetItem>} Target */
|
||||
|
||||
/** @typedef {string} ExportInfoName */
|
||||
/** @typedef {string | null} ExportInfoUsedName */
|
||||
/** @typedef {boolean | null} ExportInfoProvided */
|
||||
|
||||
class ExportInfo {
|
||||
/**
|
||||
* @param {string} name the original name of the export
|
||||
* @param {ExportInfoName} name the original name of the export
|
||||
* @param {ExportInfo=} initFrom init values from this ExportInfo
|
||||
*/
|
||||
constructor(name, initFrom) {
|
||||
/** @type {string} */
|
||||
/** @type {ExportInfoName} */
|
||||
this.name = name;
|
||||
/**
|
||||
* @private
|
||||
* @type {string | null}
|
||||
* @type {ExportInfoUsedName}
|
||||
*/
|
||||
this._usedName = initFrom ? initFrom._usedName : null;
|
||||
/**
|
||||
|
@ -867,7 +886,7 @@ class ExportInfo {
|
|||
* false: it is not provided
|
||||
* null: only the runtime knows if it is provided
|
||||
* undefined: it was not determined if it is provided
|
||||
* @type {boolean | null | undefined}
|
||||
* @type {ExportInfoProvided | undefined}
|
||||
*/
|
||||
this.provided = initFrom ? initFrom.provided : undefined;
|
||||
/**
|
||||
|
|
|
@ -28,6 +28,7 @@ const propertyAccess = require("./util/propertyAccess");
|
|||
const { register } = require("./util/serialization");
|
||||
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
|
||||
/** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
|
||||
/** @typedef {import("./Chunk")} Chunk */
|
||||
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
||||
|
@ -58,7 +59,6 @@ const { register } = require("./util/serialization");
|
|||
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
||||
/** @typedef {import("./util/Hash")} Hash */
|
||||
/** @typedef {typeof import("./util/Hash")} HashConstructor */
|
||||
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
||||
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
|
||||
|
@ -215,9 +215,10 @@ const getSourceForImportExternal = (
|
|||
};
|
||||
|
||||
/**
|
||||
* @param {string} key key
|
||||
* @param {TODO | undefined} value value
|
||||
* @returns {undefined | string} replaced value
|
||||
* @template {{ [key: string]: string }} T
|
||||
* @param {keyof T} key key
|
||||
* @param {T[keyof T]} value value
|
||||
* @returns {undefined | T[keyof T]} replaced value
|
||||
*/
|
||||
const importAssertionReplacer = (key, value) => {
|
||||
if (key === "_isLegacyAssert") {
|
||||
|
@ -235,7 +236,7 @@ class ModuleExternalInitFragment extends InitFragment {
|
|||
* @param {string} request import source
|
||||
* @param {string=} ident recomputed ident
|
||||
* @param {ImportDependencyMeta=} dependencyMeta the dependency meta
|
||||
* @param {string | HashConstructor=} hashFunction the hash function to use
|
||||
* @param {HashFunction=} hashFunction the hash function to use
|
||||
*/
|
||||
constructor(
|
||||
request,
|
||||
|
|
|
@ -24,7 +24,7 @@ const processAsyncTree = require("./util/processAsyncTree");
|
|||
/** @typedef {import("./logging/Logger").Logger} Logger */
|
||||
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
||||
/** @typedef {typeof import("./util/Hash")} Hash */
|
||||
/** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
|
||||
/** @typedef {import("./util/fs").IStats} IStats */
|
||||
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
||||
/** @typedef {import("./util/fs").PathLike} PathLike */
|
||||
|
@ -1058,7 +1058,7 @@ class FileSystemInfo {
|
|||
* @param {Iterable<string | RegExp>=} options.managedPaths paths that are only managed by a package manager
|
||||
* @param {Iterable<string | RegExp>=} options.immutablePaths paths that are immutable
|
||||
* @param {Logger=} options.logger logger used to log invalid snapshots
|
||||
* @param {string | Hash=} options.hashFunction the hash function to use
|
||||
* @param {HashFunction=} options.hashFunction the hash function to use
|
||||
*/
|
||||
constructor(
|
||||
fs,
|
||||
|
|
|
@ -19,8 +19,8 @@ const { dirname, mkdirp } = require("./util/fs");
|
|||
/**
|
||||
* @typedef {object} ManifestModuleData
|
||||
* @property {string | number} id
|
||||
* @property {BuildMeta} buildMeta
|
||||
* @property {boolean | string[] | undefined} exports
|
||||
* @property {BuildMeta=} buildMeta
|
||||
* @property {boolean | string[]=} exports
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -10,10 +10,11 @@ const { DEFAULTS } = require("./config/defaults");
|
|||
const createHash = require("./util/createHash");
|
||||
const memoize = require("./util/memoize");
|
||||
|
||||
/** @typedef {import("../declarations/WebpackOptions").DevtoolModuleFilenameTemplate} DevtoolModuleFilenameTemplate */
|
||||
/** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
|
||||
/** @typedef {import("./ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("./Module")} Module */
|
||||
/** @typedef {import("./RequestShortener")} RequestShortener */
|
||||
/** @typedef {typeof import("./util/Hash")} Hash */
|
||||
|
||||
/** @typedef {string | RegExp | (string | RegExp)[]} Matcher */
|
||||
/** @typedef {{ test?: Matcher, include?: Matcher, exclude?: Matcher }} MatchObject */
|
||||
|
@ -76,7 +77,7 @@ const getBefore = (strFn, token) => () => {
|
|||
/**
|
||||
* Returns a function that returns a hash of the string
|
||||
* @param {ReturnStringCallback} strFn the function to get the string
|
||||
* @param {string | Hash=} hashFunction the hash function to use
|
||||
* @param {HashFunction=} hashFunction the hash function to use
|
||||
* @returns {ReturnStringCallback} a function that returns the hash of the string
|
||||
*/
|
||||
const getHash =
|
||||
|
@ -117,10 +118,13 @@ const lazyObject = obj => {
|
|||
|
||||
const SQUARE_BRACKET_TAG_REGEXP = /\[\\*([\w-]+)\\*\]/gi;
|
||||
|
||||
/** @typedef {((context: TODO) => string)} ModuleFilenameTemplateFunction */
|
||||
/** @typedef {string | ModuleFilenameTemplateFunction} ModuleFilenameTemplate */
|
||||
|
||||
/**
|
||||
* @param {Module | string} module the module
|
||||
* @param {{ namespace?: string, moduleFilenameTemplate?: string | TODO }} options options
|
||||
* @param {{ requestShortener: RequestShortener, chunkGraph: ChunkGraph, hashFunction?: string | Hash }} contextInfo context info
|
||||
* @param {{ namespace?: string, moduleFilenameTemplate?: ModuleFilenameTemplate }} options options
|
||||
* @param {{ requestShortener: RequestShortener, chunkGraph: ChunkGraph, hashFunction?: HashFunction }} contextInfo context info
|
||||
* @returns {string} the filename
|
||||
*/
|
||||
ModuleFilenameHelpers.createFilename = (
|
||||
|
|
|
@ -92,7 +92,7 @@ const memoize = require("./util/memoize");
|
|||
/** @typedef {import("./util/Hash")} Hash */
|
||||
/** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */
|
||||
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
/** @typedef {import("./util/createHash").Algorithm} Algorithm */
|
||||
/** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
|
||||
/** @typedef {import("./util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
|
||||
/**
|
||||
* @template T
|
||||
|
@ -649,13 +649,13 @@ class NormalModule extends Module {
|
|||
? getContextifyInContext()(request)
|
||||
: getContextify()(context, request),
|
||||
/**
|
||||
* @param {(string | typeof import("./util/Hash"))=} type type
|
||||
* @param {HashFunction=} type type
|
||||
* @returns {Hash} hash
|
||||
*/
|
||||
createHash: type =>
|
||||
createHash(
|
||||
type ||
|
||||
/** @type {Algorithm} */
|
||||
/** @type {HashFunction} */
|
||||
(compilation.outputOptions.hashFunction)
|
||||
)
|
||||
};
|
||||
|
@ -803,7 +803,7 @@ class NormalModule extends Module {
|
|||
webpack: true,
|
||||
sourceMap: Boolean(this.useSourceMap),
|
||||
mode: options.mode || "production",
|
||||
hashFunction: /** @type {TODO} */ (options.output.hashFunction),
|
||||
hashFunction: /** @type {string} */ (options.output.hashFunction),
|
||||
hashDigest: /** @type {string} */ (options.output.hashDigest),
|
||||
hashDigestLength: /** @type {number} */ (options.output.hashDigestLength),
|
||||
hashSalt: /** @type {string} */ (options.output.hashSalt),
|
||||
|
@ -1132,7 +1132,7 @@ class NormalModule extends Module {
|
|||
*/
|
||||
_initBuildHash(compilation) {
|
||||
const hash = createHash(
|
||||
/** @type {Algorithm} */
|
||||
/** @type {HashFunction} */
|
||||
(compilation.outputOptions.hashFunction)
|
||||
);
|
||||
if (this._source) {
|
||||
|
|
|
@ -19,6 +19,7 @@ const { makePathsAbsolute } = require("./util/identifier");
|
|||
|
||||
/** @typedef {import("webpack-sources").MapOptions} MapOptions */
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */
|
||||
/** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */
|
||||
/** @typedef {import("./Cache").Etag} Etag */
|
||||
/** @typedef {import("./CacheFacade").ItemCacheFacade} ItemCacheFacade */
|
||||
|
@ -29,8 +30,6 @@ const { makePathsAbsolute } = require("./util/identifier");
|
|||
/** @typedef {import("./Module")} Module */
|
||||
/** @typedef {import("./NormalModule").SourceMap} SourceMap */
|
||||
/** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
|
||||
/** @typedef {import("./util/Hash")} Hash */
|
||||
/** @typedef {import("./util/createHash").Algorithm} Algorithm */
|
||||
/** @typedef {import("./util/fs").OutputFileSystem} OutputFileSystem */
|
||||
|
||||
const validate = createSchemaValidation(
|
||||
|
@ -489,7 +488,7 @@ class SourceMapDevToolPlugin {
|
|||
(
|
||||
usesContentHash &&
|
||||
createHash(
|
||||
/** @type {Algorithm} */
|
||||
/** @type {HashFunction} */
|
||||
(compilation.outputOptions.hashFunction)
|
||||
)
|
||||
.update(sourceMapString)
|
||||
|
|
|
@ -33,6 +33,7 @@ const nonNumericOnlyHash = require("../util/nonNumericOnlyHash");
|
|||
/** @typedef {import("../../declarations/WebpackOptions").AssetModuleFilename} AssetModuleFilename */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").AssetModuleOutputPath} AssetModuleOutputPath */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").AssetResourceGeneratorOptions} AssetResourceGeneratorOptions */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").RawPublicPath} RawPublicPath */
|
||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("../Compilation")} Compilation */
|
||||
|
@ -51,7 +52,6 @@ const nonNumericOnlyHash = require("../util/nonNumericOnlyHash");
|
|||
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
||||
/** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */
|
||||
/** @typedef {import("../util/Hash")} Hash */
|
||||
/** @typedef {import("../util/createHash").Algorithm} Algorithm */
|
||||
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
|
||||
/**
|
||||
|
@ -232,7 +232,7 @@ class AssetGenerator extends Generator {
|
|||
*/
|
||||
static getFullContentHash(module, runtimeTemplate) {
|
||||
const hash = createHash(
|
||||
/** @type {Algorithm} */
|
||||
/** @type {HashFunction} */
|
||||
(runtimeTemplate.outputOptions.hashFunction)
|
||||
);
|
||||
|
||||
|
|
|
@ -1551,7 +1551,7 @@ const applyOptimizationDefaults = (
|
|||
passes: 2
|
||||
}
|
||||
}
|
||||
}).apply(/** @type {TODO} */ (compiler));
|
||||
}).apply(/** @type {EXPECTED_ANY} */ (compiler));
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
@ -1726,8 +1726,8 @@ const getResolveLoaderDefaults = ({ cache }) => {
|
|||
const applyInfrastructureLoggingDefaults = infrastructureLogging => {
|
||||
F(infrastructureLogging, "stream", () => process.stderr);
|
||||
const tty =
|
||||
/** @type {EXPECTED_ANY} */ (infrastructureLogging.stream).isTTY &&
|
||||
process.env.TERM !== "dumb";
|
||||
/** @type {NonNullable<InfrastructureLogging["stream"]>} */
|
||||
(infrastructureLogging.stream).isTTY && process.env.TERM !== "dumb";
|
||||
D(infrastructureLogging, "level", "info");
|
||||
D(infrastructureLogging, "debug", false);
|
||||
D(infrastructureLogging, "colors", tty);
|
||||
|
|
|
@ -48,6 +48,7 @@ const CssGenerator = require("./CssGenerator");
|
|||
const CssParser = require("./CssParser");
|
||||
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} OutputOptions */
|
||||
/** @typedef {import("../Chunk")} Chunk */
|
||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||
|
@ -60,7 +61,6 @@ const CssParser = require("./CssParser");
|
|||
/** @typedef {import("../Template").RuntimeTemplate} RuntimeTemplate */
|
||||
/** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */
|
||||
/** @typedef {import("../util/Hash")} Hash */
|
||||
/** @typedef {import("../util/createHash").Algorithm} Algorithm */
|
||||
/** @typedef {import("../util/memoize")} Memoize */
|
||||
|
||||
/**
|
||||
|
@ -444,7 +444,7 @@ class CssModulesPlugin {
|
|||
hashFunction
|
||||
}
|
||||
} = compilation;
|
||||
const hash = createHash(/** @type {Algorithm} */ (hashFunction));
|
||||
const hash = createHash(/** @type {HashFunction} */ (hashFunction));
|
||||
if (hashSalt) hash.update(hashSalt);
|
||||
hooks.chunkHash.call(chunk, hash, {
|
||||
chunkGraph,
|
||||
|
|
|
@ -14,6 +14,7 @@ const {
|
|||
const createSchemaValidation = require("../util/create-schema-validation");
|
||||
const { dirname, mkdirpSync } = require("../util/fs");
|
||||
|
||||
/** @typedef {import("inspector").Session} Session */
|
||||
/** @typedef {import("tapable").FullTap} FullTap */
|
||||
/** @typedef {import("../../declarations/plugins/debug/ProfilingPlugin").ProfilingPluginOptions} ProfilingPluginOptions */
|
||||
/** @typedef {import("../Compilation")} Compilation */
|
||||
|
@ -25,8 +26,6 @@ const { dirname, mkdirpSync } = require("../util/fs");
|
|||
/** @typedef {import("../ResolverFactory")} ResolverFactory */
|
||||
/** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */
|
||||
|
||||
/** @typedef {TODO} Inspector */
|
||||
|
||||
const validate = createSchemaValidation(
|
||||
require("../../schemas/plugins/debug/ProfilingPlugin.check.js"),
|
||||
() => require("../../schemas/plugins/debug/ProfilingPlugin.json"),
|
||||
|
@ -36,6 +35,8 @@ const validate = createSchemaValidation(
|
|||
}
|
||||
);
|
||||
|
||||
/** @typedef {{ Session: typeof import("inspector").Session }} Inspector */
|
||||
|
||||
/** @type {Inspector | undefined} */
|
||||
let inspector;
|
||||
|
||||
|
@ -52,6 +53,7 @@ class Profiler {
|
|||
* @param {Inspector} inspector inspector
|
||||
*/
|
||||
constructor(inspector) {
|
||||
/** @type {undefined | Session} */
|
||||
this.session = undefined;
|
||||
this.inspector = inspector;
|
||||
this._startTime = 0;
|
||||
|
@ -67,8 +69,9 @@ class Profiler {
|
|||
}
|
||||
|
||||
try {
|
||||
this.session = new inspector.Session();
|
||||
this.session.connect();
|
||||
this.session = new /** @type {Inspector} */ (inspector).Session();
|
||||
/** @type {Session} */
|
||||
(this.session).connect();
|
||||
} catch (_) {
|
||||
this.session = undefined;
|
||||
return Promise.resolve();
|
||||
|
@ -88,27 +91,20 @@ class Profiler {
|
|||
|
||||
/**
|
||||
* @param {string} method method name
|
||||
* @param {Record<string, EXPECTED_ANY>=} params params
|
||||
* @returns {Promise<TODO>} Promise for the result
|
||||
* @param {EXPECTED_OBJECT=} params params
|
||||
* @returns {Promise<EXPECTED_ANY | void>} Promise for the result
|
||||
*/
|
||||
sendCommand(method, params) {
|
||||
if (this.hasSession()) {
|
||||
return new Promise((res, rej) => {
|
||||
this.session.post(
|
||||
method,
|
||||
params,
|
||||
/**
|
||||
* @param {Error | null} err error
|
||||
* @param {object} params params
|
||||
*/
|
||||
(err, params) => {
|
||||
if (err !== null) {
|
||||
rej(err);
|
||||
} else {
|
||||
res(params);
|
||||
}
|
||||
/** @type {Session} */
|
||||
(this.session).post(method, params, (err, params) => {
|
||||
if (err !== null) {
|
||||
rej(err);
|
||||
} else {
|
||||
res(params);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
return Promise.resolve();
|
||||
|
@ -116,7 +112,8 @@ class Profiler {
|
|||
|
||||
destroy() {
|
||||
if (this.hasSession()) {
|
||||
this.session.disconnect();
|
||||
/** @type {Session} */
|
||||
(this.session).disconnect();
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
|
|
|
@ -204,7 +204,7 @@ class CommonJsImportsParserPlugin {
|
|||
{
|
||||
request: /** @type {string} */ (options.unknownContextRequest),
|
||||
recursive: /** @type {boolean} */ (options.unknownContextRecursive),
|
||||
regExp: /** @type {TODO} */ (options.unknownContextRegExp),
|
||||
regExp: /** @type {RegExp} */ (options.unknownContextRegExp),
|
||||
mode: "sync"
|
||||
},
|
||||
/** @type {Range} */ (expr.range),
|
||||
|
|
|
@ -22,7 +22,7 @@ const ModuleDependency = require("./ModuleDependency");
|
|||
class ContextElementDependency extends ModuleDependency {
|
||||
/**
|
||||
* @param {string} request request
|
||||
* @param {string|undefined} userRequest user request
|
||||
* @param {string | undefined} userRequest user request
|
||||
* @param {string | undefined} typePrefix type prefix
|
||||
* @param {string} category category
|
||||
* @param {(string[][] | null)=} referencedExports referenced exports
|
||||
|
|
|
@ -15,6 +15,7 @@ const NullDependency = require("./NullDependency");
|
|||
/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").CssGeneratorExportsConvention} CssGeneratorExportsConvention */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").CssGeneratorLocalIdentName} CssGeneratorLocalIdentName */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */
|
||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("../CssModule")} CssModule */
|
||||
/** @typedef {import("../Dependency")} Dependency */
|
||||
|
@ -29,7 +30,6 @@ const NullDependency = require("./NullDependency");
|
|||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
||||
/** @typedef {import("../util/Hash")} Hash */
|
||||
/** @typedef {import("../util/createHash").Algorithm} Algorithm */
|
||||
|
||||
const getCssParser = memoize(() => require("../css/CssParser"));
|
||||
|
||||
|
@ -53,7 +53,7 @@ const getLocalIdent = (local, module, chunkGraph, runtimeTemplate) => {
|
|||
);
|
||||
const { hashFunction, hashDigest, hashDigestLength, hashSalt, uniqueName } =
|
||||
runtimeTemplate.outputOptions;
|
||||
const hash = createHash(/** @type {Algorithm} */ (hashFunction));
|
||||
const hash = createHash(/** @type {HashFunction} */ (hashFunction));
|
||||
|
||||
if (hashSalt) {
|
||||
hash.update(hashSalt);
|
||||
|
|
|
@ -80,7 +80,8 @@ class RequireContextPlugin {
|
|||
cachedSetProperty(
|
||||
options.resolveOptions || EMPTY_RESOLVE_OPTIONS,
|
||||
"dependencyType",
|
||||
/** @type {string} */ (options.category)
|
||||
/** @type {string} */
|
||||
(options.category)
|
||||
)
|
||||
).options;
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ const WorkerDependency = require("./WorkerDependency");
|
|||
/** @typedef {import("estree").Property} Property */
|
||||
/** @typedef {import("estree").SpreadElement} SpreadElement */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").ChunkLoading} ChunkLoading */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").OutputModule} OutputModule */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").WasmLoading} WasmLoading */
|
||||
|
@ -47,7 +48,6 @@ const WorkerDependency = require("./WorkerDependency");
|
|||
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
||||
/** @typedef {import("../javascript/JavascriptParser")} Parser */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {import("../util/createHash").Algorithm} Algorithm */
|
||||
/** @typedef {import("./HarmonyImportDependencyParserPlugin").HarmonySettings} HarmonySettings */
|
||||
|
||||
/**
|
||||
|
@ -376,7 +376,7 @@ class WorkerPlugin {
|
|||
parser.state.module.identifier()
|
||||
)}|${i}`;
|
||||
const hash = createHash(
|
||||
/** @type {Algorithm} */
|
||||
/** @type {HashFunction} */
|
||||
(compilation.outputOptions.hashFunction)
|
||||
);
|
||||
hash.update(name);
|
||||
|
|
|
@ -117,7 +117,6 @@ module.exports = function () {
|
|||
for (var moduleId in currentUpdate) {
|
||||
if ($hasOwnProperty$(currentUpdate, moduleId)) {
|
||||
var newModuleFactory = currentUpdate[moduleId];
|
||||
/** @type {TODO} */
|
||||
var result = newModuleFactory
|
||||
? getAffectedModuleEffects(moduleId)
|
||||
: {
|
||||
|
|
|
@ -52,6 +52,7 @@ const JavascriptParser = require("./JavascriptParser");
|
|||
/** @typedef {import("eslint-scope").Variable} Variable */
|
||||
/** @typedef {import("estree").Program} Program */
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").Output} OutputOptions */
|
||||
/** @typedef {import("../Chunk")} Chunk */
|
||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||
|
@ -69,7 +70,6 @@ const JavascriptParser = require("./JavascriptParser");
|
|||
/** @typedef {import("../WebpackError")} WebpackError */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {import("../util/Hash")} Hash */
|
||||
/** @typedef {import("../util/createHash").Algorithm} Algorithm */
|
||||
|
||||
/**
|
||||
* @param {Chunk} chunk a chunk
|
||||
|
@ -429,7 +429,7 @@ class JavascriptModulesPlugin {
|
|||
hashFunction
|
||||
}
|
||||
} = compilation;
|
||||
const hash = createHash(/** @type {Algorithm} */ (hashFunction));
|
||||
const hash = createHash(/** @type {HashFunction} */ (hashFunction));
|
||||
if (hashSalt) hash.update(hashSalt);
|
||||
if (chunk.hasRuntime()) {
|
||||
this.updateHashWithBootstrap(
|
||||
|
|
|
@ -93,7 +93,7 @@ class AbstractLibraryPlugin {
|
|||
|
||||
/**
|
||||
* @param {Chunk} chunk chunk
|
||||
* @returns {TODO} options for the chunk
|
||||
* @returns {T | false} options for the chunk
|
||||
*/
|
||||
const getOptionsForChunk = chunk => {
|
||||
if (compilation.chunkGraph.getNumberOfEntryModules(chunk) === 0)
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
const util = require("util");
|
||||
const truncateArgs = require("../logging/truncateArgs");
|
||||
|
||||
/** @typedef {import("../../declarations/WebpackOptions").InfrastructureLogging} InfrastructureLogging */
|
||||
/** @typedef {import("../logging/createConsoleLogger").LoggerConsole} LoggerConsole */
|
||||
|
||||
/* eslint-disable no-console */
|
||||
|
@ -16,7 +17,7 @@ const truncateArgs = require("../logging/truncateArgs");
|
|||
* @param {object} options options
|
||||
* @param {boolean=} options.colors colors
|
||||
* @param {boolean=} options.appendOnly append only
|
||||
* @param {NodeJS.WritableStream} options.stream stream
|
||||
* @param {NonNullable<InfrastructureLogging["stream"]>} options.stream stream
|
||||
* @returns {LoggerConsole} logger function
|
||||
*/
|
||||
module.exports = ({ colors, appendOnly, stream }) => {
|
||||
|
@ -57,7 +58,7 @@ module.exports = ({ colors, appendOnly, stream }) => {
|
|||
|
||||
const writeStatusMessage = () => {
|
||||
if (!currentStatusMessage) return;
|
||||
const l = /** @type {TODO} */ (stream).columns || 40;
|
||||
const l = stream.columns || 40;
|
||||
const args = truncateArgs(currentStatusMessage, l - 1);
|
||||
const str = args.join(" ");
|
||||
const coloredStr = `\u001B[1m${str}\u001B[39m\u001B[22m`;
|
||||
|
|
|
@ -195,7 +195,7 @@ class AggressiveSplittingPlugin {
|
|||
moveModuleBetween(chunkGraph, chunk, newChunk)(module);
|
||||
}
|
||||
chunk.split(newChunk);
|
||||
chunk.name = /** @type {TODO} */ (null);
|
||||
chunk.name = null;
|
||||
}
|
||||
fromAggressiveSplittingSet.add(newChunk);
|
||||
chunkSplitDataMap.set(newChunk, splitData);
|
||||
|
|
|
@ -1739,7 +1739,9 @@ ${defineGetters}`
|
|||
sourceType: "module"
|
||||
});
|
||||
} catch (_err) {
|
||||
const err = /** @type {TODO} */ (_err);
|
||||
const err =
|
||||
/** @type {Error & { loc?: { line: number, column: number } }} */
|
||||
(_err);
|
||||
if (
|
||||
err.loc &&
|
||||
typeof err.loc === "object" &&
|
||||
|
|
|
@ -398,9 +398,9 @@ class ModuleConcatenationPlugin {
|
|||
newModule.build(
|
||||
compiler.options,
|
||||
compilation,
|
||||
/** @type {TODO} */
|
||||
/** @type {EXPECTED_ANY} */
|
||||
(null),
|
||||
/** @type {TODO} */
|
||||
/** @type {EXPECTED_ANY} */
|
||||
(null),
|
||||
err => {
|
||||
if (err) {
|
||||
|
|
|
@ -145,7 +145,8 @@ class SideEffectsFlagPlugin {
|
|||
if (
|
||||
!parser.isPure(
|
||||
statement.expression,
|
||||
/** @type {Range} */ (statement.range)[0]
|
||||
/** @type {Range} */
|
||||
(statement.range)[0]
|
||||
)
|
||||
) {
|
||||
sideEffectsStatement = statement;
|
||||
|
@ -157,7 +158,8 @@ class SideEffectsFlagPlugin {
|
|||
if (
|
||||
!parser.isPure(
|
||||
statement.test,
|
||||
/** @type {Range} */ (statement.range)[0]
|
||||
/** @type {Range} */
|
||||
(statement.range)[0]
|
||||
)
|
||||
) {
|
||||
sideEffectsStatement = statement;
|
||||
|
@ -193,7 +195,8 @@ class SideEffectsFlagPlugin {
|
|||
if (
|
||||
!parser.isPure(
|
||||
statement.discriminant,
|
||||
/** @type {Range} */ (statement.range)[0]
|
||||
/** @type {Range} */
|
||||
(statement.range)[0]
|
||||
)
|
||||
) {
|
||||
sideEffectsStatement = statement;
|
||||
|
@ -216,9 +219,9 @@ class SideEffectsFlagPlugin {
|
|||
case "ExportDefaultDeclaration":
|
||||
if (
|
||||
!parser.isPure(
|
||||
/** @type {TODO} */
|
||||
(statement.declaration),
|
||||
/** @type {Range} */ (statement.range)[0]
|
||||
statement.declaration,
|
||||
/** @type {Range} */
|
||||
(statement.range)[0]
|
||||
)
|
||||
) {
|
||||
sideEffectsStatement = statement;
|
||||
|
|
|
@ -21,6 +21,7 @@ const { makePathsRelative } = require("../util/identifier");
|
|||
const memoize = require("../util/memoize");
|
||||
const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
||||
|
||||
/** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksCacheGroup} OptimizationSplitChunksCacheGroup */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksGetCacheGroups} OptimizationSplitChunksGetCacheGroups */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksOptions} OptimizationSplitChunksOptions */
|
||||
|
@ -33,7 +34,6 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
|||
/** @typedef {import("../Module")} Module */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */
|
||||
/** @typedef {import("../util/createHash").Algorithm} Algorithm */
|
||||
/** @typedef {import("../util/deterministicGrouping").GroupedItems<Module>} DeterministicGroupingGroupedItemsForModule */
|
||||
/** @typedef {import("../util/deterministicGrouping").Options<Module>} DeterministicGroupingOptionsForModule */
|
||||
|
||||
|
@ -184,7 +184,7 @@ const hashFilename = (name, outputOptions) => {
|
|||
const digest =
|
||||
/** @type {string} */
|
||||
(
|
||||
createHash(/** @type {Algorithm} */ (outputOptions.hashFunction))
|
||||
createHash(/** @type {HashFunction} */ (outputOptions.hashFunction))
|
||||
.update(name)
|
||||
.digest(outputOptions.hashDigest)
|
||||
);
|
||||
|
|
|
@ -16,6 +16,7 @@ const { mkdirp, dirname, join } = require("../util/fs");
|
|||
const memoize = require("../util/memoize");
|
||||
|
||||
/** @typedef {import("http").IncomingMessage} IncomingMessage */
|
||||
/** @typedef {import("http").OutgoingHttpHeaders} OutgoingHttpHeaders */
|
||||
/** @typedef {import("http").RequestOptions} RequestOptions */
|
||||
/** @typedef {import("net").Socket} Socket */
|
||||
/** @typedef {import("stream").Readable} Readable */
|
||||
|
@ -147,7 +148,7 @@ const parseKeyValuePairs = str => {
|
|||
/**
|
||||
* @param {string | undefined} cacheControl Cache-Control header
|
||||
* @param {number} requestTime timestamp of request
|
||||
* @returns {{storeCache: boolean, storeLock: boolean, validUntil: number}} Logic for storing in cache and lockfile cache
|
||||
* @returns {{ storeCache: boolean, storeLock: boolean, validUntil: number }} Logic for storing in cache and lockfile cache
|
||||
*/
|
||||
const parseCacheControl = (cacheControl, requestTime) => {
|
||||
// When false resource is not stored in cache
|
||||
|
@ -190,7 +191,7 @@ const areLockfileEntriesEqual = (a, b) =>
|
|||
|
||||
/**
|
||||
* @param {LockfileEntry} entry lockfile entry
|
||||
* @returns {`resolved: ${string}, integrity: ${string}, contentType: ${*}`} stringified entry
|
||||
* @returns {`resolved: ${string}, integrity: ${string}, contentType: ${string}`} stringified entry
|
||||
*/
|
||||
const entryToString = entry =>
|
||||
`resolved: ${entry.resolved}, integrity: ${entry.integrity}, contentType: ${entry.contentType}`;
|
||||
|
@ -636,11 +637,14 @@ class HttpUriPlugin {
|
|||
const resolveContent = (url, integrity, callback) => {
|
||||
/**
|
||||
* @param {Error | null} err error
|
||||
* @param {TODO} result result result
|
||||
* @param {FetchResult=} _result fetch result
|
||||
* @returns {void}
|
||||
*/
|
||||
const handleResult = (err, result) => {
|
||||
const handleResult = (err, _result) => {
|
||||
if (err) return callback(err);
|
||||
|
||||
const result = /** @type {FetchResult} */ (_result);
|
||||
|
||||
if ("location" in result) {
|
||||
return resolveContent(
|
||||
result.location,
|
||||
|
@ -657,6 +661,7 @@ class HttpUriPlugin {
|
|||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
!result.fresh &&
|
||||
integrity &&
|
||||
|
@ -665,12 +670,14 @@ class HttpUriPlugin {
|
|||
) {
|
||||
return fetchContent.force(url, handleResult);
|
||||
}
|
||||
|
||||
return callback(null, {
|
||||
entry: result.entry,
|
||||
content: result.content,
|
||||
storeLock: result.storeLock
|
||||
});
|
||||
};
|
||||
|
||||
fetchContent(url, handleResult);
|
||||
};
|
||||
|
||||
|
@ -682,164 +689,162 @@ class HttpUriPlugin {
|
|||
*/
|
||||
const fetchContentRaw = (url, cachedResult, callback) => {
|
||||
const requestTime = Date.now();
|
||||
fetch(
|
||||
new URL(url),
|
||||
{
|
||||
headers: {
|
||||
"accept-encoding": "gzip, deflate, br",
|
||||
"user-agent": "webpack",
|
||||
"if-none-match": /** @type {TODO} */ (
|
||||
cachedResult ? cachedResult.etag || null : null
|
||||
)
|
||||
}
|
||||
},
|
||||
res => {
|
||||
const etag = res.headers.etag;
|
||||
const location = res.headers.location;
|
||||
const cacheControl = res.headers["cache-control"];
|
||||
const { storeLock, storeCache, validUntil } = parseCacheControl(
|
||||
cacheControl,
|
||||
requestTime
|
||||
);
|
||||
/**
|
||||
* @param {Partial<Pick<FetchResultMeta, "fresh">> & (Pick<RedirectFetchResult, "location"> | Pick<ContentFetchResult, "content" | "entry">)} partialResult result
|
||||
* @returns {void}
|
||||
*/
|
||||
const finishWith = partialResult => {
|
||||
if ("location" in partialResult) {
|
||||
logger.debug(
|
||||
`GET ${url} [${res.statusCode}] -> ${partialResult.location}`
|
||||
);
|
||||
} else {
|
||||
logger.debug(
|
||||
`GET ${url} [${res.statusCode}] ${Math.ceil(
|
||||
partialResult.content.length / 1024
|
||||
)} kB${!storeLock ? " no-cache" : ""}`
|
||||
);
|
||||
}
|
||||
const result = {
|
||||
...partialResult,
|
||||
fresh: true,
|
||||
storeLock,
|
||||
storeCache,
|
||||
validUntil,
|
||||
etag
|
||||
};
|
||||
if (!storeCache) {
|
||||
logger.log(
|
||||
`${url} can't be stored in cache, due to Cache-Control header: ${cacheControl}`
|
||||
);
|
||||
return callback(null, result);
|
||||
}
|
||||
cache.store(
|
||||
url,
|
||||
null,
|
||||
{
|
||||
...result,
|
||||
fresh: false
|
||||
},
|
||||
err => {
|
||||
if (err) {
|
||||
logger.warn(
|
||||
`${url} can't be stored in cache: ${err.message}`
|
||||
);
|
||||
logger.debug(err.stack);
|
||||
}
|
||||
callback(null, result);
|
||||
}
|
||||
/** @type {OutgoingHttpHeaders} */
|
||||
const headers = {
|
||||
"accept-encoding": "gzip, deflate, br",
|
||||
"user-agent": "webpack"
|
||||
};
|
||||
|
||||
if (cachedResult && cachedResult.etag) {
|
||||
headers["if-none-match"] = cachedResult.etag;
|
||||
}
|
||||
|
||||
fetch(new URL(url), { headers }, res => {
|
||||
const etag = res.headers.etag;
|
||||
const location = res.headers.location;
|
||||
const cacheControl = res.headers["cache-control"];
|
||||
const { storeLock, storeCache, validUntil } = parseCacheControl(
|
||||
cacheControl,
|
||||
requestTime
|
||||
);
|
||||
/**
|
||||
* @param {Partial<Pick<FetchResultMeta, "fresh">> & (Pick<RedirectFetchResult, "location"> | Pick<ContentFetchResult, "content" | "entry">)} partialResult result
|
||||
* @returns {void}
|
||||
*/
|
||||
const finishWith = partialResult => {
|
||||
if ("location" in partialResult) {
|
||||
logger.debug(
|
||||
`GET ${url} [${res.statusCode}] -> ${partialResult.location}`
|
||||
);
|
||||
} else {
|
||||
logger.debug(
|
||||
`GET ${url} [${res.statusCode}] ${Math.ceil(
|
||||
partialResult.content.length / 1024
|
||||
)} kB${!storeLock ? " no-cache" : ""}`
|
||||
);
|
||||
}
|
||||
const result = {
|
||||
...partialResult,
|
||||
fresh: true,
|
||||
storeLock,
|
||||
storeCache,
|
||||
validUntil,
|
||||
etag
|
||||
};
|
||||
if (res.statusCode === 304) {
|
||||
const result = /** @type {FetchResult} */ (cachedResult);
|
||||
if (
|
||||
result.validUntil < validUntil ||
|
||||
result.storeLock !== storeLock ||
|
||||
result.storeCache !== storeCache ||
|
||||
result.etag !== etag
|
||||
) {
|
||||
return finishWith(result);
|
||||
}
|
||||
logger.debug(`GET ${url} [${res.statusCode}] (unchanged)`);
|
||||
return callback(null, { ...result, fresh: true });
|
||||
if (!storeCache) {
|
||||
logger.log(
|
||||
`${url} can't be stored in cache, due to Cache-Control header: ${cacheControl}`
|
||||
);
|
||||
return callback(null, result);
|
||||
}
|
||||
if (
|
||||
location &&
|
||||
res.statusCode &&
|
||||
res.statusCode >= 301 &&
|
||||
res.statusCode <= 308
|
||||
) {
|
||||
const result = {
|
||||
location: new URL(location, url).href
|
||||
};
|
||||
if (
|
||||
!cachedResult ||
|
||||
!("location" in cachedResult) ||
|
||||
cachedResult.location !== result.location ||
|
||||
cachedResult.validUntil < validUntil ||
|
||||
cachedResult.storeLock !== storeLock ||
|
||||
cachedResult.storeCache !== storeCache ||
|
||||
cachedResult.etag !== etag
|
||||
) {
|
||||
return finishWith(result);
|
||||
}
|
||||
logger.debug(`GET ${url} [${res.statusCode}] (unchanged)`);
|
||||
return callback(null, {
|
||||
cache.store(
|
||||
url,
|
||||
null,
|
||||
{
|
||||
...result,
|
||||
fresh: true,
|
||||
storeLock,
|
||||
storeCache,
|
||||
validUntil,
|
||||
etag
|
||||
});
|
||||
}
|
||||
const contentType = res.headers["content-type"] || "";
|
||||
/** @type {Buffer[]} */
|
||||
const bufferArr = [];
|
||||
|
||||
const contentEncoding = res.headers["content-encoding"];
|
||||
/** @type {Readable} */
|
||||
let stream = res;
|
||||
if (contentEncoding === "gzip") {
|
||||
stream = stream.pipe(createGunzip());
|
||||
} else if (contentEncoding === "br") {
|
||||
stream = stream.pipe(createBrotliDecompress());
|
||||
} else if (contentEncoding === "deflate") {
|
||||
stream = stream.pipe(createInflate());
|
||||
}
|
||||
|
||||
stream.on("data", chunk => {
|
||||
bufferArr.push(chunk);
|
||||
});
|
||||
|
||||
stream.on("end", () => {
|
||||
if (!res.complete) {
|
||||
logger.log(`GET ${url} [${res.statusCode}] (terminated)`);
|
||||
return callback(new Error(`${url} request was terminated`));
|
||||
fresh: false
|
||||
},
|
||||
err => {
|
||||
if (err) {
|
||||
logger.warn(
|
||||
`${url} can't be stored in cache: ${err.message}`
|
||||
);
|
||||
logger.debug(err.stack);
|
||||
}
|
||||
callback(null, result);
|
||||
}
|
||||
|
||||
const content = Buffer.concat(bufferArr);
|
||||
|
||||
if (res.statusCode !== 200) {
|
||||
logger.log(`GET ${url} [${res.statusCode}]`);
|
||||
return callback(
|
||||
new Error(
|
||||
`${url} request status code = ${
|
||||
res.statusCode
|
||||
}\n${content.toString("utf-8")}`
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const integrity = computeIntegrity(content);
|
||||
const entry = { resolved: url, integrity, contentType };
|
||||
|
||||
finishWith({
|
||||
entry,
|
||||
content
|
||||
});
|
||||
);
|
||||
};
|
||||
if (res.statusCode === 304) {
|
||||
const result = /** @type {FetchResult} */ (cachedResult);
|
||||
if (
|
||||
result.validUntil < validUntil ||
|
||||
result.storeLock !== storeLock ||
|
||||
result.storeCache !== storeCache ||
|
||||
result.etag !== etag
|
||||
) {
|
||||
return finishWith(result);
|
||||
}
|
||||
logger.debug(`GET ${url} [${res.statusCode}] (unchanged)`);
|
||||
return callback(null, { ...result, fresh: true });
|
||||
}
|
||||
if (
|
||||
location &&
|
||||
res.statusCode &&
|
||||
res.statusCode >= 301 &&
|
||||
res.statusCode <= 308
|
||||
) {
|
||||
const result = {
|
||||
location: new URL(location, url).href
|
||||
};
|
||||
if (
|
||||
!cachedResult ||
|
||||
!("location" in cachedResult) ||
|
||||
cachedResult.location !== result.location ||
|
||||
cachedResult.validUntil < validUntil ||
|
||||
cachedResult.storeLock !== storeLock ||
|
||||
cachedResult.storeCache !== storeCache ||
|
||||
cachedResult.etag !== etag
|
||||
) {
|
||||
return finishWith(result);
|
||||
}
|
||||
logger.debug(`GET ${url} [${res.statusCode}] (unchanged)`);
|
||||
return callback(null, {
|
||||
...result,
|
||||
fresh: true,
|
||||
storeLock,
|
||||
storeCache,
|
||||
validUntil,
|
||||
etag
|
||||
});
|
||||
}
|
||||
).on("error", err => {
|
||||
const contentType = res.headers["content-type"] || "";
|
||||
/** @type {Buffer[]} */
|
||||
const bufferArr = [];
|
||||
|
||||
const contentEncoding = res.headers["content-encoding"];
|
||||
/** @type {Readable} */
|
||||
let stream = res;
|
||||
if (contentEncoding === "gzip") {
|
||||
stream = stream.pipe(createGunzip());
|
||||
} else if (contentEncoding === "br") {
|
||||
stream = stream.pipe(createBrotliDecompress());
|
||||
} else if (contentEncoding === "deflate") {
|
||||
stream = stream.pipe(createInflate());
|
||||
}
|
||||
|
||||
stream.on("data", chunk => {
|
||||
bufferArr.push(chunk);
|
||||
});
|
||||
|
||||
stream.on("end", () => {
|
||||
if (!res.complete) {
|
||||
logger.log(`GET ${url} [${res.statusCode}] (terminated)`);
|
||||
return callback(new Error(`${url} request was terminated`));
|
||||
}
|
||||
|
||||
const content = Buffer.concat(bufferArr);
|
||||
|
||||
if (res.statusCode !== 200) {
|
||||
logger.log(`GET ${url} [${res.statusCode}]`);
|
||||
return callback(
|
||||
new Error(
|
||||
`${url} request status code = ${
|
||||
res.statusCode
|
||||
}\n${content.toString("utf-8")}`
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
const integrity = computeIntegrity(content);
|
||||
const entry = { resolved: url, integrity, contentType };
|
||||
|
||||
finishWith({
|
||||
entry,
|
||||
content
|
||||
});
|
||||
});
|
||||
}).on("error", err => {
|
||||
logger.log(`GET ${url} (error)`);
|
||||
err.message += `\nwhile fetching ${url}`;
|
||||
callback(err);
|
||||
|
@ -849,7 +854,7 @@ class HttpUriPlugin {
|
|||
const fetchContent = cachedWithKey(
|
||||
/**
|
||||
* @param {string} url URL
|
||||
* @param {(err: Error | null, result?: { validUntil: number, etag?: string, entry: LockfileEntry, content: Buffer, fresh: boolean } | { validUntil: number, etag?: string, location: string, fresh: boolean }) => void} callback callback
|
||||
* @param {(err: Error | null, result?: FetchResult) => void} callback callback
|
||||
* @returns {void}
|
||||
*/
|
||||
(url, callback) => {
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
const Hash = require("./Hash");
|
||||
|
||||
/** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */
|
||||
|
||||
const BULK_SIZE = 2000;
|
||||
|
||||
// We are using an object instead of a Map as this will stay static during the runtime
|
||||
|
@ -141,11 +143,9 @@ let createMd4;
|
|||
/** @type {typeof import("./hash/BatchedHash") | undefined} */
|
||||
let BatchedHash;
|
||||
|
||||
/** @typedef {string | typeof Hash} Algorithm */
|
||||
|
||||
/**
|
||||
* Creates a hash by name or function
|
||||
* @param {Algorithm} algorithm the algorithm name or a constructor creating a hash
|
||||
* @param {HashFunction} algorithm the algorithm name or a constructor creating a hash
|
||||
* @returns {Hash} the hash
|
||||
*/
|
||||
module.exports = algorithm => {
|
||||
|
|
|
@ -616,7 +616,7 @@
|
|||
},
|
||||
{
|
||||
"instanceof": "Function",
|
||||
"tsType": "((context: TODO) => string)"
|
||||
"tsType": "import('../lib/ModuleFilenameHelpers').ModuleFilenameTemplateFunction"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1794,7 +1794,7 @@
|
|||
},
|
||||
"stream": {
|
||||
"description": "Stream used for logging output. Defaults to process.stderr. This option is only used when no custom console is provided.",
|
||||
"tsType": "NodeJS.WritableStream"
|
||||
"tsType": "NodeJS.WritableStream & { isTTY?: boolean, columns?: number, rows?: number }"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
{
|
||||
"description": "Custom function generating the identifier.",
|
||||
"instanceof": "Function",
|
||||
"tsType": "((context: any) => string)"
|
||||
"tsType": "import('../../lib/ModuleFilenameHelpers').ModuleFilenameTemplateFunction"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -124,7 +124,7 @@
|
|||
{
|
||||
"description": "Custom function generating the identifier.",
|
||||
"instanceof": "Function",
|
||||
"tsType": "((context: any) => string)"
|
||||
"tsType": "import('../../lib/ModuleFilenameHelpers').ModuleFilenameTemplateFunction"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -88,6 +88,10 @@ import {
|
|||
YieldExpression
|
||||
} from "estree";
|
||||
import { IncomingMessage, ServerOptions } from "http";
|
||||
import {
|
||||
Session as SessionImportInspectorClass_1,
|
||||
Session as SessionImportInspectorClass_2
|
||||
} from "inspector";
|
||||
import { JSONSchema4, JSONSchema6, JSONSchema7 } from "json-schema";
|
||||
import { ListenOptions, Server } from "net";
|
||||
import { validate as validateFunction } from "schema-utils";
|
||||
|
@ -224,7 +228,6 @@ declare interface AggressiveSplittingPluginOptions {
|
|||
*/
|
||||
minSize?: number;
|
||||
}
|
||||
type Algorithm = string | typeof Hash;
|
||||
type Alias = string | false | string[];
|
||||
declare interface AliasOption {
|
||||
alias: Alias;
|
||||
|
@ -5867,7 +5870,11 @@ declare interface InfrastructureLogging {
|
|||
/**
|
||||
* Stream used for logging output. Defaults to process.stderr. This option is only used when no custom console is provided.
|
||||
*/
|
||||
stream?: NodeJS.WritableStream;
|
||||
stream?: NodeJS.WritableStream & {
|
||||
isTTY?: boolean;
|
||||
columns?: number;
|
||||
rows?: number;
|
||||
};
|
||||
}
|
||||
declare class InitFragment<GenerateContext> {
|
||||
constructor(
|
||||
|
@ -5926,6 +5933,9 @@ declare interface InputFileSystem {
|
|||
relative?: (from: string, to: string) => string;
|
||||
dirname?: (dirname: string) => string;
|
||||
}
|
||||
declare interface Inspector {
|
||||
Session: typeof SessionImportInspectorClass_1;
|
||||
}
|
||||
type IntermediateFileSystem = InputFileSystem &
|
||||
OutputFileSystem &
|
||||
IntermediateFileSystemExtras;
|
||||
|
@ -11765,12 +11775,12 @@ declare interface ProcessAssetsAdditionalOptions {
|
|||
additionalAssets?: any;
|
||||
}
|
||||
declare class Profiler {
|
||||
constructor(inspector?: any);
|
||||
session: any;
|
||||
inspector: any;
|
||||
constructor(inspector: Inspector);
|
||||
session?: SessionImportInspectorClass_2;
|
||||
inspector: Inspector;
|
||||
hasSession(): boolean;
|
||||
startProfiling(): Promise<void> | Promise<[any, any, any]>;
|
||||
sendCommand(method: string, params?: Record<string, any>): Promise<any>;
|
||||
sendCommand(method: string, params?: object): Promise<any>;
|
||||
destroy(): Promise<void>;
|
||||
stopProfiling(): Promise<{ profile: any }>;
|
||||
}
|
||||
|
@ -13347,12 +13357,19 @@ declare interface ResourceDataWithData {
|
|||
data: Record<string, any>;
|
||||
}
|
||||
declare abstract class RestoreProvidedData {
|
||||
exports: any[];
|
||||
exports: RestoreProvidedDataExports[];
|
||||
otherProvided?: null | boolean;
|
||||
otherCanMangleProvide?: boolean;
|
||||
otherTerminalBinding: boolean;
|
||||
serialize(__0: ObjectSerializerContext): void;
|
||||
}
|
||||
declare interface RestoreProvidedDataExports {
|
||||
name: string;
|
||||
provided?: null | boolean;
|
||||
canMangleProvide?: boolean;
|
||||
terminalBinding: boolean;
|
||||
exportsInfo?: RestoreProvidedData;
|
||||
}
|
||||
declare interface RmDirOptions {
|
||||
maxRetries?: number;
|
||||
recursive?: boolean;
|
||||
|
@ -16399,7 +16416,10 @@ declare namespace exports {
|
|||
export let REGEXP_NAMESPACE: RegExp;
|
||||
export let createFilename: (
|
||||
module: string | Module,
|
||||
options: { namespace?: string; moduleFilenameTemplate?: any },
|
||||
options: {
|
||||
namespace?: string;
|
||||
moduleFilenameTemplate?: string | ((context?: any) => string);
|
||||
},
|
||||
__2: {
|
||||
requestShortener: RequestShortener;
|
||||
chunkGraph: ChunkGraph;
|
||||
|
@ -16670,7 +16690,7 @@ declare namespace exports {
|
|||
export { ProfilingPlugin };
|
||||
}
|
||||
export namespace util {
|
||||
export const createHash: (algorithm: Algorithm) => Hash;
|
||||
export const createHash: (algorithm: HashFunction) => Hash;
|
||||
export namespace comparators {
|
||||
export let compareChunksById: (a: Chunk, b: Chunk) => 0 | 1 | -1;
|
||||
export let compareModulesByIdentifier: (
|
||||
|
|
Loading…
Reference in New Issue