mirror of https://github.com/webpack/webpack.git
fix(types): more
This commit is contained in:
parent
3e3dfd781b
commit
be1d35eb02
|
@ -19,8 +19,8 @@ const mergeEtags = require("./cache/mergeEtags");
|
|||
/**
|
||||
* @template T
|
||||
* @callback CallbackCache
|
||||
* @param {(WebpackError | null)=} err
|
||||
* @param {T=} result
|
||||
* @param {(Error | null)=} err
|
||||
* @param {(T | null)=} result
|
||||
* @returns {void}
|
||||
*/
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ const {
|
|||
/** @typedef {import("./ChunkGroup")} ChunkGroup */
|
||||
/** @typedef {import("./Module")} Module */
|
||||
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */
|
||||
/** @typedef {import("./RuntimeModule")} RuntimeModule */
|
||||
/** @typedef {typeof import("./util/Hash")} Hash */
|
||||
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
|
@ -55,6 +56,10 @@ const compareModuleIterables = compareIterables(compareModulesByIdentifier);
|
|||
*/
|
||||
|
||||
class ModuleHashInfo {
|
||||
/**
|
||||
* @param {string} hash hash
|
||||
* @param {string} renderedHash rendered hash
|
||||
*/
|
||||
constructor(hash, renderedHash) {
|
||||
this.hash = hash;
|
||||
this.renderedHash = renderedHash;
|
||||
|
@ -180,13 +185,16 @@ const isAvailableChunk = (a, b) => {
|
|||
return true;
|
||||
};
|
||||
|
||||
/** @typedef {Set<Chunk>} EntryInChunks */
|
||||
/** @typedef {Set<Chunk>} RuntimeInChunks */
|
||||
|
||||
class ChunkGraphModule {
|
||||
constructor() {
|
||||
/** @type {SortableSet<Chunk>} */
|
||||
this.chunks = new SortableSet();
|
||||
/** @type {Set<Chunk> | undefined} */
|
||||
/** @type {EntryInChunks | undefined} */
|
||||
this.entryInChunks = undefined;
|
||||
/** @type {Set<Chunk> | undefined} */
|
||||
/** @type {RuntimeInChunks | undefined} */
|
||||
this.runtimeInChunks = undefined;
|
||||
/** @type {RuntimeSpecMap<ModuleHashInfo> | undefined} */
|
||||
this.hashes = undefined;
|
||||
|
@ -420,7 +428,7 @@ class ChunkGraph {
|
|||
}
|
||||
for (const chunk of oldCgm.entryInChunks) {
|
||||
const cgc = this._getChunkGraphChunk(chunk);
|
||||
const old = cgc.entryModules.get(oldModule);
|
||||
const old = /** @type {Entrypoint} */ (cgc.entryModules.get(oldModule));
|
||||
/** @type {Map<Module, Entrypoint>} */
|
||||
const newEntryModules = new Map();
|
||||
for (const [m, cg] of cgc.entryModules) {
|
||||
|
@ -758,7 +766,7 @@ class ChunkGraph {
|
|||
for (const asyncChunk of includeAllChunks
|
||||
? chunk.getAllReferencedChunks()
|
||||
: chunk.getAllAsyncChunks()) {
|
||||
/** @type {Record<string|number, string>} */
|
||||
/** @type {Record<string|number, string> | undefined} */
|
||||
let idToHashMap;
|
||||
for (const module of this.getOrderedChunkModulesIterable(
|
||||
asyncChunk,
|
||||
|
@ -1118,7 +1126,7 @@ class ChunkGraph {
|
|||
*/
|
||||
disconnectEntryModule(module) {
|
||||
const cgm = this._getChunkGraphModule(module);
|
||||
for (const chunk of cgm.entryInChunks) {
|
||||
for (const chunk of /** @type {EntryInChunks} */ (cgm.entryInChunks)) {
|
||||
const cgc = this._getChunkGraphChunk(chunk);
|
||||
cgc.entryModules.delete(module);
|
||||
}
|
||||
|
@ -1226,14 +1234,7 @@ class ChunkGraph {
|
|||
const array = Array.from(cgc.runtimeModules);
|
||||
array.sort(
|
||||
concatComparators(
|
||||
compareSelect(
|
||||
/**
|
||||
* @param {RuntimeModule} r runtime module
|
||||
* @returns {number=} stage
|
||||
*/
|
||||
r => r.stage,
|
||||
compareIds
|
||||
),
|
||||
compareSelect(r => /** @type {RuntimeModule} */ (r).stage, compareIds),
|
||||
compareModulesByIdentifier
|
||||
)
|
||||
);
|
||||
|
@ -1278,7 +1279,7 @@ class ChunkGraph {
|
|||
|
||||
/**
|
||||
* @param {AsyncDependenciesBlock} depBlock the async block
|
||||
* @returns {ChunkGroup} the chunk group
|
||||
* @returns {ChunkGroup | undefined} the chunk group
|
||||
*/
|
||||
getBlockChunkGroup(depBlock) {
|
||||
return this._blockChunkGroups.get(depBlock);
|
||||
|
@ -1367,7 +1368,7 @@ class ChunkGraph {
|
|||
Caller might not support runtime-dependent code generation (opt-out via optimization.usedExports: "global").`
|
||||
);
|
||||
}
|
||||
return first(hashInfoItems);
|
||||
return /** @type {T} */ (first(hashInfoItems));
|
||||
} else {
|
||||
const hashInfo = hashes.get(runtime);
|
||||
if (!hashInfo) {
|
||||
|
@ -1579,6 +1580,10 @@ Caller might not support runtime-dependent code generation (opt-out via optimiza
|
|||
if (cgm.graphHashesWithConnections === undefined) {
|
||||
cgm.graphHashesWithConnections = new RuntimeSpecMap();
|
||||
}
|
||||
/**
|
||||
* @param {ConnectionState} state state
|
||||
* @returns {"F" | "T" | "O"} result
|
||||
*/
|
||||
const activeStateToString = state => {
|
||||
if (state === false) return "F";
|
||||
if (state === true) return "T";
|
||||
|
|
|
@ -80,7 +80,7 @@ class ChunkGroup {
|
|||
}
|
||||
/** @type {number} */
|
||||
this.groupDebugId = debugId++;
|
||||
this.options = options;
|
||||
this.options = /** @type {ChunkGroupOptions} */ (options);
|
||||
/** @type {SortableSet<ChunkGroup>} */
|
||||
this._children = new SortableSet(undefined, sortById);
|
||||
/** @type {SortableSet<ChunkGroup>} */
|
||||
|
@ -108,18 +108,18 @@ class ChunkGroup {
|
|||
* @returns {void}
|
||||
*/
|
||||
addOptions(options) {
|
||||
for (const key of Object.keys(options)) {
|
||||
if (
|
||||
this.options[/** @type {keyof ChunkGroupOptions} */ (key)] === undefined
|
||||
) {
|
||||
this.options[key] =
|
||||
options[/** @type {keyof ChunkGroupOptions} */ (key)];
|
||||
} else if (
|
||||
this.options[/** @type {keyof ChunkGroupOptions} */ (key)] !==
|
||||
options[/** @type {keyof ChunkGroupOptions} */ (key)]
|
||||
) {
|
||||
for (const _key of Object.keys(options)) {
|
||||
const key = /** @type {keyof ChunkGroupOptions} */ (_key);
|
||||
if (this.options[key] === undefined) {
|
||||
/** @type {TODO} */
|
||||
(this.options)[key] = options[key];
|
||||
} else if (this.options[key] !== options[key]) {
|
||||
if (key.endsWith("Order")) {
|
||||
this.options[key] = Math.max(this.options[key], options[key]);
|
||||
/** @type {TODO} */
|
||||
(this.options)[key] = Math.max(
|
||||
/** @type {number} */ (this.options[key]),
|
||||
/** @type {number} */ (options[key])
|
||||
);
|
||||
} else {
|
||||
throw new Error(
|
||||
`ChunkGroup.addOptions: No option merge strategy for ${key}`
|
||||
|
|
|
@ -1418,7 +1418,10 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|||
currentProfile.markStoringEnd();
|
||||
}
|
||||
if (err) {
|
||||
this.hooks.failedModule.call(module, err);
|
||||
this.hooks.failedModule.call(
|
||||
module,
|
||||
/** @type {WebpackError} */ (err)
|
||||
);
|
||||
return callback(new ModuleStoreError(module, err));
|
||||
}
|
||||
this.hooks.succeedModule.call(module);
|
||||
|
@ -1578,7 +1581,7 @@ BREAKING CHANGE: Asset processing hooks in Compilation has been merged into a si
|
|||
if (err) {
|
||||
if (inProgressSorting <= 0) return;
|
||||
inProgressSorting = -1;
|
||||
onDependenciesSorted(err);
|
||||
onDependenciesSorted(/** @type {WebpackError} */ (err));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
@ -3451,7 +3454,7 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|||
)
|
||||
);
|
||||
cache.get((err, cachedResult) => {
|
||||
if (err) return callback(err);
|
||||
if (err) return callback(/** @type {WebpackError} */ (err));
|
||||
let result;
|
||||
if (!cachedResult) {
|
||||
try {
|
||||
|
@ -3483,7 +3486,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|||
results.add(module, runtime, result);
|
||||
}
|
||||
if (!cachedResult) {
|
||||
cache.store(result, err => callback(err, codeGenerated));
|
||||
cache.store(result, err =>
|
||||
callback(/** @type {WebpackError} */ (err), codeGenerated)
|
||||
);
|
||||
} else {
|
||||
callback(null, codeGenerated);
|
||||
}
|
||||
|
@ -3952,7 +3957,9 @@ Or do you want to use the entrypoints '${name}' and '${runtime}' independently o
|
|||
const blocks = block.blocks;
|
||||
for (let indexBlock = 0; indexBlock < blocks.length; indexBlock++) {
|
||||
const asyncBlock = blocks[indexBlock];
|
||||
const chunkGroup = this.chunkGraph.getBlockChunkGroup(asyncBlock);
|
||||
const chunkGroup =
|
||||
/** @type {ChunkGroup} */
|
||||
(this.chunkGraph.getBlockChunkGroup(asyncBlock));
|
||||
// Grab all chunks from the first Block's AsyncDepBlock
|
||||
const chunks = chunkGroup.chunks;
|
||||
// For each chunk in chunkGroup
|
||||
|
|
|
@ -41,7 +41,7 @@ const wrapInCondition = (condition, source) => {
|
|||
*/
|
||||
class ConditionalInitFragment extends InitFragment {
|
||||
/**
|
||||
* @param {string|Source} content the source code that will be included as initialization code
|
||||
* @param {string | Source | undefined} content the source code that will be included as initialization code
|
||||
* @param {number} stage category of initialization code (contribute to order)
|
||||
* @param {number} position position in the category (contribute to order)
|
||||
* @param {string | undefined} key unique key to avoid emitting the same initialization code twice
|
||||
|
@ -62,7 +62,7 @@ class ConditionalInitFragment extends InitFragment {
|
|||
|
||||
/**
|
||||
* @param {GenerateContext} context context
|
||||
* @returns {string | Source} the source code that will be included as initialization code
|
||||
* @returns {string | Source | undefined} the source code that will be included as initialization code
|
||||
*/
|
||||
getContent(context) {
|
||||
if (this.runtimeCondition === false || !this.content) return "";
|
||||
|
|
|
@ -13,18 +13,23 @@
|
|||
/** @typedef {import("./Dependency").RuntimeSpec} RuntimeSpec */
|
||||
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
|
||||
/** @typedef {import("./Generator").GenerateContext} GenerateContext */
|
||||
/** @template T @typedef {import("./InitFragment")<T>} InitFragment */
|
||||
/** @typedef {import("./Module")} Module */
|
||||
/** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */
|
||||
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @typedef {import("./InitFragment")<T>} InitFragment
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} DependencyTemplateContext
|
||||
* @property {RuntimeTemplate} runtimeTemplate the runtime template
|
||||
* @property {DependencyTemplates} dependencyTemplates the dependency templates
|
||||
* @property {ModuleGraph} moduleGraph the module graph
|
||||
* @property {ChunkGraph} chunkGraph the chunk graph
|
||||
* @property {Set<string>} runtimeRequirements the requirements for runtime
|
||||
* @property {RuntimeRequirements} runtimeRequirements the requirements for runtime
|
||||
* @property {Module} module current module
|
||||
* @property {RuntimeSpec} runtime current runtime, for which code is generated
|
||||
* @property {RuntimeSpec[]} [runtimes] current runtimes, for which code is generated
|
||||
|
|
|
@ -667,7 +667,7 @@ class ExportsInfo {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {string | string[]} name the export name
|
||||
* @param {string | string[] | undefined} name the export name
|
||||
* @param {RuntimeSpec} runtime check usage for this runtime only
|
||||
* @returns {string | string[] | false} the used name
|
||||
*/
|
||||
|
|
|
@ -36,6 +36,7 @@ const { register } = require("./util/serialization");
|
|||
/** @typedef {import("./Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
|
||||
/** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */
|
||||
/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
|
||||
/** @typedef {import("./Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
||||
/** @typedef {import("./Module").SourceTypes} SourceTypes */
|
||||
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */
|
||||
|
@ -63,7 +64,7 @@ const { register } = require("./util/serialization");
|
|||
* @property {string=} init
|
||||
* @property {string} expression
|
||||
* @property {InitFragment<ChunkRenderContext>[]=} chunkInitFragments
|
||||
* @property {ReadonlySet<string>=} runtimeRequirements
|
||||
* @property {ReadOnlyRuntimeRequirements=} runtimeRequirements
|
||||
*/
|
||||
|
||||
const TYPES = new Set(["javascript"]);
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
/** @typedef {import("./DependencyTemplate")} DependencyTemplate */
|
||||
/** @typedef {import("./DependencyTemplates")} DependencyTemplates */
|
||||
/** @typedef {import("./Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
|
||||
/** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */
|
||||
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("./NormalModule")} NormalModule */
|
||||
/** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */
|
||||
|
@ -25,7 +26,7 @@
|
|||
* @property {RuntimeTemplate} runtimeTemplate the runtime template
|
||||
* @property {ModuleGraph} moduleGraph the module graph
|
||||
* @property {ChunkGraph} chunkGraph the chunk graph
|
||||
* @property {Set<string>} runtimeRequirements the requirements for runtime
|
||||
* @property {RuntimeRequirements} runtimeRequirements the requirements for runtime
|
||||
* @property {RuntimeSpec} runtime the runtime
|
||||
* @property {RuntimeSpec[]} [runtimes] the runtimes
|
||||
* @property {ConcatenationScope=} concatenationScope when in concatenated module, information about other concatenated modules
|
||||
|
|
|
@ -48,7 +48,6 @@ const {
|
|||
/** @typedef {import("./Module")} Module */
|
||||
/** @typedef {import("./RuntimeModule")} RuntimeModule */
|
||||
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
/** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
|
||||
|
||||
/**
|
||||
* @typedef {Object} HMRJavascriptParserHooks
|
||||
|
|
|
@ -171,7 +171,9 @@ class InitFragment {
|
|||
|
||||
makeSerializable(InitFragment, "webpack/lib/InitFragment");
|
||||
|
||||
InitFragment.prototype.merge = undefined;
|
||||
InitFragment.prototype.merge =
|
||||
/** @type {TODO} */
|
||||
(undefined);
|
||||
|
||||
InitFragment.STAGE_CONSTANTS = 10;
|
||||
InitFragment.STAGE_ASYNC_BOUNDARY = 20;
|
||||
|
|
|
@ -75,11 +75,14 @@ const makeSerializable = require("./util/makeSerializable");
|
|||
* @property {ChunkGraph} chunkGraph the chunk graph
|
||||
*/
|
||||
|
||||
/** @typedef {Set<string>} RuntimeRequirements */
|
||||
/** @typedef {ReadonlySet<string>} ReadOnlyRuntimeRequirements */
|
||||
|
||||
/**
|
||||
* @typedef {Object} CodeGenerationResult
|
||||
* @property {Map<string, Source>} sources the resulting sources for all source types
|
||||
* @property {Map<string, any>=} data the resulting data for all source types
|
||||
* @property {ReadonlySet<string>} runtimeRequirements the runtime requirements
|
||||
* @property {ReadOnlyRuntimeRequirements} 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)
|
||||
*/
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ const makeSerializable = require("./util/makeSerializable");
|
|||
/** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */
|
||||
/** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */
|
||||
/** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */
|
||||
/** @typedef {import("./Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
||||
/** @typedef {import("./Module").SourceTypes} SourceTypes */
|
||||
/** @typedef {import("./RequestShortener")} RequestShortener */
|
||||
/** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
||||
|
@ -36,7 +37,7 @@ class RawModule extends Module {
|
|||
* @param {string} source source code
|
||||
* @param {string} identifier unique identifier
|
||||
* @param {string=} readableIdentifier readable identifier
|
||||
* @param {ReadonlySet<string>=} runtimeRequirements runtime requirements needed for the source code
|
||||
* @param {ReadOnlyRuntimeRequirements=} runtimeRequirements runtime requirements needed for the source code
|
||||
*/
|
||||
constructor(source, identifier, readableIdentifier, runtimeRequirements) {
|
||||
super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null);
|
||||
|
|
|
@ -47,7 +47,7 @@ class RuntimeModule extends Module {
|
|||
this.chunkGraph = undefined;
|
||||
this.fullHash = false;
|
||||
this.dependentHash = false;
|
||||
/** @type {string | undefined} */
|
||||
/** @type {string | undefined | null} */
|
||||
this._cachedGeneratedCode = undefined;
|
||||
}
|
||||
|
||||
|
@ -113,9 +113,9 @@ class RuntimeModule extends Module {
|
|||
if (this.fullHash || this.dependentHash) {
|
||||
// Do not use getGeneratedCode here, because i. e. compilation hash might be not
|
||||
// ready at this point. We will cache it later instead.
|
||||
hash.update(this.generate());
|
||||
hash.update(/** @type {string} */ (this.generate()));
|
||||
} else {
|
||||
hash.update(this.getGeneratedCode());
|
||||
hash.update(/** @type {string} */ (this.getGeneratedCode()));
|
||||
}
|
||||
} catch (err) {
|
||||
hash.update(/** @type {Error} */ (err).message);
|
||||
|
@ -179,7 +179,7 @@ class RuntimeModule extends Module {
|
|||
*/
|
||||
getGeneratedCode() {
|
||||
if (this._cachedGeneratedCode) {
|
||||
return /** @type {string | null} */ (this._cachedGeneratedCode);
|
||||
return this._cachedGeneratedCode;
|
||||
}
|
||||
return (this._cachedGeneratedCode = this.generate());
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ const { forEachRuntime, subtractRuntime } = require("./util/runtime");
|
|||
/** @typedef {import("./Dependency")} Dependency */
|
||||
/** @typedef {import("./Module")} Module */
|
||||
/** @typedef {import("./Module").BuildMeta} BuildMeta */
|
||||
/** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */
|
||||
/** @typedef {import("./ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("./RequestShortener")} RequestShortener */
|
||||
/** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
|
@ -459,7 +460,7 @@ class RuntimeTemplate {
|
|||
* @param {ChunkGraph} options.chunkGraph the chunk graph
|
||||
* @param {string=} options.request the request that should be printed as comment
|
||||
* @param {boolean=} options.weak if the dependency is weak (will create a nice error message)
|
||||
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||
* @returns {string} the expression
|
||||
*/
|
||||
moduleRaw({ module, chunkGraph, request, weak, runtimeRequirements }) {
|
||||
|
@ -502,7 +503,7 @@ class RuntimeTemplate {
|
|||
* @param {ChunkGraph} options.chunkGraph the chunk graph
|
||||
* @param {string} options.request the request that should be printed as comment
|
||||
* @param {boolean=} options.weak if the dependency is weak (will create a nice error message)
|
||||
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||
* @returns {string} the expression
|
||||
*/
|
||||
moduleExports({ module, chunkGraph, request, weak, runtimeRequirements }) {
|
||||
|
@ -522,7 +523,7 @@ class RuntimeTemplate {
|
|||
* @param {string} options.request the request that should be printed as comment
|
||||
* @param {boolean=} options.strict if the current module is in strict esm mode
|
||||
* @param {boolean=} options.weak if the dependency is weak (will create a nice error message)
|
||||
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||
* @returns {string} the expression
|
||||
*/
|
||||
moduleNamespace({
|
||||
|
@ -593,7 +594,7 @@ class RuntimeTemplate {
|
|||
* @param {string} options.message a message for the comment
|
||||
* @param {boolean=} options.strict if the current module is in strict esm mode
|
||||
* @param {boolean=} options.weak if the dependency is weak (will create a nice error message)
|
||||
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||
* @returns {string} the promise expression
|
||||
*/
|
||||
moduleNamespacePromise({
|
||||
|
@ -739,7 +740,7 @@ class RuntimeTemplate {
|
|||
* @param {ChunkGraph} options.chunkGraph the chunk graph
|
||||
* @param {RuntimeSpec=} options.runtime runtime for which this code will be generated
|
||||
* @param {RuntimeSpec | boolean=} options.runtimeCondition only execute the statement in some runtimes
|
||||
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||
* @returns {string} expression
|
||||
*/
|
||||
runtimeConditionExpression({
|
||||
|
@ -781,7 +782,7 @@ class RuntimeTemplate {
|
|||
* @param {string} options.importVar name of the import variable
|
||||
* @param {Module} options.originModule module in which the statement is emitted
|
||||
* @param {boolean=} options.weak true, if this is a weak dependency
|
||||
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||
* @returns {[string, string]} the import statement and the compat statement
|
||||
*/
|
||||
importStatement({
|
||||
|
@ -863,7 +864,7 @@ class RuntimeTemplate {
|
|||
* @param {string} options.importVar the identifier name of the import variable
|
||||
* @param {InitFragment<TODO>[]} options.initFragments init fragments will be added here
|
||||
* @param {RuntimeSpec} options.runtime runtime for which this code will be generated
|
||||
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||
* @returns {string} expression
|
||||
*/
|
||||
exportFromImport({
|
||||
|
@ -977,7 +978,7 @@ class RuntimeTemplate {
|
|||
* @param {AsyncDependenciesBlock | undefined} options.block the async block
|
||||
* @param {string} options.message the message
|
||||
* @param {ChunkGraph} options.chunkGraph the chunk graph
|
||||
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||
* @returns {string} expression
|
||||
*/
|
||||
blockPromise({ block, message, chunkGraph, runtimeRequirements }) {
|
||||
|
@ -1043,7 +1044,7 @@ class RuntimeTemplate {
|
|||
* @param {Object} options options
|
||||
* @param {AsyncDependenciesBlock} options.block the async block
|
||||
* @param {ChunkGraph} options.chunkGraph the chunk graph
|
||||
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||
* @param {string=} options.request request string used originally
|
||||
* @returns {string} expression
|
||||
*/
|
||||
|
@ -1075,7 +1076,7 @@ class RuntimeTemplate {
|
|||
* @param {Object} options options
|
||||
* @param {Dependency} options.dependency the dependency
|
||||
* @param {ChunkGraph} options.chunkGraph the chunk graph
|
||||
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||
* @param {string=} options.request request string used originally
|
||||
* @returns {string} expression
|
||||
*/
|
||||
|
@ -1095,7 +1096,7 @@ class RuntimeTemplate {
|
|||
/**
|
||||
* @param {Object} options options
|
||||
* @param {string} options.exportsArgument the name of the exports object
|
||||
* @param {Set<string>} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||
* @param {RuntimeRequirements} options.runtimeRequirements if set, will be filled with runtime requirements
|
||||
* @returns {string} statement
|
||||
*/
|
||||
defineEsModuleFlagStatement({ exportsArgument, runtimeRequirements }) {
|
||||
|
|
|
@ -43,7 +43,7 @@ class AwaitDependenciesInitFragment extends InitFragment {
|
|||
|
||||
/**
|
||||
* @param {GenerateContext} context context
|
||||
* @returns {string | Source} the source code that will be included as initialization code
|
||||
* @returns {string | Source | undefined} the source code that will be included as initialization code
|
||||
*/
|
||||
getContent({ runtimeRequirements }) {
|
||||
runtimeRequirements.add(RuntimeGlobals.module);
|
||||
|
|
|
@ -12,9 +12,9 @@ const ContainerExposedDependency = require("./ContainerExposedDependency");
|
|||
const { parseOptions } = require("./options");
|
||||
|
||||
/** @typedef {import("../../declarations/plugins/container/ContainerPlugin").ContainerPluginOptions} ContainerPluginOptions */
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
/** @typedef {import("./ContainerEntryModule").ExposeOptions} ExposeOptions */
|
||||
/** @typedef {import("./ContainerEntryModule").ExposesList} ExposesList */
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
|
||||
const validate = createSchemaValidation(
|
||||
require("../../schemas/plugins/container/ContainerPlugin.check.js"),
|
||||
|
|
|
@ -10,6 +10,9 @@ const RuntimeModule = require("../RuntimeModule");
|
|||
const Template = require("../Template");
|
||||
|
||||
/** @typedef {import("../Chunk")} Chunk */
|
||||
/** @typedef {import("../Chunk").ChunkId} ChunkId */
|
||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("../Compilation")} Compilation */
|
||||
/** @typedef {import("./RemoteModule")} RemoteModule */
|
||||
|
||||
class RemoteRuntimeModule extends RuntimeModule {
|
||||
|
@ -21,17 +24,23 @@ class RemoteRuntimeModule extends RuntimeModule {
|
|||
* @returns {string | null} runtime code
|
||||
*/
|
||||
generate() {
|
||||
const { compilation, chunkGraph } = this;
|
||||
const compilation = /** @type {Compilation} */ (this.compilation);
|
||||
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
|
||||
const { runtimeTemplate, moduleGraph } = compilation;
|
||||
/** @type {Record<ChunkId, (string | number)[]>} */
|
||||
const chunkToRemotesMapping = {};
|
||||
/** @type {Record<string | number, [string, string, string | number | null]>} */
|
||||
const idToExternalAndNameMapping = {};
|
||||
for (const chunk of this.chunk.getAllAsyncChunks()) {
|
||||
for (const chunk of /** @type {Chunk} */ (this.chunk).getAllAsyncChunks()) {
|
||||
const modules = chunkGraph.getChunkModulesIterableBySourceType(
|
||||
chunk,
|
||||
"remote"
|
||||
);
|
||||
if (!modules) continue;
|
||||
const remotes = (chunkToRemotesMapping[chunk.id] = []);
|
||||
/** @type {(string | number)[]} */
|
||||
const remotes = (chunkToRemotesMapping[
|
||||
/** @type {ChunkId} */ (chunk.id)
|
||||
] = []);
|
||||
for (const m of modules) {
|
||||
const module = /** @type {RemoteModule} */ (m);
|
||||
const name = module.internalRequest;
|
||||
|
|
|
@ -16,6 +16,7 @@ const { chunkHasCss } = require("./CssModulesPlugin");
|
|||
/** @typedef {import("../Chunk")} Chunk */
|
||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("../Compilation").RuntimeRequirementsContext} RuntimeRequirementsContext */
|
||||
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
||||
|
||||
/**
|
||||
* @typedef {Object} CssLoadingRuntimeModulePluginHooks
|
||||
|
@ -51,7 +52,7 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {Set<string>} runtimeRequirements runtime requirements
|
||||
* @param {ReadOnlyRuntimeRequirements} runtimeRequirements runtime requirements
|
||||
*/
|
||||
constructor(runtimeRequirements) {
|
||||
super("css loading", 10);
|
||||
|
@ -63,7 +64,9 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
|||
* @returns {string | null} runtime code
|
||||
*/
|
||||
generate() {
|
||||
const { compilation, chunk, _runtimeRequirements } = this;
|
||||
const { _runtimeRequirements } = this;
|
||||
const compilation = /** @type {Compilation} */ (this.compilation);
|
||||
const chunk = /** @type {Chunk} */ (this.chunk);
|
||||
const {
|
||||
chunkGraph,
|
||||
runtimeTemplate,
|
||||
|
@ -73,7 +76,7 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
|||
chunkLoadTimeout: loadTimeout,
|
||||
cssHeadDataCompression: withCompression
|
||||
}
|
||||
} = /** @type {Compilation} */ (compilation);
|
||||
} = compilation;
|
||||
const fn = RuntimeGlobals.ensureChunkHandlers;
|
||||
const conditionMap = chunkGraph.getChunkConditionMap(
|
||||
/** @type {Chunk} */ (chunk),
|
||||
|
@ -122,9 +125,8 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
|||
RuntimeGlobals.hasFetchPriority
|
||||
);
|
||||
|
||||
const { createStylesheet } = CssLoadingRuntimeModule.getCompilationHooks(
|
||||
/** @type {Compilation} */ (compilation)
|
||||
);
|
||||
const { createStylesheet } =
|
||||
CssLoadingRuntimeModule.getCompilationHooks(compilation);
|
||||
|
||||
const stateExpression = withHmr
|
||||
? `${RuntimeGlobals.hmrRuntimeStatePrefix}_css`
|
||||
|
@ -241,8 +243,12 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
|||
Template.indent([
|
||||
"cc = data.charCodeAt(i);",
|
||||
`if(cc == ${cc(":")}) { token2 = token; token = ""; }`,
|
||||
`else if(cc == ${cc("/")}) { token = token.replace(/^_/, ""); token2 = token2.replace(/^_/, ""); exports[token2] = token; token = ""; token2 = ""; }`,
|
||||
`else if(!cc || cc == ${cc(",")}) { token = token.replace(/^_/, ""); ${
|
||||
`else if(cc == ${cc(
|
||||
"/"
|
||||
)}) { token = token.replace(/^_/, ""); token2 = token2.replace(/^_/, ""); exports[token2] = token; token = ""; token2 = ""; }`,
|
||||
`else if(!cc || cc == ${cc(
|
||||
","
|
||||
)}) { token = token.replace(/^_/, ""); ${
|
||||
RuntimeGlobals.makeNamespaceObject
|
||||
}(exports); target[token] = (${runtimeTemplate.basicFunction(
|
||||
"exports, module",
|
||||
|
@ -391,7 +397,9 @@ class CssLoadingRuntimeModule extends RuntimeModule {
|
|||
"}"
|
||||
]
|
||||
)};`,
|
||||
`var link = loadStylesheet(chunkId, url, loadingEnded${withFetchPriority ? ", fetchPriority" : ""});`
|
||||
`var link = loadStylesheet(chunkId, url, loadingEnded${
|
||||
withFetchPriority ? ", fetchPriority" : ""
|
||||
});`
|
||||
]),
|
||||
"} else installedChunks[chunkId] = 0;"
|
||||
]),
|
||||
|
|
|
@ -103,7 +103,7 @@ class AMDDefineDependencyParserPlugin {
|
|||
/** @type {string} */ (param.string)
|
||||
)
|
||||
)
|
||||
identifiers[idx] = param.string;
|
||||
identifiers[/** @type {number} */ (idx)] = param.string;
|
||||
const result = this.processItem(parser, expr, param, namedModule);
|
||||
if (result === undefined) {
|
||||
this.processContext(parser, expr, param);
|
||||
|
@ -113,7 +113,8 @@ class AMDDefineDependencyParserPlugin {
|
|||
} else if (param.isConstArray()) {
|
||||
/** @type {(string | LocalModuleDependency | AMDRequireItemDependency)[]} */
|
||||
const deps = [];
|
||||
param.array.forEach((request, idx) => {
|
||||
/** @type {string[]} */
|
||||
(param.array).forEach((request, idx) => {
|
||||
let dep;
|
||||
let localModule;
|
||||
if (request === "require") {
|
||||
|
@ -151,7 +152,7 @@ class AMDDefineDependencyParserPlugin {
|
|||
* @param {CallExpression} expr call expression
|
||||
* @param {BasicEvaluatedExpression} param param
|
||||
* @param {string=} namedModule named module
|
||||
* @returns {boolean} result
|
||||
* @returns {boolean | undefined} result
|
||||
*/
|
||||
processItem(parser, expr, param, namedModule) {
|
||||
if (param.isConditional()) {
|
||||
|
@ -193,7 +194,10 @@ class AMDDefineDependencyParserPlugin {
|
|||
localModule.flagUsed();
|
||||
dep = new LocalModuleDependency(localModule, param.range, false);
|
||||
} else {
|
||||
dep = this.newRequireItemDependency(param.string, param.range);
|
||||
dep = this.newRequireItemDependency(
|
||||
/** @type {string} */ (param.string),
|
||||
param.range
|
||||
);
|
||||
dep.optional = !!parser.scope.inTry;
|
||||
parser.state.current.addDependency(dep);
|
||||
return true;
|
||||
|
@ -377,7 +381,7 @@ class AMDDefineDependencyParserPlugin {
|
|||
for (const [name, varInfo] of fnRenames) {
|
||||
parser.setVariable(name, varInfo);
|
||||
}
|
||||
parser.scope.inTry = inTry;
|
||||
parser.scope.inTry = /** @type {boolean} */ (inTry);
|
||||
if (fn.callee.object.body.type === "BlockStatement") {
|
||||
parser.detectMode(fn.callee.object.body.body);
|
||||
const prev = parser.prevStatement;
|
||||
|
|
|
@ -21,6 +21,7 @@ const getFunctionExpression = require("./getFunctionExpression");
|
|||
|
||||
/** @typedef {import("estree").CallExpression} CallExpression */
|
||||
/** @typedef {import("estree").Expression} Expression */
|
||||
/** @typedef {import("estree").Identifier} Identifier */
|
||||
/** @typedef {import("estree").SourceLocation} SourceLocation */
|
||||
/** @typedef {import("estree").SpreadElement} SpreadElement */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
||||
|
@ -49,7 +50,9 @@ class AMDRequireDependenciesBlockParserPlugin {
|
|||
if (fnData) {
|
||||
parser.inScope(
|
||||
fnData.fn.params.filter(i => {
|
||||
return !["require", "module", "exports"].includes(i.name);
|
||||
return !["require", "module", "exports"].includes(
|
||||
/** @type {Identifier} */ (i).name
|
||||
);
|
||||
}),
|
||||
() => {
|
||||
if (fnData.fn.body.type === "BlockStatement") {
|
||||
|
|
|
@ -8,12 +8,13 @@
|
|||
const RuntimeGlobals = require("../RuntimeGlobals");
|
||||
|
||||
/** @typedef {import("../Module")} Module */
|
||||
/** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
|
||||
/** @typedef {"exports" | "module.exports" | "this" | "Object.defineProperty(exports)" | "Object.defineProperty(module.exports)" | "Object.defineProperty(this)"} CommonJSDependencyBaseKeywords */
|
||||
|
||||
/**
|
||||
* @param {CommonJSDependencyBaseKeywords} depBase commonjs dependency base
|
||||
* @param {Module} module module
|
||||
* @param {Set<string>} runtimeRequirements runtime requirements
|
||||
* @param {RuntimeRequirements} runtimeRequirements runtime requirements
|
||||
* @returns {[string, string]} type and base
|
||||
*/
|
||||
exports.handleDependencyBase = (depBase, module, runtimeRequirements) => {
|
||||
|
|
|
@ -20,6 +20,8 @@ const processExportInfo = require("./processExportInfo");
|
|||
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
||||
/** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */
|
||||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../ExportsInfo")} ExportsInfo */
|
||||
/** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
|
||||
/** @typedef {import("../Module")} Module */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
|
@ -35,7 +37,7 @@ const EMPTY_OBJECT = {};
|
|||
class CommonJsExportRequireDependency extends ModuleDependency {
|
||||
/**
|
||||
* @param {Range} range range
|
||||
* @param {Range} valueRange value range
|
||||
* @param {Range | null} valueRange value range
|
||||
* @param {CommonJSDependencyBaseKeywords} base base
|
||||
* @param {string[]} names names
|
||||
* @param {string} request request
|
||||
|
@ -69,7 +71,9 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|||
* @returns {string[]} the imported id
|
||||
*/
|
||||
getIds(moduleGraph) {
|
||||
return moduleGraph.getMeta(this)[idsSymbol] || this.ids;
|
||||
return (
|
||||
/** @type {TODO} */ (moduleGraph.getMeta(this))[idsSymbol] || this.ids
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,7 +82,7 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|||
* @returns {void}
|
||||
*/
|
||||
setIds(moduleGraph, ids) {
|
||||
moduleGraph.getMeta(this)[idsSymbol] = ids;
|
||||
/** @type {TODO} */ (moduleGraph.getMeta(this))[idsSymbol] = ids;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -102,11 +106,14 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|||
}
|
||||
};
|
||||
if (this.resultUsed) return getFullResult();
|
||||
/** @type {ExportsInfo | undefined} */
|
||||
let exportsInfo = moduleGraph.getExportsInfo(
|
||||
moduleGraph.getParentModule(this)
|
||||
/** @type {Module} */ (moduleGraph.getParentModule(this))
|
||||
);
|
||||
for (const name of this.names) {
|
||||
const exportInfo = exportsInfo.getReadOnlyExportInfo(name);
|
||||
const exportInfo = /** @type {ExportInfo} */ (
|
||||
exportsInfo.getReadOnlyExportInfo(name)
|
||||
);
|
||||
const used = exportInfo.getUsed(runtime);
|
||||
if (used === UsageState.Unused) return Dependency.NO_EXPORTS_REFERENCED;
|
||||
if (used !== UsageState.OnlyPropertiesUsed) return getFullResult();
|
||||
|
@ -182,14 +189,17 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|||
);
|
||||
if (reexportInfo) {
|
||||
return {
|
||||
exports: Array.from(reexportInfo.exports, name => {
|
||||
exports: Array.from(
|
||||
/** @type {TODO} */ (reexportInfo).exports,
|
||||
name => {
|
||||
return {
|
||||
name,
|
||||
from,
|
||||
export: ids.concat(name),
|
||||
canMangle: !(name in EMPTY_OBJECT) && false
|
||||
};
|
||||
}),
|
||||
}
|
||||
),
|
||||
// TODO handle deep reexports
|
||||
dependencies: [from.module]
|
||||
};
|
||||
|
@ -208,19 +218,21 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|||
* @param {ModuleGraph} moduleGraph the module graph
|
||||
* @param {RuntimeSpec} runtime the runtime
|
||||
* @param {Module} importedModule the imported module (optional)
|
||||
* @returns {{exports?: Set<string>, checked?: Set<string>}} information
|
||||
* @returns {{exports?: Set<string>, checked?: Set<string>} | undefined} information
|
||||
*/
|
||||
getStarReexports(
|
||||
moduleGraph,
|
||||
runtime,
|
||||
importedModule = moduleGraph.getModule(this)
|
||||
importedModule = /** @type {Module} */ (moduleGraph.getModule(this))
|
||||
) {
|
||||
/** @type {ExportsInfo | undefined} */
|
||||
let importedExportsInfo = moduleGraph.getExportsInfo(importedModule);
|
||||
const ids = this.getIds(moduleGraph);
|
||||
if (ids.length > 0)
|
||||
importedExportsInfo = importedExportsInfo.getNestedExportsInfo(ids);
|
||||
/** @type {ExportsInfo | undefined} */
|
||||
let exportsInfo = moduleGraph.getExportsInfo(
|
||||
moduleGraph.getParentModule(this)
|
||||
/** @type {Module} */ (moduleGraph.getParentModule(this))
|
||||
);
|
||||
if (this.names.length > 0)
|
||||
exportsInfo = exportsInfo.getNestedExportsInfo(this.names);
|
||||
|
@ -245,7 +257,8 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|||
const checked = new Set();
|
||||
|
||||
if (noExtraImports) {
|
||||
for (const exportInfo of exportsInfo.orderedExports) {
|
||||
for (const exportInfo of /** @type {ExportsInfo} */ (exportsInfo)
|
||||
.orderedExports) {
|
||||
const name = exportInfo.name;
|
||||
if (exportInfo.getUsed(runtime) === UsageState.Unused) continue;
|
||||
if (name === "__esModule" && isNamespaceImport) {
|
||||
|
@ -263,7 +276,9 @@ class CommonJsExportRequireDependency extends ModuleDependency {
|
|||
}
|
||||
}
|
||||
} else if (noExtraExports) {
|
||||
for (const importedExportInfo of importedExportsInfo.orderedExports) {
|
||||
for (const importedExportInfo of /** @type {ExportsInfo} */ (
|
||||
importedExportsInfo
|
||||
).orderedExports) {
|
||||
const name = importedExportInfo.name;
|
||||
if (importedExportInfo.provided === false) continue;
|
||||
if (exportsInfo) {
|
||||
|
|
|
@ -26,7 +26,7 @@ const EMPTY_OBJECT = {};
|
|||
class CommonJsExportsDependency extends NullDependency {
|
||||
/**
|
||||
* @param {Range} range range
|
||||
* @param {Range} valueRange value range
|
||||
* @param {Range | null} valueRange value range
|
||||
* @param {CommonJSDependencyBaseKeywords} base base
|
||||
* @param {string[]} names names
|
||||
*/
|
||||
|
@ -154,20 +154,28 @@ CommonJsExportsDependency.Template = class CommonJsExportsDependencyTemplate ext
|
|||
);
|
||||
source.replace(
|
||||
dep.range[0],
|
||||
dep.valueRange[0] - 1,
|
||||
/** @type {Range} */ (dep.valueRange)[0] - 1,
|
||||
"__webpack_unused_export__ = ("
|
||||
);
|
||||
source.replace(dep.valueRange[1], dep.range[1] - 1, ")");
|
||||
source.replace(
|
||||
/** @type {Range} */ (dep.valueRange)[1],
|
||||
dep.range[1] - 1,
|
||||
")"
|
||||
);
|
||||
return;
|
||||
}
|
||||
source.replace(
|
||||
dep.range[0],
|
||||
dep.valueRange[0] - 1,
|
||||
/** @type {Range} */ (dep.valueRange)[0] - 1,
|
||||
`Object.defineProperty(${base}${propertyAccess(
|
||||
used.slice(0, -1)
|
||||
)}, ${JSON.stringify(used[used.length - 1])}, (`
|
||||
);
|
||||
source.replace(dep.valueRange[1], dep.range[1] - 1, "))");
|
||||
source.replace(
|
||||
/** @type {Range} */ (dep.valueRange)[1],
|
||||
dep.range[1] - 1,
|
||||
"))"
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,11 +20,12 @@ const ModuleDecoratorDependency = require("./ModuleDecoratorDependency");
|
|||
/** @typedef {import("estree").CallExpression} CallExpression */
|
||||
/** @typedef {import("estree").Expression} Expression */
|
||||
/** @typedef {import("estree").Super} Super */
|
||||
|
||||
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../NormalModule")} NormalModule */
|
||||
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
|
||||
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {import("./CommonJsDependencyHelpers").CommonJSDependencyBaseKeywords} CommonJSDependencyBaseKeywords */
|
||||
|
||||
/**
|
||||
|
@ -190,7 +191,7 @@ class CommonJsExportsParserPlugin {
|
|||
* @param {AssignmentExpression} expr expression
|
||||
* @param {CommonJSDependencyBaseKeywords} base commonjs base keywords
|
||||
* @param {string[]} members members of the export
|
||||
* @returns {boolean} true, when the expression was handled
|
||||
* @returns {boolean | undefined} true, when the expression was handled
|
||||
*/
|
||||
const handleAssignExport = (expr, base, members) => {
|
||||
if (HarmonyExports.isEnabled(parser.state)) return;
|
||||
|
@ -205,15 +206,15 @@ class CommonJsExportsParserPlugin {
|
|||
// It's possible to reexport __esModule, so we must convert to a dynamic module
|
||||
if (members.length === 0) DynamicExports.setDynamic(parser.state);
|
||||
const dep = new CommonJsExportRequireDependency(
|
||||
expr.range,
|
||||
/** @type {Range} */ (expr.range),
|
||||
null,
|
||||
base,
|
||||
members,
|
||||
requireCall.argument.string,
|
||||
/** @type {string} */ (requireCall.argument.string),
|
||||
requireCall.ids,
|
||||
!parser.isStatementLevelExpression(expr)
|
||||
);
|
||||
dep.loc = expr.loc;
|
||||
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||
dep.optional = !!parser.scope.inTry;
|
||||
parser.state.module.addDependency(dep);
|
||||
return true;
|
||||
|
@ -228,12 +229,12 @@ class CommonJsExportsParserPlugin {
|
|||
expr.right
|
||||
);
|
||||
const dep = new CommonJsExportsDependency(
|
||||
expr.left.range,
|
||||
/** @type {Range} */ (expr.left.range),
|
||||
null,
|
||||
base,
|
||||
remainingMembers
|
||||
);
|
||||
dep.loc = expr.loc;
|
||||
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||
parser.state.module.addDependency(dep);
|
||||
parser.walkExpression(expr.right);
|
||||
return true;
|
||||
|
@ -284,12 +285,12 @@ class CommonJsExportsParserPlugin {
|
|||
getValueOfPropertyDescription(descArg)
|
||||
);
|
||||
const dep = new CommonJsExportsDependency(
|
||||
expr.range,
|
||||
expr.arguments[2].range,
|
||||
/** @type {Range} */ (expr.range),
|
||||
/** @type {Range} */ (expr.arguments[2].range),
|
||||
`Object.defineProperty(${exportsArg.identifier})`,
|
||||
[property]
|
||||
);
|
||||
dep.loc = expr.loc;
|
||||
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||
parser.state.module.addDependency(dep);
|
||||
|
||||
parser.walkExpression(expr.arguments[2]);
|
||||
|
@ -308,24 +309,28 @@ class CommonJsExportsParserPlugin {
|
|||
const handleAccessExport = (expr, base, members, call = undefined) => {
|
||||
if (HarmonyExports.isEnabled(parser.state)) return;
|
||||
if (members.length === 0) {
|
||||
bailout(`${base} is used directly at ${formatLocation(expr.loc)}`);
|
||||
bailout(
|
||||
`${base} is used directly at ${formatLocation(
|
||||
/** @type {DependencyLocation} */ (expr.loc)
|
||||
)}`
|
||||
);
|
||||
}
|
||||
if (call && members.length === 1) {
|
||||
bailoutHint(
|
||||
`${base}${propertyAccess(
|
||||
members
|
||||
)}(...) prevents optimization as ${base} is passed as call context at ${formatLocation(
|
||||
expr.loc
|
||||
/** @type {DependencyLocation} */ (expr.loc)
|
||||
)}`
|
||||
);
|
||||
}
|
||||
const dep = new CommonJsSelfReferenceDependency(
|
||||
expr.range,
|
||||
/** @type {Range} */ (expr.range),
|
||||
base,
|
||||
members,
|
||||
!!call
|
||||
);
|
||||
dep.loc = expr.loc;
|
||||
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||
parser.state.module.addDependency(dep);
|
||||
if (call) {
|
||||
parser.walkExpressions(call.arguments);
|
||||
|
@ -398,7 +403,7 @@ class CommonJsExportsParserPlugin {
|
|||
: RuntimeGlobals.nodeModuleDecorator,
|
||||
!isHarmony
|
||||
);
|
||||
dep.loc = expr.loc;
|
||||
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||
parser.state.module.addDependency(dep);
|
||||
return true;
|
||||
});
|
||||
|
|
|
@ -10,8 +10,10 @@ const { parseResource } = require("../util/identifier");
|
|||
/** @typedef {import("estree").Node} EsTreeNode */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptions */
|
||||
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
||||
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
|
||||
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {import("./ContextDependency")} ContextDependency */
|
||||
/** @typedef {import("./ContextDependency").ContextDependencyOptions} ContextDependencyOptions */
|
||||
|
||||
|
@ -24,6 +26,10 @@ const quoteMeta = str => {
|
|||
return str.replace(/[-[\]\\/{}()*+?.^$|]/g, "\\$&");
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} prefix prefix
|
||||
* @returns {{prefix: string, context: string}} result
|
||||
*/
|
||||
const splitContextFromPrefix = prefix => {
|
||||
const idx = prefix.lastIndexOf("/");
|
||||
let context = ".";
|
||||
|
@ -38,7 +44,6 @@ const splitContextFromPrefix = prefix => {
|
|||
};
|
||||
|
||||
/** @typedef {Partial<Omit<ContextDependencyOptions, "resource">>} PartialContextDependencyOptions */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {{ new(options: ContextDependencyOptions, range: Range, valueRange: [number, number], ...args: any[]): ContextDependency }} ContextDependencyConstructor */
|
||||
|
||||
/**
|
||||
|
@ -63,13 +68,13 @@ exports.create = (
|
|||
...depArgs
|
||||
) => {
|
||||
if (param.isTemplateString()) {
|
||||
let prefixRaw = param.quasis[0].string;
|
||||
const quasis = /** @type {BasicEvaluatedExpression[]} */ (param.quasis);
|
||||
let prefixRaw = /** @type {string} */ (quasis[0].string);
|
||||
let postfixRaw =
|
||||
param.quasis.length > 1
|
||||
? param.quasis[param.quasis.length - 1].string
|
||||
: "";
|
||||
/** @type {string} */
|
||||
(quasis.length > 1 ? quasis[quasis.length - 1].string : "");
|
||||
|
||||
const valueRange = param.range;
|
||||
const valueRange = /** @type {Range} */ (param.range);
|
||||
const { context, prefix } = splitContextFromPrefix(prefixRaw);
|
||||
const {
|
||||
path: postfix,
|
||||
|
@ -79,11 +84,15 @@ exports.create = (
|
|||
|
||||
// When there are more than two quasis, the generated RegExp can be more precise
|
||||
// We join the quasis with the expression regexp
|
||||
const innerQuasis = param.quasis.slice(1, param.quasis.length - 1);
|
||||
const innerQuasis = quasis.slice(1, quasis.length - 1);
|
||||
const innerRegExp =
|
||||
options.wrappedContextRegExp.source +
|
||||
/** @type {RegExp} */ (options.wrappedContextRegExp).source +
|
||||
innerQuasis
|
||||
.map(q => quoteMeta(q.string) + options.wrappedContextRegExp.source)
|
||||
.map(
|
||||
q =>
|
||||
quoteMeta(/** @type {string} */ (q.string)) +
|
||||
/** @type {RegExp} */ (options.wrappedContextRegExp).source
|
||||
)
|
||||
.join("");
|
||||
|
||||
// Example: `./context/pre${e}inner${e}inner2${e}post?query#frag`
|
||||
|
@ -101,7 +110,7 @@ exports.create = (
|
|||
const dep = new Dep(
|
||||
{
|
||||
request: context + query + fragment,
|
||||
recursive: options.wrappedContextRecursive,
|
||||
recursive: /** @type {boolean} */ (options.wrappedContextRecursive),
|
||||
regExp,
|
||||
mode: "sync",
|
||||
...contextOptions
|
||||
|
@ -110,14 +119,17 @@ exports.create = (
|
|||
valueRange,
|
||||
...depArgs
|
||||
);
|
||||
dep.loc = expr.loc;
|
||||
const replaces = [];
|
||||
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||
|
||||
param.parts.forEach((part, i) => {
|
||||
/** @type {{ value: string, range: Range }[]} */
|
||||
const replaces = [];
|
||||
const parts = /** @type {BasicEvaluatedExpression[]} */ (param.parts);
|
||||
|
||||
parts.forEach((part, i) => {
|
||||
if (i % 2 === 0) {
|
||||
// Quasis or merged quasi
|
||||
let range = part.range;
|
||||
let value = part.string;
|
||||
let range = /** @type {Range} */ (part.range);
|
||||
let value = /** @type {string} */ (part.string);
|
||||
if (param.templateStringKind === "cooked") {
|
||||
value = JSON.stringify(value);
|
||||
value = value.slice(1, value.length - 1);
|
||||
|
@ -125,14 +137,20 @@ exports.create = (
|
|||
if (i === 0) {
|
||||
// prefix
|
||||
value = prefix;
|
||||
range = [param.range[0], part.range[1]];
|
||||
range = [
|
||||
/** @type {Range} */ (param.range)[0],
|
||||
/** @type {Range} */ (part.range)[1]
|
||||
];
|
||||
value =
|
||||
(param.templateStringKind === "cooked" ? "`" : "String.raw`") +
|
||||
value;
|
||||
} else if (i === param.parts.length - 1) {
|
||||
} else if (i === parts.length - 1) {
|
||||
// postfix
|
||||
value = postfix;
|
||||
range = [part.range[0], param.range[1]];
|
||||
range = [
|
||||
/** @type {Range} */ (part.range)[0],
|
||||
/** @type {Range} */ (param.range)[1]
|
||||
];
|
||||
value = value + "`";
|
||||
} else if (
|
||||
part.expression &&
|
||||
|
@ -163,14 +181,16 @@ exports.create = (
|
|||
(param.postfix && param.postfix.isString()))
|
||||
) {
|
||||
let prefixRaw =
|
||||
param.prefix && param.prefix.isString() ? param.prefix.string : "";
|
||||
/** @type {string} */
|
||||
(param.prefix && param.prefix.isString() ? param.prefix.string : "");
|
||||
let postfixRaw =
|
||||
param.postfix && param.postfix.isString() ? param.postfix.string : "";
|
||||
/** @type {string} */
|
||||
(param.postfix && param.postfix.isString() ? param.postfix.string : "");
|
||||
const prefixRange =
|
||||
param.prefix && param.prefix.isString() ? param.prefix.range : null;
|
||||
const postfixRange =
|
||||
param.postfix && param.postfix.isString() ? param.postfix.range : null;
|
||||
const valueRange = param.range;
|
||||
const valueRange = /** @type {Range} */ (param.range);
|
||||
const { context, prefix } = splitContextFromPrefix(prefixRaw);
|
||||
const {
|
||||
path: postfix,
|
||||
|
@ -178,14 +198,14 @@ exports.create = (
|
|||
fragment
|
||||
} = parseResource(postfixRaw, parser);
|
||||
const regExp = new RegExp(
|
||||
`^${quoteMeta(prefix)}${options.wrappedContextRegExp.source}${quoteMeta(
|
||||
postfix
|
||||
)}$`
|
||||
`^${quoteMeta(prefix)}${
|
||||
/** @type {RegExp} */ (options.wrappedContextRegExp).source
|
||||
}${quoteMeta(postfix)}$`
|
||||
);
|
||||
const dep = new Dep(
|
||||
{
|
||||
request: context + query + fragment,
|
||||
recursive: options.wrappedContextRecursive,
|
||||
recursive: /** @type {boolean} */ (options.wrappedContextRecursive),
|
||||
regExp,
|
||||
mode: "sync",
|
||||
...contextOptions
|
||||
|
@ -194,7 +214,7 @@ exports.create = (
|
|||
valueRange,
|
||||
...depArgs
|
||||
);
|
||||
dep.loc = expr.loc;
|
||||
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||
const replaces = [];
|
||||
if (prefixRange) {
|
||||
replaces.push({
|
||||
|
@ -223,17 +243,17 @@ exports.create = (
|
|||
} else {
|
||||
const dep = new Dep(
|
||||
{
|
||||
request: options.exprContextRequest,
|
||||
recursive: options.exprContextRecursive,
|
||||
request: /** @type {string} */ (options.exprContextRequest),
|
||||
recursive: /** @type {boolean} */ (options.exprContextRecursive),
|
||||
regExp: /** @type {RegExp} */ (options.exprContextRegExp),
|
||||
mode: "sync",
|
||||
...contextOptions
|
||||
},
|
||||
range,
|
||||
param.range,
|
||||
/** @type {Range} */ (param.range),
|
||||
...depArgs
|
||||
);
|
||||
dep.loc = expr.loc;
|
||||
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||
dep.critical =
|
||||
options.exprContextCritical &&
|
||||
"the request of a dependency is an expression";
|
||||
|
|
|
@ -34,11 +34,11 @@ const NullDependency = require("./NullDependency");
|
|||
* @returns {string} local ident
|
||||
*/
|
||||
const getLocalIdent = (local, module, chunkGraph, runtimeTemplate) => {
|
||||
const localIdentName = /** @type {CssGenerator | CssExportsGenerator} */ (
|
||||
module.generator
|
||||
).localIdentName;
|
||||
const localIdentName =
|
||||
/** @type {CssGenerator | CssExportsGenerator} */
|
||||
(module.generator).localIdentName;
|
||||
const relativeResourcePath = makePathsRelative(
|
||||
module.context,
|
||||
/** @type {string} */ (module.context),
|
||||
module.resourceResolveData.path
|
||||
);
|
||||
const { hashFunction, hashDigest, hashDigestLength, hashSalt, uniqueName } =
|
||||
|
|
|
@ -25,13 +25,13 @@ const NullDependency = require("./NullDependency");
|
|||
/**
|
||||
* @param {ModuleGraph} moduleGraph the module graph
|
||||
* @param {Module} module the module
|
||||
* @param {string[] | null} exportName name of the export if any
|
||||
* @param {string[] | null} _exportName name of the export if any
|
||||
* @param {string | null} property name of the requested property
|
||||
* @param {RuntimeSpec} runtime for which runtime
|
||||
* @returns {any} value of the property
|
||||
*/
|
||||
const getProperty = (moduleGraph, module, exportName, property, runtime) => {
|
||||
if (!exportName) {
|
||||
const getProperty = (moduleGraph, module, _exportName, property, runtime) => {
|
||||
if (!_exportName) {
|
||||
switch (property) {
|
||||
case "usedExports": {
|
||||
const usedExports = moduleGraph
|
||||
|
@ -48,6 +48,7 @@ const getProperty = (moduleGraph, module, exportName, property, runtime) => {
|
|||
}
|
||||
}
|
||||
}
|
||||
const exportName = /** @type {string[]} */ (_exportName);
|
||||
switch (property) {
|
||||
case "canMangle": {
|
||||
const exportsInfo = moduleGraph.getExportsInfo(module);
|
||||
|
|
|
@ -56,7 +56,9 @@ class ExternalModuleInitFragment extends InitFragment {
|
|||
const newSpecifiersMap = new Map(this.specifiers);
|
||||
for (const [name, specifiers] of other.specifiers) {
|
||||
if (newSpecifiersMap.has(name)) {
|
||||
const currentSpecifiers = newSpecifiersMap.get(name);
|
||||
const currentSpecifiers =
|
||||
/** @type {Set<string>} */
|
||||
(newSpecifiersMap.get(name));
|
||||
for (const spec of specifiers) currentSpecifiers.add(spec);
|
||||
} else {
|
||||
newSpecifiersMap.set(name, specifiers);
|
||||
|
@ -71,7 +73,7 @@ class ExternalModuleInitFragment extends InitFragment {
|
|||
|
||||
/**
|
||||
* @param {GenerateContext} context context
|
||||
* @returns {string | Source} the source code that will be included as initialization code
|
||||
* @returns {string | Source | undefined} the source code that will be included as initialization code
|
||||
*/
|
||||
getContent({ runtimeRequirements }) {
|
||||
const namedImports = [];
|
||||
|
|
|
@ -18,8 +18,10 @@ const {
|
|||
} = require("./HarmonyImportDependencyParserPlugin");
|
||||
const HarmonyImportSideEffectDependency = require("./HarmonyImportSideEffectDependency");
|
||||
|
||||
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
||||
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
||||
/** @typedef {import("../javascript/JavascriptParser").FunctionDeclaration} FunctionDeclaration */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
|
||||
const { HarmonyStarExportsList } = HarmonyExportImportedSpecifierDependency;
|
||||
|
||||
|
@ -48,10 +50,14 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|||
"HarmonyExportDependencyParserPlugin",
|
||||
statement => {
|
||||
const dep = new HarmonyExportHeaderDependency(
|
||||
statement.declaration && statement.declaration.range,
|
||||
statement.range
|
||||
/** @type {Range | false} */ (
|
||||
statement.declaration && statement.declaration.range
|
||||
),
|
||||
/** @type {Range} */ (statement.range)
|
||||
);
|
||||
dep.loc = Object.create(
|
||||
/** @type {DependencyLocation} */ (statement.loc)
|
||||
);
|
||||
dep.loc = Object.create(statement.loc);
|
||||
dep.loc.index = -1;
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
return true;
|
||||
|
@ -62,8 +68,11 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|||
(statement, source) => {
|
||||
parser.state.lastHarmonyImportOrder =
|
||||
(parser.state.lastHarmonyImportOrder || 0) + 1;
|
||||
const clearDep = new ConstDependency("", statement.range);
|
||||
clearDep.loc = Object.create(statement.loc);
|
||||
const clearDep = new ConstDependency(
|
||||
"",
|
||||
/** @type {Range} */ (statement.range)
|
||||
);
|
||||
clearDep.loc = /** @type {DependencyLocation} */ (statement.loc);
|
||||
clearDep.loc.index = -1;
|
||||
parser.state.module.addPresentationalDependency(clearDep);
|
||||
const sideEffectDep = new HarmonyImportSideEffectDependency(
|
||||
|
@ -71,7 +80,9 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|||
parser.state.lastHarmonyImportOrder,
|
||||
getAttributes(statement)
|
||||
);
|
||||
sideEffectDep.loc = Object.create(statement.loc);
|
||||
sideEffectDep.loc = Object.create(
|
||||
/** @type {DependencyLocation} */ (statement.loc)
|
||||
);
|
||||
sideEffectDep.loc.index = -1;
|
||||
parser.state.current.addDependency(sideEffectDep);
|
||||
return true;
|
||||
|
@ -81,13 +92,12 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|||
"HarmonyExportDependencyParserPlugin",
|
||||
(statement, expr) => {
|
||||
const isFunctionDeclaration = expr.type === "FunctionDeclaration";
|
||||
const comments = parser.getComments([
|
||||
statement.range[0],
|
||||
expr.range[0]
|
||||
]);
|
||||
const exprRange = /** @type {Range} */ (expr.range);
|
||||
const statementRange = /** @type {Range} */ (statement.range);
|
||||
const comments = parser.getComments([statementRange[0], exprRange[0]]);
|
||||
const dep = new HarmonyExportExpressionDependency(
|
||||
expr.range,
|
||||
statement.range,
|
||||
exprRange,
|
||||
statementRange,
|
||||
comments
|
||||
.map(c => {
|
||||
switch (c.type) {
|
||||
|
@ -104,10 +114,10 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|||
: isFunctionDeclaration
|
||||
? {
|
||||
range: [
|
||||
expr.range[0],
|
||||
exprRange[0],
|
||||
expr.params.length > 0
|
||||
? expr.params[0].range[0]
|
||||
: expr.body.range[0]
|
||||
? /** @type {Range} */ (expr.params[0].range)[0]
|
||||
: /** @type {Range} */ (expr.body.range)[0]
|
||||
],
|
||||
prefix: `${expr.async ? "async " : ""}function${
|
||||
expr.generator ? "*" : ""
|
||||
|
@ -116,7 +126,9 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|||
}
|
||||
: undefined
|
||||
);
|
||||
dep.loc = Object.create(statement.loc);
|
||||
dep.loc = Object.create(
|
||||
/** @type {DependencyLocation} */ (statement.loc)
|
||||
);
|
||||
dep.loc.index = -1;
|
||||
parser.state.current.addDependency(dep);
|
||||
InnerGraph.addVariableUsage(
|
||||
|
@ -153,7 +165,9 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|||
} else {
|
||||
dep = new HarmonyExportSpecifierDependency(id, name);
|
||||
}
|
||||
dep.loc = Object.create(statement.loc);
|
||||
dep.loc = Object.create(
|
||||
/** @type {DependencyLocation} */ (statement.loc)
|
||||
);
|
||||
dep.loc.index = idx;
|
||||
parser.state.current.addDependency(dep);
|
||||
return true;
|
||||
|
@ -184,7 +198,9 @@ module.exports = class HarmonyExportDependencyParserPlugin {
|
|||
if (harmonyStarExports) {
|
||||
harmonyStarExports.push(dep);
|
||||
}
|
||||
dep.loc = Object.create(statement.loc);
|
||||
dep.loc = Object.create(
|
||||
/** @type {DependencyLocation} */ (statement.loc)
|
||||
);
|
||||
dep.loc.index = idx;
|
||||
parser.state.current.addDependency(dep);
|
||||
return true;
|
||||
|
|
|
@ -17,7 +17,7 @@ const NullDependency = require("./NullDependency");
|
|||
|
||||
class HarmonyExportHeaderDependency extends NullDependency {
|
||||
/**
|
||||
* @param {Range} range range
|
||||
* @param {Range | false} range range
|
||||
* @param {Range} rangeStatement range statement
|
||||
*/
|
||||
constructor(range, rangeStatement) {
|
||||
|
|
|
@ -31,7 +31,10 @@ const processExportInfo = require("./processExportInfo");
|
|||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../ExportsInfo")} ExportsInfo */
|
||||
/** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
|
||||
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
||||
/** @typedef {import("../Module")} Module */
|
||||
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
||||
/** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
||||
/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
||||
|
@ -177,7 +180,7 @@ const getMode = (moduleGraph, dep, runtimeKey) => {
|
|||
|
||||
const name = dep.name;
|
||||
const runtime = keyToRuntime(runtimeKey);
|
||||
const parentModule = moduleGraph.getParentModule(dep);
|
||||
const parentModule = /** @type {Module} */ (moduleGraph.getParentModule(dep));
|
||||
const exportsInfo = moduleGraph.getExportsInfo(parentModule);
|
||||
|
||||
if (
|
||||
|
@ -194,7 +197,7 @@ const getMode = (moduleGraph, dep, runtimeKey) => {
|
|||
|
||||
const importedExportsType = importedModule.getExportsType(
|
||||
moduleGraph,
|
||||
parentModule.buildMeta.strictHarmonyModule
|
||||
/** @type {BuildMeta} */ (parentModule.buildMeta).strictHarmonyModule
|
||||
);
|
||||
|
||||
const ids = dep.getIds(moduleGraph);
|
||||
|
@ -423,11 +426,12 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|||
getStarReexports(
|
||||
moduleGraph,
|
||||
runtime,
|
||||
exportsInfo = moduleGraph.getExportsInfo(moduleGraph.getParentModule(this)),
|
||||
importedModule = moduleGraph.getModule(this)
|
||||
exportsInfo = moduleGraph.getExportsInfo(
|
||||
/** @type {Module} */ (moduleGraph.getParentModule(this))
|
||||
),
|
||||
importedModule = /** @type {Module} */ (moduleGraph.getModule(this))
|
||||
) {
|
||||
const importedExportsInfo = moduleGraph.getExportsInfo(importedModule);
|
||||
|
||||
const noExtraExports =
|
||||
importedExportsInfo.otherExportsInfo.provided === false;
|
||||
const noExtraImports =
|
||||
|
@ -457,7 +461,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|||
const exports = new Set();
|
||||
/** @type {Set<string>} */
|
||||
const checked = new Set();
|
||||
/** @type {Set<string>} */
|
||||
/** @type {Set<string> | undefined} */
|
||||
const hidden = hiddenExports !== undefined ? new Set() : undefined;
|
||||
|
||||
if (noExtraImports) {
|
||||
|
@ -469,7 +473,8 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|||
importedExportsInfo.getReadOnlyExportInfo(name);
|
||||
if (importedExportInfo.provided === false) continue;
|
||||
if (hiddenExports !== undefined && hiddenExports.has(name)) {
|
||||
hidden.add(name);
|
||||
/** @type {Set<string>} */
|
||||
(hidden).add(name);
|
||||
continue;
|
||||
}
|
||||
exports.add(name);
|
||||
|
@ -484,7 +489,8 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|||
const exportInfo = exportsInfo.getReadOnlyExportInfo(name);
|
||||
if (exportInfo.getUsed(runtime) === UsageState.Unused) continue;
|
||||
if (hiddenExports !== undefined && hiddenExports.has(name)) {
|
||||
hidden.add(name);
|
||||
/** @type {Set<string>} */
|
||||
(hidden).add(name);
|
||||
continue;
|
||||
}
|
||||
exports.add(name);
|
||||
|
@ -634,7 +640,9 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|||
case "missing":
|
||||
return undefined;
|
||||
case "dynamic-reexport": {
|
||||
const from = moduleGraph.getConnection(this);
|
||||
const from =
|
||||
/** @type {ModuleGraphConnection} */
|
||||
(moduleGraph.getConnection(this));
|
||||
return {
|
||||
exports: true,
|
||||
from,
|
||||
|
@ -650,11 +658,13 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|||
return {
|
||||
exports: [],
|
||||
hideExports: mode.hidden,
|
||||
dependencies: [moduleGraph.getModule(this)]
|
||||
dependencies: [/** @type {Module} */ (moduleGraph.getModule(this))]
|
||||
};
|
||||
// falls through
|
||||
case "normal-reexport": {
|
||||
const from = moduleGraph.getConnection(this);
|
||||
const from =
|
||||
/** @type {ModuleGraphConnection} */
|
||||
(moduleGraph.getConnection(this));
|
||||
return {
|
||||
exports: Array.from(mode.items, item => ({
|
||||
name: item.name,
|
||||
|
@ -668,11 +678,13 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|||
}
|
||||
case "reexport-dynamic-default": {
|
||||
{
|
||||
const from = moduleGraph.getConnection(this);
|
||||
const from =
|
||||
/** @type {ModuleGraphConnection} */
|
||||
(moduleGraph.getConnection(this));
|
||||
return {
|
||||
exports: [
|
||||
{
|
||||
name: mode.name,
|
||||
name: /** @type {string} */ (mode.name),
|
||||
from,
|
||||
export: ["default"]
|
||||
}
|
||||
|
@ -684,15 +696,17 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|||
}
|
||||
case "reexport-undefined":
|
||||
return {
|
||||
exports: [mode.name],
|
||||
dependencies: [moduleGraph.getModule(this)]
|
||||
exports: [/** @type {string} */ (mode.name)],
|
||||
dependencies: [/** @type {Module} */ (moduleGraph.getModule(this))]
|
||||
};
|
||||
case "reexport-fake-namespace-object": {
|
||||
const from = moduleGraph.getConnection(this);
|
||||
const from =
|
||||
/** @type {ModuleGraphConnection} */
|
||||
(moduleGraph.getConnection(this));
|
||||
return {
|
||||
exports: [
|
||||
{
|
||||
name: mode.name,
|
||||
name: /** @type {string} */ (mode.name),
|
||||
from,
|
||||
export: null,
|
||||
exports: [
|
||||
|
@ -710,11 +724,13 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|||
};
|
||||
}
|
||||
case "reexport-namespace-object": {
|
||||
const from = moduleGraph.getConnection(this);
|
||||
const from =
|
||||
/** @type {ModuleGraphConnection} */
|
||||
(moduleGraph.getConnection(this));
|
||||
return {
|
||||
exports: [
|
||||
{
|
||||
name: mode.name,
|
||||
name: /** @type {string} */ (mode.name),
|
||||
from,
|
||||
export: null
|
||||
}
|
||||
|
@ -724,11 +740,13 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|||
};
|
||||
}
|
||||
case "reexport-named-default": {
|
||||
const from = moduleGraph.getConnection(this);
|
||||
const from =
|
||||
/** @type {ModuleGraphConnection} */
|
||||
(moduleGraph.getConnection(this));
|
||||
return {
|
||||
exports: [
|
||||
{
|
||||
name: mode.name,
|
||||
name: /** @type {string} */ (mode.name),
|
||||
from,
|
||||
export: ["default"]
|
||||
}
|
||||
|
@ -749,7 +767,8 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|||
_getEffectiveExportPresenceLevel(moduleGraph) {
|
||||
if (this.exportPresenceMode !== ExportPresenceModes.AUTO)
|
||||
return this.exportPresenceMode;
|
||||
return moduleGraph.getParentModule(this).buildMeta.strictHarmonyModule
|
||||
const module = /** @type {Module} */ (moduleGraph.getParentModule(this));
|
||||
return /** @type {BuildMeta} */ (module.buildMeta).strictHarmonyModule
|
||||
? ExportPresenceModes.ERROR
|
||||
: ExportPresenceModes.WARN;
|
||||
}
|
||||
|
@ -827,7 +846,7 @@ class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency {
|
|||
);
|
||||
if (conflictingModule === importedModule) continue;
|
||||
const conflictingExportInfo = moduleGraph.getExportInfo(
|
||||
conflictingModule,
|
||||
/** @type {Module} */ (conflictingModule),
|
||||
exportInfo.name
|
||||
);
|
||||
const conflictingTarget =
|
||||
|
@ -949,14 +968,14 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {InitFragment[]} initFragments target array for init fragments
|
||||
* @param {InitFragment<GenerateContext>[]} initFragments target array for init fragments
|
||||
* @param {HarmonyExportImportedSpecifierDependency} dep dependency
|
||||
* @param {ExportMode} mode the export mode
|
||||
* @param {Module} module the current module
|
||||
* @param {ModuleGraph} moduleGraph the module graph
|
||||
* @param {RuntimeSpec} runtime the runtime
|
||||
* @param {RuntimeTemplate} runtimeTemplate the runtime template
|
||||
* @param {Set<string>} runtimeRequirements runtime requirements
|
||||
* @param {RuntimeRequirements} runtimeRequirements runtime requirements
|
||||
* @returns {void}
|
||||
*/
|
||||
_addExportFragments(
|
||||
|
@ -969,7 +988,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|||
runtimeTemplate,
|
||||
runtimeRequirements
|
||||
) {
|
||||
const importedModule = moduleGraph.getModule(dep);
|
||||
const importedModule = /** @type {Module} */ (moduleGraph.getModule(dep));
|
||||
const importVar = dep.getImportVar(moduleGraph);
|
||||
|
||||
switch (mode.type) {
|
||||
|
@ -1170,6 +1189,14 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|||
return new HarmonyExportInitFragment(module.exportsArgument, map);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Module} module module
|
||||
* @param {string | string[] | false} key key
|
||||
* @param {string} name name
|
||||
* @param {number} fakeType fake type
|
||||
* @param {RuntimeRequirements} runtimeRequirements runtime requirements
|
||||
* @returns {[InitFragment<GenerateContext>, HarmonyExportInitFragment]} init fragments
|
||||
*/
|
||||
getReexportFakeNamespaceObjectFragments(
|
||||
module,
|
||||
key,
|
||||
|
@ -1200,6 +1227,14 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Module} module module
|
||||
* @param {string} key key
|
||||
* @param {string} name name
|
||||
* @param {string | string[] | false} valueKey value key
|
||||
* @param {RuntimeRequirements} runtimeRequirements runtime requirements
|
||||
* @returns {string} result
|
||||
*/
|
||||
getConditionalReexportStatement(
|
||||
module,
|
||||
key,
|
||||
|
@ -1227,6 +1262,11 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
|||
)}: function() { return ${returnValue}; } });\n`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} name name
|
||||
* @param {null | false | string | string[]} valueKey value key
|
||||
* @returns {string | undefined} value
|
||||
*/
|
||||
getReturnValue(name, valueKey) {
|
||||
if (valueKey === null) {
|
||||
return `${name}_default.a`;
|
||||
|
|
|
@ -13,6 +13,10 @@ const { propertyName } = require("../util/propertyName");
|
|||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
||||
|
||||
/**
|
||||
* @param {Iterable<string>} iterable iterable strings
|
||||
* @returns {string} result
|
||||
*/
|
||||
const joinIterableWithComma = iterable => {
|
||||
// This is more performant than Array.from().join(", ")
|
||||
// as it doesn't create an array
|
||||
|
@ -33,7 +37,7 @@ const EMPTY_MAP = new Map();
|
|||
const EMPTY_SET = new Set();
|
||||
|
||||
/**
|
||||
* @typedef {GenerateContext} Context
|
||||
* @extends {InitFragment<GenerateContext>} Context
|
||||
*/
|
||||
class HarmonyExportInitFragment extends InitFragment {
|
||||
/**
|
||||
|
@ -99,6 +103,10 @@ class HarmonyExportInitFragment extends InitFragment {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {HarmonyExportInitFragment} other other
|
||||
* @returns {HarmonyExportInitFragment} merged result
|
||||
*/
|
||||
merge(other) {
|
||||
let exportMap;
|
||||
if (this.exportMap.size === 0) {
|
||||
|
@ -131,7 +139,7 @@ class HarmonyExportInitFragment extends InitFragment {
|
|||
|
||||
/**
|
||||
* @param {GenerateContext} context context
|
||||
* @returns {string | Source} the source code that will be included as initialization code
|
||||
* @returns {string | Source | undefined} the source code that will be included as initialization code
|
||||
*/
|
||||
getContent({ runtimeTemplate, runtimeRequirements }) {
|
||||
runtimeRequirements.add(RuntimeGlobals.exports);
|
||||
|
|
|
@ -20,7 +20,9 @@ const ModuleDependency = require("./ModuleDependency");
|
|||
/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
||||
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
||||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../ExportsInfo")} ExportsInfo */
|
||||
/** @typedef {import("../Module")} Module */
|
||||
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
||||
/** @typedef {import("../WebpackError")} WebpackError */
|
||||
|
@ -35,6 +37,10 @@ const ExportPresenceModes = {
|
|||
WARN: /** @type {1} */ (1),
|
||||
AUTO: /** @type {2} */ (2),
|
||||
ERROR: /** @type {3} */ (3),
|
||||
/**
|
||||
* @param {string | false} str param
|
||||
* @returns {0 | 1 | 2 | 3} result
|
||||
*/
|
||||
fromUserOption(str) {
|
||||
switch (str) {
|
||||
case "error":
|
||||
|
@ -84,15 +90,20 @@ class HarmonyImportDependency extends ModuleDependency {
|
|||
*/
|
||||
getImportVar(moduleGraph) {
|
||||
const module = moduleGraph.getParentModule(this);
|
||||
const meta = moduleGraph.getMeta(module);
|
||||
const meta = /** @type {TODO} */ (moduleGraph.getMeta(module));
|
||||
let importVarMap = meta.importVarMap;
|
||||
if (!importVarMap) meta.importVarMap = importVarMap = new Map();
|
||||
let importVar = importVarMap.get(moduleGraph.getModule(this));
|
||||
let importVar = importVarMap.get(
|
||||
/** @type {Module} */ (moduleGraph.getModule(this))
|
||||
);
|
||||
if (importVar) return importVar;
|
||||
importVar = `${Template.toIdentifier(
|
||||
`${this.userRequest}`
|
||||
)}__WEBPACK_IMPORTED_MODULE_${importVarMap.size}__`;
|
||||
importVarMap.set(moduleGraph.getModule(this), importVar);
|
||||
importVarMap.set(
|
||||
/** @type {Module} */ (moduleGraph.getModule(this)),
|
||||
importVar
|
||||
);
|
||||
return importVar;
|
||||
}
|
||||
|
||||
|
@ -107,7 +118,7 @@ class HarmonyImportDependency extends ModuleDependency {
|
|||
) {
|
||||
return runtimeTemplate.importStatement({
|
||||
update,
|
||||
module: moduleGraph.getModule(this),
|
||||
module: /** @type {Module} */ (moduleGraph.getModule(this)),
|
||||
chunkGraph,
|
||||
importVar: this.getImportVar(moduleGraph),
|
||||
request: this.request,
|
||||
|
@ -129,10 +140,12 @@ class HarmonyImportDependency extends ModuleDependency {
|
|||
return;
|
||||
}
|
||||
|
||||
const parentModule = moduleGraph.getParentModule(this);
|
||||
const parentModule =
|
||||
/** @type {Module} */
|
||||
(moduleGraph.getParentModule(this));
|
||||
const exportsType = importedModule.getExportsType(
|
||||
moduleGraph,
|
||||
parentModule.buildMeta.strictHarmonyModule
|
||||
/** @type {BuildMeta} */ (parentModule.buildMeta).strictHarmonyModule
|
||||
);
|
||||
if (exportsType === "namespace" || exportsType === "default-with-named") {
|
||||
if (ids.length === 0) {
|
||||
|
@ -170,7 +183,9 @@ class HarmonyImportDependency extends ModuleDependency {
|
|||
)
|
||||
];
|
||||
}
|
||||
exportsInfo = exportInfo.getNestedExportsInfo();
|
||||
exportsInfo =
|
||||
/** @type {ExportsInfo} */
|
||||
(exportInfo.getNestedExportsInfo());
|
||||
}
|
||||
|
||||
// General error message
|
||||
|
@ -207,7 +222,8 @@ class HarmonyImportDependency extends ModuleDependency {
|
|||
if (
|
||||
ids.length > 0 &&
|
||||
ids[0] !== "default" &&
|
||||
importedModule.buildMeta.defaultObject === "redirect-warn"
|
||||
/** @type {BuildMeta} */
|
||||
(importedModule.buildMeta).defaultObject === "redirect-warn"
|
||||
) {
|
||||
// For these modules only the default export is supported
|
||||
return [
|
||||
|
|
|
@ -9,7 +9,14 @@ const makeSerializable = require("../util/makeSerializable");
|
|||
const ContextDependency = require("./ContextDependency");
|
||||
const ModuleDependencyTemplateAsRequireId = require("./ModuleDependencyTemplateAsRequireId");
|
||||
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {import("./ContextDependency").ContextDependencyOptions} ContextDependencyOptions */
|
||||
|
||||
class ImportMetaContextDependency extends ContextDependency {
|
||||
/**
|
||||
* @param {ContextDependencyOptions} options options
|
||||
* @param {Range} range range
|
||||
*/
|
||||
constructor(options, range) {
|
||||
super(options);
|
||||
|
||||
|
|
|
@ -16,8 +16,11 @@ const ImportMetaContextDependency = require("./ImportMetaContextDependency");
|
|||
/** @typedef {import("estree").Property} Property */
|
||||
/** @typedef {import("estree").SourceLocation} SourceLocation */
|
||||
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {import("../ContextModule").ContextModuleOptions} ContextModuleOptions */
|
||||
/** @typedef {import("../ChunkGroup").RawChunkGroupOptions} RawChunkGroupOptions */
|
||||
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
||||
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
|
||||
/** @typedef {Pick<ContextModuleOptions, 'mode'|'recursive'|'regExp'|'include'|'exclude'|'chunkName'>&{groupOptions: RawChunkGroupOptions, exports?: ContextModuleOptions["referencedExports"]}} ImportMetaContextOptions */
|
||||
|
||||
/**
|
||||
|
@ -36,7 +39,7 @@ function createPropertyParseError(prop, expect) {
|
|||
|
||||
/**
|
||||
* @param {string} msg message
|
||||
* @param {SourceLocation} loc location
|
||||
* @param {DependencyLocation} loc location
|
||||
* @returns {WebpackError} error
|
||||
*/
|
||||
function createError(msg, loc) {
|
||||
|
@ -72,7 +75,7 @@ module.exports = class ImportMetaContextDependencyParserPlugin {
|
|||
/** @type {Expression} */ (directoryNode)
|
||||
);
|
||||
if (!requestExpr.isString()) return;
|
||||
const request = requestExpr.string;
|
||||
const request = /** @type {string} */ (requestExpr.string);
|
||||
const errors = [];
|
||||
let regExp = /^\.\/.*$/;
|
||||
let recursive = true;
|
||||
|
@ -95,7 +98,7 @@ module.exports = class ImportMetaContextDependencyParserPlugin {
|
|||
errors.push(
|
||||
createError(
|
||||
"Parsing import.meta.webpackContext options failed.",
|
||||
optionsNode.loc
|
||||
/** @type {DependencyLocation} */ (optionsNode.loc)
|
||||
)
|
||||
);
|
||||
break;
|
||||
|
@ -108,7 +111,7 @@ module.exports = class ImportMetaContextDependencyParserPlugin {
|
|||
if (!regExpExpr.isRegExp()) {
|
||||
errors.push(createPropertyParseError(prop, "RegExp"));
|
||||
} else {
|
||||
regExp = regExpExpr.regExp;
|
||||
regExp = /** @type {RegExp} */ (regExpExpr.regExp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -163,21 +166,27 @@ module.exports = class ImportMetaContextDependencyParserPlugin {
|
|||
/** @type {Expression} */ (prop.value)
|
||||
);
|
||||
if (expr.isString()) {
|
||||
exports = [[expr.string]];
|
||||
exports = [[/** @type {string} */ (expr.string)]];
|
||||
} else if (expr.isArray()) {
|
||||
const items = expr.items;
|
||||
const items =
|
||||
/** @type {BasicEvaluatedExpression[]} */
|
||||
(expr.items);
|
||||
if (
|
||||
items.every(i => {
|
||||
if (!i.isArray()) return false;
|
||||
const innerItems = i.items;
|
||||
const innerItems =
|
||||
/** @type {BasicEvaluatedExpression[]} */ (i.items);
|
||||
return innerItems.every(i => i.isString());
|
||||
})
|
||||
) {
|
||||
exports = [];
|
||||
for (const i1 of items) {
|
||||
/** @type {string[]} */
|
||||
const export_ = [];
|
||||
for (const i2 of i1.items) {
|
||||
export_.push(i2.string);
|
||||
for (const i2 of /** @type {BasicEvaluatedExpression[]} */ (
|
||||
i1.items
|
||||
)) {
|
||||
export_.push(/** @type {string} */ (i2.string));
|
||||
}
|
||||
exports.push(export_);
|
||||
}
|
||||
|
@ -225,7 +234,9 @@ module.exports = class ImportMetaContextDependencyParserPlugin {
|
|||
);
|
||||
if (
|
||||
expr.isString() &&
|
||||
["high", "low", "auto"].includes(expr.string)
|
||||
["high", "low", "auto"].includes(
|
||||
/** @type {string} */ (expr.string)
|
||||
)
|
||||
) {
|
||||
groupOptions.fetchPriority =
|
||||
/** @type {RawChunkGroupOptions["fetchPriority"]} */ (
|
||||
|
@ -245,7 +256,7 @@ module.exports = class ImportMetaContextDependencyParserPlugin {
|
|||
if (!recursiveExpr.isBoolean()) {
|
||||
errors.push(createPropertyParseError(prop, "boolean"));
|
||||
} else {
|
||||
recursive = recursiveExpr.bool;
|
||||
recursive = /** @type {boolean} */ (recursiveExpr.bool);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -255,7 +266,7 @@ module.exports = class ImportMetaContextDependencyParserPlugin {
|
|||
`Parsing import.meta.webpackContext options failed. Unknown property ${JSON.stringify(
|
||||
prop.key.name
|
||||
)}.`,
|
||||
optionsNode.loc
|
||||
/** @type {DependencyLocation} */ (optionsNode.loc)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -279,9 +290,9 @@ module.exports = class ImportMetaContextDependencyParserPlugin {
|
|||
mode,
|
||||
category: "esm"
|
||||
},
|
||||
expr.range
|
||||
/** @type {Range} */ (expr.range)
|
||||
);
|
||||
dep.loc = expr.loc;
|
||||
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||
dep.optional = !!parser.scope.inTry;
|
||||
parser.state.current.addDependency(dep);
|
||||
return true;
|
||||
|
|
|
@ -15,6 +15,7 @@ const NullDependency = require("./NullDependency");
|
|||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
||||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../Module")} Module */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
|
@ -106,7 +107,9 @@ PureExpressionDependency.Template = class PureExpressionDependencyTemplate exten
|
|||
|
||||
const usedByExports = dep.usedByExports;
|
||||
if (usedByExports !== false) {
|
||||
const selfModule = moduleGraph.getParentModule(dep);
|
||||
const selfModule =
|
||||
/** @type {Module} */
|
||||
(moduleGraph.getParentModule(dep));
|
||||
const exportsInfo = moduleGraph.getExportsInfo(selfModule);
|
||||
const merged = deepMergeRuntime(runtimes, runtime);
|
||||
const runtimeCondition = filterRuntime(merged, runtime => {
|
||||
|
|
|
@ -80,7 +80,7 @@ class RequireContextPlugin {
|
|||
cachedSetProperty(
|
||||
options.resolveOptions || EMPTY_RESOLVE_OPTIONS,
|
||||
"dependencyType",
|
||||
options.category
|
||||
/** @type {string} */ (options.category)
|
||||
)
|
||||
).options;
|
||||
|
||||
|
|
|
@ -11,9 +11,16 @@ const RequireEnsureItemDependency = require("./RequireEnsureItemDependency");
|
|||
const getFunctionExpression = require("./getFunctionExpression");
|
||||
|
||||
/** @typedef {import("../ChunkGroup").ChunkGroupOptions} ChunkGroupOptions */
|
||||
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
||||
/** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */
|
||||
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
|
||||
module.exports = class RequireEnsureDependenciesBlockParserPlugin {
|
||||
/**
|
||||
* @param {JavascriptParser} parser the parser
|
||||
* @returns {void}
|
||||
*/
|
||||
apply(parser) {
|
||||
parser.hooks.call
|
||||
.for("require.ensure")
|
||||
|
@ -45,9 +52,12 @@ module.exports = class RequireEnsureDependenciesBlockParserPlugin {
|
|||
const dependenciesExpr = parser.evaluateExpression(
|
||||
expr.arguments[0]
|
||||
);
|
||||
const dependenciesItems = dependenciesExpr.isArray()
|
||||
const dependenciesItems =
|
||||
/** @type {BasicEvaluatedExpression[]} */ (
|
||||
dependenciesExpr.isArray()
|
||||
? dependenciesExpr.items
|
||||
: [dependenciesExpr];
|
||||
: [dependenciesExpr]
|
||||
);
|
||||
const successExpressionArg = expr.arguments[1];
|
||||
const successExpression =
|
||||
getFunctionExpression(successExpressionArg);
|
||||
|
@ -60,32 +70,34 @@ module.exports = class RequireEnsureDependenciesBlockParserPlugin {
|
|||
}
|
||||
|
||||
const depBlock = new RequireEnsureDependenciesBlock(
|
||||
/** @type {ChunkGroupOptions & { entryOptions?: TODO }} */ (
|
||||
chunkName
|
||||
),
|
||||
expr.loc
|
||||
/** @type {ChunkGroupOptions & { entryOptions?: TODO }} */
|
||||
(chunkName),
|
||||
/** @type {DependencyLocation} */ (expr.loc)
|
||||
);
|
||||
const errorCallbackExists =
|
||||
expr.arguments.length === 4 ||
|
||||
(!chunkName && expr.arguments.length === 3);
|
||||
const dep = new RequireEnsureDependency(
|
||||
expr.range,
|
||||
expr.arguments[1].range,
|
||||
errorCallbackExists && expr.arguments[2].range
|
||||
/** @type {Range} */ (expr.range),
|
||||
/** @type {Range} */ (expr.arguments[1].range),
|
||||
errorCallbackExists &&
|
||||
/** @type {Range} */ (expr.arguments[2].range)
|
||||
);
|
||||
dep.loc = expr.loc;
|
||||
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||
depBlock.addDependency(dep);
|
||||
const old = parser.state.current;
|
||||
parser.state.current = depBlock;
|
||||
parser.state.current = /** @type {TODO} */ (depBlock);
|
||||
try {
|
||||
let failed = false;
|
||||
parser.inScope([], () => {
|
||||
for (const ee of dependenciesItems) {
|
||||
if (ee.isString()) {
|
||||
const ensureDependency = new RequireEnsureItemDependency(
|
||||
ee.string
|
||||
/** @type {string} */ (ee.string)
|
||||
);
|
||||
ensureDependency.loc = ee.loc || expr.loc;
|
||||
ensureDependency.loc =
|
||||
/** @type {DependencyLocation} */
|
||||
(expr.loc);
|
||||
depBlock.addDependency(ensureDependency);
|
||||
} else {
|
||||
failed = true;
|
||||
|
|
|
@ -21,7 +21,7 @@ class RequireEnsureDependency extends NullDependency {
|
|||
/**
|
||||
* @param {Range} range range
|
||||
* @param {Range} contentRange content range
|
||||
* @param {Range} errorHandlerRange error handler range
|
||||
* @param {Range | false} errorHandlerRange error handler range
|
||||
*/
|
||||
constructor(range, contentRange, errorHandlerRange) {
|
||||
super();
|
||||
|
|
|
@ -369,7 +369,8 @@ class WorkerPlugin {
|
|||
);
|
||||
dep.loc = /** @type {DependencyLocation} */ (expr.loc);
|
||||
parser.state.module.addPresentationalDependency(dep);
|
||||
expressions.type = undefined;
|
||||
/** @type {TODO} */
|
||||
(expressions).type = undefined;
|
||||
}
|
||||
} else if (insertType === "comma") {
|
||||
if (this._module || hasSpreadInOptions) {
|
||||
|
|
|
@ -5,12 +5,14 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/** @typedef {import("estree").ArrowFunctionExpression} ArrowFunctionExpression */
|
||||
/** @typedef {import("estree").Expression} Expression */
|
||||
/** @typedef {import("estree").FunctionExpression} FunctionExpression */
|
||||
/** @typedef {import("estree").SpreadElement} SpreadElement */
|
||||
|
||||
/**
|
||||
* @param {Expression | SpreadElement} expr expressions
|
||||
* @returns {{fn: TODO, expressions: (Expression | SpreadElement)[], needThis: boolean | undefined } | undefined} function expression with additional information
|
||||
* @returns {{fn: FunctionExpression | ArrowFunctionExpression, expressions: (Expression | SpreadElement)[], needThis: boolean | undefined } | undefined} function expression with additional information
|
||||
*/
|
||||
module.exports = expr => {
|
||||
// <FunctionExpression>
|
||||
|
|
|
@ -19,6 +19,7 @@ const { getUndoPath } = require("../util/identifier");
|
|||
|
||||
/** @typedef {import("../Chunk")} Chunk */
|
||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
||||
|
||||
/**
|
||||
* @typedef {Object} JsonpCompilationPluginHooks
|
||||
|
@ -52,7 +53,7 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {ReadonlySet<string>} runtimeRequirements runtime requirements
|
||||
* @param {ReadOnlyRuntimeRequirements} runtimeRequirements runtime requirements
|
||||
*/
|
||||
constructor(runtimeRequirements) {
|
||||
super("import chunk loading", RuntimeModule.STAGE_ATTACH);
|
||||
|
|
|
@ -27,7 +27,7 @@ const TypeBigInt = 13;
|
|||
class BasicEvaluatedExpression {
|
||||
constructor() {
|
||||
this.type = TypeUnknown;
|
||||
/** @type {[number, number] | undefined} */
|
||||
/** @type {Range | undefined} */
|
||||
this.range = undefined;
|
||||
/** @type {boolean} */
|
||||
this.falsy = false;
|
||||
|
|
|
@ -11,8 +11,8 @@ const Entrypoint = require("../Entrypoint");
|
|||
|
||||
/**
|
||||
* @param {Entrypoint} entrypoint a chunk group
|
||||
* @param {Chunk=} excludedChunk1 current chunk which is excluded
|
||||
* @param {Chunk=} excludedChunk2 runtime chunk which is excluded
|
||||
* @param {(Chunk | null)=} excludedChunk1 current chunk which is excluded
|
||||
* @param {(Chunk | null)=} excludedChunk2 runtime chunk which is excluded
|
||||
* @returns {Set<Chunk>} chunks
|
||||
*/
|
||||
const getAllChunks = (entrypoint, excludedChunk1, excludedChunk2) => {
|
||||
|
|
|
@ -12,8 +12,10 @@ const { getAllChunks } = require("./ChunkHelpers");
|
|||
|
||||
/** @typedef {import("../util/Hash")} Hash */
|
||||
/** @typedef {import("../Chunk")} Chunk */
|
||||
/** @typedef {import("../Chunk").ChunkId} ChunkId */
|
||||
/** @typedef {import("../Compilation")} Compilation */
|
||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("../Entrypoint")} Entrypoint */
|
||||
/** @typedef {import("../ChunkGraph").EntryModuleWithChunkGroup} EntryModuleWithChunkGroup */
|
||||
/** @typedef {import("../ChunkGroup")} ChunkGroup */
|
||||
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
||||
|
@ -73,9 +75,15 @@ exports.generateEntryStartup = (
|
|||
let currentModuleIds = undefined;
|
||||
|
||||
for (const [module, entrypoint] of entries) {
|
||||
const runtimeChunk = entrypoint.getRuntimeChunk();
|
||||
const runtimeChunk =
|
||||
/** @type {Entrypoint} */
|
||||
(entrypoint).getRuntimeChunk();
|
||||
const moduleId = chunkGraph.getModuleId(module);
|
||||
const chunks = getAllChunks(entrypoint, chunk, runtimeChunk);
|
||||
const chunks = getAllChunks(
|
||||
/** @type {Entrypoint} */ (entrypoint),
|
||||
chunk,
|
||||
runtimeChunk
|
||||
);
|
||||
if (
|
||||
currentChunks &&
|
||||
currentChunks.size === chunks.size &&
|
||||
|
@ -108,12 +116,19 @@ exports.generateEntryStartup = (
|
|||
*/
|
||||
exports.updateHashForEntryStartup = (hash, chunkGraph, entries, chunk) => {
|
||||
for (const [module, entrypoint] of entries) {
|
||||
const runtimeChunk = entrypoint.getRuntimeChunk();
|
||||
const runtimeChunk =
|
||||
/** @type {Entrypoint} */
|
||||
(entrypoint).getRuntimeChunk();
|
||||
const moduleId = chunkGraph.getModuleId(module);
|
||||
hash.update(`${moduleId}`);
|
||||
for (const c of getAllChunks(entrypoint, chunk, runtimeChunk))
|
||||
for (const c of getAllChunks(
|
||||
/** @type {Entrypoint} */ (entrypoint),
|
||||
chunk,
|
||||
/** @type {Chunk} */ (runtimeChunk)
|
||||
)) {
|
||||
hash.update(`${c.id}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -126,7 +141,9 @@ exports.getInitialChunkIds = (chunk, chunkGraph, filterFn) => {
|
|||
const initialChunkIds = new Set(chunk.ids);
|
||||
for (const c of chunk.getAllInitialChunks()) {
|
||||
if (c === chunk || filterFn(c, chunkGraph)) continue;
|
||||
for (const id of c.ids) initialChunkIds.add(id);
|
||||
for (const id of /** @type {ChunkId[]} */ (c.ids)) {
|
||||
initialChunkIds.add(id);
|
||||
}
|
||||
}
|
||||
return initialChunkIds;
|
||||
};
|
||||
|
|
|
@ -18,10 +18,11 @@ const { getUndoPath } = require("../util/identifier");
|
|||
/** @typedef {import("../Chunk")} Chunk */
|
||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("../Compilation")} Compilation */
|
||||
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
||||
|
||||
class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
|
||||
/**
|
||||
* @param {ReadonlySet<string>} runtimeRequirements runtime requirements
|
||||
* @param {ReadOnlyRuntimeRequirements} runtimeRequirements runtime requirements
|
||||
*/
|
||||
constructor(runtimeRequirements) {
|
||||
super("readFile chunk loading", RuntimeModule.STAGE_ATTACH);
|
||||
|
|
|
@ -18,10 +18,11 @@ const { getUndoPath } = require("../util/identifier");
|
|||
/** @typedef {import("../Chunk")} Chunk */
|
||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("../Compilation")} Compilation */
|
||||
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
||||
|
||||
class RequireChunkLoadingRuntimeModule extends RuntimeModule {
|
||||
/**
|
||||
* @param {ReadonlySet<string>} runtimeRequirements runtime requirements
|
||||
* @param {ReadOnlyRuntimeRequirements} runtimeRequirements runtime requirements
|
||||
*/
|
||||
constructor(runtimeRequirements) {
|
||||
super("require chunk loading", RuntimeModule.STAGE_ATTACH);
|
||||
|
|
|
@ -37,9 +37,9 @@ const {
|
|||
subtractRuntimeCondition
|
||||
} = require("../util/runtime");
|
||||
|
||||
/** @typedef {import("eslint-scope").Reference} Reference */
|
||||
/** @typedef {import("eslint-scope").Scope} Scope */
|
||||
/** @typedef {import("eslint-scope").Variable} Variable */
|
||||
/** @typedef {import("eslint-scope").Reference} Reference */
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
|
||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||
|
@ -50,13 +50,13 @@ const {
|
|||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */
|
||||
/** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
|
||||
/** @template T @typedef {import("../InitFragment")<T>} InitFragment */
|
||||
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
||||
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
||||
/** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */
|
||||
/** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */
|
||||
/** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */
|
||||
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
||||
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
||||
/** @typedef {import("../Module").BuildInfo} BuildInfo */
|
||||
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
||||
/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
||||
|
@ -65,11 +65,19 @@ const {
|
|||
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
||||
/** @typedef {import("../WebpackError")} WebpackError */
|
||||
/** @typedef {import("../javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Program} Program */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
||||
/** @typedef {import("../util/Hash")} Hash */
|
||||
/** @typedef {typeof import("../util/Hash")} HashConstructor */
|
||||
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
||||
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @typedef {import("../InitFragment")<T>} InitFragment
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @typedef {import("../util/comparators").Comparator<T>} Comparator
|
||||
|
@ -117,24 +125,24 @@ if (!ReferencerClass.prototype.PropertyDefinition) {
|
|||
* @property {"concatenated"} type
|
||||
* @property {Module} module
|
||||
* @property {number} index
|
||||
* @property {Object} ast
|
||||
* @property {Program | undefined} ast
|
||||
* @property {Source} internalSource
|
||||
* @property {ReplaceSource} source
|
||||
* @property {InitFragment<ChunkRenderContext>[]=} chunkInitFragments
|
||||
* @property {Iterable<string>} runtimeRequirements
|
||||
* @property {ReadOnlyRuntimeRequirements} runtimeRequirements
|
||||
* @property {Scope} globalScope
|
||||
* @property {Scope} moduleScope
|
||||
* @property {Map<string, string>} internalNames
|
||||
* @property {Map<string, string>} exportMap
|
||||
* @property {Map<string, string>} rawExportMap
|
||||
* @property {Map<string, string> | undefined} exportMap
|
||||
* @property {Map<string, string> | undefined} rawExportMap
|
||||
* @property {string=} namespaceExportSymbol
|
||||
* @property {string} namespaceObjectName
|
||||
* @property {string | undefined} namespaceObjectName
|
||||
* @property {boolean} interopNamespaceObjectUsed
|
||||
* @property {string} interopNamespaceObjectName
|
||||
* @property {string | undefined} interopNamespaceObjectName
|
||||
* @property {boolean} interopNamespaceObject2Used
|
||||
* @property {string} interopNamespaceObject2Name
|
||||
* @property {string | undefined} interopNamespaceObject2Name
|
||||
* @property {boolean} interopDefaultAccessUsed
|
||||
* @property {string} interopDefaultAccessName
|
||||
* @property {string | undefined} interopDefaultAccessName
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -291,7 +299,7 @@ const getFinalBinding = (
|
|||
info.interopNamespaceObject2Used = true;
|
||||
return {
|
||||
info,
|
||||
rawName: info.interopNamespaceObject2Name,
|
||||
rawName: /** @type {string} */ (info.interopNamespaceObject2Name),
|
||||
ids: exportName,
|
||||
exportName
|
||||
};
|
||||
|
@ -299,7 +307,7 @@ const getFinalBinding = (
|
|||
info.interopNamespaceObjectUsed = true;
|
||||
return {
|
||||
info,
|
||||
rawName: info.interopNamespaceObjectName,
|
||||
rawName: /** @type {string} */ (info.interopNamespaceObjectName),
|
||||
ids: exportName,
|
||||
exportName
|
||||
};
|
||||
|
@ -387,7 +395,7 @@ const getFinalBinding = (
|
|||
neededNamespaceObjects.add(info);
|
||||
return {
|
||||
info,
|
||||
rawName: info.namespaceObjectName,
|
||||
rawName: /** @type {string} */ (info.namespaceObjectName),
|
||||
ids: exportName,
|
||||
exportName
|
||||
};
|
||||
|
@ -414,7 +422,7 @@ const getFinalBinding = (
|
|||
neededNamespaceObjects.add(info);
|
||||
return {
|
||||
info,
|
||||
rawName: info.namespaceObjectName,
|
||||
rawName: /** @type {string} */ (info.namespaceObjectName),
|
||||
ids: exportName,
|
||||
exportName
|
||||
};
|
||||
|
@ -488,7 +496,7 @@ const getFinalBinding = (
|
|||
);
|
||||
return {
|
||||
info,
|
||||
rawName: info.namespaceObjectName,
|
||||
rawName: /** @type {string} */ (info.namespaceObjectName),
|
||||
ids: usedName,
|
||||
exportName
|
||||
};
|
||||
|
@ -636,6 +644,11 @@ const getAllReferences = variable => {
|
|||
return set;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {TODO} ast ast
|
||||
* @param {TODO} node node
|
||||
* @returns {TODO} result
|
||||
*/
|
||||
const getPathInAst = (ast, node) => {
|
||||
if (ast === node) {
|
||||
return [];
|
||||
|
@ -879,7 +892,7 @@ class ConcatenatedModule extends Module {
|
|||
if (this.buildInfo.assets === undefined) {
|
||||
this.buildInfo.assets = Object.create(null);
|
||||
}
|
||||
Object.assign(this.buildInfo.assets, assets);
|
||||
Object.assign(/** @type {BuildInfo} */ (this.buildInfo).assets, assets);
|
||||
}
|
||||
if (assetsInfo) {
|
||||
if (this.buildInfo.assetsInfo === undefined) {
|
||||
|
@ -1372,7 +1385,9 @@ class ConcatenatedModule extends Module {
|
|||
);
|
||||
allUsedNames.add(namespaceObjectName);
|
||||
}
|
||||
info.namespaceObjectName = namespaceObjectName;
|
||||
info.namespaceObjectName =
|
||||
/** @type {string} */
|
||||
(namespaceObjectName);
|
||||
topLevelDeclarations.add(namespaceObjectName);
|
||||
break;
|
||||
}
|
||||
|
@ -1864,7 +1879,10 @@ ${defineGetters}`
|
|||
`Unsupported concatenation entry type ${info.type}`
|
||||
);
|
||||
}
|
||||
map.set(item.module, item);
|
||||
map.set(
|
||||
/** @type {ModuleInfo} */ (item).module,
|
||||
/** @type {ModuleInfo} */ (item)
|
||||
);
|
||||
return item;
|
||||
} else {
|
||||
/** @type {ReferenceToModuleInfo} */
|
||||
|
@ -1951,6 +1969,10 @@ ${defineGetters}`
|
|||
super.updateHash(hash, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ObjectDeserializerContext} context context
|
||||
* @returns {ConcatenatedModule} ConcatenatedModule
|
||||
*/
|
||||
static deserialize(context) {
|
||||
const obj = new ConcatenatedModule({
|
||||
identifier: undefined,
|
||||
|
|
|
@ -9,6 +9,7 @@ const { UsageState } = require("../ExportsInfo");
|
|||
|
||||
/** @typedef {import("estree").Node} AnyNode */
|
||||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../Module")} Module */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
||||
/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
||||
|
@ -295,7 +296,9 @@ exports.isDependencyUsedByExports = (
|
|||
) => {
|
||||
if (usedByExports === false) return false;
|
||||
if (usedByExports !== true && usedByExports !== undefined) {
|
||||
const selfModule = moduleGraph.getParentModule(dependency);
|
||||
const selfModule =
|
||||
/** @type {Module} */
|
||||
(moduleGraph.getParentModule(dependency));
|
||||
const exportsInfo = moduleGraph.getExportsInfo(selfModule);
|
||||
let used = false;
|
||||
for (const exportName of usedByExports) {
|
||||
|
@ -320,7 +323,9 @@ exports.getDependencyUsedByExportsCondition = (
|
|||
) => {
|
||||
if (usedByExports === false) return false;
|
||||
if (usedByExports !== true && usedByExports !== undefined) {
|
||||
const selfModule = moduleGraph.getParentModule(dependency);
|
||||
const selfModule =
|
||||
/** @type {Module} */
|
||||
(moduleGraph.getParentModule(dependency));
|
||||
const exportsInfo = moduleGraph.getExportsInfo(selfModule);
|
||||
return (connections, runtime) => {
|
||||
for (const exportName of usedByExports) {
|
||||
|
|
|
@ -19,6 +19,7 @@ const InnerGraph = require("./InnerGraph");
|
|||
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
||||
/** @typedef {import("../dependencies/HarmonyImportSpecifierDependency")} HarmonyImportSpecifierDependency */
|
||||
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
|
@ -230,7 +231,9 @@ class InnerGraphPlugin {
|
|||
const dep = new PureExpressionDependency(
|
||||
/** @type {Range} */ (purePart.range)
|
||||
);
|
||||
dep.loc = statement.loc;
|
||||
dep.loc =
|
||||
/** @type {DependencyLocation} */
|
||||
(statement.loc);
|
||||
dep.usedByExports = usedByExports;
|
||||
parser.state.module.addDependency(dep);
|
||||
break;
|
||||
|
@ -304,7 +307,9 @@ class InnerGraphPlugin {
|
|||
const dep = new PureExpressionDependency(
|
||||
/** @type {Range} */ (expression.range)
|
||||
);
|
||||
dep.loc = expression.loc;
|
||||
dep.loc =
|
||||
/** @type {DependencyLocation} */
|
||||
(expression.loc);
|
||||
dep.usedByExports = usedByExports;
|
||||
parser.state.module.addDependency(dep);
|
||||
break;
|
||||
|
@ -341,7 +346,7 @@ class InnerGraphPlugin {
|
|||
const dep = new PureExpressionDependency(
|
||||
/** @type {Range} */ (decl.init.range)
|
||||
);
|
||||
dep.loc = decl.loc;
|
||||
dep.loc = /** @type {DependencyLocation} */ (decl.loc);
|
||||
dep.usedByExports = usedByExports;
|
||||
parser.state.module.addDependency(dep);
|
||||
break;
|
||||
|
|
|
@ -40,8 +40,9 @@ class RuntimeChunkPlugin {
|
|||
(compilation.entries.get(entryName));
|
||||
if (data.options.runtime === undefined && !data.options.dependOn) {
|
||||
// Determine runtime chunk name
|
||||
let name =
|
||||
/** @type {string | ((entrypoint: { name: string }) => string)} */
|
||||
let name = this.options.name;
|
||||
(this.options.name);
|
||||
if (typeof name === "function") {
|
||||
name = name({ name: entryName });
|
||||
}
|
||||
|
|
|
@ -9,10 +9,11 @@ const RuntimeModule = require("../RuntimeModule");
|
|||
const Template = require("../Template");
|
||||
|
||||
/** @typedef {import("../Compilation")} Compilation */
|
||||
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
||||
|
||||
class EnsureChunkRuntimeModule extends RuntimeModule {
|
||||
/**
|
||||
* @param {ReadonlySet<string>} runtimeRequirements runtime requirements
|
||||
* @param {ReadOnlyRuntimeRequirements} runtimeRequirements runtime requirements
|
||||
*/
|
||||
constructor(runtimeRequirements) {
|
||||
super("ensure chunk");
|
||||
|
|
|
@ -9,10 +9,11 @@ const Template = require("../Template");
|
|||
const HelperRuntimeModule = require("./HelperRuntimeModule");
|
||||
|
||||
/** @typedef {import("../Compilation")} Compilation */
|
||||
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
||||
|
||||
class GetTrustedTypesPolicyRuntimeModule extends HelperRuntimeModule {
|
||||
/**
|
||||
* @param {ReadonlySet<string>} runtimeRequirements runtime requirements
|
||||
* @param {ReadOnlyRuntimeRequirements} runtimeRequirements runtime requirements
|
||||
*/
|
||||
constructor(runtimeRequirements) {
|
||||
super("trusted types policy");
|
||||
|
|
|
@ -42,7 +42,7 @@ const ConsumeSharedFallbackDependency = require("./ConsumeSharedFallbackDependen
|
|||
* @property {string} shareKey global share key
|
||||
* @property {string} shareScope share scope
|
||||
* @property {SemVerRange | false | undefined} requiredVersion version requirement
|
||||
* @property {string} packageName package name to determine required version automatically
|
||||
* @property {string=} packageName package name to determine required version automatically
|
||||
* @property {boolean} strictVersion don't use shared version even if version isn't valid
|
||||
* @property {boolean} singleton use single global version
|
||||
* @property {boolean} eager include the fallback module in a sync way
|
||||
|
|
|
@ -117,7 +117,12 @@ class ConsumeSharedPlugin {
|
|||
normalModuleFactory
|
||||
);
|
||||
|
||||
let unresolvedConsumes, resolvedConsumes, prefixedConsumes;
|
||||
/** @type {Map<string, ConsumeOptions>} */
|
||||
let unresolvedConsumes;
|
||||
/** @type {Map<string, ConsumeOptions>} */
|
||||
let resolvedConsumes;
|
||||
/** @type {Map<string, ConsumeOptions>} */
|
||||
let prefixedConsumes;
|
||||
const promise = resolveMatchedConfigs(compilation, this._consumes).then(
|
||||
({ resolved, unresolved, prefixed }) => {
|
||||
resolvedConsumes = resolved;
|
||||
|
@ -138,6 +143,9 @@ class ConsumeSharedPlugin {
|
|||
* @returns {Promise<ConsumeSharedModule>} create module
|
||||
*/
|
||||
const createConsumeSharedModule = (context, request, config) => {
|
||||
/**
|
||||
* @param {string} details details
|
||||
*/
|
||||
const requiredVersionWarning = details => {
|
||||
const error = new WebpackError(
|
||||
`No required version specified and unable to automatically determine one. ${details}`
|
||||
|
@ -293,9 +301,15 @@ class ConsumeSharedPlugin {
|
|||
) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
const options = resolvedConsumes.get(resource);
|
||||
const options = resolvedConsumes.get(
|
||||
/** @type {string} */ (resource)
|
||||
);
|
||||
if (options !== undefined) {
|
||||
return createConsumeSharedModule(context, resource, options);
|
||||
return createConsumeSharedModule(
|
||||
context,
|
||||
/** @type {string} */ (resource),
|
||||
options
|
||||
);
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
|
|
@ -17,14 +17,16 @@ const {
|
|||
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("../Chunk")} Chunk */
|
||||
/** @typedef {import("../Chunk").ChunkId} ChunkId */
|
||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("../Compilation")} Compilation */
|
||||
/** @typedef {import("../Module")} Module */
|
||||
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
||||
/** @typedef {import("./ConsumeSharedModule")} ConsumeSharedModule */
|
||||
|
||||
class ConsumeSharedRuntimeModule extends RuntimeModule {
|
||||
/**
|
||||
* @param {ReadonlySet<string>} runtimeRequirements runtime requirements
|
||||
* @param {ReadOnlyRuntimeRequirements} runtimeRequirements runtime requirements
|
||||
*/
|
||||
constructor(runtimeRequirements) {
|
||||
super("consumes", RuntimeModule.STAGE_ATTACH);
|
||||
|
@ -38,6 +40,7 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
|
|||
const compilation = /** @type {Compilation} */ (this.compilation);
|
||||
const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
|
||||
const { runtimeTemplate, codeGenerationResults } = compilation;
|
||||
/** @type {Record<ChunkId, (string | number)[]>} */
|
||||
const chunkToModuleMapping = {};
|
||||
/** @type {Map<string | number, Source>} */
|
||||
const moduleIdToSourceMapping = new Map();
|
||||
|
@ -70,7 +73,11 @@ class ConsumeSharedRuntimeModule extends RuntimeModule {
|
|||
"consume-shared"
|
||||
);
|
||||
if (!modules) continue;
|
||||
addModules(modules, chunk, (chunkToModuleMapping[chunk.id] = []));
|
||||
addModules(
|
||||
modules,
|
||||
chunk,
|
||||
(chunkToModuleMapping[/** @type {ChunkId} */ (chunk.id)] = [])
|
||||
);
|
||||
}
|
||||
for (const chunk of /** @type {Chunk} */ (
|
||||
this.chunk
|
||||
|
|
|
@ -15,6 +15,7 @@ const ProvideSharedModuleFactory = require("./ProvideSharedModuleFactory");
|
|||
/** @typedef {import("../../declarations/plugins/sharing/ProvideSharedPlugin").ProvideSharedPluginOptions} ProvideSharedPluginOptions */
|
||||
/** @typedef {import("../Compilation")} Compilation */
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
/** @typedef {import("../NormalModuleFactory").NormalModuleCreateData} NormalModuleCreateData */
|
||||
|
||||
const validate = createSchemaValidation(
|
||||
require("../../schemas/plugins/sharing/ProvideSharedPlugin.check.js"),
|
||||
|
@ -112,6 +113,12 @@ class ProvideSharedPlugin {
|
|||
}
|
||||
}
|
||||
compilationData.set(compilation, resolvedProvideMap);
|
||||
/**
|
||||
* @param {string} key key
|
||||
* @param {ProvideOptions} config config
|
||||
* @param {NormalModuleCreateData["resource"]} resource resource
|
||||
* @param {NormalModuleCreateData["resourceResolveData"]} resourceResolveData resource resolve data
|
||||
*/
|
||||
const provideSharedModule = (
|
||||
key,
|
||||
config,
|
||||
|
@ -151,7 +158,7 @@ class ProvideSharedPlugin {
|
|||
normalModuleFactory.hooks.module.tap(
|
||||
"ProvideSharedPlugin",
|
||||
(module, { resource, resourceResolveData }, resolveData) => {
|
||||
if (resolvedProvideMap.has(resource)) {
|
||||
if (resolvedProvideMap.has(/** @type {string} */ (resource))) {
|
||||
return module;
|
||||
}
|
||||
const { request } = resolveData;
|
||||
|
@ -161,7 +168,7 @@ class ProvideSharedPlugin {
|
|||
provideSharedModule(
|
||||
request,
|
||||
config,
|
||||
resource,
|
||||
/** @type {string} */ (resource),
|
||||
resourceResolveData
|
||||
);
|
||||
resolveData.cacheable = false;
|
||||
|
@ -171,12 +178,12 @@ class ProvideSharedPlugin {
|
|||
if (request.startsWith(prefix)) {
|
||||
const remainder = request.slice(prefix.length);
|
||||
provideSharedModule(
|
||||
resource,
|
||||
/** @type {string} */ (resource),
|
||||
{
|
||||
...config,
|
||||
shareKey: config.shareKey + remainder
|
||||
},
|
||||
resource,
|
||||
/** @type {string} */ (resource),
|
||||
resourceResolveData
|
||||
);
|
||||
resolveData.cacheable = false;
|
||||
|
@ -209,7 +216,7 @@ class ProvideSharedPlugin {
|
|||
},
|
||||
err => {
|
||||
if (err) return reject(err);
|
||||
resolve();
|
||||
resolve(null);
|
||||
}
|
||||
);
|
||||
})
|
||||
|
|
|
@ -64,10 +64,10 @@ exports.resolveMatchedConfigs = (compilation, configs) => {
|
|||
name: `shared module ${request}`
|
||||
})
|
||||
);
|
||||
return resolve();
|
||||
return resolve(null);
|
||||
}
|
||||
resolved.set(/** @type {string} */ (result), config);
|
||||
resolve();
|
||||
resolve(null);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
const { join, dirname, readJson } = require("../util/fs");
|
||||
|
||||
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
||||
/** @typedef {import("../util/fs").JsonObject} JsonObject */
|
||||
/** @typedef {import("../util/fs").JsonPrimitive} JsonPrimitive */
|
||||
|
||||
// Extreme shorthand only for github. eg: foo/bar
|
||||
const RE_URL_GITHUB_EXTREME_SHORT = /^[^/@:.\s][^/@:\s]*\/[^@:\s]*[^/@:\s]#\S+/;
|
||||
|
@ -373,9 +375,9 @@ exports.getDescriptionFile = getDescriptionFile;
|
|||
|
||||
/**
|
||||
*
|
||||
* @param {object} data description file data i.e.: package.json
|
||||
* @param {JsonObject} data description file data i.e.: package.json
|
||||
* @param {string} packageName name of the dependency
|
||||
* @returns {string} normalized version
|
||||
* @returns {string | undefined} normalized version
|
||||
*/
|
||||
const getRequiredVersionFromDescriptionFile = (data, packageName) => {
|
||||
const dependencyTypes = [
|
||||
|
@ -386,12 +388,17 @@ const getRequiredVersionFromDescriptionFile = (data, packageName) => {
|
|||
];
|
||||
|
||||
for (const dependencyType of dependencyTypes) {
|
||||
const dependency = /** @type {JsonObject} */ (data[dependencyType]);
|
||||
if (
|
||||
data[dependencyType] &&
|
||||
typeof data[dependencyType] === "object" &&
|
||||
packageName in data[dependencyType]
|
||||
dependency &&
|
||||
typeof dependency === "object" &&
|
||||
packageName in dependency
|
||||
) {
|
||||
return normalizeVersion(data[dependencyType][packageName]);
|
||||
return normalizeVersion(
|
||||
/** @type {Exclude<JsonPrimitive, null | boolean| number>} */ (
|
||||
dependency[packageName]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -230,7 +230,7 @@ const mergeRuntime = (a, b) => {
|
|||
exports.mergeRuntime = mergeRuntime;
|
||||
|
||||
/**
|
||||
* @param {RuntimeSpec[]} runtimes first
|
||||
* @param {RuntimeSpec[] | undefined} runtimes first
|
||||
* @param {RuntimeSpec} runtime second
|
||||
* @returns {RuntimeSpec} merged
|
||||
*/
|
||||
|
|
|
@ -15,6 +15,7 @@ const WebAssemblyUtils = require("./WebAssemblyUtils");
|
|||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("../Compilation")} Compilation */
|
||||
/** @typedef {import("../Module")} Module */
|
||||
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
|
||||
|
@ -213,7 +214,7 @@ const generateImportObject = (
|
|||
* @property {(path: string) => string} generateLoadBinaryCode
|
||||
* @property {boolean} [supportsStreaming]
|
||||
* @property {boolean} [mangleImports]
|
||||
* @property {Set<string>} runtimeRequirements
|
||||
* @property {ReadOnlyRuntimeRequirements} runtimeRequirements
|
||||
*/
|
||||
|
||||
class WasmChunkLoadingRuntimeModule extends RuntimeModule {
|
||||
|
|
|
@ -15,6 +15,7 @@ const compileBooleanMatcher = require("../util/compileBooleanMatcher");
|
|||
|
||||
/** @typedef {import("../Chunk")} Chunk */
|
||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
||||
|
||||
/**
|
||||
* @typedef {Object} JsonpCompilationPluginHooks
|
||||
|
@ -48,7 +49,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {Set<string>} runtimeRequirements runtime requirements
|
||||
* @param {ReadOnlyRuntimeRequirements} runtimeRequirements runtime requirements
|
||||
*/
|
||||
constructor(runtimeRequirements) {
|
||||
super("jsonp chunk loading", RuntimeModule.STAGE_ATTACH);
|
||||
|
|
|
@ -18,10 +18,11 @@ const { getUndoPath } = require("../util/identifier");
|
|||
/** @typedef {import("../Chunk")} Chunk */
|
||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("../Compilation")} Compilation */
|
||||
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
||||
|
||||
class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
||||
/**
|
||||
* @param {Set<string>} runtimeRequirements runtime requirements
|
||||
* @param {ReadOnlyRuntimeRequirements} runtimeRequirements runtime requirements
|
||||
* @param {boolean} withCreateScriptUrl with createScriptUrl support
|
||||
*/
|
||||
constructor(runtimeRequirements, withCreateScriptUrl) {
|
||||
|
|
|
@ -995,7 +995,7 @@ declare interface CallbackCacheCache<T> {
|
|||
(err: null | WebpackError, result?: T): void;
|
||||
}
|
||||
declare interface CallbackCacheCacheFacade<T> {
|
||||
(err?: null | WebpackError, result?: T): void;
|
||||
(err?: null | Error, result?: null | T): void;
|
||||
}
|
||||
declare interface CallbackFunction_1<T> {
|
||||
(err: null | Error, result?: T): any;
|
||||
|
@ -1204,7 +1204,7 @@ declare class ChunkGraph {
|
|||
getChunkEntryModulesWithChunkGroupIterable(
|
||||
chunk: Chunk
|
||||
): Iterable<[Module, undefined | Entrypoint]>;
|
||||
getBlockChunkGroup(depBlock: AsyncDependenciesBlock): ChunkGroup;
|
||||
getBlockChunkGroup(depBlock: AsyncDependenciesBlock): undefined | ChunkGroup;
|
||||
connectBlockAndChunkGroup(
|
||||
depBlock: AsyncDependenciesBlock,
|
||||
chunkGroup: ChunkGroup
|
||||
|
@ -1581,7 +1581,7 @@ declare interface CodeGenerationContext {
|
|||
/**
|
||||
* code generation results of other modules (need to have a codeGenerationDependency to use that)
|
||||
*/
|
||||
codeGenerationResults: CodeGenerationResults;
|
||||
codeGenerationResults?: CodeGenerationResults;
|
||||
|
||||
/**
|
||||
* the compilation
|
||||
|
@ -1903,14 +1903,14 @@ declare class Compilation {
|
|||
contextDependencies: LazySet<string>;
|
||||
missingDependencies: LazySet<string>;
|
||||
buildDependencies: LazySet<string>;
|
||||
compilationDependencies: { add: (item?: any) => LazySet<string> };
|
||||
compilationDependencies: { add: (item: string) => LazySet<string> };
|
||||
getStats(): Stats;
|
||||
createStatsOptions(
|
||||
optionsOrPreset?: string | boolean | StatsOptions,
|
||||
context?: CreateStatsOptionsContext
|
||||
): NormalizedStatsOptions;
|
||||
createStatsFactory(options?: any): StatsFactory;
|
||||
createStatsPrinter(options?: any): StatsPrinter;
|
||||
createStatsFactory(options: NormalizedStatsOptions): StatsFactory;
|
||||
createStatsPrinter(options: NormalizedStatsOptions): StatsPrinter;
|
||||
getCache(name: string): CacheFacade;
|
||||
getLogger(name: string | (() => string)): WebpackLogger;
|
||||
addModule(
|
||||
|
@ -2069,7 +2069,7 @@ declare class Compilation {
|
|||
newSourceOrFunction: Source | ((arg0: Source) => Source),
|
||||
assetInfoUpdateOrFunction?: AssetInfo | ((arg0?: AssetInfo) => AssetInfo)
|
||||
): void;
|
||||
renameAsset(file?: any, newFile?: any): void;
|
||||
renameAsset(file: string, newFile: string): void;
|
||||
deleteAsset(file: string): void;
|
||||
getAssets(): Readonly<Asset>[];
|
||||
getAsset(name: string): undefined | Readonly<Asset>;
|
||||
|
@ -2315,7 +2315,7 @@ declare class Compiler {
|
|||
moduleMemCaches?: Map<
|
||||
Module,
|
||||
{
|
||||
buildInfo: object;
|
||||
buildInfo: BuildInfo;
|
||||
references?: WeakMap<Dependency, Module>;
|
||||
memCache: WeakTupleMap<any, any>;
|
||||
}
|
||||
|
@ -4286,7 +4286,7 @@ declare abstract class ExportsInfo {
|
|||
isEquallyUsed(runtimeA: RuntimeSpec, runtimeB: RuntimeSpec): boolean;
|
||||
getUsed(name: string | string[], runtime: RuntimeSpec): UsageStateType;
|
||||
getUsedName(
|
||||
name: string | string[],
|
||||
name: undefined | string | string[],
|
||||
runtime: RuntimeSpec
|
||||
): string | false | string[];
|
||||
updateHash(hash: Hash, runtime: RuntimeSpec): void;
|
||||
|
@ -5087,7 +5087,7 @@ declare class HarmonyImportDependency extends ModuleDependency {
|
|||
WARN: 1;
|
||||
AUTO: 2;
|
||||
ERROR: 3;
|
||||
fromUserOption(str?: any): 0 | 1 | 2 | 3;
|
||||
fromUserOption(str: string | false): 0 | 1 | 2 | 3;
|
||||
};
|
||||
static NO_EXPORTS_REFERENCED: string[][];
|
||||
static EXPORTS_OBJECT_REFERENCED: string[][];
|
||||
|
@ -5369,12 +5369,12 @@ declare interface InfrastructureLogging {
|
|||
stream?: NodeJS.WritableStream;
|
||||
}
|
||||
declare abstract class InitFragment<GenerateContext> {
|
||||
content: string | Source;
|
||||
content?: string | Source;
|
||||
stage: number;
|
||||
position: number;
|
||||
key?: string;
|
||||
endContent?: string | Source;
|
||||
getContent(context: GenerateContext): string | Source;
|
||||
getContent(context: GenerateContext): undefined | string | Source;
|
||||
getEndContent(context: GenerateContext): undefined | string | Source;
|
||||
serialize(context: ObjectSerializerContext): void;
|
||||
deserialize(context: ObjectDeserializerContext): void;
|
||||
|
@ -6678,7 +6678,7 @@ type JsonValueTypes =
|
|||
| JsonObjectTypes
|
||||
| JsonValueTypes[];
|
||||
declare class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
||||
constructor(runtimeRequirements: Set<string>);
|
||||
constructor(runtimeRequirements: ReadonlySet<string>);
|
||||
static getCompilationHooks(
|
||||
compilation: Compilation
|
||||
): JsonpCompilationPluginHooks;
|
||||
|
@ -8218,7 +8218,7 @@ declare class ModuleGraph {
|
|||
getParentBlock(dependency: Dependency): undefined | DependenciesBlock;
|
||||
getParentBlockIndex(dependency: Dependency): number;
|
||||
setResolvedModule(
|
||||
originModule: Module,
|
||||
originModule: null | Module,
|
||||
dependency: Dependency,
|
||||
module: Module
|
||||
): void;
|
||||
|
@ -8929,7 +8929,7 @@ declare abstract class NormalModuleFactory extends ModuleFactory {
|
|||
resolveInScheme: HookMap<
|
||||
AsyncSeriesBailHook<[ResourceDataWithData, ResolveData], true | void>
|
||||
>;
|
||||
factorize: AsyncSeriesBailHook<[ResolveData], Module>;
|
||||
factorize: AsyncSeriesBailHook<[ResolveData], undefined | Module>;
|
||||
beforeResolve: AsyncSeriesBailHook<[ResolveData], false | void>;
|
||||
afterResolve: AsyncSeriesBailHook<[ResolveData], false | void>;
|
||||
createModule: AsyncSeriesBailHook<
|
||||
|
@ -9143,6 +9143,8 @@ declare interface ObjectSerializer {
|
|||
}
|
||||
declare interface ObjectSerializerContext {
|
||||
write: (arg0?: any) => void;
|
||||
writeLazy?: (arg0?: any) => void;
|
||||
writeSeparate?: (arg0: any, arg1?: object) => () => any;
|
||||
setCircularReference: (arg0?: any) => void;
|
||||
}
|
||||
declare class OccurrenceChunkIdsPlugin {
|
||||
|
@ -12886,11 +12888,21 @@ declare interface Selector<A, B> {
|
|||
(input: A): undefined | null | B;
|
||||
}
|
||||
declare abstract class Serializer {
|
||||
serializeMiddlewares: any;
|
||||
deserializeMiddlewares: any;
|
||||
serializeMiddlewares: SerializerMiddleware<any, any>[];
|
||||
deserializeMiddlewares: SerializerMiddleware<any, any>[];
|
||||
context: any;
|
||||
serialize(obj?: any, context?: any): any;
|
||||
deserialize(value?: any, context?: any): any;
|
||||
serialize(obj?: any, context?: any): Promise<any>;
|
||||
deserialize(value?: any, context?: any): Promise<any>;
|
||||
}
|
||||
declare abstract class SerializerMiddleware<DeserializedType, SerializedType> {
|
||||
serialize(
|
||||
data: DeserializedType,
|
||||
context: Object
|
||||
): SerializedType | Promise<SerializedType>;
|
||||
deserialize(
|
||||
data: SerializedType,
|
||||
context: Object
|
||||
): DeserializedType | Promise<DeserializedType>;
|
||||
}
|
||||
type ServerOptionsHttps<
|
||||
Request extends typeof IncomingMessage = typeof IncomingMessage,
|
||||
|
@ -15217,7 +15229,7 @@ declare namespace exports {
|
|||
export let compareRuntime: (a: RuntimeSpec, b: RuntimeSpec) => 0 | 1 | -1;
|
||||
export let mergeRuntime: (a: RuntimeSpec, b: RuntimeSpec) => RuntimeSpec;
|
||||
export let deepMergeRuntime: (
|
||||
runtimes: RuntimeSpec[],
|
||||
runtimes: undefined | RuntimeSpec[],
|
||||
runtime: RuntimeSpec
|
||||
) => RuntimeSpec;
|
||||
export let mergeRuntimeCondition: (
|
||||
|
|
Loading…
Reference in New Issue