mirror of https://github.com/webpack/webpack.git
fix: types
This commit is contained in:
parent
3f9a75fadf
commit
8c287addee
|
@ -13,6 +13,7 @@
|
|||
/** @typedef {import("./ConcatenationScope")} ConcatenationScope */
|
||||
/** @typedef {import("./DependencyTemplate")} DependencyTemplate */
|
||||
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
|
||||
/** @typedef {import("./Module").CodeGenerationResultData} CodeGenerationResultData */
|
||||
/** @typedef {import("./Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
|
||||
/** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */
|
||||
/** @typedef {import("./Module").SourceTypes} SourceTypes */
|
||||
|
@ -22,15 +23,6 @@
|
|||
/** @typedef {import("./util/Hash")} Hash */
|
||||
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @typedef {import("./InitFragment")<T>} InitFragment
|
||||
*/
|
||||
|
||||
/** @typedef {Map<"url", { [key: string]: string }> & Map<"fullContentHash", string> & Map<"contentHash", string> & Map<"filename", string> & Map<"assetInfo", AssetInfo> & Map<"chunkInitFragments", InitFragment<GenerateContext>[]>} KnownGenerateContextData */
|
||||
|
||||
/** @typedef {KnownGenerateContextData & Record<string, EXPECTED_ANY>} GenerateContextData */
|
||||
|
||||
/**
|
||||
* @typedef {object} GenerateContext
|
||||
* @property {DependencyTemplates} dependencyTemplates mapping from dependencies to templates
|
||||
|
@ -42,7 +34,7 @@
|
|||
* @property {ConcatenationScope=} concatenationScope when in concatenated module, information about other concatenated modules
|
||||
* @property {CodeGenerationResults=} codeGenerationResults code generation results of other modules (need to have a codeGenerationDependency to use that)
|
||||
* @property {string} type which kind of code should be generated
|
||||
* @property {() => GenerateContextData=} getData get access to the code generation data
|
||||
* @property {() => CodeGenerationResultData=} getData get access to the code generation data
|
||||
*/
|
||||
|
||||
/**
|
||||
|
|
|
@ -39,6 +39,10 @@ const makeSerializable = require("./util/makeSerializable");
|
|||
/** @typedef {import("./RequestShortener")} RequestShortener */
|
||||
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
||||
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
||||
/**
|
||||
* @template T
|
||||
* @typedef {import("./InitFragment")<T>} InitFragment
|
||||
*/
|
||||
/** @typedef {import("./WebpackError")} WebpackError */
|
||||
/** @typedef {import("./json/JsonData")} JsonData */
|
||||
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||
|
@ -94,10 +98,16 @@ const makeSerializable = require("./util/makeSerializable");
|
|||
/** @typedef {Set<string>} RuntimeRequirements */
|
||||
/** @typedef {ReadonlySet<string>} ReadOnlyRuntimeRequirements */
|
||||
|
||||
/** @typedef {Map<"topLevelDeclarations", Set<string>> & Map<"chunkInitFragments", InitFragment<TODO>[]>} KnownCodeGenerationResultDataForJavascriptModules */
|
||||
/** @typedef {Map<"url", { ["css-url"]: string }>} KnownCodeGenerationResultDataForCssModules */
|
||||
/** @typedef {Map<"filename", string> & Map<"assetInfo", AssetInfo> & Map<"fullContentHash", string>} KnownCodeGenerationResultDataForAssetModules */
|
||||
|
||||
/** @typedef {KnownCodeGenerationResultDataForJavascriptModules & KnownCodeGenerationResultDataForCssModules & KnownCodeGenerationResultDataForAssetModules & Map<string, EXPECTED_ANY>} CodeGenerationResultData */
|
||||
|
||||
/**
|
||||
* @typedef {object} CodeGenerationResult
|
||||
* @property {Map<string, Source>} sources the resulting sources for all source types
|
||||
* @property {Map<string, TODO>=} data the resulting data for all source types
|
||||
* @property {CodeGenerationResultData=} 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)
|
||||
*/
|
||||
|
|
|
@ -65,11 +65,11 @@ const memoize = require("./util/memoize");
|
|||
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
|
||||
/** @typedef {import("./Generator")} Generator */
|
||||
/** @typedef {import("./Generator").GenerateErrorFn} GenerateErrorFn */
|
||||
/** @typedef {import("./Generator").GenerateContextData} GenerateContextData */
|
||||
/** @typedef {import("./Module").BuildInfo} BuildInfo */
|
||||
/** @typedef {import("./Module").BuildMeta} BuildMeta */
|
||||
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
|
||||
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
|
||||
/** @typedef {import("./Module").CodeGenerationResultData} CodeGenerationResultData */
|
||||
/** @typedef {import("./Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
|
||||
/** @typedef {import("./Module").KnownBuildInfo} KnownBuildInfo */
|
||||
/** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */
|
||||
|
@ -399,7 +399,7 @@ class NormalModule extends Module {
|
|||
this._isEvaluatingSideEffects = false;
|
||||
/** @type {WeakSet<ModuleGraph> | undefined} */
|
||||
this._addedSideEffectsBailout = undefined;
|
||||
/** @type {GenerateContextData} */
|
||||
/** @type {CodeGenerationResultData} */
|
||||
this._codeGeneratorData = new Map();
|
||||
}
|
||||
|
||||
|
|
|
@ -245,10 +245,15 @@ class AssetModulesPlugin {
|
|||
entryInfo = assetInfo;
|
||||
entryHash = fullContentHash;
|
||||
} else {
|
||||
entryFilename = buildInfo.filename || data.get("filename");
|
||||
entryInfo = buildInfo.assetInfo || data.get("assetInfo");
|
||||
entryFilename =
|
||||
/** @type {string} */
|
||||
(buildInfo.filename || data.get("filename"));
|
||||
entryInfo =
|
||||
/** @type {AssetInfo} */
|
||||
(buildInfo.assetInfo || data.get("assetInfo"));
|
||||
entryHash =
|
||||
buildInfo.fullContentHash || data.get("fullContentHash");
|
||||
/** @type {string} */
|
||||
(buildInfo.fullContentHash || data.get("fullContentHash"));
|
||||
}
|
||||
|
||||
result.push({
|
||||
|
@ -280,10 +285,14 @@ class AssetModulesPlugin {
|
|||
const data =
|
||||
/** @type {NonNullable<CodeGenerationResult["data"]>} */
|
||||
(codeGenerationResult.data);
|
||||
context.assets.set(data.get("filename"), {
|
||||
context.assets.set(
|
||||
/** @type {string} */
|
||||
(data.get("filename")),
|
||||
{
|
||||
source,
|
||||
info: data.get("assetInfo")
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1891,7 +1891,7 @@ declare interface CodeGenerationResult {
|
|||
/**
|
||||
* the resulting data for all source types
|
||||
*/
|
||||
data?: Map<string, any>;
|
||||
data?: CodeGenerationResultData;
|
||||
|
||||
/**
|
||||
* the runtime requirements
|
||||
|
@ -1903,6 +1903,13 @@ declare interface CodeGenerationResult {
|
|||
*/
|
||||
hash?: string;
|
||||
}
|
||||
type CodeGenerationResultData = Map<"topLevelDeclarations", Set<string>> &
|
||||
Map<"chunkInitFragments", InitFragment<any>[]> &
|
||||
Map<"url", { "css-url": string }> &
|
||||
Map<"filename", string> &
|
||||
Map<"assetInfo", AssetInfo> &
|
||||
Map<"fullContentHash", string> &
|
||||
Map<string, any>;
|
||||
declare abstract class CodeGenerationResults {
|
||||
map: Map<Module, RuntimeSpecMap<CodeGenerationResult, CodeGenerationResult>>;
|
||||
get(module: Module, runtime: RuntimeSpec): CodeGenerationResult;
|
||||
|
@ -5771,15 +5778,8 @@ declare interface GenerateContext {
|
|||
/**
|
||||
* get access to the code generation data
|
||||
*/
|
||||
getData?: () => GenerateContextData;
|
||||
getData?: () => CodeGenerationResultData;
|
||||
}
|
||||
type GenerateContextData = Map<"url", { [index: string]: string }> &
|
||||
Map<"fullContentHash", string> &
|
||||
Map<"contentHash", string> &
|
||||
Map<"filename", string> &
|
||||
Map<"assetInfo", AssetInfo> &
|
||||
Map<"chunkInitFragments", InitFragment<GenerateContext>[]> &
|
||||
Record<string, any>;
|
||||
declare interface GeneratedSourceInfo {
|
||||
/**
|
||||
* generated line
|
||||
|
@ -10105,57 +10105,57 @@ declare interface ModuleFederationPluginOptions {
|
|||
}
|
||||
declare interface ModuleFilenameTemplateContext {
|
||||
/**
|
||||
* The identifier of the module.
|
||||
* the identifier of the module
|
||||
*/
|
||||
identifier: string;
|
||||
|
||||
/**
|
||||
* The shortened identifier of the module.
|
||||
* the shortened identifier of the module
|
||||
*/
|
||||
shortIdentifier: string;
|
||||
|
||||
/**
|
||||
* The resource of the module request.
|
||||
* the resource of the module request
|
||||
*/
|
||||
resource: string;
|
||||
|
||||
/**
|
||||
* The resource path of the module request.
|
||||
* the resource path of the module request
|
||||
*/
|
||||
resourcePath: string;
|
||||
|
||||
/**
|
||||
* The absolute resource path of the module request.
|
||||
* the absolute resource path of the module request
|
||||
*/
|
||||
absoluteResourcePath: string;
|
||||
|
||||
/**
|
||||
* The loaders of the module request.
|
||||
* the loaders of the module request
|
||||
*/
|
||||
loaders: string;
|
||||
|
||||
/**
|
||||
* The all loaders of the module request.
|
||||
* the all loaders of the module request
|
||||
*/
|
||||
allLoaders: string;
|
||||
|
||||
/**
|
||||
* The query of the module identifier.
|
||||
* the query of the module identifier
|
||||
*/
|
||||
query: string;
|
||||
|
||||
/**
|
||||
* The module id of the module.
|
||||
* the module id of the module
|
||||
*/
|
||||
moduleId: string;
|
||||
|
||||
/**
|
||||
* The hash of the module identifier.
|
||||
* the hash of the module identifier
|
||||
*/
|
||||
hash: string;
|
||||
|
||||
/**
|
||||
* The module namespace.
|
||||
* the module namespace
|
||||
*/
|
||||
namespace: string;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue