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