| /* | ||
| MIT License http://www.opensource.org/licenses/mit-license.php | ||
| Author Alexander Akait @alexander-akait | ||
| */ | ||
| "use strict"; | ||
| const { RawSource } = require("webpack-sources"); | ||
| const ConcatenationScope = require("../ConcatenationScope"); | ||
| const Generator = require("../Generator"); | ||
| const { | ||
| CSS_URL_TYPES, | ||
| JS_AND_CSS_URL_TYPES, | ||
| JS_TYPES, | ||
| NO_TYPES | ||
| } = require("../ModuleSourceTypesConstants"); | ||
| const RuntimeGlobals = require("../RuntimeGlobals"); | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("../Generator").GenerateContext} GenerateContext */ | ||
| /** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */ | ||
| /** @typedef {import("../Module").SourceTypes} SourceTypes */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../NormalModule")} NormalModule */ | ||
| class AssetSourceGenerator extends Generator { | ||
| /** | ||
| * @param {ModuleGraph} moduleGraph the module graph | ||
| */ | ||
| constructor(moduleGraph) { | ||
| super(); | ||
| this._moduleGraph = moduleGraph; | ||
| } | ||
| /** | ||
| * @param {NormalModule} module module for which the code should be generated | ||
| * @param {GenerateContext} generateContext context for generate | ||
| * @returns {Source | null} generated code | ||
| */ | ||
| generate( | ||
| module, | ||
| { type, concatenationScope, getData, runtimeTemplate, runtimeRequirements } | ||
| ) { | ||
| const originalSource = module.originalSource(); | ||
| const data = getData ? getData() : undefined; | ||
| switch (type) { | ||
| case "javascript": { | ||
| if (!originalSource) { | ||
| return new RawSource(""); | ||
| } | ||
| const encodedSource = originalSource.buffer().toString("base64"); | ||
| runtimeRequirements.add(RuntimeGlobals.toBinary); | ||
| let sourceContent; | ||
| if (concatenationScope) { | ||
| concatenationScope.registerNamespaceExport( | ||
| ConcatenationScope.NAMESPACE_OBJECT_EXPORT | ||
| ); | ||
| sourceContent = `${runtimeTemplate.renderConst()} ${ | ||
| ConcatenationScope.NAMESPACE_OBJECT_EXPORT | ||
| } = ${RuntimeGlobals.toBinary}(${JSON.stringify(encodedSource)});`; | ||
| } else { | ||
| runtimeRequirements.add(RuntimeGlobals.module); | ||
| sourceContent = `${RuntimeGlobals.module}.exports = ${RuntimeGlobals.toBinary}(${JSON.stringify( | ||
| encodedSource | ||
| )});`; | ||
| } | ||
| return new RawSource(sourceContent); | ||
| } | ||
| case "css-url": { | ||
| if (!originalSource) { | ||
| return null; | ||
| } | ||
| const encodedSource = originalSource.buffer().toString("base64"); | ||
| if (data) { | ||
| data.set("url", { | ||
| [type]: `data:application/octet-stream;base64,${encodedSource}` | ||
| }); | ||
| } | ||
| return null; | ||
| } | ||
| default: | ||
| return null; | ||
| } | ||
| } | ||
| /** | ||
| * @param {Error} error the error | ||
| * @param {NormalModule} module module for which the code should be generated | ||
| * @param {GenerateContext} generateContext context for generate | ||
| * @returns {Source | null} generated code | ||
| */ | ||
| generateError(error, module, generateContext) { | ||
| switch (generateContext.type) { | ||
| case "javascript": { | ||
| return new RawSource( | ||
| `throw new Error(${JSON.stringify(error.message)});` | ||
| ); | ||
| } | ||
| default: | ||
| return null; | ||
| } | ||
| } | ||
| /** | ||
| * @param {NormalModule} module module for which the bailout reason should be determined | ||
| * @param {ConcatenationBailoutReasonContext} context context | ||
| * @returns {string | undefined} reason why this module can't be concatenated, undefined when it can be concatenated | ||
| */ | ||
| getConcatenationBailoutReason(module, context) { | ||
| return undefined; | ||
| } | ||
| /** | ||
| * @param {NormalModule} module fresh module | ||
| * @returns {SourceTypes} available types (do not mutate) | ||
| */ | ||
| getTypes(module) { | ||
| /** @type {Set<string>} */ | ||
| const sourceTypes = new Set(); | ||
| const connections = this._moduleGraph.getIncomingConnections(module); | ||
| for (const connection of connections) { | ||
| if (!connection.originModule) { | ||
| continue; | ||
| } | ||
| sourceTypes.add(connection.originModule.type.split("/")[0]); | ||
| } | ||
| if (sourceTypes.size > 0) { | ||
| if (sourceTypes.has("javascript") && sourceTypes.has("css")) { | ||
| return JS_AND_CSS_URL_TYPES; | ||
| } else if (sourceTypes.has("css")) { | ||
| return CSS_URL_TYPES; | ||
| } | ||
| return JS_TYPES; | ||
| } | ||
| return NO_TYPES; | ||
| } | ||
| /** | ||
| * @param {NormalModule} module the module | ||
| * @param {string=} type source type | ||
| * @returns {number} estimate size of the module | ||
| */ | ||
| getSize(module, type) { | ||
| const originalSource = module.originalSource(); | ||
| if (!originalSource) { | ||
| return 0; | ||
| } | ||
| // Example: m.exports="abcd" | ||
| return originalSource.size() + 12; | ||
| } | ||
| } | ||
| module.exports = AssetSourceGenerator; |
| /* | ||
| MIT License http://www.opensource.org/licenses/mit-license.php | ||
| Author Alexander Akait @alexander-akait | ||
| */ | ||
| "use strict"; | ||
| const Parser = require("../Parser"); | ||
| /** @typedef {import("../Module").BuildInfo} BuildInfo */ | ||
| /** @typedef {import("../Module").BuildMeta} BuildMeta */ | ||
| /** @typedef {import("../Parser").ParserState} ParserState */ | ||
| /** @typedef {import("../Parser").PreparsedAst} PreparsedAst */ | ||
| class AssetBytesParser extends Parser { | ||
| /** | ||
| * @param {string | Buffer | PreparsedAst} source the source to parse | ||
| * @param {ParserState} state the parser state | ||
| * @returns {ParserState} the parser state | ||
| */ | ||
| parse(source, state) { | ||
| if (typeof source === "object" && !Buffer.isBuffer(source)) { | ||
| throw new Error("AssetBytesParser doesn't accept preparsed AST"); | ||
| } | ||
| const { module } = state; | ||
| /** @type {BuildInfo} */ | ||
| (module.buildInfo).strict = true; | ||
| /** @type {BuildMeta} */ | ||
| (module.buildMeta).exportsType = "default"; | ||
| /** @type {BuildMeta} */ | ||
| (state.module.buildMeta).defaultObject = false; | ||
| return state; | ||
| } | ||
| } | ||
| module.exports = AssetBytesParser; |
| /* | ||
| MIT License http://www.opensource.org/licenses/mit-license.php | ||
| Author Alexander Akait @alexander-akait | ||
| */ | ||
| "use strict"; | ||
| const RuntimeGlobals = require("../RuntimeGlobals"); | ||
| const RuntimeModule = require("../RuntimeModule"); | ||
| const Template = require("../Template"); | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
| class ToBinaryRuntimeModule extends RuntimeModule { | ||
| constructor() { | ||
| super("to binary"); | ||
| } | ||
| /** | ||
| * @returns {string | null} runtime code | ||
| */ | ||
| generate() { | ||
| const compilation = /** @type {Compilation} */ (this.compilation); | ||
| const fn = RuntimeGlobals.toBinary; | ||
| const { runtimeTemplate } = compilation; | ||
| // Inspired by esbuild | ||
| const isNodePlatform = compilation.compiler.platform.node; | ||
| const isWebPlatform = compilation.compiler.platform.web; | ||
| const isNeutralPlatform = runtimeTemplate.isNeutralPlatform(); | ||
| return Template.asString([ | ||
| "// define to binary helper", | ||
| `${fn} = ${isNeutralPlatform ? "typeof Buffer !== 'undefined' ? " : ""}${ | ||
| isNodePlatform || isNeutralPlatform | ||
| ? `${runtimeTemplate.returningFunction("new Uint8Array(Buffer.from(base64, 'base64'))", "base64")}` | ||
| : "" | ||
| } ${isNeutralPlatform ? ": " : ""}${ | ||
| isWebPlatform || isNeutralPlatform | ||
| ? `(${runtimeTemplate.basicFunction("", [ | ||
| "var table = new Uint8Array(128);", | ||
| "for (var i = 0; i < 64; i++) table[i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i * 4 - 205] = i;", | ||
| `return ${runtimeTemplate.basicFunction("base64", [ | ||
| "var n = base64.length, bytes = new Uint8Array((n - (base64[n - 1] == '=') - (base64[n - 2] == '=')) * 3 / 4 | 0);", | ||
| "for (var i = 0, j = 0; i < n;) {", | ||
| Template.indent([ | ||
| "var c0 = table[base64.charCodeAt(i++)], c1 = table[base64.charCodeAt(i++)];", | ||
| "var c2 = table[base64.charCodeAt(i++)], c3 = table[base64.charCodeAt(i++)];", | ||
| "bytes[j++] = (c0 << 2) | (c1 >> 4);", | ||
| "bytes[j++] = (c1 << 4) | (c2 >> 2);", | ||
| "bytes[j++] = (c2 << 6) | c3;" | ||
| ]), | ||
| "}", | ||
| "return bytes" | ||
| ])}` | ||
| ])})();` | ||
| : "" | ||
| }` | ||
| ]); | ||
| } | ||
| } | ||
| module.exports = ToBinaryRuntimeModule; |
| /* | ||
| MIT License http://www.opensource.org/licenses/mit-license.php | ||
| Author Natsu @xiaoxiaojx | ||
| */ | ||
| "use strict"; | ||
| // data URL scheme: "data:text/javascript;charset=utf-8;base64,some-string" | ||
| // http://www.ietf.org/rfc/rfc2397.txt | ||
| const URIRegEx = /^data:([^;,]+)?((?:;[^;,]+)*?)(?:;(base64)?)?,(.*)$/i; | ||
| /** | ||
| * @param {string} uri data URI | ||
| * @returns {Buffer | null} decoded data | ||
| */ | ||
| const decodeDataURI = (uri) => { | ||
| const match = URIRegEx.exec(uri); | ||
| if (!match) return null; | ||
| const isBase64 = match[3]; | ||
| const body = match[4]; | ||
| if (isBase64) { | ||
| return Buffer.from(body, "base64"); | ||
| } | ||
| // CSS allows to use `data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%" style="stroke: rgb(223,224,225); stroke-width: 2px; fill: none; stroke-dasharray: 6px 3px" /></svg>` | ||
| // so we return original body if we can't `decodeURIComponent` | ||
| try { | ||
| return Buffer.from(decodeURIComponent(body), "ascii"); | ||
| } catch (_) { | ||
| return Buffer.from(body, "ascii"); | ||
| } | ||
| }; | ||
| module.exports = { | ||
| URIRegEx, | ||
| decodeDataURI | ||
| }; |
| /* | ||
| MIT License http://www.opensource.org/licenses/mit-license.php | ||
| Author Natsu @xiaoxiaojx | ||
| */ | ||
| "use strict"; | ||
| const path = require("path"); | ||
| const urlUtils = require("url"); | ||
| const { isAbsolute, join } = require("./fs"); | ||
| /** @typedef {import("./fs").InputFileSystem} InputFileSystem */ | ||
| /** | ||
| * @typedef {(input: string | Buffer<ArrayBufferLike>, resourcePath: string, fs: InputFileSystem) => Promise<{source: string | Buffer<ArrayBufferLike>, sourceMap: string | RawSourceMap | undefined, fileDependencies: string[]}>} SourceMapExtractorFunction | ||
| */ | ||
| /** @typedef {import("webpack-sources").RawSourceMap} RawSourceMap */ | ||
| /** | ||
| * @typedef {(resourcePath: string) => Promise<string | Buffer<ArrayBufferLike>>} ReadResource | ||
| */ | ||
| /** | ||
| * @typedef {object} SourceMappingURL | ||
| * @property {string} sourceMappingURL | ||
| * @property {string} replacementString | ||
| */ | ||
| // Matches only the last occurrence of sourceMappingURL | ||
| const innerRegex = /\s*[#@]\s*sourceMappingURL\s*=\s*([^\s'"]*)\s*/; | ||
| const validProtocolPattern = /^[a-z][a-z0-9+.-]*:/i; | ||
| const sourceMappingURLRegex = new RegExp( | ||
| "(?:" + | ||
| "/\\*" + | ||
| "(?:\\s*\r?\n(?://)?)?" + | ||
| `(?:${innerRegex.source})` + | ||
| "\\s*" + | ||
| "\\*/" + | ||
| "|" + | ||
| `//(?:${innerRegex.source})` + | ||
| ")" + | ||
| "\\s*" | ||
| ); | ||
| /** | ||
| * Extract source mapping URL from code comments | ||
| * @param {string} code source code content | ||
| * @returns {SourceMappingURL} source mapping information | ||
| */ | ||
| function getSourceMappingURL(code) { | ||
| const lines = code.split(/^/m); | ||
| let match; | ||
| for (let i = lines.length - 1; i >= 0; i--) { | ||
| match = lines[i].match(sourceMappingURLRegex); | ||
| if (match) { | ||
| break; | ||
| } | ||
| } | ||
| const sourceMappingURL = match ? match[1] || match[2] || "" : ""; | ||
| return { | ||
| sourceMappingURL: sourceMappingURL | ||
| ? decodeURI(sourceMappingURL) | ||
| : sourceMappingURL, | ||
| replacementString: match ? match[0] : "" | ||
| }; | ||
| } | ||
| /** | ||
| * Get absolute path for source file | ||
| * @param {string} context context directory | ||
| * @param {string} request file request | ||
| * @param {string} sourceRoot source root directory | ||
| * @returns {string} absolute path | ||
| */ | ||
| function getAbsolutePath(context, request, sourceRoot) { | ||
| if (sourceRoot) { | ||
| if (isAbsolute(sourceRoot)) { | ||
| return join(undefined, sourceRoot, request); | ||
| } | ||
| return join(undefined, join(undefined, context, sourceRoot), request); | ||
| } | ||
| return join(undefined, context, request); | ||
| } | ||
| /** | ||
| * Check if value is a URL | ||
| * @param {string} value string to check | ||
| * @returns {boolean} true if value is a URL | ||
| */ | ||
| function isURL(value) { | ||
| return validProtocolPattern.test(value) && !path.win32.isAbsolute(value); | ||
| } | ||
| /** | ||
| * Fetch from multiple possible file paths | ||
| * @param {ReadResource} readResource read resource function | ||
| * @param {string[]} possibleRequests array of possible file paths | ||
| * @param {string} errorsAccumulator accumulated error messages | ||
| * @returns {Promise<{path: string, data?: string}>} source content promise | ||
| */ | ||
| async function fetchPathsFromURL( | ||
| readResource, | ||
| possibleRequests, | ||
| errorsAccumulator = "" | ||
| ) { | ||
| let result; | ||
| try { | ||
| result = await readResource(possibleRequests[0]); | ||
| } catch (error) { | ||
| errorsAccumulator += `${/** @type {Error} */ (error).message}\n\n`; | ||
| const [, ...tailPossibleRequests] = possibleRequests; | ||
| if (tailPossibleRequests.length === 0) { | ||
| /** @type {Error} */ (error).message = errorsAccumulator; | ||
| throw error; | ||
| } | ||
| return fetchPathsFromURL( | ||
| readResource, | ||
| tailPossibleRequests, | ||
| errorsAccumulator | ||
| ); | ||
| } | ||
| return { | ||
| path: possibleRequests[0], | ||
| data: result.toString("utf8") | ||
| }; | ||
| } | ||
| /** | ||
| * Fetch source content from URL | ||
| * @param {ReadResource} readResource The read resource function | ||
| * @param {string} context context directory | ||
| * @param {string} url source URL | ||
| * @param {string=} sourceRoot source root directory | ||
| * @param {boolean=} skipReading whether to skip reading file content | ||
| * @returns {Promise<{sourceURL: string, sourceContent?: string | Buffer<ArrayBufferLike>}>} source content promise | ||
| */ | ||
| async function fetchFromURL( | ||
| readResource, | ||
| context, | ||
| url, | ||
| sourceRoot, | ||
| skipReading = false | ||
| ) { | ||
| // 1. It's an absolute url and it is not `windows` path like `C:\dir\file` | ||
| if (isURL(url)) { | ||
| // eslint-disable-next-line n/no-deprecated-api | ||
| const { protocol } = urlUtils.parse(url); | ||
| if (protocol === "data:") { | ||
| const sourceContent = skipReading ? "" : await readResource(url); | ||
| return { sourceURL: "", sourceContent }; | ||
| } | ||
| if (protocol === "file:") { | ||
| const pathFromURL = urlUtils.fileURLToPath(url); | ||
| const sourceURL = path.normalize(pathFromURL); | ||
| const sourceContent = skipReading ? "" : await readResource(sourceURL); | ||
| return { sourceURL, sourceContent }; | ||
| } | ||
| const sourceContent = skipReading ? "" : await readResource(url); | ||
| return { sourceURL: url, sourceContent }; | ||
| } | ||
| // 3. Absolute path | ||
| if (isAbsolute(url)) { | ||
| let sourceURL = path.normalize(url); | ||
| let sourceContent; | ||
| if (!skipReading) { | ||
| const possibleRequests = [sourceURL]; | ||
| if (url.startsWith("/")) { | ||
| possibleRequests.push( | ||
| getAbsolutePath(context, sourceURL.slice(1), sourceRoot || "") | ||
| ); | ||
| } | ||
| const result = await fetchPathsFromURL(readResource, possibleRequests); | ||
| sourceURL = result.path; | ||
| sourceContent = result.data; | ||
| } | ||
| return { sourceURL, sourceContent }; | ||
| } | ||
| // 4. Relative path | ||
| const sourceURL = getAbsolutePath(context, url, sourceRoot || ""); | ||
| let sourceContent; | ||
| if (!skipReading) { | ||
| sourceContent = await readResource(sourceURL); | ||
| } | ||
| return { sourceURL, sourceContent }; | ||
| } | ||
| /** | ||
| * Extract source map from code content | ||
| * @param {string | Buffer<ArrayBufferLike>} stringOrBuffer The input code content as string or buffer | ||
| * @param {string} resourcePath The path to the resource file | ||
| * @param {ReadResource} readResource The read resource function | ||
| * @returns {Promise<{source: string | Buffer<ArrayBufferLike>, sourceMap: string | RawSourceMap | undefined}>} Promise resolving to extracted source map information | ||
| */ | ||
| async function extractSourceMap(stringOrBuffer, resourcePath, readResource) { | ||
| const input = | ||
| typeof stringOrBuffer === "string" | ||
| ? stringOrBuffer | ||
| : stringOrBuffer.toString("utf8"); | ||
| const inputSourceMap = undefined; | ||
| const output = { | ||
| source: stringOrBuffer, | ||
| sourceMap: inputSourceMap | ||
| }; | ||
| const { sourceMappingURL, replacementString } = getSourceMappingURL(input); | ||
| if (!sourceMappingURL) { | ||
| return output; | ||
| } | ||
| const baseContext = path.dirname(resourcePath); | ||
| const { sourceURL, sourceContent } = await fetchFromURL( | ||
| readResource, | ||
| baseContext, | ||
| sourceMappingURL | ||
| ); | ||
| if (!sourceContent) { | ||
| return output; | ||
| } | ||
| /** @type {RawSourceMap} */ | ||
| const map = JSON.parse( | ||
| sourceContent.toString("utf8").replace(/^\)\]\}'/, "") | ||
| ); | ||
| const context = sourceURL ? path.dirname(sourceURL) : baseContext; | ||
| const resolvedSources = await Promise.all( | ||
| map.sources.map( | ||
| async (/** @type {string} */ source, /** @type {number} */ i) => { | ||
| const originalSourceContent = | ||
| map.sourcesContent && | ||
| typeof map.sourcesContent[i] !== "undefined" && | ||
| map.sourcesContent[i] !== null | ||
| ? map.sourcesContent[i] | ||
| : undefined; | ||
| const skipReading = typeof originalSourceContent !== "undefined"; | ||
| // We do not skipReading here, because we need absolute paths in sources. | ||
| // This is necessary so that for sourceMaps with the same file structure in sources, name collisions do not occur. | ||
| // https://github.com/webpack-contrib/source-map-loader/issues/51 | ||
| let { sourceURL, sourceContent } = await fetchFromURL( | ||
| readResource, | ||
| context, | ||
| source, | ||
| map.sourceRoot, | ||
| skipReading | ||
| ); | ||
| if (skipReading) { | ||
| sourceContent = originalSourceContent; | ||
| } | ||
| // Return original value of `source` when error happens | ||
| return { sourceURL, sourceContent }; | ||
| } | ||
| ) | ||
| ); | ||
| /** @type {RawSourceMap} */ | ||
| const newMap = { ...map }; | ||
| newMap.sources = []; | ||
| newMap.sourcesContent = []; | ||
| delete newMap.sourceRoot; | ||
| for (const source of resolvedSources) { | ||
| const { sourceURL, sourceContent } = source; | ||
| newMap.sources.push(sourceURL || ""); | ||
| newMap.sourcesContent.push( | ||
| sourceContent ? sourceContent.toString("utf8") : "" | ||
| ); | ||
| } | ||
| const sourcesContentIsEmpty = | ||
| newMap.sourcesContent.filter(Boolean).length === 0; | ||
| if (sourcesContentIsEmpty) { | ||
| delete newMap.sourcesContent; | ||
| } | ||
| return { | ||
| source: input.replace(replacementString, ""), | ||
| sourceMap: /** @type {RawSourceMap} */ (newMap) | ||
| }; | ||
| } | ||
| module.exports = extractSourceMap; | ||
| module.exports.getSourceMappingURL = getSourceMappingURL; |
| /* | ||
| MIT License http://www.opensource.org/licenses/mit-license.php | ||
| Author Tobias Koppers @sokra | ||
| */ | ||
| "use strict"; | ||
| /** @typedef {import("../javascript/JavascriptParser").DestructuringAssignmentProperties} DestructuringAssignmentProperties */ | ||
| /** @typedef {import("../javascript/JavascriptParser").DestructuringAssignmentProperty} DestructuringAssignmentProperty */ | ||
| /** | ||
| * Deep first traverse the properties of a destructuring assignment. | ||
| * @param {DestructuringAssignmentProperties} properties destructuring assignment properties | ||
| * @param {((stack: DestructuringAssignmentProperty[]) => void) | undefined=} onLeftNode on left node callback | ||
| * @param {((stack: DestructuringAssignmentProperty[]) => void) | undefined=} enterNode enter node callback | ||
| * @param {((stack: DestructuringAssignmentProperty[]) => void) | undefined=} exitNode exit node callback | ||
| * @param {DestructuringAssignmentProperty[] | undefined=} stack stack of the walking nodes | ||
| */ | ||
| function traverseDestructuringAssignmentProperties( | ||
| properties, | ||
| onLeftNode, | ||
| enterNode, | ||
| exitNode, | ||
| stack = [] | ||
| ) { | ||
| for (const property of properties) { | ||
| stack.push(property); | ||
| if (enterNode) enterNode(stack); | ||
| if (property.pattern) { | ||
| traverseDestructuringAssignmentProperties( | ||
| property.pattern, | ||
| onLeftNode, | ||
| enterNode, | ||
| exitNode, | ||
| stack | ||
| ); | ||
| } else if (onLeftNode) { | ||
| onLeftNode(stack); | ||
| } | ||
| if (exitNode) exitNode(stack); | ||
| stack.pop(); | ||
| } | ||
| } | ||
| module.exports = traverseDestructuringAssignmentProperties; |
+30
-36
@@ -8,4 +8,6 @@ /* | ||
| const InitFragment = require("./InitFragment"); | ||
| const { | ||
| getExternalModuleNodeCommonjsInitFragment | ||
| } = require("./ExternalModule"); | ||
| const { | ||
| JAVASCRIPT_MODULE_TYPE_AUTO, | ||
@@ -34,7 +36,5 @@ JAVASCRIPT_MODULE_TYPE_DYNAMIC, | ||
| /** | ||
| * @param {boolean | undefined} module true if ES module | ||
| * @param {string} importMetaName `import.meta` name | ||
| * @returns {Record<string, {expr: string, req: string[] | null, type?: string, assign: boolean}>} replacements | ||
| */ | ||
| function getReplacements(module, importMetaName) { | ||
| function getReplacements() { | ||
| return { | ||
@@ -72,5 +72,3 @@ __webpack_require__: { | ||
| __non_webpack_require__: { | ||
| expr: module | ||
| ? `__WEBPACK_EXTERNAL_createRequire(${importMetaName}.url)` | ||
| : "require", | ||
| expr: "require", | ||
| req: null, | ||
@@ -138,16 +136,4 @@ type: undefined, // type is not known, depends on environment | ||
| /** | ||
| * @typedef {object} APIPluginOptions | ||
| * @property {boolean=} module the output filename | ||
| */ | ||
| class APIPlugin { | ||
| /** | ||
| * @param {APIPluginOptions=} options options | ||
| */ | ||
| constructor(options = {}) { | ||
| this.options = options; | ||
| } | ||
| /** | ||
| * Apply the plugin | ||
@@ -161,10 +147,12 @@ * @param {Compiler} compiler the compiler instance | ||
| (compilation, { normalModuleFactory }) => { | ||
| const importMetaName = /** @type {string} */ ( | ||
| compilation.outputOptions.importMetaName | ||
| ); | ||
| const REPLACEMENTS = getReplacements( | ||
| this.options.module, | ||
| importMetaName | ||
| ); | ||
| const moduleOutput = compilation.options.output.module; | ||
| const nodeTarget = compiler.platform.node; | ||
| const nodeEsm = moduleOutput && nodeTarget; | ||
| const REPLACEMENTS = getReplacements(); | ||
| if (nodeEsm) { | ||
| REPLACEMENTS.__non_webpack_require__.expr = | ||
| "__WEBPACK_EXTERNAL_createRequire_require"; | ||
| } | ||
| compilation.dependencyTemplates.set( | ||
@@ -199,9 +187,4 @@ ConstDependency, | ||
| const chunkInitFragments = [ | ||
| new InitFragment( | ||
| `import { createRequire as __WEBPACK_EXTERNAL_createRequire } from ${renderContext.runtimeTemplate.renderNodePrefixForCoreModule( | ||
| "module" | ||
| )};\n`, | ||
| InitFragment.STAGE_HARMONY_IMPORTS, | ||
| 0, | ||
| "external module node-commonjs" | ||
| getExternalModuleNodeCommonjsInitFragment( | ||
| renderContext.runtimeTemplate | ||
| ) | ||
@@ -226,5 +209,16 @@ ]; | ||
| if (key === "__non_webpack_require__" && this.options.module) { | ||
| /** @type {BuildInfo} */ | ||
| (parser.state.module.buildInfo).needCreateRequire = true; | ||
| if (key === "__non_webpack_require__" && moduleOutput) { | ||
| if (nodeTarget) { | ||
| /** @type {BuildInfo} */ | ||
| (parser.state.module.buildInfo).needCreateRequire = true; | ||
| } else { | ||
| const warning = new WebpackError( | ||
| `${PLUGIN_NAME}\n__non_webpack_require__ is only allowed in target node` | ||
| ); | ||
| warning.loc = /** @type {DependencyLocation} */ ( | ||
| expression.loc | ||
| ); | ||
| warning.module = parser.state.module; | ||
| compilation.warnings.push(warning); | ||
| } | ||
| } | ||
@@ -231,0 +225,0 @@ |
@@ -9,3 +9,2 @@ /* | ||
| const path = require("path"); | ||
| const mimeTypes = require("mime-types"); | ||
| const { RawSource } = require("webpack-sources"); | ||
@@ -29,4 +28,7 @@ const ConcatenationScope = require("../ConcatenationScope"); | ||
| const { makePathsRelative } = require("../util/identifier"); | ||
| const memoize = require("../util/memoize"); | ||
| const nonNumericOnlyHash = require("../util/nonNumericOnlyHash"); | ||
| const getMimeTypes = memoize(() => require("mime-types")); | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
@@ -38,14 +40,9 @@ /** @typedef {import("../../declarations/WebpackOptions").AssetGeneratorDataUrlOptions} AssetGeneratorDataUrlOptions */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").AssetResourceGeneratorOptions} AssetResourceGeneratorOptions */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").RawPublicPath} RawPublicPath */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
| /** @typedef {import("../Compilation").AssetInfo} AssetInfo */ | ||
| /** @typedef {import("../Compilation").InterpolatedPathAndAssetInfo} InterpolatedPathAndAssetInfo */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Generator").GenerateContext} GenerateContext */ | ||
| /** @typedef {import("../Generator").UpdateHashContext} UpdateHashContext */ | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../Module").NameForCondition} NameForCondition */ | ||
| /** @typedef {import("../Module").BuildInfo} BuildInfo */ | ||
| /** @typedef {import("../Module").BuildMeta} BuildMeta */ | ||
| /** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */ | ||
@@ -56,3 +53,2 @@ /** @typedef {import("../Module").SourceTypes} SourceTypes */ | ||
| /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ | ||
| /** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */ | ||
| /** @typedef {import("../util/Hash")} Hash */ | ||
@@ -64,5 +60,5 @@ /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */ | ||
| * @template U | ||
| * @param {null | string | Array<T> | Set<T> | undefined} a a | ||
| * @param {null | string | Array<U> | Set<U> | undefined} b b | ||
| * @returns {Array<T> & Array<U>} array | ||
| * @param {null | string | T[] | Set<T> | undefined} a a | ||
| * @param {null | string | U[] | Set<U> | undefined} b b | ||
| * @returns {T[] & U[]} array | ||
| */ | ||
@@ -228,3 +224,4 @@ const mergeMaybeArrays = (a, b) => { | ||
| runtimeTemplate.compilation.compiler.context, | ||
| module.matchResource || module.resource, | ||
| /** @type {string} */ | ||
| (module.getResource()), | ||
| runtimeTemplate.compilation.compiler.root | ||
@@ -240,6 +237,3 @@ ).replace(/^\.\//, ""); | ||
| static getFullContentHash(module, runtimeTemplate) { | ||
| const hash = createHash( | ||
| /** @type {HashFunction} */ | ||
| (runtimeTemplate.outputOptions.hashFunction) | ||
| ); | ||
| const hash = createHash(runtimeTemplate.outputOptions.hashFunction); | ||
@@ -267,4 +261,3 @@ if (runtimeTemplate.outputOptions.hashSalt) { | ||
| fullContentHash, | ||
| /** @type {number} */ | ||
| (runtimeTemplate.outputOptions.hashDigestLength) | ||
| runtimeTemplate.outputOptions.hashDigestLength | ||
| ); | ||
@@ -290,4 +283,3 @@ | ||
| generatorOptions.filename || | ||
| /** @type {AssetModuleFilename} */ | ||
| (runtimeTemplate.outputOptions.assetModuleFilename); | ||
| runtimeTemplate.outputOptions.assetModuleFilename; | ||
@@ -393,9 +385,5 @@ const sourceFilename = AssetGenerator.getSourceFileName( | ||
| ? CssUrlDependency.PUBLIC_PATH_AUTO | ||
| : compilation.getAssetPath( | ||
| /** @type {TemplatePath} */ | ||
| (compilation.outputOptions.publicPath), | ||
| { | ||
| hash: compilation.hash | ||
| } | ||
| ); | ||
| : compilation.getAssetPath(compilation.outputOptions.publicPath, { | ||
| hash: compilation.hash | ||
| }); | ||
@@ -438,3 +426,3 @@ assetPath = path + filename; | ||
| const ext = path.extname( | ||
| /** @type {string} */ | ||
| /** @type {NameForCondition} */ | ||
| (module.nameForCondition()) | ||
@@ -450,3 +438,3 @@ ); | ||
| } else if (ext) { | ||
| mimeType = mimeTypes.lookup(ext); | ||
| mimeType = getMimeTypes().lookup(ext); | ||
@@ -486,3 +474,3 @@ if (typeof mimeType !== "string") { | ||
| encodedSource = this.dataUrlOptions.call(null, source.source(), { | ||
| filename: module.matchResource || module.resource, | ||
| filename: /** @type {string} */ (module.getResource()), | ||
| module | ||
@@ -635,3 +623,3 @@ }); | ||
| return new RawSource( | ||
| `${runtimeTemplate.supportsConst() ? "const" : "var"} ${ | ||
| `${runtimeTemplate.renderConst()} ${ | ||
| ConcatenationScope.NAMESPACE_OBJECT_EXPORT | ||
@@ -811,5 +799,3 @@ } = ${content};` | ||
| const assetModuleFilename = | ||
| this.filename || | ||
| /** @type {AssetModuleFilename} */ | ||
| (runtimeTemplate.outputOptions.assetModuleFilename); | ||
| this.filename || runtimeTemplate.outputOptions.assetModuleFilename; | ||
| const { path: filename, info } = | ||
@@ -816,0 +802,0 @@ runtimeTemplate.compilation.getAssetPathWithInfo( |
@@ -10,2 +10,3 @@ /* | ||
| ASSET_MODULE_TYPE, | ||
| ASSET_MODULE_TYPE_BYTES, | ||
| ASSET_MODULE_TYPE_INLINE, | ||
@@ -15,3 +16,2 @@ ASSET_MODULE_TYPE_RESOURCE, | ||
| } = require("../ModuleTypeConstants"); | ||
| const { cleverMerge } = require("../util/cleverMerge"); | ||
| const { compareModulesByIdOrIdentifier } = require("../util/comparators"); | ||
@@ -22,8 +22,5 @@ const createSchemaValidation = require("../util/create-schema-validation"); | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").AssetParserOptions} AssetParserOptions */ | ||
| /** @typedef {import("schema-utils").Schema} Schema */ | ||
| /** @typedef {import("../Chunk")} Chunk */ | ||
| /** @typedef {import("../Compilation").AssetInfo} AssetInfo */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../Module").BuildInfo} BuildInfo */ | ||
@@ -80,5 +77,7 @@ /** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */ | ||
| const getAssetSourceParser = memoize(() => require("./AssetSourceParser")); | ||
| const getAssetBytesParser = memoize(() => require("./AssetBytesParser")); | ||
| const getAssetSourceGenerator = memoize(() => | ||
| require("./AssetSourceGenerator") | ||
| ); | ||
| const getAssetBytesGenerator = memoize(() => require("./AssetBytesGenerator")); | ||
@@ -102,7 +101,2 @@ const type = ASSET_MODULE_TYPE; | ||
| validateParserOptions(parserOptions); | ||
| parserOptions = cleverMerge( | ||
| /** @type {AssetParserOptions} */ | ||
| (compiler.options.module.parser.asset), | ||
| parserOptions | ||
| ); | ||
@@ -142,3 +136,10 @@ let dataUrlCondition = parserOptions.dataUrlCondition; | ||
| }); | ||
| normalModuleFactory.hooks.createParser | ||
| .for(ASSET_MODULE_TYPE_BYTES) | ||
| .tap(PLUGIN_NAME, (_parserOptions) => { | ||
| const AssetBytesParser = getAssetBytesParser(); | ||
| return new AssetBytesParser(); | ||
| }); | ||
| for (const type of [ | ||
@@ -195,2 +196,10 @@ ASSET_MODULE_TYPE, | ||
| normalModuleFactory.hooks.createGenerator | ||
| .for(ASSET_MODULE_TYPE_BYTES) | ||
| .tap(PLUGIN_NAME, () => { | ||
| const AssetBytesGenerator = getAssetBytesGenerator(); | ||
| return new AssetBytesGenerator(compilation.moduleGraph); | ||
| }); | ||
| compilation.hooks.renderManifest.tap(PLUGIN_NAME, (result, options) => { | ||
@@ -255,6 +264,11 @@ const { chunkGraph } = compilation; | ||
| } else { | ||
| entryFilename = buildInfo.filename || data.get("filename"); | ||
| entryInfo = buildInfo.assetInfo || data.get("assetInfo"); | ||
| entryFilename = | ||
| /** @type {string} */ | ||
| (buildInfo.filename || data.get("filename")); | ||
| entryInfo = | ||
| /** @type {AssetInfo} */ | ||
| (buildInfo.assetInfo || data.get("assetInfo")); | ||
| entryHash = | ||
| buildInfo.fullContentHash || data.get("fullContentHash"); | ||
| /** @type {string} */ | ||
| (buildInfo.fullContentHash || data.get("fullContentHash")); | ||
| } | ||
@@ -291,6 +305,10 @@ | ||
| (codeGenerationResult.data); | ||
| context.assets.set(data.get("filename"), { | ||
| source, | ||
| info: data.get("assetInfo") | ||
| }); | ||
| context.assets.set( | ||
| /** @type {string} */ | ||
| (data.get("filename")), | ||
| { | ||
| source, | ||
| info: data.get("assetInfo") | ||
| } | ||
| ); | ||
| } | ||
@@ -297,0 +315,0 @@ ); |
@@ -36,5 +36,9 @@ /* | ||
| const buildInfo = /** @type {BuildInfo} */ (state.module.buildInfo); | ||
| const buildInfo = | ||
| /** @type {BuildInfo} */ | ||
| (state.module.buildInfo); | ||
| buildInfo.strict = true; | ||
| const buildMeta = /** @type {BuildMeta} */ (state.module.buildMeta); | ||
| const buildMeta = | ||
| /** @type {BuildMeta} */ | ||
| (state.module.buildMeta); | ||
| buildMeta.exportsType = "default"; | ||
@@ -45,3 +49,3 @@ buildMeta.defaultObject = false; | ||
| buildInfo.dataUrl = this.dataUrlCondition(source, { | ||
| filename: state.module.matchResource || state.module.resource, | ||
| filename: /** @type {string} */ (state.module.getResource()), | ||
| module: state.module | ||
@@ -48,0 +52,0 @@ }); |
@@ -63,3 +63,3 @@ /* | ||
| ); | ||
| sourceContent = `${runtimeTemplate.supportsConst() ? "const" : "var"} ${ | ||
| sourceContent = `${runtimeTemplate.renderConst()} ${ | ||
| ConcatenationScope.NAMESPACE_OBJECT_EXPORT | ||
@@ -66,0 +66,0 @@ } = ${JSON.stringify(encodedSource)};`; |
@@ -15,6 +15,7 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */ | ||
| /** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */ | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
| /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */ | ||
| /** @typedef {import("../Module").BuildCallback} BuildCallback */ | ||
| /** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */ | ||
| /** @typedef {import("../Module").CodeGenerationContext} CodeGenerationContext */ | ||
@@ -27,3 +28,2 @@ /** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */ | ||
| /** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */ | ||
| /** @typedef {import("../WebpackError")} WebpackError */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
@@ -125,2 +125,3 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| }); | ||
| /** @type {RuntimeRequirements} */ | ||
| const runtimeRequirements = new Set(); | ||
@@ -127,0 +128,0 @@ runtimeRequirements.add(RuntimeGlobals.module); |
@@ -13,13 +13,15 @@ /* | ||
| /** @typedef {Set<Module>} Modules */ | ||
| /** | ||
| * @param {ModuleGraph} moduleGraph module graph | ||
| * @param {Module} module module | ||
| * @returns {Set<Module>} set of modules | ||
| * @returns {Modules} set of modules | ||
| */ | ||
| const getOutgoingAsyncModules = (moduleGraph, module) => { | ||
| /** @type {Set<Module>} */ | ||
| /** @type {Modules} */ | ||
| const set = new Set(); | ||
| /** @type {Set<Module>} */ | ||
| /** @type {Modules} */ | ||
| const seen = new Set(); | ||
| (function g(/** @type {Module} */ module) { | ||
| (function g(module) { | ||
| if (!moduleGraph.isAsync(module) || seen.has(module)) return; | ||
@@ -26,0 +28,0 @@ seen.add(module); |
@@ -11,4 +11,2 @@ /* | ||
| /** @typedef {import("./ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("./ChunkGroup")} ChunkGroup */ | ||
| /** @typedef {import("./ChunkGroup").ChunkGroupOptions} ChunkGroupOptions */ | ||
@@ -18,3 +16,2 @@ /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */ | ||
| /** @typedef {import("./Entrypoint").EntryOptions} EntryOptions */ | ||
| /** @typedef {import("./Module")} Module */ | ||
| /** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
@@ -46,3 +43,3 @@ /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** | ||
| * @returns {string | null | undefined} The name of the chunk | ||
| * @returns {ChunkGroupOptions["name"]} The name of the chunk | ||
| */ | ||
@@ -49,0 +46,0 @@ get chunkName() { |
@@ -16,3 +16,2 @@ /* | ||
| /** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginArgument} BannerPluginArgument */ | ||
| /** @typedef {import("../declarations/plugins/BannerPlugin").BannerPluginOptions} BannerPluginOptions */ | ||
| /** @typedef {import("./Compilation").PathData} PathData */ | ||
@@ -19,0 +18,0 @@ /** @typedef {import("./Compiler")} Compiler */ |
@@ -18,3 +18,2 @@ /* | ||
| /** @typedef {import("./DependenciesBlock")} DependenciesBlock */ | ||
| /** @typedef {import("./Dependency")} Dependency */ | ||
| /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */ | ||
@@ -21,0 +20,0 @@ /** @typedef {import("./Entrypoint")} Entrypoint */ |
+7
-6
@@ -32,5 +32,6 @@ /* | ||
| /** | ||
| * @template T | ||
| * @callback GotHandler | ||
| * @param {TODO} result | ||
| * @param {(err?: Error) => void} callback | ||
| * @param {T} result | ||
| * @param {() => void} callback | ||
| * @returns {void} | ||
@@ -41,4 +42,4 @@ */ | ||
| * @param {number} times times | ||
| * @param {(err?: Error) => void} callback callback | ||
| * @returns {(err?: Error) => void} callback | ||
| * @param {(err?: Error | null) => void} callback callback | ||
| * @returns {(err?: Error | null) => void} callback | ||
| */ | ||
@@ -58,3 +59,3 @@ const needCalls = (times, callback) => (err) => { | ||
| this.hooks = { | ||
| /** @type {AsyncSeriesBailHook<[string, Etag | null, GotHandler[]], Data>} */ | ||
| /** @type {AsyncSeriesBailHook<[string, Etag | null, GotHandler<EXPECTED_ANY>[]], Data>} */ | ||
| get: new AsyncSeriesBailHook(["identifier", "etag", "gotHandlers"]), | ||
@@ -82,3 +83,3 @@ /** @type {AsyncParallelHook<[string, Etag | null, Data]>} */ | ||
| get(identifier, etag, callback) { | ||
| /** @type {GotHandler[]} */ | ||
| /** @type {GotHandler<T>[]} */ | ||
| const gotHandlers = []; | ||
@@ -85,0 +86,0 @@ this.hooks.get.callAsync(identifier, etag, gotHandlers, (err, result) => { |
@@ -10,7 +10,5 @@ /* | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("../Cache").Data} Data */ | ||
| /** @typedef {import("../Cache").Etag} Etag */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Module")} Module */ | ||
@@ -17,0 +15,0 @@ class MemoryCachePlugin { |
@@ -10,7 +10,5 @@ /* | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("../Cache").Data} Data */ | ||
| /** @typedef {import("../Cache").Etag} Etag */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Module")} Module */ | ||
@@ -17,0 +15,0 @@ /** |
@@ -54,7 +54,13 @@ /* | ||
| ) { | ||
| /** @type {Pack | (() => Pack) } */ | ||
| this.data = data; | ||
| /** @type {string} */ | ||
| this.version = version; | ||
| /** @type {Snapshot} */ | ||
| this.buildSnapshot = buildSnapshot; | ||
| /** @type {BuildDependencies} */ | ||
| this.buildDependencies = buildDependencies; | ||
| /** @type {ResolveResults} */ | ||
| this.resolveResults = resolveResults; | ||
| /** @type {Snapshot} */ | ||
| this.resolveBuildDependenciesSnapshot = resolveBuildDependenciesSnapshot; | ||
@@ -108,6 +114,11 @@ } | ||
| constructor(identifier, etag, value) { | ||
| /** @type {string} */ | ||
| this.identifier = identifier; | ||
| /** @type {string | null | undefined} */ | ||
| this.etag = etag; | ||
| /** @type {number} */ | ||
| this.location = -1; | ||
| /** @type {number} */ | ||
| this.lastAccess = Date.now(); | ||
| /** @type {Data} */ | ||
| this.freshValue = value; | ||
@@ -1290,3 +1301,5 @@ } | ||
| logger.time("restore cache content metadata"); | ||
| const d = /** @type {TODO} */ (packContainer).data(); | ||
| const d = | ||
| /** @type {() => Pack} */ | ||
| (packContainer.data)(); | ||
| logger.timeEnd("restore cache content metadata"); | ||
@@ -1293,0 +1306,0 @@ return d; |
@@ -29,6 +29,3 @@ /* | ||
| /** | ||
| * @template H | ||
| * @typedef {import("tapable").HookMapInterceptor<H>} HookMapInterceptor | ||
| */ | ||
| /** @typedef {Set<string>} Dependencies */ | ||
@@ -167,7 +164,4 @@ class CacheEntry { | ||
| stack: new Set(), | ||
| /** @type {LazySet<string>} */ | ||
| missingDependencies: new LazySet(), | ||
| /** @type {LazySet<string>} */ | ||
| fileDependencies: new LazySet(), | ||
| /** @type {LazySet<string>} */ | ||
| contextDependencies: new LazySet() | ||
@@ -191,4 +185,4 @@ }; | ||
| addAllToSet( | ||
| /** @type {Set<string>} */ (resolveContext[key]), | ||
| /** @type {Set<string>} */ (newResolveContext[key]) | ||
| /** @type {Dependencies} */ (resolveContext[key]), | ||
| /** @type {Dependencies} */ (newResolveContext[key]) | ||
| ); | ||
@@ -213,7 +207,7 @@ } | ||
| resolveTime, | ||
| /** @type {Set<string>} */ | ||
| /** @type {Dependencies} */ | ||
| (fileDependencies), | ||
| /** @type {Set<string>} */ | ||
| /** @type {Dependencies} */ | ||
| (contextDependencies), | ||
| /** @type {Set<string>} */ | ||
| /** @type {Dependencies} */ | ||
| (missingDependencies), | ||
@@ -411,3 +405,3 @@ snapshotOptions, | ||
| addAllToSet( | ||
| /** @type {Set<string>} */ | ||
| /** @type {Dependencies} */ | ||
| (resolveContext.missingDependencies), | ||
@@ -419,3 +413,3 @@ snapshot.getMissingIterable() | ||
| addAllToSet( | ||
| /** @type {Set<string>} */ | ||
| /** @type {Dependencies} */ | ||
| (resolveContext.fileDependencies), | ||
@@ -427,3 +421,3 @@ snapshot.getFileIterable() | ||
| addAllToSet( | ||
| /** @type {Set<string>} */ | ||
| /** @type {Dependencies} */ | ||
| (resolveContext.contextDependencies), | ||
@@ -430,0 +424,0 @@ snapshot.getContextIterable() |
@@ -15,3 +15,2 @@ /* | ||
| /** @typedef {import("./Cache").Etag} Etag */ | ||
| /** @typedef {import("./WebpackError")} WebpackError */ | ||
| /** @typedef {import("./cache/getLazyHashedEtag").HashableObject} HashableObject */ | ||
@@ -18,0 +17,0 @@ /** @typedef {typeof import("./util/Hash")} HashConstructor */ |
+49
-31
@@ -21,3 +21,2 @@ /* | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("./ChunkGraph").ChunkFilterPredicate} ChunkFilterPredicate */ | ||
@@ -29,7 +28,4 @@ /** @typedef {import("./ChunkGraph").ChunkSizeOptions} ChunkSizeOptions */ | ||
| /** @typedef {import("./ChunkGroup").ChunkGroupOptions} ChunkGroupOptions */ | ||
| /** @typedef {import("./Compilation")} Compilation */ | ||
| /** @typedef {import("./Compilation").AssetInfo} AssetInfo */ | ||
| /** @typedef {import("./Entrypoint").EntryOptions} EntryOptions */ | ||
| /** @typedef {import("./Module")} Module */ | ||
| /** @typedef {import("./ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */ | ||
@@ -40,3 +36,3 @@ /** @typedef {import("./util/Hash")} Hash */ | ||
| /** @typedef {string | null} ChunkName */ | ||
| /** @typedef {number | string} ChunkId */ | ||
| /** @typedef {string | number} ChunkId */ | ||
| /** @typedef {SortableSet<string>} IdNameHints */ | ||
@@ -47,4 +43,7 @@ | ||
| /** | ||
| * @typedef {object} WithId an object who has an id property * | ||
| * @property {string | number} id the id of the object | ||
| * @deprecated | ||
| * @typedef {object} ChunkMaps | ||
| * @property {Record<ChunkId, string>} hash | ||
| * @property {Record<ChunkId, Record<string, string>>} contentHash | ||
| * @property {Record<ChunkId, string>} name | ||
| */ | ||
@@ -54,6 +53,3 @@ | ||
| * @deprecated | ||
| * @typedef {object} ChunkMaps | ||
| * @property {Record<string | number, string>} hash | ||
| * @property {Record<string | number, Record<string, string>>} contentHash | ||
| * @property {Record<string | number, string>} name | ||
| * @typedef {Record<ChunkId, ChunkId[]>} ChunkModuleIdMap | ||
| */ | ||
@@ -63,7 +59,19 @@ | ||
| * @deprecated | ||
| * @typedef {Record<ModuleId, string>} chunkModuleHashMap | ||
| */ | ||
| /** | ||
| * @deprecated | ||
| * @typedef {object} ChunkModuleMaps | ||
| * @property {Record<string|number, (string|number)[]>} id | ||
| * @property {Record<string|number, string>} hash | ||
| * @property {ChunkModuleIdMap} id | ||
| * @property {chunkModuleHashMap} hash | ||
| */ | ||
| /** @typedef {Set<Chunk>} Chunks */ | ||
| /** @typedef {Set<Entrypoint>} Entrypoints */ | ||
| /** @typedef {Set<ChunkGroup>} Queue */ | ||
| /** @typedef {SortableSet<ChunkGroup>} SortableChunkGroups */ | ||
| /** @typedef {Record<string, ChunkId[]>} ChunkChildIdsByOrdersMap */ | ||
| /** @typedef {Record<string, ChunkChildIdsByOrdersMap>} ChunkChildIdsByOrdersMapByData */ | ||
| let debugId = 1000; | ||
@@ -99,3 +107,3 @@ | ||
| * @private | ||
| * @type {SortableSet<ChunkGroup>} | ||
| * @type {SortableChunkGroups} | ||
| */ | ||
@@ -363,5 +371,5 @@ this._groups = new SortableSet(undefined, compareChunkGroupsByIndex); | ||
| ); | ||
| /** @type {Record<string|number, (string|number)[]>} */ | ||
| /** @type {ChunkModuleIdMap} */ | ||
| const chunkModuleIdMap = Object.create(null); | ||
| /** @type {Record<string|number, string>} */ | ||
| /** @type {chunkModuleHashMap} */ | ||
| const chunkModuleHashMap = Object.create(null); | ||
@@ -419,7 +427,7 @@ | ||
| getChunkMaps(realHash) { | ||
| /** @type {Record<string|number, string>} */ | ||
| /** @type {Record<ChunkId, string>} */ | ||
| const chunkHashMap = Object.create(null); | ||
| /** @type {Record<string|number, Record<string, string>>} */ | ||
| /** @type {Record<string, Record<ChunkId, string>>} */ | ||
| const chunkContentHashMap = Object.create(null); | ||
| /** @type {Record<string|number, string>} */ | ||
| /** @type {Record<ChunkId, string>} */ | ||
| const chunkNameMap = Object.create(null); | ||
@@ -531,3 +539,3 @@ | ||
| /** | ||
| * @returns {SortableSet<ChunkGroup>} the chunkGroups that the said chunk is referenced in | ||
| * @returns {SortableChunkGroups} the chunkGroups that the said chunk is referenced in | ||
| */ | ||
@@ -589,6 +597,8 @@ get groupsIterable() { | ||
| /** | ||
| * @returns {Set<Chunk>} a set of all the async chunks | ||
| * @returns {Chunks} a set of all the async chunks | ||
| */ | ||
| getAllAsyncChunks() { | ||
| /** @type {Queue} */ | ||
| const queue = new Set(); | ||
| /** @type {Chunks} */ | ||
| const chunks = new Set(); | ||
@@ -600,2 +610,3 @@ | ||
| /** @type {Queue} */ | ||
| const initialQueue = new Set(this.groupsIterable); | ||
@@ -628,6 +639,8 @@ | ||
| /** | ||
| * @returns {Set<Chunk>} a set of all the initial chunks (including itself) | ||
| * @returns {Chunks} a set of all the initial chunks (including itself) | ||
| */ | ||
| getAllInitialChunks() { | ||
| /** @type {Chunks} */ | ||
| const chunks = new Set(); | ||
| /** @type {Queue} */ | ||
| const queue = new Set(this.groupsIterable); | ||
@@ -644,6 +657,8 @@ for (const group of queue) { | ||
| /** | ||
| * @returns {Set<Chunk>} a set of all the referenced chunks (including itself) | ||
| * @returns {Chunks} a set of all the referenced chunks (including itself) | ||
| */ | ||
| getAllReferencedChunks() { | ||
| /** @type {Queue} */ | ||
| const queue = new Set(this.groupsIterable); | ||
| /** @type {Chunks} */ | ||
| const chunks = new Set(); | ||
@@ -664,6 +679,8 @@ | ||
| /** | ||
| * @returns {Set<Entrypoint>} a set of all the referenced entrypoints | ||
| * @returns {Entrypoints} a set of all the referenced entrypoints | ||
| */ | ||
| getAllReferencedAsyncEntrypoints() { | ||
| /** @type {Queue} */ | ||
| const queue = new Set(this.groupsIterable); | ||
| /** @type {Entrypoints} */ | ||
| const entrypoints = new Set(); | ||
@@ -673,3 +690,3 @@ | ||
| for (const entrypoint of chunkGroup.asyncEntrypointsIterable) { | ||
| entrypoints.add(entrypoint); | ||
| entrypoints.add(/** @type {Entrypoint} */ (entrypoint)); | ||
| } | ||
@@ -688,2 +705,3 @@ for (const child of chunkGroup.childrenIterable) { | ||
| hasAsyncChunks() { | ||
| /** @type {Queue} */ | ||
| const queue = new Set(); | ||
@@ -750,3 +768,3 @@ | ||
| } | ||
| /** @type {Record<string, (string | number)[]>} */ | ||
| /** @type {Record<string, ChunkId[]>} */ | ||
| const result = Object.create(null); | ||
@@ -777,3 +795,3 @@ for (const [name, list] of lists) { | ||
| * @param {string} type option name | ||
| * @returns {{ onChunks: Chunk[], chunks: Set<Chunk> }[] | undefined} referenced chunks for a specific type | ||
| * @returns {{ onChunks: Chunk[], chunks: Chunks }[] | undefined} referenced chunks for a specific type | ||
| */ | ||
@@ -824,6 +842,6 @@ getChildrenOfTypeInOrder(chunkGraph, type) { | ||
| * @param {ChunkFilterPredicate=} filterFn function used to filter chunks | ||
| * @returns {Record<string|number, Record<string, (string | number)[]>>} a record object of names to lists of child ids(?) by chunk id | ||
| * @returns {ChunkChildIdsByOrdersMapByData} a record object of names to lists of child ids(?) by chunk id | ||
| */ | ||
| getChildIdsByOrdersMap(chunkGraph, includeDirectChildren, filterFn) { | ||
| /** @type {Record<string|number, Record<string, (string | number)[]>>} */ | ||
| /** @type {ChunkChildIdsByOrdersMapByData} */ | ||
| const chunkMaps = Object.create(null); | ||
@@ -847,3 +865,3 @@ | ||
| if (includeDirectChildren) { | ||
| /** @type {Set<Chunk>} */ | ||
| /** @type {Chunks} */ | ||
| const chunks = new Set(); | ||
@@ -876,3 +894,3 @@ for (const chunkGroup of this.groupsIterable) { | ||
| if (includeDirectChildren) { | ||
| /** @type {Set<Chunk>} */ | ||
| /** @type {Chunks} */ | ||
| const chunks = new Set(); | ||
@@ -879,0 +897,0 @@ for (const chunkGroup of this.groupsIterable) { |
+35
-25
@@ -34,2 +34,4 @@ /* | ||
| /** @typedef {import("./Chunk")} Chunk */ | ||
| /** @typedef {import("./Chunk").Chunks} Chunks */ | ||
| /** @typedef {import("./Chunk").Entrypoints} Entrypoints */ | ||
| /** @typedef {import("./Chunk").ChunkId} ChunkId */ | ||
@@ -83,3 +85,3 @@ /** @typedef {import("./ChunkGroup")} ChunkGroup */ | ||
| /** | ||
| * @param {SortableSet<Chunk>} chunks the chunks | ||
| * @param {SortableChunks} chunks the chunks | ||
| * @returns {RuntimeSpecSet} runtimes | ||
@@ -96,3 +98,3 @@ */ | ||
| /** | ||
| * @param {WeakMap<Module, Set<string>> | undefined} sourceTypesByModule sourceTypesByModule | ||
| * @param {SourceTypesByModule | undefined} sourceTypesByModule sourceTypesByModule | ||
| * @returns {(set: SortableSet<Module>) => Map<string, SortableSet<Module>>} modules by source type | ||
@@ -198,2 +200,3 @@ */ | ||
| /** @typedef {SortableSet<Chunk>} SortableChunks */ | ||
| /** @typedef {Set<Chunk>} EntryInChunks */ | ||
@@ -205,3 +208,3 @@ /** @typedef {Set<Chunk>} RuntimeInChunks */ | ||
| constructor() { | ||
| /** @type {SortableSet<Chunk>} */ | ||
| /** @type {SortableChunks} */ | ||
| this.chunks = new SortableSet(); | ||
@@ -225,2 +228,5 @@ /** @type {EntryInChunks | undefined} */ | ||
| /** @typedef {WeakMap<Module, Set<string>>} SourceTypesByModule */ | ||
| /** @typedef {Map<Module, Entrypoint>} EntryModules */ | ||
| class ChunkGraphChunk { | ||
@@ -230,5 +236,5 @@ constructor() { | ||
| this.modules = new SortableSet(); | ||
| /** @type {WeakMap<Module, Set<string>> | undefined} */ | ||
| /** @type {SourceTypesByModule | undefined} */ | ||
| this.sourceTypesByModule = undefined; | ||
| /** @type {Map<Module, Entrypoint>} */ | ||
| /** @type {EntryModules} */ | ||
| this.entryModules = new Map(); | ||
@@ -241,3 +247,3 @@ /** @type {SortableSet<RuntimeModule>} */ | ||
| this.dependentHashModules = undefined; | ||
| /** @type {Set<string> | undefined} */ | ||
| /** @type {RuntimeRequirements | undefined} */ | ||
| this.runtimeRequirements = undefined; | ||
@@ -251,2 +257,7 @@ /** @type {Set<string>} */ | ||
| /** @typedef {string | number} RuntimeId */ | ||
| /** @typedef {Record<ModuleId, string>} IdToHashMap */ | ||
| /** @typedef {Record<ChunkId, IdToHashMap>} ChunkModuleHashMap */ | ||
| /** @typedef {Record<ChunkId, ModuleId[]>} ChunkModuleIdMap */ | ||
| /** @typedef {(a: Module, b: Module) => -1 | 0 | 1} ModuleComparator */ | ||
@@ -277,3 +288,3 @@ | ||
| * @private | ||
| * @type {Map<string, string | number>} | ||
| * @type {Map<string, RuntimeId>} | ||
| */ | ||
@@ -465,3 +476,3 @@ this._runtimeIds = new Map(); | ||
| const old = /** @type {Entrypoint} */ (cgc.entryModules.get(oldModule)); | ||
| /** @type {Map<Module, Entrypoint>} */ | ||
| /** @type {EntryModules} */ | ||
| const newEntryModules = new Map(); | ||
@@ -754,6 +765,6 @@ for (const [m, cg] of cgc.entryModules) { | ||
| * @param {boolean} includeAllChunks all chunks or only async chunks | ||
| * @returns {Record<string|number, (string|number)[]>} chunk to module ids object | ||
| * @returns {ChunkModuleIdMap} chunk to module ids object | ||
| */ | ||
| getChunkModuleIdMap(chunk, filterFn, includeAllChunks = false) { | ||
| /** @type {Record<string|number, (string|number)[]>} */ | ||
| /** @type {ChunkModuleIdMap} */ | ||
| const chunkModuleIdMap = Object.create(null); | ||
@@ -764,3 +775,3 @@ | ||
| : chunk.getAllAsyncChunks()) { | ||
| /** @type {(string | number)[] | undefined} */ | ||
| /** @type {ModuleId[] | undefined} */ | ||
| let array; | ||
@@ -790,3 +801,3 @@ for (const module of this.getOrderedChunkModulesIterable( | ||
| * @param {boolean} includeAllChunks all chunks or only async chunks | ||
| * @returns {Record<string|number, Record<string|number, string>>} chunk to module id to module hash object | ||
| * @returns {ChunkModuleHashMap} chunk to module id to module hash object | ||
| */ | ||
@@ -799,7 +810,5 @@ getChunkModuleRenderedHashMap( | ||
| ) { | ||
| /** @type {Record<ChunkId, Record<string|number, string>>} */ | ||
| /** @type {ChunkModuleHashMap} */ | ||
| const chunkModuleHashMap = Object.create(null); | ||
| /** @typedef {Record<string|number, string>} IdToHashMap */ | ||
| for (const asyncChunk of includeAllChunks | ||
@@ -818,3 +827,4 @@ ? chunk.getAllReferencedChunks() | ||
| chunkModuleHashMap[/** @type {ChunkId} */ (asyncChunk.id)] = | ||
| /** @type {IdToHashMap} */ (idToHashMap); | ||
| /** @type {IdToHashMap} */ | ||
| (idToHashMap); | ||
| } | ||
@@ -837,3 +847,3 @@ const moduleId = this.getModuleId(module); | ||
| * @param {ChunkFilterPredicate} filterFn function used to filter chunks | ||
| * @returns {Record<string|number, boolean>} chunk map | ||
| * @returns {Record<ChunkId, boolean>} chunk map | ||
| */ | ||
@@ -1239,3 +1249,3 @@ getChunkConditionMap(chunk, filterFn) { | ||
| getChunkEntryDependentChunksIterable(chunk) { | ||
| /** @type {Set<Chunk>} */ | ||
| /** @type {Chunks} */ | ||
| const set = new Set(); | ||
@@ -1264,6 +1274,6 @@ for (const chunkGroup of chunk.groupsIterable) { | ||
| getRuntimeChunkDependentChunksIterable(chunk) { | ||
| /** @type {Set<Chunk>} */ | ||
| /** @type {Chunks} */ | ||
| const set = new Set(); | ||
| /** @type {Set<Entrypoint>} */ | ||
| /** @type {Entrypoints} */ | ||
| const entrypoints = new Set(); | ||
@@ -1445,6 +1455,6 @@ | ||
| * @param {string} runtime runtime | ||
| * @returns {string | number} the id of the runtime | ||
| * @returns {RuntimeId} the id of the runtime | ||
| */ | ||
| getRuntimeId(runtime) { | ||
| return /** @type {string | number} */ (this._runtimeIds.get(runtime)); | ||
| return /** @type {RuntimeId} */ (this._runtimeIds.get(runtime)); | ||
| } | ||
@@ -1454,3 +1464,3 @@ | ||
| * @param {string} runtime runtime | ||
| * @param {string | number} id the id of the runtime | ||
| * @param {RuntimeId} id the id of the runtime | ||
| * @returns {void} | ||
@@ -1555,3 +1565,3 @@ */ | ||
| * @param {RuntimeSpec} runtime the runtime | ||
| * @param {Set<string>} items runtime requirements to be added (ownership of this Set is given to ChunkGraph when transferOwnership not false) | ||
| * @param {RuntimeRequirements} items runtime requirements to be added (ownership of this Set is given to ChunkGraph when transferOwnership not false) | ||
| * @param {boolean} transferOwnership true: transfer ownership of the items object, false: items is immutable and shared and won't be modified | ||
@@ -1590,3 +1600,3 @@ * @returns {void} | ||
| * @param {Chunk} chunk the chunk | ||
| * @param {Set<string>} items runtime requirements to be added (ownership of this Set is given to ChunkGraph) | ||
| * @param {RuntimeRequirements} items runtime requirements to be added (ownership of this Set is given to ChunkGraph) | ||
| * @returns {void} | ||
@@ -1593,0 +1603,0 @@ */ |
+8
-10
@@ -24,4 +24,3 @@ /* | ||
| /** @typedef {{id: number}} HasId */ | ||
| /** @typedef {{module: Module | null, loc: DependencyLocation, request: string}} OriginRecord */ | ||
| /** @typedef {{ module: Module | null, loc: DependencyLocation, request: string }} OriginRecord */ | ||
@@ -118,9 +117,8 @@ /** | ||
| addOptions(options) { | ||
| for (const _key of Object.keys(options)) { | ||
| const key = | ||
| /** @type {keyof ChunkGroupOptions} */ | ||
| (_key); | ||
| for (const key of /** @type {(keyof ChunkGroupOptions)[]} */ ( | ||
| Object.keys(options) | ||
| )) { | ||
| if (this.options[key] === undefined) { | ||
| /** @type {EXPECTED_ANY} */ | ||
| (this.options)[key] = options[key]; | ||
| /** @type {ChunkGroupOptions[keyof ChunkGroupOptions]} */ | ||
| (this.options[key]) = options[key]; | ||
| } else if (this.options[key] !== options[key]) { | ||
@@ -149,3 +147,3 @@ if (key.endsWith("Order")) { | ||
| * returns the name of current ChunkGroup | ||
| * @returns {string | null | undefined} returns the ChunkGroup name | ||
| * @returns {ChunkGroupOptions["name"]} returns the ChunkGroup name | ||
| */ | ||
@@ -379,3 +377,3 @@ get name() { | ||
| /** | ||
| * @returns {Array<AsyncDependenciesBlock>} an array containing the blocks | ||
| * @returns {AsyncDependenciesBlock[]} an array containing the blocks | ||
| */ | ||
@@ -382,0 +380,0 @@ getBlocks() { |
@@ -12,3 +12,3 @@ /* | ||
| /** @typedef {import("tapable").Tap} Tap */ | ||
| /** @typedef {import("../declarations/WebpackOptions").Output} OutputOptions */ | ||
| /** @typedef {import("./config/defaults").OutputNormalizedWithDefaults} OutputOptions */ | ||
| /** @typedef {import("./Chunk")} Chunk */ | ||
@@ -15,0 +15,0 @@ /** @typedef {import("./Compilation")} Compilation */ |
@@ -33,3 +33,3 @@ /* | ||
| * @param {string} path path | ||
| * @returns {boolean | void} true, if the path should be kept | ||
| * @returns {boolean | undefined} true, if the path should be kept | ||
| */ | ||
@@ -174,3 +174,3 @@ | ||
| * @param {Diff} diff filenames of the assets that shouldn't be there | ||
| * @param {(path: string) => boolean | void} isKept check if the entry is ignored | ||
| * @param {KeepFn} isKept check if the entry is ignored | ||
| * @param {(err?: Error, assets?: Assets) => void} callback callback | ||
@@ -441,3 +441,3 @@ * @returns {void} | ||
| * @param {string} path path | ||
| * @returns {boolean | void} true, if needs to be kept | ||
| * @returns {boolean | undefined} true, if needs to be kept | ||
| */ | ||
@@ -444,0 +444,0 @@ const isKept = (path) => { |
@@ -17,2 +17,3 @@ /* | ||
| /** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */ | ||
| /** @typedef {import("./Module").CodeGenerationResultData} CodeGenerationResultData */ | ||
| /** @typedef {import("./Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */ | ||
@@ -121,3 +122,3 @@ /** @typedef {typeof import("./util/Hash")} Hash */ | ||
| * @param {string} key data key | ||
| * @returns {TODO | undefined} data generated by code generation | ||
| * @returns {ReturnType<CodeGenerationResultData["get"]>} data generated by code generation | ||
| */ | ||
@@ -124,0 +125,0 @@ getData(module, runtime, key) { |
@@ -19,6 +19,19 @@ /* | ||
| /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */ | ||
| /** @typedef {import("./dependencies/ContextDependency")} ContextDependency */ | ||
| /** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */ | ||
| /** @typedef {import("./javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("./javascript/JavascriptParser").TagData} TagData */ | ||
| /** | ||
| * @typedef {object} CompatibilitySettingsDeclaration | ||
| * @property {boolean} updated | ||
| * @property {DependencyLocation} loc | ||
| * @property {Range} range | ||
| */ | ||
| /** | ||
| * @typedef {object} CompatibilitySettings | ||
| * @property {string} name | ||
| * @property {CompatibilitySettingsDeclaration} declaration | ||
| */ | ||
| const nestedWebpackIdentifierTag = Symbol("nested webpack identifier"); | ||
@@ -71,5 +84,8 @@ const PLUGIN_NAME = "CompatibilityPlugin"; | ||
| const last = | ||
| parser.state.current.dependencies[ | ||
| parser.state.current.dependencies.length - 1 | ||
| ]; | ||
| /** @type {ContextDependency} */ | ||
| ( | ||
| parser.state.current.dependencies[ | ||
| parser.state.current.dependencies.length - 1 | ||
| ] | ||
| ); | ||
| if ( | ||
@@ -104,3 +120,4 @@ last.critical && | ||
| const newName = `__nested_webpack_require_${ | ||
| /** @type {Range} */ (statement.range)[0] | ||
| /** @type {Range} */ | ||
| (statement.range)[0] | ||
| }__`; | ||
@@ -114,4 +131,4 @@ parser.tagVariable( | ||
| updated: false, | ||
| loc: statement.id.loc, | ||
| range: statement.id.range | ||
| loc: /** @type {DependencyLocation} */ (statement.id.loc), | ||
| range: /** @type {Range} */ (statement.id.range) | ||
| } | ||
@@ -133,4 +150,4 @@ } | ||
| updated: false, | ||
| loc: pattern.loc, | ||
| range: pattern.range | ||
| loc: /** @type {DependencyLocation} */ (pattern.loc), | ||
| range: /** @type {Range} */ (pattern.range) | ||
| } | ||
@@ -147,4 +164,4 @@ }); | ||
| updated: false, | ||
| loc: pattern.loc, | ||
| range: pattern.range | ||
| loc: /** @type {DependencyLocation} */ (pattern.loc), | ||
| range: /** @type {Range} */ (pattern.range) | ||
| } | ||
@@ -158,3 +175,3 @@ }); | ||
| const { name, declaration } = | ||
| /** @type {TagData} */ | ||
| /** @type {CompatibilitySettings} */ | ||
| (parser.currentTagData); | ||
@@ -161,0 +178,0 @@ if (!declaration.updated) { |
+36
-35
@@ -41,5 +41,5 @@ /* | ||
| /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */ | ||
| /** @typedef {import("../declarations/WebpackOptions").WebpackPluginInstance} WebpackPluginInstance */ | ||
| /** @typedef {import("../declarations/WebpackOptions").Plugins} Plugins */ | ||
| /** @typedef {import("../declarations/WebpackOptions").WebpackPluginFunction} WebpackPluginFunction */ | ||
| /** @typedef {import("./Chunk")} Chunk */ | ||
| /** @typedef {import("./ChunkGraph").ModuleId} ModuleId */ | ||
| /** @typedef {import("./Dependency")} Dependency */ | ||
@@ -74,13 +74,7 @@ /** @typedef {import("./HotModuleReplacementPlugin").ChunkHashes} ChunkHashes */ | ||
| * @template T | ||
| * @callback RunCallback | ||
| * @param {Error | null} err | ||
| * @param {T=} result | ||
| * @template [R=void] | ||
| * @typedef {import("./webpack").Callback<T, R>} Callback | ||
| */ | ||
| /** | ||
| * @template T | ||
| * @callback Callback | ||
| * @param {(Error | null)=} err | ||
| * @param {T=} result | ||
| */ | ||
| /** @typedef {import("./webpack").ErrorCallback} ErrorCallback */ | ||
@@ -92,2 +86,3 @@ /** | ||
| * @param {Compilation=} compilation | ||
| * @returns {void} | ||
| */ | ||
@@ -128,3 +123,4 @@ | ||
| /** | ||
| * @param {string[]} array an array | ||
| * @template T | ||
| * @param {T[]} array an array | ||
| * @returns {boolean} true, if the array is sorted | ||
@@ -485,8 +481,9 @@ */ | ||
| * @param {WatchOptions} watchOptions the watcher's options | ||
| * @param {RunCallback<Stats>} handler signals when the call finishes | ||
| * @returns {Watching} a compiler watcher | ||
| * @param {Callback<Stats>} handler signals when the call finishes | ||
| * @returns {Watching | undefined} a compiler watcher | ||
| */ | ||
| watch(watchOptions, handler) { | ||
| if (this.running) { | ||
| return handler(new ConcurrentCompilationError()); | ||
| handler(new ConcurrentCompilationError()); | ||
| return; | ||
| } | ||
@@ -501,3 +498,3 @@ | ||
| /** | ||
| * @param {RunCallback<Stats>} callback signals when the call finishes | ||
| * @param {Callback<Stats>} callback signals when the call finishes | ||
| * @returns {void} | ||
@@ -507,3 +504,4 @@ */ | ||
| if (this.running) { | ||
| return callback(new ConcurrentCompilationError()); | ||
| callback(new ConcurrentCompilationError()); | ||
| return; | ||
| } | ||
@@ -705,3 +703,3 @@ | ||
| * @param {Compilation} compilation the compilation | ||
| * @param {Callback<void>} callback signals when the assets are emitted | ||
| * @param {ErrorCallback} callback signals when the assets are emitted | ||
| * @returns {void} | ||
@@ -1039,3 +1037,3 @@ */ | ||
| return callback(); | ||
| return callback(null); | ||
| }); | ||
@@ -1058,3 +1056,3 @@ } | ||
| /** | ||
| * @param {Callback<void>} callback signals when the call finishes | ||
| * @param {ErrorCallback} callback signals when the call finishes | ||
| * @returns {void} | ||
@@ -1078,3 +1076,3 @@ */ | ||
| } else { | ||
| callback(); | ||
| callback(null); | ||
| } | ||
@@ -1084,3 +1082,3 @@ } | ||
| /** | ||
| * @param {Callback<void>} callback signals when the call finishes | ||
| * @param {ErrorCallback} callback signals when the call finishes | ||
| * @returns {void} | ||
@@ -1134,3 +1132,3 @@ */ | ||
| /** | ||
| * @param {Callback<void>} callback signals when the call finishes | ||
| * @param {ErrorCallback} callback signals when the call finishes | ||
| * @returns {void} | ||
@@ -1156,3 +1154,3 @@ */ | ||
| this.records = {}; | ||
| callback(); | ||
| callback(null); | ||
| } | ||
@@ -1162,3 +1160,3 @@ } | ||
| /** | ||
| * @param {Callback<void>} callback signals when the call finishes | ||
| * @param {ErrorCallback} callback signals when the call finishes | ||
| * @returns {void} | ||
@@ -1169,3 +1167,3 @@ */ | ||
| this.records = {}; | ||
| return callback(); | ||
| return callback(null); | ||
| } | ||
@@ -1176,7 +1174,8 @@ /** @type {InputFileSystem} */ | ||
| // We can ignore this. | ||
| if (err) return callback(); | ||
| if (err) return callback(null); | ||
| /** @type {InputFileSystem} */ | ||
| (this.inputFileSystem).readFile( | ||
| /** @type {string} */ (this.recordsInputPath), | ||
| /** @type {string} */ | ||
| (this.recordsInputPath), | ||
| (err, content) => { | ||
@@ -1197,3 +1196,3 @@ if (err) return callback(err); | ||
| return callback(); | ||
| return callback(null); | ||
| } | ||
@@ -1209,3 +1208,3 @@ ); | ||
| * @param {Partial<OutputOptions>=} outputOptions the output options | ||
| * @param {WebpackPluginInstance[]=} plugins the plugins to apply | ||
| * @param {Plugins=} plugins the plugins to apply | ||
| * @returns {Compiler} a child compiler | ||
@@ -1261,3 +1260,6 @@ */ | ||
| for (const plugin of plugins) { | ||
| if (plugin) { | ||
| if (typeof plugin === "function") { | ||
| /** @type {WebpackPluginFunction} */ | ||
| (plugin).call(childCompiler, childCompiler); | ||
| } else if (plugin) { | ||
| plugin.apply(childCompiler); | ||
@@ -1334,4 +1336,3 @@ } | ||
| options: this.options.module, | ||
| associatedObjectForCache: this.root, | ||
| layers: this.options.experiments.layers | ||
| associatedObjectForCache: this.root | ||
| }); | ||
@@ -1358,3 +1359,3 @@ this._lastNormalModuleFactory = normalModuleFactory; | ||
| /** | ||
| * @param {RunCallback<Compilation>} callback signals when the compilation finishes | ||
| * @param {Callback<Compilation>} callback signals when the compilation finishes | ||
| * @returns {void} | ||
@@ -1410,3 +1411,3 @@ */ | ||
| /** | ||
| * @param {RunCallback<void>} callback signals when the compiler closes | ||
| * @param {ErrorCallback} callback signals when the compiler closes | ||
| * @returns {void} | ||
@@ -1413,0 +1414,0 @@ */ |
@@ -13,5 +13,7 @@ /* | ||
| /** @typedef {import("./Chunk")} Chunk */ | ||
| /** @typedef {import("./Module")} Module */ | ||
| /** @typedef {import("./optimize/ConcatenatedModule").ConcatenatedModuleInfo} ConcatenatedModuleInfo */ | ||
| /** @typedef {import("./optimize/ConcatenatedModule").ModuleInfo} ModuleInfo */ | ||
| /** @typedef {import("./optimize/ConcatenatedModule").ExportName} Ids */ | ||
@@ -23,3 +25,3 @@ const MODULE_REFERENCE_REGEXP = | ||
| * @typedef {object} ModuleReferenceOptions | ||
| * @property {string[]} ids the properties/exports of the module | ||
| * @property {Ids} ids the properties/exports of the module | ||
| * @property {boolean} call true, when this referenced export is called | ||
@@ -192,2 +194,5 @@ * @property {boolean} directImport true, when this referenced export is directly imported (not via property access) | ||
| /** @type {WeakMap<Chunk, Set<string>>} */ | ||
| ConcatenationScope.chunkUsedNames = new WeakMap(); | ||
| module.exports = ConcatenationScope; |
@@ -81,3 +81,3 @@ /* | ||
| * @param {GenerateContext} context context | ||
| * @returns {string | Source=} the source code that will be included at the end of the module | ||
| * @returns {string | Source | undefined} the source code that will be included at the end of the module | ||
| */ | ||
@@ -84,0 +84,0 @@ getEndContent(context) { |
+155
-21
@@ -12,4 +12,6 @@ /* | ||
| ASSET_MODULE_TYPE, | ||
| ASSET_MODULE_TYPE_BYTES, | ||
| ASSET_MODULE_TYPE_INLINE, | ||
| ASSET_MODULE_TYPE_RESOURCE, | ||
| ASSET_MODULE_TYPE_SOURCE, | ||
| CSS_MODULE_TYPE, | ||
@@ -34,10 +36,7 @@ CSS_MODULE_TYPE_AUTO, | ||
| /** @typedef {import("../../declarations/WebpackOptions").CacheOptions} CacheOptions */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").CacheOptionsNormalized} CacheOptionsNormalized */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").Context} Context */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").CssGeneratorOptions} CssGeneratorOptions */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").CssParserOptions} CssParserOptions */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").EntryDescription} EntryDescription */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").EntryNormalized} Entry */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").EntryStaticNormalized} EntryStaticNormalized */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").Environment} Environment */ | ||
@@ -55,3 +54,2 @@ /** @typedef {import("../../declarations/WebpackOptions").Experiments} Experiments */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").LibraryName} LibraryName */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").LibraryOptions} LibraryOptions */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").LibraryType} LibraryType */ | ||
@@ -62,3 +60,3 @@ /** @typedef {import("../../declarations/WebpackOptions").Loader} Loader */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").Node} WebpackNode */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").Optimization} Optimization */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").OptimizationNormalized} Optimization */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksOptions} OptimizationSplitChunksOptions */ | ||
@@ -71,6 +69,3 @@ /** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} Output */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").SnapshotOptions} SnapshotOptions */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").Target} Target */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").WebpackOptions} WebpackOptions */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptionsNormalized */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Module")} Module */ | ||
@@ -81,2 +76,140 @@ /** @typedef {import("./target").PlatformTargetProperties} PlatformTargetProperties */ | ||
| /** | ||
| * @template T | ||
| * @typedef {{ [P in keyof T]-?: T[P] extends object ? RecursiveNonNullable<NonNullable<T[P]>> : NonNullable<T[P]> }} RecursiveNonNullable | ||
| */ | ||
| /** | ||
| * @typedef {Output & { | ||
| * uniqueName: NonNullable<Output["uniqueName"]>, | ||
| * filename: NonNullable<Output["filename"]>, | ||
| * cssFilename: NonNullable<Output["cssFilename"]>, | ||
| * chunkFilename: NonNullable<Output["chunkFilename"]>, | ||
| * cssChunkFilename: NonNullable<Output["cssChunkFilename"]>, | ||
| * hotUpdateChunkFilename: NonNullable<Output["hotUpdateChunkFilename"]>, | ||
| * hotUpdateGlobal: NonNullable<Output["hotUpdateGlobal"]>, | ||
| * assetModuleFilename: NonNullable<Output["assetModuleFilename"]>, | ||
| * webassemblyModuleFilename: NonNullable<Output["webassemblyModuleFilename"]> | ||
| * sourceMapFilename: NonNullable<Output["sourceMapFilename"]>, | ||
| * hotUpdateMainFilename: NonNullable<Output["hotUpdateMainFilename"]>, | ||
| * devtoolNamespace: NonNullable<Output["devtoolNamespace"]>, | ||
| * publicPath: NonNullable<Output["publicPath"]> | ||
| * workerPublicPath: NonNullable<Output["workerPublicPath"]> | ||
| * workerWasmLoading: NonNullable<Output["workerWasmLoading"]> | ||
| * workerChunkLoading: NonNullable<Output["workerChunkLoading"]> | ||
| * chunkFormat: NonNullable<Output["chunkFormat"]>, | ||
| * module: NonNullable<Output["module"]>, | ||
| * asyncChunks: NonNullable<Output["asyncChunks"]>, | ||
| * charset: NonNullable<Output["charset"]>, | ||
| * iife: NonNullable<Output["iife"]>, | ||
| * globalObject: NonNullable<Output["globalObject"]>, | ||
| * scriptType: NonNullable<Output["scriptType"]>, | ||
| * path: NonNullable<Output["path"]>, | ||
| * pathinfo: NonNullable<Output["pathinfo"]>, | ||
| * hashFunction: NonNullable<Output["hashFunction"]>, | ||
| * hashDigest: NonNullable<Output["hashDigest"]>, | ||
| * hashDigestLength: NonNullable<Output["hashDigestLength"]>, | ||
| * chunkLoadTimeout: NonNullable<Output["chunkLoadTimeout"]>, | ||
| * chunkLoading: NonNullable<Output["chunkLoading"]>, | ||
| * chunkLoadingGlobal: NonNullable<Output["chunkLoadingGlobal"]>, | ||
| * compareBeforeEmit: NonNullable<Output["compareBeforeEmit"]>, | ||
| * strictModuleErrorHandling: NonNullable<Output["strictModuleErrorHandling"]>, | ||
| * strictModuleExceptionHandling: NonNullable<Output["strictModuleExceptionHandling"]>, | ||
| * importFunctionName: NonNullable<Output["importFunctionName"]>, | ||
| * importMetaName: NonNullable<Output["importMetaName"]>, | ||
| * environment: RecursiveNonNullable<Output["environment"]>, | ||
| * crossOriginLoading: NonNullable<Output["crossOriginLoading"]>, | ||
| * wasmLoading: NonNullable<Output["wasmLoading"]>, | ||
| * }} OutputNormalizedWithDefaults | ||
| */ | ||
| /** | ||
| * @typedef {SnapshotOptions & { | ||
| * managedPaths: NonNullable<SnapshotOptions["managedPaths"]>, | ||
| * unmanagedPaths: NonNullable<SnapshotOptions["unmanagedPaths"]>, | ||
| * immutablePaths: NonNullable<SnapshotOptions["immutablePaths"]>, | ||
| * resolveBuildDependencies: NonNullable<SnapshotOptions["resolveBuildDependencies"]>, | ||
| * buildDependencies: NonNullable<SnapshotOptions["buildDependencies"]>, | ||
| * module: NonNullable<SnapshotOptions["module"]>, | ||
| * resolve: NonNullable<SnapshotOptions["resolve"]>, | ||
| * }} SnapshotNormalizedWithDefaults | ||
| */ | ||
| /** | ||
| * @typedef {Optimization & { | ||
| * runtimeChunk: NonNullable<Optimization["runtimeChunk"]>, | ||
| * splitChunks: NonNullable<Optimization["splitChunks"]>, | ||
| * mergeDuplicateChunks: NonNullable<Optimization["mergeDuplicateChunks"]>, | ||
| * removeAvailableModules: NonNullable<Optimization["removeAvailableModules"]>, | ||
| * removeEmptyChunks: NonNullable<Optimization["removeEmptyChunks"]>, | ||
| * flagIncludedChunks: NonNullable<Optimization["flagIncludedChunks"]>, | ||
| * moduleIds: NonNullable<Optimization["moduleIds"]>, | ||
| * chunkIds: NonNullable<Optimization["chunkIds"]>, | ||
| * sideEffects: NonNullable<Optimization["sideEffects"]>, | ||
| * providedExports: NonNullable<Optimization["providedExports"]>, | ||
| * usedExports: NonNullable<Optimization["usedExports"]>, | ||
| * mangleExports: NonNullable<Optimization["mangleExports"]>, | ||
| * innerGraph: NonNullable<Optimization["innerGraph"]>, | ||
| * concatenateModules: NonNullable<Optimization["concatenateModules"]>, | ||
| * avoidEntryIife: NonNullable<Optimization["avoidEntryIife"]>, | ||
| * emitOnErrors: NonNullable<Optimization["emitOnErrors"]>, | ||
| * checkWasmTypes: NonNullable<Optimization["checkWasmTypes"]>, | ||
| * mangleWasmImports: NonNullable<Optimization["mangleWasmImports"]>, | ||
| * portableRecords: NonNullable<Optimization["portableRecords"]>, | ||
| * realContentHash: NonNullable<Optimization["realContentHash"]>, | ||
| * minimize: NonNullable<Optimization["minimize"]>, | ||
| * minimizer: NonNullable<Exclude<Optimization["minimizer"], "...">>, | ||
| * nodeEnv: NonNullable<Optimization["nodeEnv"]>, | ||
| * }} OptimizationNormalizedWithDefaults | ||
| */ | ||
| /** | ||
| * @typedef {ExternalsPresets & { | ||
| * web: NonNullable<ExternalsPresets["web"]>, | ||
| * node: NonNullable<ExternalsPresets["node"]>, | ||
| * nwjs: NonNullable<ExternalsPresets["nwjs"]>, | ||
| * electron: NonNullable<ExternalsPresets["electron"]>, | ||
| * electronMain: NonNullable<ExternalsPresets["electronMain"]>, | ||
| * electronPreload: NonNullable<ExternalsPresets["electronPreload"]>, | ||
| * electronRenderer: NonNullable<ExternalsPresets["electronRenderer"]>, | ||
| * }} ExternalsPresetsNormalizedWithDefaults | ||
| */ | ||
| /** | ||
| * @typedef {InfrastructureLogging & { | ||
| * stream: NonNullable<InfrastructureLogging["stream"]>, | ||
| * level: NonNullable<InfrastructureLogging["level"]>, | ||
| * debug: NonNullable<InfrastructureLogging["debug"]>, | ||
| * colors: NonNullable<InfrastructureLogging["colors"]>, | ||
| * appendOnly: NonNullable<InfrastructureLogging["appendOnly"]>, | ||
| * }} InfrastructureLoggingNormalizedWithDefaults | ||
| */ | ||
| /** | ||
| * @typedef {WebpackOptionsNormalized | ||
| * & { context: NonNullable<WebpackOptionsNormalized["context"]> } | ||
| * & { infrastructureLogging: InfrastructureLoggingNormalizedWithDefaults } | ||
| * } WebpackOptionsNormalizedWithBaseDefaults | ||
| */ | ||
| /** | ||
| * @typedef {WebpackOptionsNormalizedWithBaseDefaults | ||
| * & { target: NonNullable<WebpackOptionsNormalized["target"]> } | ||
| * & { output: OutputNormalizedWithDefaults } | ||
| * & { optimization: OptimizationNormalizedWithDefaults } | ||
| * & { devtool: NonNullable<WebpackOptionsNormalized["devtool"]> } | ||
| * & { stats: NonNullable<WebpackOptionsNormalized["stats"]> } | ||
| * & { node: NonNullable<WebpackOptionsNormalized["node"]> } | ||
| * & { profile: NonNullable<WebpackOptionsNormalized["profile"]> } | ||
| * & { parallelism: NonNullable<WebpackOptionsNormalized["parallelism"]> } | ||
| * & { snapshot: SnapshotNormalizedWithDefaults } | ||
| * & { externalsPresets: ExternalsPresetsNormalizedWithDefaults } | ||
| * & { externalsType: NonNullable<WebpackOptionsNormalized["externalsType"]> } | ||
| * & { watch: NonNullable<WebpackOptionsNormalized["watch"]> } | ||
| * & { performance: NonNullable<WebpackOptionsNormalized["performance"]> } | ||
| * & { recordsInputPath: NonNullable<WebpackOptionsNormalized["recordsInputPath"]> } | ||
| * & { recordsOutputPath: NonNullable<WebpackOptionsNormalized["recordsOutputPath"]> | ||
| * }} WebpackOptionsNormalizedWithDefaults | ||
| */ | ||
| /** | ||
| * @typedef {object} ResolvedOptions | ||
@@ -149,5 +282,5 @@ * @property {PlatformTargetProperties | false} platform - platform target properties | ||
| } | ||
| const items = /** @type {EXPECTED_ANY[]} */ ( | ||
| /** @type {unknown} */ (factory()) | ||
| ); | ||
| const items = | ||
| /** @type {EXPECTED_ANY[]} */ | ||
| (/** @type {unknown} */ (factory())); | ||
| if (items !== undefined) { | ||
@@ -393,3 +526,2 @@ for (const item of items) { | ||
| D(experiments, "outputModule", false); | ||
| D(experiments, "layers", false); | ||
| D(experiments, "lazyCompilation", undefined); | ||
@@ -401,9 +533,2 @@ D(experiments, "buildHttp", undefined); | ||
| // TODO webpack 6: remove this. topLevelAwait should be enabled by default | ||
| let shouldEnableTopLevelAwait = true; | ||
| if (typeof experiments.topLevelAwait === "boolean") { | ||
| shouldEnableTopLevelAwait = experiments.topLevelAwait; | ||
| } | ||
| D(experiments, "topLevelAwait", shouldEnableTopLevelAwait); | ||
| if (typeof experiments.buildHttp === "object") { | ||
@@ -568,2 +693,3 @@ D(experiments.buildHttp, "frozen", production); | ||
| ); | ||
| F(snapshot, "contextModule", () => ({ timestamp: true })); | ||
| F(snapshot, "resolve", () => | ||
@@ -944,2 +1070,6 @@ production ? { timestamp: true, hash: true } : { timestamp: true } | ||
| { | ||
| with: { type: JSON_MODULE_TYPE }, | ||
| type: JSON_MODULE_TYPE | ||
| }, | ||
| { | ||
| assert: { type: JSON_MODULE_TYPE }, | ||
@@ -949,4 +1079,8 @@ type: JSON_MODULE_TYPE | ||
| { | ||
| with: { type: JSON_MODULE_TYPE }, | ||
| type: JSON_MODULE_TYPE | ||
| with: { type: "text" }, | ||
| type: ASSET_MODULE_TYPE_SOURCE | ||
| }, | ||
| { | ||
| with: { type: "bytes" }, | ||
| type: ASSET_MODULE_TYPE_BYTES | ||
| } | ||
@@ -953,0 +1087,0 @@ ); |
@@ -18,9 +18,9 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptionsNormalized */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").OptimizationNormalized} OptimizationNormalized */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").OptimizationRuntimeChunk} OptimizationRuntimeChunk */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").OptimizationRuntimeChunkNormalized} OptimizationRuntimeChunkNormalized */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} OutputNormalized */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").Plugins} Plugins */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").PluginsNormalized} PluginsNormalized */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").WebpackOptions} WebpackOptions */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptionsNormalized */ | ||
| /** @typedef {import("../Entrypoint")} Entrypoint */ | ||
| /** @typedef {import("../WebpackError")} WebpackError */ | ||
@@ -291,2 +291,8 @@ | ||
| ), | ||
| minimizer: | ||
| optimization.minimizer !== undefined | ||
| ? /** @type {OptimizationNormalized["minimizer"]} */ ( | ||
| nestedArray(optimization.minimizer, (p) => p.filter(Boolean)) | ||
| ) | ||
| : optimization.minimizer, | ||
| emitOnErrors: | ||
@@ -415,3 +421,5 @@ optimization.noEmitOnErrors !== undefined | ||
| }), | ||
| plugins: /** @type {Plugins} */ (nestedArray(config.plugins, (p) => [...p])), | ||
| plugins: /** @type {PluginsNormalized} */ ( | ||
| nestedArray(config.plugins, (p) => p.filter(Boolean)) | ||
| ), | ||
| profile: config.profile, | ||
@@ -454,2 +462,9 @@ recordsInputPath: | ||
| })), | ||
| contextModule: optionalNestedConfig( | ||
| snapshot.contextModule, | ||
| (contextModule) => ({ | ||
| timestamp: contextModule.timestamp, | ||
| hash: contextModule.hash | ||
| }) | ||
| ), | ||
| immutablePaths: optionalNestedArray(snapshot.immutablePaths, (p) => [...p]), | ||
@@ -456,0 +471,0 @@ managedPaths: optionalNestedArray(snapshot.managedPaths, (p) => [...p]), |
@@ -27,8 +27,9 @@ /* | ||
| /** @typedef {import("./Compiler")} Compiler */ | ||
| /** @typedef {import("./javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */ | ||
| /** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */ | ||
| /** @typedef {import("./javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {Set<string>} Declarations */ | ||
| /** | ||
| * @param {Set<string>} declarations set of declarations | ||
| * @param {Declarations} declarations set of declarations | ||
| * @param {Identifier | Pattern} pattern pattern to collect declarations from | ||
@@ -69,8 +70,8 @@ */ | ||
| * @param {boolean} includeFunctionDeclarations whether to include function declarations | ||
| * @returns {Array<string>} hoisted declarations | ||
| * @returns {string[]} hoisted declarations | ||
| */ | ||
| const getHoistedDeclarations = (branch, includeFunctionDeclarations) => { | ||
| /** @type {Set<string>} */ | ||
| /** @type {Declarations} */ | ||
| const declarations = new Set(); | ||
| /** @type {Array<Statement | null | undefined>} */ | ||
| /** @type {(Statement | null | undefined)[]} */ | ||
| const stack = [branch]; | ||
@@ -77,0 +78,0 @@ while (stack.length > 0) { |
@@ -11,3 +11,2 @@ /* | ||
| /** @typedef {import("./ContainerEntryModule").ExposeOptions} ExposeOptions */ | ||
| /** @typedef {import("./ContainerEntryModule").ExposesList} ExposesList */ | ||
@@ -14,0 +13,0 @@ |
@@ -19,5 +19,3 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../ChunkGroup")} ChunkGroup */ | ||
| /** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */ | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
@@ -28,2 +26,3 @@ /** @typedef {import("../Module").BuildCallback} BuildCallback */ | ||
| /** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */ | ||
| /** @typedef {import("../Module").LibIdent} LibIdent */ | ||
| /** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */ | ||
@@ -34,8 +33,5 @@ /** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */ | ||
| /** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */ | ||
| /** @typedef {import("../WebpackError")} WebpackError */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @typedef {import("../util/Hash")} Hash */ | ||
| /** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */ | ||
| /** @typedef {import("./ContainerEntryDependency")} ContainerEntryDependency */ | ||
@@ -89,3 +85,3 @@ /** | ||
| * @param {LibIdentOptions} options options | ||
| * @returns {string | null} an identifier for library inclusion | ||
| * @returns {LibIdent | null} an identifier for library inclusion | ||
| */ | ||
@@ -92,0 +88,0 @@ libIdent(options) { |
@@ -17,3 +17,2 @@ /* | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("./ContainerEntryModule").ExposeOptions} ExposeOptions */ | ||
| /** @typedef {import("./ContainerEntryModule").ExposesList} ExposesList */ | ||
@@ -87,3 +86,3 @@ | ||
| compilation.addEntry( | ||
| /** @type {string} */ (compilation.options.context), | ||
| compilation.options.context, | ||
| dep, | ||
@@ -90,0 +89,0 @@ { |
@@ -20,3 +20,2 @@ /* | ||
| /** @typedef {import("../../declarations/plugins/container/ContainerReferencePlugin").ContainerReferencePluginOptions} ContainerReferencePluginOptions */ | ||
| /** @typedef {import("../../declarations/plugins/container/ContainerReferencePlugin").RemotesConfig} RemotesConfig */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
@@ -23,0 +22,0 @@ |
@@ -11,2 +11,3 @@ /* | ||
| /** @typedef {import("./RemoteModule").ExternalRequests} ExternalRequests */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
@@ -17,3 +18,3 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** | ||
| * @param {string[]} requests requests | ||
| * @param {ExternalRequests} requests requests | ||
| */ | ||
@@ -20,0 +21,0 @@ constructor(requests) { |
@@ -17,6 +17,4 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */ | ||
| /** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */ | ||
| /** @typedef {import("../Chunk")} Chunk */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../ChunkGroup")} ChunkGroup */ | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
@@ -27,2 +25,4 @@ /** @typedef {import("../Module").BuildCallback} BuildCallback */ | ||
| /** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */ | ||
| /** @typedef {import("../Module").LibIdent} LibIdent */ | ||
| /** @typedef {import("../Module").NameForCondition} NameForCondition */ | ||
| /** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */ | ||
@@ -33,7 +33,6 @@ /** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */ | ||
| /** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */ | ||
| /** @typedef {import("../WebpackError")} WebpackError */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @typedef {import("../util/Hash")} Hash */ | ||
| /** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */ | ||
| /** @typedef {import("./RemoteModule").ExternalRequests} ExternalRequests */ | ||
@@ -44,3 +43,3 @@ const RUNTIME_REQUIREMENTS = new Set([RuntimeGlobals.module]); | ||
| /** | ||
| * @param {string[]} requests list of requests to choose one | ||
| * @param {ExternalRequests} requests list of requests to choose one | ||
| */ | ||
@@ -70,3 +69,3 @@ constructor(requests) { | ||
| * @param {LibIdentOptions} options options | ||
| * @returns {string | null} an identifier for library inclusion | ||
| * @returns {LibIdent | null} an identifier for library inclusion | ||
| */ | ||
@@ -73,0 +72,0 @@ libIdent(options) { |
@@ -19,3 +19,2 @@ /* | ||
| /** @typedef {import("../../declarations/plugins/container/ModuleFederationPlugin").ModuleFederationPluginOptions} ModuleFederationPluginOptions */ | ||
| /** @typedef {import("../../declarations/plugins/container/ModuleFederationPlugin").Shared} Shared */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
@@ -22,0 +21,0 @@ /** @typedef {import("../Dependency")} Dependency */ |
@@ -19,5 +19,3 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../ChunkGroup")} ChunkGroup */ | ||
| /** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */ | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
@@ -28,2 +26,4 @@ /** @typedef {import("../Module").BuildCallback} BuildCallback */ | ||
| /** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */ | ||
| /** @typedef {import("../Module").LibIdent} LibIdent */ | ||
| /** @typedef {import("../Module").NameForCondition} NameForCondition */ | ||
| /** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */ | ||
@@ -34,6 +34,4 @@ /** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */ | ||
| /** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */ | ||
| /** @typedef {import("../WebpackError")} WebpackError */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @typedef {import("../util/Hash")} Hash */ | ||
| /** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */ | ||
@@ -43,6 +41,8 @@ | ||
| /** @typedef {string[]} ExternalRequests */ | ||
| class RemoteModule extends Module { | ||
| /** | ||
| * @param {string} request request string | ||
| * @param {string[]} externalRequests list of external requests to containers | ||
| * @param {ExternalRequests} externalRequests list of external requests to containers | ||
| * @param {string} internalRequest name of exposed module in container | ||
@@ -79,3 +79,3 @@ * @param {string} shareScope the used share scope name | ||
| * @param {LibIdentOptions} options options | ||
| * @returns {string | null} an identifier for library inclusion | ||
| * @returns {LibIdent | null} an identifier for library inclusion | ||
| */ | ||
@@ -139,3 +139,3 @@ libIdent(options) { | ||
| /** | ||
| * @returns {string | null} absolute path which should be used for condition matching (usually the resource path) | ||
| * @returns {NameForCondition | null} absolute path which should be used for condition matching (usually the resource path) | ||
| */ | ||
@@ -142,0 +142,0 @@ nameForCondition() { |
@@ -31,5 +31,5 @@ /* | ||
| const { runtimeTemplate, moduleGraph } = compilation; | ||
| /** @type {Record<ChunkId, (string | number)[]>} */ | ||
| /** @type {Record<ChunkId, ModuleId[]>} */ | ||
| const chunkToRemotesMapping = {}; | ||
| /** @type {Record<ModuleId, [string, string, string | number | null]>} */ | ||
| /** @type {Record<ModuleId, [string, string, ModuleId]>} */ | ||
| const idToExternalAndNameMapping = {}; | ||
@@ -36,0 +36,0 @@ for (const chunk of /** @type {Chunk} */ ( |
@@ -8,3 +8,2 @@ /* | ||
| /** @typedef {import("./Compiler")} Compiler */ | ||
| /** @typedef {import("./ContextModuleFactory")} ContextModuleFactory */ | ||
@@ -11,0 +10,0 @@ const PLUGIN_NAME = "ContextExclusionPlugin"; |
+22
-20
@@ -33,5 +33,6 @@ /* | ||
| /** @typedef {import("../declarations/WebpackOptions").ResolveOptions} ResolveOptions */ | ||
| /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */ | ||
| /** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */ | ||
| /** @typedef {import("./Chunk")} Chunk */ | ||
| /** @typedef {import("./Chunk").ChunkId} ChunkId */ | ||
| /** @typedef {import("./Chunk").ChunkName} ChunkName */ | ||
| /** @typedef {import("./ChunkGraph")} ChunkGraph */ | ||
@@ -42,6 +43,7 @@ /** @typedef {import("./ChunkGraph").ModuleId} ModuleId */ | ||
| /** @typedef {import("./Dependency")} Dependency */ | ||
| /** @typedef {import("./DependencyTemplates")} DependencyTemplates */ | ||
| /** @typedef {import("./Dependency").RawReferencedExports} RawReferencedExports */ | ||
| /** @typedef {import("./Generator").SourceTypes} SourceTypes */ | ||
| /** @typedef {import("./Module").BuildCallback} BuildCallback */ | ||
| /** @typedef {import("./Module").BuildInfo} BuildInfo */ | ||
| /** @typedef {import("./Module").FileSystemDependencies} FileSystemDependencies */ | ||
| /** @typedef {import("./Module").BuildMeta} BuildMeta */ | ||
@@ -51,5 +53,5 @@ /** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */ | ||
| /** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */ | ||
| /** @typedef {import("./Module").LibIdent} LibIdent */ | ||
| /** @typedef {import("./Module").NeedBuildCallback} NeedBuildCallback */ | ||
| /** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */ | ||
| /** @typedef {import("./ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("./RequestShortener")} RequestShortener */ | ||
@@ -62,3 +64,2 @@ /** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */ | ||
| /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @template T @typedef {import("./util/LazySet")<T>} LazySet<T> */ | ||
| /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */ | ||
@@ -72,13 +73,13 @@ | ||
| * @property {boolean} recursive | ||
| * @property {RegExp} regExp | ||
| * @property {("strict" | boolean)=} namespaceObject | ||
| * @property {RegExp | false | null} regExp | ||
| * @property {"strict" | boolean=} namespaceObject | ||
| * @property {string=} addon | ||
| * @property {(string | null)=} chunkName | ||
| * @property {(RegExp | null)=} include | ||
| * @property {(RegExp | null)=} exclude | ||
| * @property {ChunkName=} chunkName | ||
| * @property {RegExp | null=} include | ||
| * @property {RegExp | null=} exclude | ||
| * @property {RawChunkGroupOptions=} groupOptions | ||
| * @property {string=} typePrefix | ||
| * @property {string=} category | ||
| * @property {(string[][] | null)=} referencedExports exports referenced from modules (won't be mangled) | ||
| * @property {string=} layer | ||
| * @property {RawReferencedExports | null=} referencedExports exports referenced from modules (won't be mangled) | ||
| * @property {string | null=} layer | ||
| * @property {ImportAttributes=} attributes | ||
@@ -101,2 +102,3 @@ */ | ||
| * @param {ContextElementDependency[]=} dependencies | ||
| * @returns {void} | ||
| */ | ||
@@ -115,4 +117,2 @@ | ||
| const SNAPSHOT_OPTIONS = { timestamp: true }; | ||
| class ContextModule extends Module { | ||
@@ -344,3 +344,3 @@ /** | ||
| * @param {LibIdentOptions} options options | ||
| * @returns {string | null} an identifier for library inclusion | ||
| * @returns {LibIdent | null} an identifier for library inclusion | ||
| */ | ||
@@ -543,2 +543,4 @@ libIdent(options) { | ||
| const snapshotOptions = compilation.options.snapshot.contextModule; | ||
| compilation.fileSystemInfo.createSnapshot( | ||
@@ -553,3 +555,3 @@ startTime, | ||
| null, | ||
| SNAPSHOT_OPTIONS, | ||
| snapshotOptions, | ||
| (err, snapshot) => { | ||
@@ -566,6 +568,6 @@ if (err) return callback(err); | ||
| /** | ||
| * @param {LazySet<string>} fileDependencies set where file dependencies are added to | ||
| * @param {LazySet<string>} contextDependencies set where context dependencies are added to | ||
| * @param {LazySet<string>} missingDependencies set where missing dependencies are added to | ||
| * @param {LazySet<string>} buildDependencies set where build dependencies are added to | ||
| * @param {FileSystemDependencies} fileDependencies set where file dependencies are added to | ||
| * @param {FileSystemDependencies} contextDependencies set where context dependencies are added to | ||
| * @param {FileSystemDependencies} missingDependencies set where missing dependencies are added to | ||
| * @param {FileSystemDependencies} buildDependencies set where build dependencies are added to | ||
| */ | ||
@@ -592,3 +594,3 @@ addCacheDependencies( | ||
| * @param {ChunkGraph} chunkGraph chunk graph | ||
| * @returns {Map<string, string | number>} map with user requests | ||
| * @returns {Map<string, ModuleId>} map with user requests | ||
| */ | ||
@@ -595,0 +597,0 @@ getUserRequestMap(dependencies, chunkGraph) { |
@@ -20,3 +20,2 @@ /* | ||
| /** @typedef {import("./ContextModule").ResolveDependenciesCallback} ResolveDependenciesCallback */ | ||
| /** @typedef {import("./Module")} Module */ | ||
| /** @typedef {import("./ModuleFactory").ModuleFactoryCreateData} ModuleFactoryCreateData */ | ||
@@ -26,2 +25,3 @@ /** @typedef {import("./ModuleFactory").ModuleFactoryCallback} ModuleFactoryCallback */ | ||
| /** @typedef {import("./dependencies/ContextDependency")} ContextDependency */ | ||
| /** @typedef {import("./dependencies/ContextDependency").ContextOptions} ContextOptions */ | ||
| /** @typedef {import("enhanced-resolve").ResolveRequest} ResolveRequest */ | ||
@@ -36,5 +36,19 @@ /** | ||
| /** | ||
| * @typedef {object} ContextResolveData | ||
| * @property {string} context | ||
| * @property {string} request | ||
| * @property {ModuleFactoryCreateData["resolveOptions"]} resolveOptions | ||
| * @property {LazySet<string>} fileDependencies | ||
| * @property {LazySet<string>} missingDependencies | ||
| * @property {LazySet<string>} contextDependencies | ||
| * @property {ContextDependency[]} dependencies | ||
| */ | ||
| /** @typedef {ContextResolveData & ContextOptions} BeforeContextResolveData */ | ||
| /** @typedef {BeforeContextResolveData & { resource: string | string[], resourceQuery: string | undefined, resourceFragment: string | undefined, resolveDependencies: ContextModuleFactory["resolveDependencies"] }} AfterContextResolveData */ | ||
| const EMPTY_RESOLVE_OPTIONS = {}; | ||
| module.exports = class ContextModuleFactory extends ModuleFactory { | ||
| class ContextModuleFactory extends ModuleFactory { | ||
| /** | ||
@@ -51,5 +65,5 @@ * @param {ResolverFactory} resolverFactory resolverFactory | ||
| this.hooks = Object.freeze({ | ||
| /** @type {AsyncSeriesWaterfallHook<[TODO]>} */ | ||
| /** @type {AsyncSeriesWaterfallHook<[BeforeContextResolveData], BeforeContextResolveData | false | void>} */ | ||
| beforeResolve: new AsyncSeriesWaterfallHook(["data"]), | ||
| /** @type {AsyncSeriesWaterfallHook<[TODO]>} */ | ||
| /** @type {AsyncSeriesWaterfallHook<[AfterContextResolveData], AfterContextResolveData | false | void>} */ | ||
| afterResolve: new AsyncSeriesWaterfallHook(["data"]), | ||
@@ -98,5 +112,5 @@ /** @type {SyncWaterfallHook<[string[]]>} */ | ||
| const context = data.context; | ||
| const dependencies = data.dependencies; | ||
| const dependencies = /** @type {ContextDependency[]} */ (data.dependencies); | ||
| const resolveOptions = data.resolveOptions; | ||
| const dependency = /** @type {ContextDependency} */ (dependencies[0]); | ||
| const dependency = dependencies[0]; | ||
| const fileDependencies = new LazySet(); | ||
@@ -138,3 +152,5 @@ const missingDependencies = new LazySet(); | ||
| /** @type {undefined | string[]} */ | ||
| let loaders; | ||
| /** @type {undefined | string} */ | ||
| let resource; | ||
@@ -179,3 +195,3 @@ let loadersPrefix = ""; | ||
| (callback) => { | ||
| const results = /** @type ResolveRequest[] */ ([]); | ||
| const results = /** @type {ResolveRequest[]} */ ([]); | ||
| /** | ||
@@ -220,3 +236,3 @@ * @param {ResolveRequest} obj obj | ||
| if (err) return callback(err); | ||
| callback(null, /** @type {string} */ (result)); | ||
| callback(null, result); | ||
| } | ||
@@ -252,4 +268,4 @@ ); | ||
| contextResult.length > 1 | ||
| ? contextResult.map((r) => r.path) | ||
| : contextResult[0].path, | ||
| ? /** @type {string[]} */ (contextResult.map((r) => r.path)) | ||
| : /** @type {string} */ (contextResult[0].path), | ||
| resolveDependencies: this.resolveDependencies.bind(this), | ||
@@ -349,2 +365,3 @@ resourceQuery: contextResult[0].query, | ||
| * @param {ResolveDependenciesCallback} callback callback | ||
| * @returns {void} | ||
| */ | ||
@@ -491,2 +508,4 @@ const addDirectory = (ctx, directory, addSubDirectory, callback) => { | ||
| } | ||
| }; | ||
| } | ||
| module.exports = ContextModuleFactory; |
@@ -13,2 +13,4 @@ /* | ||
| /** @typedef {import("./ContextModule").ContextModuleOptions} ContextModuleOptions */ | ||
| /** @typedef {import("./ContextModuleFactory").BeforeContextResolveData} BeforeContextResolveData */ | ||
| /** @typedef {import("./ContextModuleFactory").AfterContextResolveData} AfterContextResolveData */ | ||
| /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */ | ||
@@ -23,3 +25,3 @@ | ||
| * @param {RegExp} resourceRegExp A regular expression that determines which files will be selected | ||
| * @param {(string | ((context: TODO) => void) | RegExp | boolean)=} newContentResource A new resource to replace the match | ||
| * @param {(string | ((context: BeforeContextResolveData | AfterContextResolveData) => void) | RegExp | boolean)=} newContentResource A new resource to replace the match | ||
| * @param {(boolean | NewContentCreateContextMap | RegExp)=} newContentRecursive If true, all subdirectories are searched for matches | ||
@@ -127,3 +129,10 @@ * @param {RegExp=} newContentRegExp A regular expression that determines which files will be selected | ||
| if (!result) return; | ||
| if (resourceRegExp.test(result.resource)) { | ||
| const isMatchResourceRegExp = () => { | ||
| if (Array.isArray(result.resource)) { | ||
| return result.resource.some((item) => resourceRegExp.test(item)); | ||
| } | ||
| return resourceRegExp.test(result.resource); | ||
| }; | ||
| if (isMatchResourceRegExp()) { | ||
| if (newContentResource !== undefined) { | ||
@@ -136,6 +145,11 @@ if ( | ||
| } else { | ||
| const rootPath = | ||
| typeof result.resource === "string" | ||
| ? result.resource | ||
| : /** @type {string} */ | ||
| (result.resource.find((item) => resourceRegExp.test(item))); | ||
| result.resource = join( | ||
| /** @type {InputFileSystem} */ | ||
| (compiler.inputFileSystem), | ||
| result.resource, | ||
| rootPath, | ||
| newContentResource | ||
@@ -160,14 +174,23 @@ ); | ||
| newContentCallback(result); | ||
| if ( | ||
| result.resource !== origResource && | ||
| !result.resource.startsWith("/") && | ||
| (result.resource.length <= 1 || result.resource[1] !== ":") | ||
| ) { | ||
| // When the function changed it to an relative path | ||
| result.resource = join( | ||
| /** @type {InputFileSystem} */ | ||
| (compiler.inputFileSystem), | ||
| origResource, | ||
| result.resource | ||
| ); | ||
| if (result.resource !== origResource) { | ||
| const newResource = Array.isArray(result.resource) | ||
| ? result.resource | ||
| : [result.resource]; | ||
| for (let i = 0; i < newResource.length; i++) { | ||
| if ( | ||
| !newResource[i].startsWith("/") && | ||
| (newResource[i].length <= 1 || newResource[i][1] !== ":") | ||
| ) { | ||
| // When the function changed it to an relative path | ||
| newResource[i] = join( | ||
| /** @type {InputFileSystem} */ | ||
| (compiler.inputFileSystem), | ||
| origResource[i], | ||
| newResource[i] | ||
| ); | ||
| } | ||
| } | ||
| result.resource = newResource; | ||
| } | ||
@@ -174,0 +197,0 @@ } else { |
@@ -27,2 +27,3 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").CssModuleGeneratorOptions} CssModuleGeneratorOptions */ | ||
| /** @typedef {import("../Compilation").DependencyConstructor} DependencyConstructor */ | ||
| /** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */ | ||
@@ -128,3 +129,3 @@ /** @typedef {import("../Dependency")} Dependency */ | ||
| const constructor = | ||
| /** @type {new (...args: EXPECTED_ANY[]) => Dependency} */ | ||
| /** @type {DependencyConstructor} */ | ||
| (dependency.constructor); | ||
@@ -175,7 +176,3 @@ const template = generateContext.dependencyTemplates.get(constructor); | ||
| source.add( | ||
| `${ | ||
| generateContext.runtimeTemplate.supportsConst() | ||
| ? "const" | ||
| : "var" | ||
| } ${identifier} = ${JSON.stringify(v)};\n` | ||
| `${generateContext.runtimeTemplate.renderConst()} ${identifier} = ${JSON.stringify(v)};\n` | ||
| ); | ||
@@ -182,0 +179,0 @@ } |
@@ -16,6 +16,5 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").Environment} Environment */ | ||
| /** @typedef {import("../Chunk")} Chunk */ | ||
| /** @typedef {import("../Chunk").ChunkId} ChunkId */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../Compilation").RuntimeRequirementsContext} RuntimeRequirementsContext */ | ||
| /** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */ | ||
@@ -84,3 +83,3 @@ | ||
| const conditionMap = chunkGraph.getChunkConditionMap( | ||
| /** @type {Chunk} */ (chunk), | ||
| chunk, | ||
| /** | ||
@@ -103,7 +102,7 @@ * @param {Chunk} chunk the chunk | ||
| ); | ||
| /** @type {Set<number | string | null>} */ | ||
| /** @type {Set<ChunkId>} */ | ||
| const initialChunkIds = new Set(); | ||
| for (const c of /** @type {Chunk} */ (chunk).getAllInitialChunks()) { | ||
| for (const c of chunk.getAllInitialChunks()) { | ||
| if (chunkHasCss(c, chunkGraph)) { | ||
| initialChunkIds.add(c.id); | ||
| initialChunkIds.add(/** @type {ChunkId} */ (c.id)); | ||
| } | ||
@@ -116,5 +115,3 @@ } | ||
| const environment = | ||
| /** @type {Environment} */ | ||
| (compilation.outputOptions.environment); | ||
| const environment = compilation.outputOptions.environment; | ||
| const isNeutralPlatform = runtimeTemplate.isNeutralPlatform(); | ||
@@ -121,0 +118,0 @@ const withPrefetch = |
@@ -51,4 +51,3 @@ /* | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} OutputOptions */ | ||
| /** @typedef {import("../config/defaults").OutputNormalizedWithDefaults} OutputOptions */ | ||
| /** @typedef {import("../Chunk")} Chunk */ | ||
@@ -63,6 +62,6 @@ /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../Module").BuildInfo} BuildInfo */ | ||
| /** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */ | ||
| /** @typedef {import("../Template").RuntimeTemplate} RuntimeTemplate */ | ||
| /** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */ | ||
| /** @typedef {import("../util/Hash")} Hash */ | ||
| /** @typedef {import("../util/memoize")} Memoize */ | ||
@@ -450,3 +449,2 @@ /** | ||
| chunkGraph, | ||
| codeGenerationResults, | ||
| moduleGraph, | ||
@@ -461,4 +459,7 @@ runtimeTemplate, | ||
| } = compilation; | ||
| const hash = createHash(/** @type {HashFunction} */ (hashFunction)); | ||
| const hash = createHash(hashFunction); | ||
| if (hashSalt) hash.update(hashSalt); | ||
| const codeGenerationResults = | ||
| /** @type {CodeGenerationResults} */ | ||
| (compilation.codeGenerationResults); | ||
| hooks.chunkHash.call(chunk, hash, { | ||
@@ -507,4 +508,3 @@ chunkGraph, | ||
| filename, | ||
| /** @type {string} */ | ||
| (compilation.outputOptions.path), | ||
| compilation.outputOptions.path, | ||
| false | ||
@@ -519,5 +519,3 @@ ); | ||
| codeGenerationResults, | ||
| uniqueName: | ||
| /** @type {string} */ | ||
| (compilation.outputOptions.uniqueName), | ||
| uniqueName: compilation.outputOptions.uniqueName, | ||
| undoPath, | ||
@@ -553,3 +551,3 @@ modules, | ||
| * @param {Chunk} chunk chunk to check | ||
| * @param {Set<string>} set runtime requirements | ||
| * @param {RuntimeRequirements} set runtime requirements | ||
| */ | ||
@@ -924,5 +922,5 @@ const handler = (chunk, set) => { | ||
| } else if (chunk.canBeInitial()) { | ||
| return /** @type {TemplatePath} */ (outputOptions.cssFilename); | ||
| return outputOptions.cssFilename; | ||
| } | ||
| return /** @type {TemplatePath} */ (outputOptions.cssChunkFilename); | ||
| return outputOptions.cssChunkFilename; | ||
| } | ||
@@ -929,0 +927,0 @@ |
@@ -358,3 +358,3 @@ /* | ||
| IS_MODULES.test( | ||
| parseResource(module.matchResource || module.resource).path | ||
| parseResource(/** @type {string} */ (module.getResource())).path | ||
| ) | ||
@@ -376,3 +376,3 @@ ) { | ||
| let allowImportAtRule = true; | ||
| /** @type [string, number, number][] */ | ||
| /** @type {[string, number, number][]} */ | ||
| const balanced = []; | ||
@@ -1616,3 +1616,3 @@ let lastTokenEndForComments = 0; | ||
| Object.assign(newErr, { comment }); | ||
| errors.push(/** @type (Error & { comment: Comment }) */ (newErr)); | ||
| errors.push(/** @type {(Error & { comment: Comment })} */ (newErr)); | ||
| } | ||
@@ -1619,0 +1619,0 @@ } |
@@ -1592,3 +1592,3 @@ /* | ||
| const arr = Array.from( | ||
| { length: charCodes.reduce((a, b) => Math.max(a, b), 0) + 1 }, | ||
| { length: Math.max(...charCodes, 0) + 1 }, | ||
| () => false | ||
@@ -1595,0 +1595,0 @@ ); |
@@ -22,9 +22,26 @@ /* | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../ContextModuleFactory")} ContextModuleFactory */ | ||
| /** @typedef {import("../ModuleFactory")} ModuleFactory */ | ||
| /** @typedef {import("../NormalModuleFactory")} NormalModuleFactory */ | ||
| /** @typedef {import("../Parser")} Parser */ | ||
| /** @typedef {import("../ResolverFactory")} ResolverFactory */ | ||
| /** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */ | ||
| /** | ||
| * @template T, R | ||
| * @typedef {import("tapable").Hook<T, R>} Hook | ||
| */ | ||
| /** | ||
| * @template T | ||
| * @typedef {import("../util/deprecation").FakeHook<T>} FakeHook | ||
| */ | ||
| /** | ||
| * @template T | ||
| * @typedef {import("tapable").HookMap<T>} HookMap | ||
| */ | ||
| /** | ||
| * @template T, R | ||
| * @typedef {import("tapable").HookInterceptor<T, R>} HookInterceptor | ||
| */ | ||
| const validate = createSchemaValidation( | ||
@@ -123,2 +140,5 @@ require("../../schemas/plugins/debug/ProfilingPlugin.check"), | ||
| /** | ||
| * @returns {Promise<{ profile: { startTime: number, endTime: number } }>} profile result | ||
| */ | ||
| stopProfiling() { | ||
@@ -260,3 +280,6 @@ return this.sendCommand("Profiler.stop").then(({ profile }) => { | ||
| if (hook) { | ||
| hook.intercept(makeInterceptorFor("Resolver", tracer)(hookName)); | ||
| hook.intercept( | ||
| /** @type {EXPECTED_ANY} */ | ||
| (makeInterceptorFor("Resolver", tracer)(hookName)) | ||
| ); | ||
| } | ||
@@ -353,4 +376,6 @@ } | ||
| /** @typedef {Record<string, Hook<EXPECTED_ANY, EXPECTED_ANY> | FakeHook<EXPECTED_ANY> | HookMap<EXPECTED_ANY>>} Hooks */ | ||
| /** | ||
| * @param {EXPECTED_ANY & { hooks: TODO }} instance instance | ||
| * @param {EXPECTED_OBJECT & { hooks?: Hooks }} instance instance | ||
| * @param {Trace} tracer tracer | ||
@@ -361,4 +386,5 @@ * @param {string} logLabel log label | ||
| if (Reflect.has(instance, "hooks")) { | ||
| for (const hookName of Object.keys(instance.hooks)) { | ||
| const hook = instance.hooks[hookName]; | ||
| const hooks = /** @type {Hooks} */ (instance.hooks); | ||
| for (const hookName of Object.keys(hooks)) { | ||
| const hook = hooks[hookName]; | ||
| if (hook && !hook._fakeHook) { | ||
@@ -447,5 +473,6 @@ hook.intercept(makeInterceptorFor(logLabel, tracer)(hookName)); | ||
| /** | ||
| * @template T | ||
| * @param {string} instance instance | ||
| * @param {Trace} tracer tracer | ||
| * @returns {(hookName: string) => TODO} interceptor | ||
| * @returns {(hookName: string) => HookInterceptor<EXPECTED_ANY, EXPECTED_ANY>} interceptor | ||
| */ | ||
@@ -452,0 +479,0 @@ const makeInterceptorFor = (instance, tracer) => (hookName) => ({ |
@@ -25,5 +25,5 @@ /* | ||
| /** @typedef {import("estree").Expression} Expression */ | ||
| /** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */ | ||
| /** @typedef {import("./Compiler")} Compiler */ | ||
| /** @typedef {import("./Module").BuildInfo} BuildInfo */ | ||
| /** @typedef {import("./Module").ValueCacheVersion} ValueCacheVersion */ | ||
| /** @typedef {import("./Module").ValueCacheVersions} ValueCacheVersions */ | ||
@@ -33,3 +33,3 @@ /** @typedef {import("./NormalModule")} NormalModule */ | ||
| /** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */ | ||
| /** @typedef {import("./javascript/JavascriptParser").DestructuringAssignmentProperty} DestructuringAssignmentProperty */ | ||
| /** @typedef {import("./javascript/JavascriptParser").DestructuringAssignmentProperties} DestructuringAssignmentProperties */ | ||
| /** @typedef {import("./javascript/JavascriptParser").Range} Range */ | ||
@@ -50,3 +50,2 @@ /** @typedef {import("./logging/Logger").Logger} Logger */ | ||
| /** @typedef {string | Set<string>} ValueCacheVersion */ | ||
| /** @typedef {(value: { module: NormalModule, key: string, readonly version: ValueCacheVersion }) => CodeValuePrimitive} GeneratorFn */ | ||
@@ -131,3 +130,3 @@ | ||
| /** | ||
| * @param {Set<DestructuringAssignmentProperty> | undefined} properties properties | ||
| * @param {DestructuringAssignmentProperties | undefined} properties properties | ||
| * @returns {Set<string> | undefined} used keys | ||
@@ -383,6 +382,3 @@ */ | ||
| const mainHash = createHash( | ||
| /** @type {HashFunction} */ | ||
| (compilation.outputOptions.hashFunction) | ||
| ); | ||
| const mainHash = createHash(compilation.outputOptions.hashFunction); | ||
| mainHash.update( | ||
@@ -389,0 +385,0 @@ /** @type {string} */ |
@@ -17,11 +17,9 @@ /* | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */ | ||
| /** @typedef {import("../declarations/plugins/DllReferencePlugin").DllReferencePluginOptions} DllReferencePluginOptions */ | ||
| /** @typedef {import("./ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */ | ||
| /** @typedef {import("./Compilation")} Compilation */ | ||
| /** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */ | ||
| /** @typedef {import("./DependencyTemplates")} DependencyTemplates */ | ||
| /** @typedef {import("./Generator").SourceTypes} SourceTypes */ | ||
| /** @typedef {import("./LibManifestPlugin").ManifestModuleData} ManifestModuleData */ | ||
| /** @typedef {import("./Module").ModuleId} ModuleId */ | ||
| /** @typedef {import("./Module").BuildCallback} BuildCallback */ | ||
@@ -32,12 +30,10 @@ /** @typedef {import("./Module").BuildMeta} BuildMeta */ | ||
| /** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */ | ||
| /** @typedef {import("./Module").LibIdent} LibIdent */ | ||
| /** @typedef {import("./Module").NeedBuildCallback} NeedBuildCallback */ | ||
| /** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */ | ||
| /** @typedef {import("./Module").SourceContext} SourceContext */ | ||
| /** @typedef {import("./RequestShortener")} RequestShortener */ | ||
| /** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */ | ||
| /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */ | ||
| /** @typedef {import("./WebpackError")} WebpackError */ | ||
| /** @typedef {import("./dependencies/ModuleDependency")} ModuleDependency */ | ||
| /** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
| /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @typedef {import("./dependencies/StaticExportsDependency").Exports} Exports */ | ||
| /** @typedef {import("./util/Hash")} Hash */ | ||
@@ -53,4 +49,4 @@ /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */ | ||
| * @property {BuildMeta=} buildMeta build meta | ||
| * @property {true | string[]=} exports exports | ||
| * @property {number | string} id module id | ||
| * @property {Exports=} exports exports | ||
| * @property {ModuleId} id module id | ||
| */ | ||
@@ -95,3 +91,3 @@ | ||
| * @param {LibIdentOptions} options options | ||
| * @returns {string | null} an identifier for library inclusion | ||
| * @returns {LibIdent | null} an identifier for library inclusion | ||
| */ | ||
@@ -98,0 +94,0 @@ libIdent(options) { |
@@ -27,3 +27,2 @@ /* | ||
| /** @typedef {import("estree").ObjectExpression} ObjectExpression */ | ||
| /** @typedef {import("estree").SimpleCallExpression} SimpleCallExpression */ | ||
| /** @typedef {import("estree").SpreadElement} SpreadElement */ | ||
@@ -34,2 +33,3 @@ /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */ | ||
| /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */ | ||
| /** @typedef {import("../javascript/JavascriptParser").ExportedVariableInfo} ExportedVariableInfo */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
@@ -73,2 +73,4 @@ | ||
| /** @typedef {Record<number, string>} Identifiers */ | ||
| const PLUGIN_NAME = "AMDDefineDependencyParserPlugin"; | ||
@@ -98,3 +100,3 @@ | ||
| * @param {BasicEvaluatedExpression} param param | ||
| * @param {Record<number, string>} identifiers identifiers | ||
| * @param {Identifiers} identifiers identifiers | ||
| * @param {string=} namedModule named module | ||
@@ -113,3 +115,3 @@ * @returns {boolean | undefined} result | ||
| ) { | ||
| identifiers[/** @type {number} */ (idx)] = | ||
| identifiers[idx] = | ||
| /** @type {string} */ | ||
@@ -355,5 +357,6 @@ (item.string); | ||
| } | ||
| /** @type {Map<string, ExportedVariableInfo>} */ | ||
| const fnRenames = new Map(); | ||
| if (array) { | ||
| /** @type {Record<number, string>} */ | ||
| /** @type {Identifiers} */ | ||
| const identifiers = {}; | ||
@@ -426,15 +429,7 @@ const param = parser.evaluateExpression(array); | ||
| parser.scope.inTry = /** @type {boolean} */ (inTry); | ||
| if (object.body.type === "BlockStatement") { | ||
| parser.detectMode(object.body.body); | ||
| const prev = parser.prevStatement; | ||
| parser.preWalkStatement(object.body); | ||
| parser.prevStatement = prev; | ||
| parser.walkStatement(object.body); | ||
| } else { | ||
| parser.walkExpression( | ||
| /** @type {TODO} */ | ||
| (object.body) | ||
| ); | ||
| } | ||
| parser.detectMode(object.body.body); | ||
| const prev = parser.prevStatement; | ||
| parser.preWalkStatement(object.body); | ||
| parser.prevStatement = prev; | ||
| parser.walkStatement(object.body); | ||
| } | ||
@@ -441,0 +436,0 @@ ); |
@@ -37,3 +37,2 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptions */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
@@ -43,2 +42,3 @@ /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("../javascript/BasicEvaluatedExpression").GetMembers} GetMembers */ | ||
@@ -148,3 +148,3 @@ const PLUGIN_NAME = "AMDPlugin"; | ||
| * @param {string} rootName root name | ||
| * @param {() => string[]} getMembers callback | ||
| * @param {GetMembers} getMembers callback | ||
| */ | ||
@@ -151,0 +151,0 @@ const tapOptionsHooks = (optionExpr, rootName, getMembers) => { |
@@ -29,3 +29,2 @@ /* | ||
| /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */ | ||
| /** @typedef {import("../Module").BuildInfo} BuildInfo */ | ||
| /** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */ | ||
@@ -300,3 +299,3 @@ /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */ | ||
| parser.state.current = /** @type {TODO} */ (depBlock); | ||
| parser.state.current = /** @type {EXPECTED_ANY} */ (depBlock); | ||
| } | ||
@@ -303,0 +302,0 @@ |
@@ -14,9 +14,5 @@ /* | ||
| /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
| /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */ | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| /** @typedef {import("../DependencyTemplates")} DependencyTemplates */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
@@ -23,0 +19,0 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ |
@@ -20,3 +20,4 @@ /* | ||
| /** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */ | ||
| /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ | ||
| /** @typedef {import("../Dependency").RawReferencedExports} RawReferencedExports */ | ||
| /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */ | ||
| /** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */ | ||
@@ -26,2 +27,3 @@ /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| /** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */ | ||
| /** @typedef {import("../ExportsInfo").ExportInfoName} ExportInfoName */ | ||
| /** @typedef {import("../Module")} Module */ | ||
@@ -39,2 +41,5 @@ /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {Set<string>} Exports */ | ||
| /** @typedef {Set<string>} Checked */ | ||
| class CommonJsExportRequireDependency extends ModuleDependency { | ||
@@ -45,5 +50,5 @@ /** | ||
| * @param {CommonJSDependencyBaseKeywords} base base | ||
| * @param {string[]} names names | ||
| * @param {ExportInfoName[]} names names | ||
| * @param {string} request request | ||
| * @param {string[]} ids ids | ||
| * @param {ExportInfoName[]} ids ids | ||
| * @param {boolean} resultUsed true, when the result is used | ||
@@ -75,3 +80,3 @@ */ | ||
| * @param {ModuleGraph} moduleGraph the module graph | ||
| * @returns {string[]} the imported id | ||
| * @returns {ExportInfoName[]} the imported id | ||
| */ | ||
@@ -84,3 +89,3 @@ getIds(moduleGraph) { | ||
| * @param {ModuleGraph} moduleGraph the module graph | ||
| * @param {string[]} ids the imported ids | ||
| * @param {ExportInfoName[]} ids the imported ids | ||
| * @returns {void} | ||
@@ -96,3 +101,3 @@ */ | ||
| * @param {RuntimeSpec} runtime the runtime for which the module is analysed | ||
| * @returns {(string[] | ReferencedExport)[]} referenced exports | ||
| * @returns {ReferencedExports} referenced exports | ||
| */ | ||
@@ -118,5 +123,5 @@ getReferencedExports(moduleGraph, runtime) { | ||
| for (const name of this.names) { | ||
| const exportInfo = /** @type {ExportInfo} */ ( | ||
| exportsInfo.getReadOnlyExportInfo(name) | ||
| ); | ||
| const exportInfo = | ||
| /** @type {ExportInfo} */ | ||
| (exportsInfo.getReadOnlyExportInfo(name)); | ||
| const used = exportInfo.getUsed(runtime); | ||
@@ -131,3 +136,3 @@ if (used === UsageState.Unused) return Dependency.NO_EXPORTS_REFERENCED; | ||
| } | ||
| /** @type {string[][]} */ | ||
| /** @type {RawReferencedExports} */ | ||
| const referencedExports = []; | ||
@@ -200,3 +205,3 @@ for (const exportInfo of exportsInfo.orderedExports) { | ||
| exports: Array.from( | ||
| /** @type {Set<string>} */ | ||
| /** @type {Exports} */ | ||
| (reexportInfo.exports), | ||
@@ -226,3 +231,3 @@ (name) => ({ | ||
| * @param {Module} importedModule the imported module (optional) | ||
| * @returns {{exports?: Set<string>, checked?: Set<string>} | undefined} information | ||
| * @returns {{ exports?: Exports, checked?: Checked } | undefined} information | ||
| */ | ||
@@ -262,5 +267,5 @@ getStarReexports( | ||
| /** @type {Set<string>} */ | ||
| /** @type {Exports} */ | ||
| const exports = new Set(); | ||
| /** @type {Set<string>} */ | ||
| /** @type {Checked} */ | ||
| const checked = new Set(); | ||
@@ -418,1 +423,2 @@ | ||
| module.exports = CommonJsExportRequireDependency; | ||
| module.exports.idsSymbol = idsSymbol; |
@@ -19,2 +19,3 @@ /* | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../ExportsInfo").ExportInfoName} ExportInfoName */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
@@ -32,3 +33,3 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
| * @param {CommonJSDependencyBaseKeywords} base base | ||
| * @param {string[]} names names | ||
| * @param {ExportInfoName[]} names names | ||
| */ | ||
@@ -35,0 +36,0 @@ constructor(range, valueRange, base, names) { |
@@ -25,8 +25,10 @@ /* | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../NormalModule")} NormalModule */ | ||
| /** @typedef {import("../ExportsInfo").ExportInfoName} ExportInfoName */ | ||
| /** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */ | ||
| /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Members} Members */ | ||
| /** @typedef {import("../javascript/JavascriptParser").StatementPath} StatementPath */ | ||
| /** @typedef {import("./CommonJsDependencyHelpers").CommonJSDependencyBaseKeywords} CommonJSDependencyBaseKeywords */ | ||
| /** @typedef {import("../Module").BuildMeta} BuildMeta */ | ||
@@ -98,5 +100,6 @@ /** | ||
| * @param {Expression} expr expression | ||
| * @returns {{ argument: BasicEvaluatedExpression, ids: string[] } | undefined} parsed call | ||
| * @returns {{ argument: BasicEvaluatedExpression, ids: ExportInfoName[] } | undefined} parsed call | ||
| */ | ||
| const parseRequireCall = (parser, expr) => { | ||
| /** @type {ExportInfoName[]} */ | ||
| const ids = []; | ||
@@ -151,3 +154,3 @@ while (expr.type === "MemberExpression") { | ||
| * @param {boolean} topLevel true, when the export is on top level | ||
| * @param {string[]} members members of the export | ||
| * @param {Members} members members of the export | ||
| * @param {Expression | undefined} valueExpr expression for the value | ||
@@ -195,3 +198,3 @@ * @returns {void} | ||
| * @param {CommonJSDependencyBaseKeywords} base commonjs base keywords | ||
| * @param {string[]} members members of the export | ||
| * @param {Members} members members of the export | ||
| * @returns {boolean | undefined} true, when the expression was handled | ||
@@ -223,2 +226,6 @@ */ | ||
| parser.state.module.addDependency(dep); | ||
| /** @type {BuildMeta} */ ( | ||
| parser.state.module.buildMeta | ||
| ).treatAsCommonJs = true; | ||
| return true; | ||
@@ -244,2 +251,4 @@ } | ||
| parser.state.module.addDependency(dep); | ||
| /** @type {BuildMeta} */ (parser.state.module.buildMeta).treatAsCommonJs = | ||
| true; | ||
| parser.walkExpression(expr.right); | ||
@@ -302,2 +311,5 @@ return true; | ||
| parser.state.module.addDependency(dep); | ||
| /** @type {BuildMeta} */ ( | ||
| parser.state.module.buildMeta | ||
| ).treatAsCommonJs = true; | ||
@@ -313,3 +325,3 @@ parser.walkExpression(expr.arguments[2]); | ||
| * @param {CommonJSDependencyBaseKeywords} base commonjs base keywords | ||
| * @param {string[]} members members of the export | ||
| * @param {Members} members members of the export | ||
| * @param {CallExpression=} call call expression | ||
@@ -344,2 +356,5 @@ * @returns {boolean | void} true, when the expression was handled | ||
| parser.state.module.addDependency(dep); | ||
| /** @type {BuildMeta} */ (parser.state.module.buildMeta).treatAsCommonJs = | ||
| true; | ||
| if (call) { | ||
@@ -346,0 +361,0 @@ parser.walkExpressions(call.arguments); |
@@ -17,9 +17,11 @@ /* | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
| /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ | ||
| /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */ | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("../ExportsInfo").ExportInfoName} ExportInfoName */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */ | ||
| /** @typedef {import("../util/chainedImports").IdRanges} IdRanges */ | ||
@@ -30,4 +32,4 @@ class CommonJsFullRequireDependency extends ModuleDependency { | ||
| * @param {Range} range location in source code | ||
| * @param {string[]} names accessed properties on module | ||
| * @param {Range[]=} idRanges ranges for members of ids; the two arrays are right-aligned | ||
| * @param {ExportInfoName[]} names accessed properties on module | ||
| * @param {IdRanges=} idRanges ranges for members of ids; the two arrays are right-aligned | ||
| */ | ||
@@ -52,3 +54,3 @@ constructor( | ||
| * @param {RuntimeSpec} runtime the runtime for which the module is analysed | ||
| * @returns {(string[] | ReferencedExport)[]} referenced exports | ||
| * @returns {ReferencedExports} referenced exports | ||
| */ | ||
@@ -55,0 +57,0 @@ getReferencedExports(moduleGraph, runtime) { |
@@ -41,3 +41,11 @@ /* | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Members} Members */ | ||
| /** @typedef {import("../javascript/JavascriptParser").CalleeMembers} CalleeMembers */ | ||
| /** | ||
| * @typedef {object} CommonJsImportSettings | ||
| * @property {string=} name | ||
| * @property {string} context | ||
| */ | ||
| const createRequireSpecifierTag = Symbol("createRequire"); | ||
@@ -62,6 +70,7 @@ const createdRequireIdentifierTag = Symbol("createRequire()"); | ||
| const options = this.options; | ||
| const getContext = () => { | ||
| if (parser.currentTagData) { | ||
| const { context } = parser.currentTagData; | ||
| const { context } = | ||
| /** @type {CommonJsImportSettings} */ | ||
| (parser.currentTagData); | ||
| return context; | ||
@@ -74,3 +83,3 @@ } | ||
| * @param {string} expression expression | ||
| * @param {() => string[]} getMembers get members | ||
| * @param {() => Members} getMembers get members | ||
| */ | ||
@@ -372,5 +381,5 @@ const tapRequireExpression = (expression, getMembers) => { | ||
| * @param {Expression} expr expression | ||
| * @param {string[]} calleeMembers callee members | ||
| * @param {CalleeMembers} calleeMembers callee members | ||
| * @param {CallExpression} callExpr call expression | ||
| * @param {string[]} members members | ||
| * @param {Members} members members | ||
| * @param {Range[]} memberRanges member ranges | ||
@@ -409,5 +418,5 @@ * @returns {boolean | void} true when handled | ||
| * @param {CallExpression} expr expression | ||
| * @param {string[]} calleeMembers callee members | ||
| * @param {CalleeMembers} calleeMembers callee members | ||
| * @param {CallExpression} callExpr call expression | ||
| * @param {string[]} members members | ||
| * @param {Members} members members | ||
| * @param {Range[]} memberRanges member ranges | ||
@@ -414,0 +423,0 @@ * @returns {boolean | void} true when handled |
@@ -23,3 +23,3 @@ /* | ||
| * @param {boolean | string } inShorthand true or name | ||
| * @param {string} context context | ||
| * @param {string=} context context | ||
| */ | ||
@@ -26,0 +26,0 @@ constructor(options, range, valueRange, inShorthand, context) { |
@@ -16,6 +16,6 @@ /* | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
| /** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */ | ||
| /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ | ||
| /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */ | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../ExportsInfo").ExportInfoName} ExportInfoName */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
@@ -31,3 +31,3 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
| * @param {CommonJSDependencyBaseKeywords} base base | ||
| * @param {string[]} names names | ||
| * @param {ExportInfoName[]} names names | ||
| * @param {boolean} call is a call | ||
@@ -62,3 +62,3 @@ */ | ||
| * @param {RuntimeSpec} runtime the runtime for which the module is analysed | ||
| * @returns {(string[] | ReferencedExport)[]} referenced exports | ||
| * @returns {ReferencedExports} referenced exports | ||
| */ | ||
@@ -65,0 +65,0 @@ getReferencedExports(moduleGraph, runtime) { |
@@ -12,3 +12,3 @@ /* | ||
| /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("./NullDependency").RawRuntimeRequirements} RawRuntimeRequirements */ | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
@@ -28,3 +28,3 @@ /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */ | ||
| * @param {number | Range} range the source range | ||
| * @param {(string[] | null)=} runtimeRequirements runtime requirements | ||
| * @param {RawRuntimeRequirements | null=} runtimeRequirements runtime requirements | ||
| */ | ||
@@ -31,0 +31,0 @@ constructor(expression, range, runtimeRequirements) { |
@@ -13,2 +13,3 @@ /* | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("../ContextModule").ContextOptions} ContextOptions */ | ||
@@ -27,4 +28,6 @@ /** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */ | ||
| /** @typedef {{ value: string, range: Range }[]} Replaces */ | ||
| /** | ||
| * @param {RegExp | null | undefined} r regexp | ||
| * @param {RegExp | false | null | undefined} r regexp | ||
| * @returns {string} stringified regexp | ||
@@ -50,2 +53,3 @@ */ | ||
| this.options && | ||
| this.options.regExp && | ||
| (this.options.regExp.global || this.options.regExp.sticky) | ||
@@ -57,8 +61,11 @@ ) { | ||
| /** @type {string | undefined} */ | ||
| this.request = undefined; | ||
| /** @type {Range | undefined} */ | ||
| this.range = undefined; | ||
| /** @type {Range | undefined} */ | ||
| this.valueRange = undefined; | ||
| /** @type {boolean | string | undefined} */ | ||
| this.inShorthand = undefined; | ||
| // TODO refactor this | ||
| /** @type {Replaces | undefined} */ | ||
| this.replaces = undefined; | ||
@@ -148,3 +155,2 @@ this._requestContext = context; | ||
| write(this.valueRange); | ||
| write(this.prepend); | ||
| write(this.replaces); | ||
@@ -169,3 +175,2 @@ | ||
| this.valueRange = read(); | ||
| this.prepend = read(); | ||
| this.replaces = read(); | ||
@@ -172,0 +177,0 @@ |
@@ -12,3 +12,2 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptions */ | ||
| /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */ | ||
@@ -20,2 +19,3 @@ /** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */ | ||
| /** @typedef {import("./ContextDependency").ContextDependencyOptions} ContextDependencyOptions */ | ||
| /** @typedef {import("./ContextDependency").Replaces} Replaces */ | ||
@@ -124,3 +124,3 @@ /** | ||
| /** @type {{ value: string, range: Range }[]} */ | ||
| /** @type {Replaces} */ | ||
| const replaces = []; | ||
@@ -127,0 +127,0 @@ const parts = /** @type {BasicEvaluatedExpression[]} */ (param.parts); |
@@ -11,2 +11,3 @@ /* | ||
| /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
@@ -32,3 +33,3 @@ /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| chunkGraph, | ||
| request: dep.request, | ||
| request: /** @type {string} */ (dep.request), | ||
| weak: dep.weak, | ||
@@ -38,2 +39,4 @@ runtimeRequirements | ||
| const range = /** @type {Range} */ (dep.range); | ||
| if (module) { | ||
@@ -47,5 +50,6 @@ if (dep.valueRange) { | ||
| } | ||
| source.replace(dep.valueRange[1], dep.range[1] - 1, ")"); | ||
| source.replace(dep.valueRange[1], range[1] - 1, ")"); | ||
| source.replace( | ||
| dep.range[0], | ||
| range[0], | ||
| dep.valueRange[0] - 1, | ||
@@ -55,10 +59,6 @@ `${moduleExports}.resolve(` | ||
| } else { | ||
| source.replace( | ||
| dep.range[0], | ||
| dep.range[1] - 1, | ||
| `${moduleExports}.resolve` | ||
| ); | ||
| source.replace(range[0], range[1] - 1, `${moduleExports}.resolve`); | ||
| } | ||
| } else { | ||
| source.replace(dep.range[0], dep.range[1] - 1, moduleExports); | ||
| source.replace(range[0], range[1] - 1, moduleExports); | ||
| } | ||
@@ -65,0 +65,0 @@ } |
@@ -11,2 +11,3 @@ /* | ||
| /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
@@ -31,3 +32,3 @@ /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| chunkGraph, | ||
| request: dep.request, | ||
| request: /** @type {string} */ (dep.request), | ||
| runtimeRequirements | ||
@@ -39,2 +40,5 @@ }); | ||
| } | ||
| const range = /** @type {Range} */ (dep.range); | ||
| if (moduleGraph.getModule(dep)) { | ||
@@ -48,13 +52,9 @@ if (dep.valueRange) { | ||
| } | ||
| source.replace(dep.valueRange[1], dep.range[1] - 1, ")"); | ||
| source.replace( | ||
| dep.range[0], | ||
| dep.valueRange[0] - 1, | ||
| `${moduleExports}(` | ||
| ); | ||
| source.replace(dep.valueRange[1], range[1] - 1, ")"); | ||
| source.replace(range[0], dep.valueRange[0] - 1, `${moduleExports}(`); | ||
| } else { | ||
| source.replace(dep.range[0], dep.range[1] - 1, moduleExports); | ||
| source.replace(range[0], range[1] - 1, moduleExports); | ||
| } | ||
| } else { | ||
| source.replace(dep.range[0], dep.range[1] - 1, moduleExports); | ||
| source.replace(range[0], range[1] - 1, moduleExports); | ||
| } | ||
@@ -61,0 +61,0 @@ } |
@@ -13,5 +13,5 @@ /* | ||
| /** @typedef {import("../ContextModule")} ContextModule */ | ||
| /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ | ||
| /** @typedef {import("../Dependency").RawReferencedExports} RawReferencedExports */ | ||
| /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */ | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../Module").BuildMeta} BuildMeta */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
@@ -29,3 +29,3 @@ /** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */ | ||
| * @param {string} category category | ||
| * @param {(string[][] | null)=} referencedExports referenced exports | ||
| * @param {RawReferencedExports | null=} referencedExports referenced exports | ||
| * @param {string=} context context | ||
@@ -44,6 +44,2 @@ * @param {ImportAttributes=} attributes import assertions | ||
| super(request); | ||
| this.referencedExports = referencedExports; | ||
| this._typePrefix = typePrefix; | ||
| this._category = category; | ||
| this._context = context || undefined; | ||
@@ -54,3 +50,7 @@ if (userRequest) { | ||
| this.assertions = attributes; | ||
| this._typePrefix = typePrefix; | ||
| this._category = category; | ||
| this.referencedExports = referencedExports; | ||
| this._context = context || undefined; | ||
| this.attributes = attributes; | ||
| } | ||
@@ -71,6 +71,17 @@ | ||
| /** | ||
| * @returns {string | null} an identifier to merge equal requests | ||
| */ | ||
| getResourceIdentifier() { | ||
| let str = super.getResourceIdentifier(); | ||
| if (this.attributes !== undefined) { | ||
| str += JSON.stringify(this.attributes); | ||
| } | ||
| return str; | ||
| } | ||
| /** | ||
| * Returns list of exports referenced by this dependency | ||
| * @param {ModuleGraph} moduleGraph module graph | ||
| * @param {RuntimeSpec} runtime the runtime for which the module is analysed | ||
| * @returns {(string[] | ReferencedExport)[]} referenced exports | ||
| * @returns {ReferencedExports} referenced exports | ||
| */ | ||
@@ -118,3 +129,3 @@ getReferencedExports(moduleGraph, runtime) { | ||
| write(this.referencedExports); | ||
| write(this.assertions); | ||
| write(this.attributes); | ||
| super.serialize(context); | ||
@@ -131,3 +142,3 @@ } | ||
| this.referencedExports = read(); | ||
| this.assertions = read(); | ||
| this.attributes = read(); | ||
| super.deserialize(context); | ||
@@ -134,0 +145,0 @@ } |
@@ -15,6 +15,4 @@ /* | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
| /** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */ | ||
| /** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */ | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
@@ -21,0 +19,0 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ |
@@ -14,3 +14,3 @@ /* | ||
| /** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */ | ||
| /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ | ||
| /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */ | ||
| /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */ | ||
@@ -81,3 +81,3 @@ /** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */ | ||
| * @param {RuntimeSpec} runtime the runtime for which the module is analysed | ||
| * @returns {(string[] | ReferencedExport)[]} referenced exports | ||
| * @returns {ReferencedExports} referenced exports | ||
| */ | ||
@@ -84,0 +84,0 @@ getReferencedExports(moduleGraph, runtime) { |
@@ -12,15 +12,7 @@ /* | ||
| /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
| /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */ | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */ | ||
| /** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */ | ||
| /** @typedef {import("../css/CssParser").Range} Range */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @typedef {import("../util/Hash")} Hash */ | ||
| /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */ | ||
@@ -27,0 +19,0 @@ class CssImportDependency extends ModuleDependency { |
@@ -18,3 +18,2 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").CssGeneratorLocalIdentName} CssGeneratorLocalIdentName */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
@@ -27,3 +26,2 @@ /** @typedef {import("../CssModule")} CssModule */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../NormalModuleFactory").ResourceDataWithData} ResourceDataWithData */ | ||
| /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ | ||
@@ -53,3 +51,4 @@ /** @typedef {import("../css/CssGenerator")} CssGenerator */ | ||
| (module.context), | ||
| module.matchResource || module.resource, | ||
| /** @type {string} */ | ||
| (module.getResource()), | ||
| runtimeTemplate.compilation.compiler.root | ||
@@ -59,3 +58,3 @@ ); | ||
| runtimeTemplate.outputOptions; | ||
| const hash = createHash(/** @type {HashFunction} */ (hashFunction)); | ||
| const hash = createHash(hashFunction); | ||
@@ -62,0 +61,0 @@ if (hashSalt) { |
@@ -14,3 +14,3 @@ /* | ||
| /** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */ | ||
| /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ | ||
| /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */ | ||
| /** @typedef {import("../DependencyTemplate").CssDependencyTemplateContext} DependencyTemplateContext */ | ||
@@ -64,3 +64,3 @@ /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| * @param {RuntimeSpec} runtime the runtime for which the module is analysed | ||
| * @returns {(string[] | ReferencedExport)[]} referenced exports | ||
| * @returns {ReferencedExports} referenced exports | ||
| */ | ||
@@ -67,0 +67,0 @@ getReferencedExports(moduleGraph, runtime) { |
@@ -14,16 +14,10 @@ /* | ||
| /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */ | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
| /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */ | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../Module").CodeGenerationResult} CodeGenerationResult */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */ | ||
| /** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @typedef {import("../util/Hash")} Hash */ | ||
| /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */ | ||
@@ -30,0 +24,0 @@ |
@@ -13,12 +13,10 @@ /* | ||
| /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
| /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */ | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../ExportsInfo").ExportInfoName} ExportInfoName */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @typedef {import("../util/Hash")} Hash */ | ||
| /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */ | ||
@@ -34,9 +32,9 @@ | ||
| * @param {Module} module the module | ||
| * @param {string[] | null} _exportName name of the export if any | ||
| * @param {ExportInfoName[] | null} exportName_ name of the export if any | ||
| * @param {string | null} property name of the requested property | ||
| * @param {RuntimeSpec} runtime for which runtime | ||
| * @returns {undefined | null | number | boolean | string[] | SortableSet<string>} value of the property | ||
| * @returns {undefined | null | boolean | ExportInfoName[]} value of the property | ||
| */ | ||
| const getProperty = (moduleGraph, module, _exportName, property, runtime) => { | ||
| if (!_exportName) { | ||
| const getProperty = (moduleGraph, module, exportName_, property, runtime) => { | ||
| if (!exportName_) { | ||
| switch (property) { | ||
@@ -58,3 +56,3 @@ case "usedExports": { | ||
| } | ||
| const exportName = /** @type {string[]} */ (_exportName); | ||
| const exportName = /** @type {ExportInfoName[]} */ (exportName_); | ||
| switch (property) { | ||
@@ -98,3 +96,3 @@ case "canMangle": { | ||
| * @param {Range} range range | ||
| * @param {string[] | null} exportName export name | ||
| * @param {ExportInfoName[] | null} exportName export name | ||
| * @param {string | null} property property | ||
@@ -101,0 +99,0 @@ */ |
@@ -14,9 +14,6 @@ /* | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
| /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */ | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| /** @typedef {import("../javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @typedef {import("../util/Hash")} Hash */ | ||
@@ -23,0 +20,0 @@ class ExternalModuleDependency extends CachedConstDependency { |
@@ -23,3 +23,3 @@ /* | ||
| * @param {string} importedModule imported module | ||
| * @param {Array<{ name: string, value?: string }> | ImportSpecifiers} specifiers import specifiers | ||
| * @param {{ name: string, value?: string }[] | ImportSpecifiers} specifiers import specifiers | ||
| * @param {string=} defaultImport default import | ||
@@ -26,0 +26,0 @@ */ |
@@ -123,3 +123,3 @@ /* | ||
| if (isRelatedHarmonyImportDependency(dependency, d)) { | ||
| if (d.defer) { | ||
| if (/** @type {HarmonyImportDependency} */ (d).defer) { | ||
| deferDependency = /** @type {HarmonyImportDependency} */ (d); | ||
@@ -126,0 +126,0 @@ } else { |
@@ -12,6 +12,2 @@ /* | ||
| /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| class HarmonyAcceptImportDependency extends HarmonyImportDependency { | ||
@@ -18,0 +14,0 @@ /** |
@@ -17,3 +17,2 @@ /* | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../Module").BuildMeta} BuildMeta */ | ||
@@ -20,0 +19,0 @@ |
@@ -16,3 +16,2 @@ /* | ||
| /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */ | ||
| /** @typedef {import("./HarmonyModulesPlugin").HarmonyModulesPluginOptions} HarmonyModulesPluginOptions */ | ||
@@ -23,10 +22,2 @@ const PLUGIN_NAME = "HarmonyDetectionParserPlugin"; | ||
| /** | ||
| * @param {HarmonyModulesPluginOptions} options options | ||
| */ | ||
| constructor(options) { | ||
| const { topLevelAwait = false } = options || {}; | ||
| this.topLevelAwait = topLevelAwait; | ||
| } | ||
| /** | ||
| * @param {JavascriptParser} parser the parser | ||
@@ -71,7 +62,2 @@ * @returns {void} | ||
| const module = parser.state.module; | ||
| if (!this.topLevelAwait) { | ||
| throw new Error( | ||
| "The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enable it)" | ||
| ); | ||
| } | ||
| if (!HarmonyExports.isEnabled(parser.state)) { | ||
@@ -78,0 +64,0 @@ throw new Error( |
@@ -12,3 +12,2 @@ /* | ||
| /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
@@ -22,2 +21,3 @@ /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @typedef {import("./HarmonyImportDependency").Ids} Ids */ | ||
@@ -35,6 +35,6 @@ /** | ||
| * @param {number} sourceOrder source order | ||
| * @param {string[]} ids ids | ||
| * @param {Ids} ids ids | ||
| * @param {string} name name | ||
| * @param {Range} range location in source code | ||
| * @param {ImportAttributes} attributes import assertions | ||
| * @param {ImportAttributes | undefined} attributes import assertions | ||
| * @param {string} operator operator | ||
@@ -41,0 +41,0 @@ */ |
@@ -28,2 +28,3 @@ /* | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("./HarmonyImportDependencyParserPlugin").HarmonySettings} HarmonySettings */ | ||
@@ -160,3 +161,5 @@ const { HarmonyStarExportsList } = HarmonyExportImportedSpecifierDependency; | ||
| (statement, id, name, idx) => { | ||
| const settings = parser.getTagData(id, harmonySpecifierTag); | ||
| const settings = | ||
| /** @type {HarmonySettings} */ | ||
| (parser.getTagData(id, harmonySpecifierTag)); | ||
| const harmonyNamedExports = (parser.state.harmonyNamedExports = | ||
@@ -163,0 +166,0 @@ parser.state.harmonyNamedExports || new Set()); |
@@ -36,8 +36,9 @@ /* | ||
| /** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */ | ||
| /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ | ||
| /** @typedef {import("../Dependency").RawReferencedExports} RawReferencedExports */ | ||
| /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */ | ||
| /** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */ | ||
| /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */ | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| /** @typedef {import("../ExportsInfo")} ExportsInfo */ | ||
| /** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */ | ||
| /** @typedef {import("../ExportsInfo").ExportInfoName} ExportInfoName */ | ||
| /** @typedef {import("../ExportsInfo").UsedName} UsedName */ | ||
@@ -48,2 +49,3 @@ /** @typedef {import("../Generator").GenerateContext} GenerateContext */ | ||
| /** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */ | ||
| /** @typedef {import("../Module").ExportsType} ExportsType */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
@@ -57,6 +59,5 @@ /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @typedef {import("../util/Hash")} Hash */ | ||
| /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */ | ||
| /** @typedef {import("./HarmonyImportDependency").Ids} Ids */ | ||
| /** @typedef {import("./HarmonyImportDependency").ExportPresenceMode} ExportPresenceMode */ | ||
| /** @typedef {import("./processExportInfo").ReferencedExports} ReferencedExports */ | ||
@@ -72,3 +73,3 @@ /** @typedef {"missing"|"unused"|"empty-star"|"reexport-dynamic-default"|"reexport-named-default"|"reexport-namespace-object"|"reexport-fake-namespace-object"|"reexport-undefined"|"normal-reexport"|"dynamic-reexport"} ExportModeType */ | ||
| * @param {string} name export name | ||
| * @param {string[]} ids reexported ids from other module | ||
| * @param {Ids} ids reexported ids from other module | ||
| * @param {ExportInfo} exportInfo export info from other module | ||
@@ -126,3 +127,2 @@ * @param {boolean} checked true, if it should be checked at runtime if this export exists | ||
| /** @typedef {string[]} Names */ | ||
| /** @typedef {number[]} DependencyIndices */ | ||
@@ -132,5 +132,5 @@ | ||
| * @param {ModuleGraph} moduleGraph module graph | ||
| * @param {ReadonlyArray<HarmonyExportImportedSpecifierDependency>} dependencies dependencies | ||
| * @param {TODO=} additionalDependency additional dependency | ||
| * @returns {{ names: Names, dependencyIndices: DependencyIndices }} result | ||
| * @param {HarmonyExportImportedSpecifierDependency[]} dependencies dependencies | ||
| * @param {HarmonyExportImportedSpecifierDependency=} additionalDependency additional dependency | ||
| * @returns {{ names: ExportInfoName[], dependencyIndices: DependencyIndices }} result | ||
| */ | ||
@@ -142,5 +142,5 @@ const determineExportAssignments = ( | ||
| ) => { | ||
| /** @type {Set<string>} */ | ||
| /** @type {Set<ExportInfoName>} */ | ||
| const names = new Set(); | ||
| /** @type {number[]} */ | ||
| /** @type {DependencyIndices} */ | ||
| const dependencyIndices = []; | ||
@@ -177,3 +177,3 @@ | ||
| * @param {object} options options | ||
| * @param {Names} options.names names | ||
| * @param {ExportInfoName[]} options.names names | ||
| * @param {DependencyIndices} options.dependencyIndices dependency indices | ||
@@ -350,3 +350,3 @@ * @param {string} name name | ||
| exportsInfo.getReadOnlyExportInfo(exportName), | ||
| /** @type {Set<string>} */ | ||
| /** @type {Checked} */ | ||
| (checked).has(exportName), | ||
@@ -373,3 +373,2 @@ false | ||
| /** @typedef {string[]} Ids */ | ||
| /** @typedef {Set<string>} Exports */ | ||
@@ -528,3 +527,3 @@ /** @typedef {Set<string>} Checked */ | ||
| if (hiddenExports !== undefined && hiddenExports.has(name)) { | ||
| /** @type {Set<string>} */ | ||
| /** @type {Hidden} */ | ||
| (hidden).add(name); | ||
@@ -581,3 +580,3 @@ continue; | ||
| * @param {RuntimeSpec} runtime the runtime for which the module is analysed | ||
| * @returns {(string[] | ReferencedExport)[]} referenced exports | ||
| * @returns {ReferencedExports} referenced exports | ||
| */ | ||
@@ -601,3 +600,3 @@ getReferencedExports(moduleGraph, runtime) { | ||
| } | ||
| /** @type {ReferencedExports} */ | ||
| /** @type {RawReferencedExports} */ | ||
| const referencedExports = []; | ||
@@ -618,3 +617,3 @@ processExportInfo( | ||
| } | ||
| /** @type {ReferencedExports} */ | ||
| /** @type {RawReferencedExports} */ | ||
| const referencedExports = []; | ||
@@ -635,3 +634,3 @@ processExportInfo( | ||
| case "normal-reexport": { | ||
| /** @type {ReferencedExports} */ | ||
| /** @type {RawReferencedExports} */ | ||
| const referencedExports = []; | ||
@@ -656,3 +655,3 @@ for (const { | ||
| * @param {ModuleGraph} moduleGraph the module graph | ||
| * @returns {{ names: Names, namesSlice: number, dependencyIndices: DependencyIndices, dependencyIndex: number } | undefined} exported names and their origin dependency | ||
| * @returns {{ names: ExportInfoName[], namesSlice: number, dependencyIndices: DependencyIndices, dependencyIndex: number } | undefined} exported names and their origin dependency | ||
| */ | ||
@@ -899,3 +898,3 @@ _discoverActiveExportsFromOtherStarExports(moduleGraph) { | ||
| const exportsInfo = moduleGraph.getExportsInfo(importedModule); | ||
| /** @type {Map<string, string[]>} */ | ||
| /** @type {Map<string, ExportInfoName[]>} */ | ||
| const conflicts = new Map(); | ||
@@ -1000,4 +999,2 @@ for (const exportInfo of exportsInfo.orderedExports) { | ||
| module.exports = HarmonyExportImportedSpecifierDependency; | ||
| HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedSpecifierDependencyTemplate extends ( | ||
@@ -1254,10 +1251,5 @@ HarmonyImportDependency.Template | ||
| : /** @type {ExportModeIgnored} */ (mode.ignored); | ||
| const modern = | ||
| runtimeTemplate.supportsConst() && | ||
| runtimeTemplate.supportsArrowFunction(); | ||
| let content = | ||
| "/* harmony reexport (unknown) */ var __WEBPACK_REEXPORT_OBJECT__ = {};\n" + | ||
| `/* harmony reexport (unknown) */ for(${ | ||
| modern ? "const" : "var" | ||
| } __WEBPACK_IMPORT_KEY__ in ${importVar}) `; | ||
| `/* harmony reexport (unknown) */ for(${runtimeTemplate.renderConst()} __WEBPACK_IMPORT_KEY__ in ${importVar}) `; | ||
@@ -1277,3 +1269,3 @@ // Filter out exports which are defined by other exports | ||
| content += "__WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = "; | ||
| content += modern | ||
| content += runtimeTemplate.supportsArrowFunction() | ||
| ? `() => ${importVar}[__WEBPACK_IMPORT_KEY__]` | ||
@@ -1308,3 +1300,3 @@ : `function(key) { return ${importVar}[key]; }.bind(0, __WEBPACK_IMPORT_KEY__)`; | ||
| * @param {string} name name | ||
| * @param {string | string[] | null | false} valueKey value key | ||
| * @param {UsedName | null} valueKey value key | ||
| * @param {RuntimeRequirements} runtimeRequirements runtime requirements | ||
@@ -1334,3 +1326,3 @@ * @returns {HarmonyExportInitFragment} harmony export init fragment | ||
| * @param {Module} module module | ||
| * @param {string | string[] | false} key key | ||
| * @param {UsedName} key key | ||
| * @param {string} name name | ||
@@ -1374,6 +1366,6 @@ * @param {number} fakeType fake type | ||
| * @param {ChunkGraph} chunkGraph chunkGraph | ||
| * @param {string | false | string[]} key key | ||
| * @param {UsedName} key key | ||
| * @param {string} name name | ||
| * @param {import("../Module").ExportsType} exportsType exportsType | ||
| * @param {Set<string>} runtimeRequirements runtimeRequirements | ||
| * @param {ExportsType} exportsType exportsType | ||
| * @param {RuntimeRequirements} runtimeRequirements runtimeRequirements | ||
| * @returns {InitFragment<GenerateContext>[]} fragments | ||
@@ -1510,2 +1502,4 @@ */ | ||
| module.exports = HarmonyExportImportedSpecifierDependency; | ||
| module.exports.HarmonyStarExportsList = HarmonyStarExportsList; | ||
| module.exports.idsSymbol = idsSymbol; |
@@ -18,6 +18,3 @@ /* | ||
| /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ | ||
| /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */ | ||
| /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */ | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
@@ -28,3 +25,2 @@ /** @typedef {import("../ExportsInfo")} ExportsInfo */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ | ||
| /** @typedef {import("../WebpackError")} WebpackError */ | ||
@@ -34,3 +30,2 @@ /** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @typedef {import("../util/Hash")} Hash */ | ||
| /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */ | ||
@@ -65,2 +60,4 @@ | ||
| /** @typedef {string[]} Ids */ | ||
| class HarmonyImportDependency extends ModuleDependency { | ||
@@ -76,3 +73,3 @@ /** | ||
| this.sourceOrder = sourceOrder; | ||
| this.assertions = attributes; | ||
| this.attributes = attributes; | ||
| this.defer = defer; | ||
@@ -86,6 +83,17 @@ } | ||
| /** | ||
| * @returns {string | null} an identifier to merge equal requests | ||
| */ | ||
| getResourceIdentifier() { | ||
| let str = super.getResourceIdentifier(); | ||
| if (this.attributes !== undefined) { | ||
| str += JSON.stringify(this.attributes); | ||
| } | ||
| return str; | ||
| } | ||
| /** | ||
| * Returns list of exports referenced by this dependency | ||
| * @param {ModuleGraph} moduleGraph module graph | ||
| * @param {RuntimeSpec} runtime the runtime for which the module is analysed | ||
| * @returns {(string[] | ReferencedExport)[]} referenced exports | ||
| * @returns {ReferencedExports} referenced exports | ||
| */ | ||
@@ -107,6 +115,11 @@ getReferencedExports(moduleGraph, runtime) { | ||
| let importVarMap = meta[metaKey]; | ||
| if (!importVarMap) meta[metaKey] = importVarMap = new Map(); | ||
| if (!importVarMap) { | ||
| meta[metaKey] = importVarMap = | ||
| /** @type {Map<Module, string>} */ | ||
| (new Map()); | ||
| } | ||
| let importVar = importVarMap.get( | ||
| /** @type {Module} */ (moduleGraph.getModule(this)) | ||
| /** @type {Module} */ | ||
| (moduleGraph.getModule(this)) | ||
| ); | ||
@@ -118,3 +131,4 @@ if (importVar) return importVar; | ||
| importVarMap.set( | ||
| /** @type {Module} */ (moduleGraph.getModule(this)), | ||
| /** @type {Module} */ | ||
| (moduleGraph.getModule(this)), | ||
| importVar | ||
@@ -167,3 +181,3 @@ ); | ||
| * @param {ModuleGraph} moduleGraph module graph | ||
| * @param {string[]} ids imported ids | ||
| * @param {Ids} ids imported ids | ||
| * @param {string} additionalMessage extra info included in the error message | ||
@@ -285,3 +299,4 @@ * @returns {WebpackError[] | undefined} errors | ||
| write(this.sourceOrder); | ||
| write(this.assertions); | ||
| write(this.attributes); | ||
| write(this.defer); | ||
| super.serialize(context); | ||
@@ -296,3 +311,4 @@ } | ||
| this.sourceOrder = read(); | ||
| this.assertions = read(); | ||
| this.attributes = read(); | ||
| this.defer = read(); | ||
| super.deserialize(context); | ||
@@ -299,0 +315,0 @@ } |
@@ -27,11 +27,6 @@ /* | ||
| /** @typedef {import("estree").Identifier} Identifier */ | ||
| /** @typedef {import("estree").Literal} Literal */ | ||
| /** @typedef {import("estree").MemberExpression} MemberExpression */ | ||
| /** @typedef {import("estree").ObjectExpression} ObjectExpression */ | ||
| /** @typedef {import("estree").Property} Property */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */ | ||
| /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */ | ||
| /** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */ | ||
| /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */ | ||
| /** @typedef {import("../javascript/JavascriptParser").DestructuringAssignmentProperty} DestructuringAssignmentProperty */ | ||
| /** @typedef {import("../javascript/JavascriptParser").ExportAllDeclaration} ExportAllDeclaration */ | ||
@@ -41,8 +36,6 @@ /** @typedef {import("../javascript/JavascriptParser").ExportNamedDeclaration} ExportNamedDeclaration */ | ||
| /** @typedef {import("../javascript/JavascriptParser").ImportDeclaration} ImportDeclaration */ | ||
| /** @typedef {import("../javascript/JavascriptParser").ImportExpression} ImportExpression */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("../javascript/JavascriptParser").TagData} TagData */ | ||
| /** @typedef {import("../optimize/InnerGraph").InnerGraph} InnerGraph */ | ||
| /** @typedef {import("../optimize/InnerGraph").TopLevelSymbol} TopLevelSymbol */ | ||
| /** @typedef {import("./HarmonyImportDependency")} HarmonyImportDependency */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Members} Members */ | ||
| /** @typedef {import("../javascript/JavascriptParser").MembersOptionals} MembersOptionals */ | ||
| /** @typedef {import("./HarmonyImportDependency").Ids} Ids */ | ||
@@ -53,3 +46,3 @@ const harmonySpecifierTag = Symbol("harmony import"); | ||
| * @typedef {object} HarmonySettings | ||
| * @property {string[]} ids | ||
| * @property {Ids} ids | ||
| * @property {string} source | ||
@@ -90,5 +83,5 @@ * @property {number} sourceOrder | ||
| /** | ||
| * @param {string[]} members members | ||
| * @param {boolean[]} membersOptionals members Optionals | ||
| * @returns {string[]} a non optional part | ||
| * @param {Members} members members | ||
| * @param {MembersOptionals} membersOptionals members Optionals | ||
| * @returns {Ids} a non optional part | ||
| */ | ||
@@ -165,10 +158,14 @@ function getNonOptionalPart(members, membersOptionals) { | ||
| : false; | ||
| parser.tagVariable(name, harmonySpecifierTag, { | ||
| parser.tagVariable( | ||
| name, | ||
| source, | ||
| ids, | ||
| sourceOrder: parser.state.lastHarmonyImportOrder, | ||
| attributes: getImportAttributes(statement), | ||
| defer | ||
| }); | ||
| harmonySpecifierTag, | ||
| /** @type {HarmonySettings} */ ({ | ||
| name, | ||
| source, | ||
| ids, | ||
| sourceOrder: parser.state.lastHarmonyImportOrder, | ||
| attributes: getImportAttributes(statement), | ||
| defer | ||
| }) | ||
| ); | ||
| return true; | ||
@@ -199,6 +196,6 @@ } | ||
| const settings = | ||
| /** @type {TagData} */ | ||
| /** @type {HarmonySettings} */ | ||
| (rootInfo.tagInfo.data); | ||
| const members = | ||
| /** @type {(() => string[])} */ | ||
| /** @type {(() => Members)} */ | ||
| (rightPart.getMembers)(); | ||
@@ -205,0 +202,0 @@ const dep = new HarmonyEvaluatedImportSpecifierDependency( |
@@ -17,8 +17,4 @@ /* | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */ | ||
| /** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */ | ||
| /** @typedef {import("../WebpackError")} WebpackError */ | ||
| /** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */ | ||
| /** @typedef {import("../util/Hash")} Hash */ | ||
| /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */ | ||
@@ -25,0 +21,0 @@ class HarmonyImportSideEffectDependency extends HarmonyImportDependency { |
@@ -16,10 +16,9 @@ /* | ||
| const propertyAccess = require("../util/propertyAccess"); | ||
| const traverseDestructuringAssignmentProperties = require("../util/traverseDestructuringAssignmentProperties"); | ||
| const HarmonyImportDependency = require("./HarmonyImportDependency"); | ||
| /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */ | ||
| /** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */ | ||
| /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ | ||
| /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */ | ||
| /** @typedef {import("../Dependency").RawReferencedExports} RawReferencedExports */ | ||
| /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */ | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
@@ -29,13 +28,14 @@ /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */ | ||
| /** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */ | ||
| /** @typedef {import("../WebpackError")} WebpackError */ | ||
| /** @typedef {import("../javascript/JavascriptParser").DestructuringAssignmentProperty} DestructuringAssignmentProperty */ | ||
| /** @typedef {import("../javascript/JavascriptParser").DestructuringAssignmentProperties} DestructuringAssignmentProperties */ | ||
| /** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("../optimize/InnerGraph").UsedByExports} UsedByExports */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @typedef {import("../util/Hash")} Hash */ | ||
| /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */ | ||
| /** @typedef {import("../util/chainedImports").IdRanges} IdRanges */ | ||
| /** @typedef {import("./HarmonyImportDependency").ExportPresenceMode} ExportPresenceMode */ | ||
| /** @typedef {HarmonyImportDependency.Ids} Ids */ | ||
@@ -50,3 +50,3 @@ const idsSymbol = Symbol("HarmonyImportSpecifierDependency.ids"); | ||
| * @param {number} sourceOrder source order | ||
| * @param {string[]} ids ids | ||
| * @param {Ids} ids ids | ||
| * @param {string} name name | ||
@@ -56,3 +56,3 @@ * @param {Range} range range | ||
| * @param {ImportAttributes | undefined} attributes import attributes | ||
| * @param {Range[] | undefined} idRanges ranges for members of ids; the two arrays are right-aligned | ||
| * @param {IdRanges | undefined} idRanges ranges for members of ids; the two arrays are right-aligned | ||
| * @param {boolean=} defer is defer phase | ||
@@ -82,5 +82,5 @@ */ | ||
| this.asiSafe = undefined; | ||
| /** @type {Set<string> | boolean | undefined} */ | ||
| /** @type {UsedByExports | undefined} */ | ||
| this.usedByExports = undefined; | ||
| /** @type {Set<DestructuringAssignmentProperty> | undefined} */ | ||
| /** @type {DestructuringAssignmentProperties | undefined} */ | ||
| this.referencedPropertiesInDestructuring = undefined; | ||
@@ -110,3 +110,3 @@ } | ||
| * @param {ModuleGraph} moduleGraph the module graph | ||
| * @returns {string[]} the imported ids | ||
| * @returns {Ids} the imported ids | ||
| */ | ||
@@ -122,3 +122,3 @@ getIds(moduleGraph) { | ||
| * @param {ModuleGraph} moduleGraph the module graph | ||
| * @param {string[]} ids the imported ids | ||
| * @param {Ids} ids the imported ids | ||
| * @returns {void} | ||
@@ -154,3 +154,3 @@ */ | ||
| * @param {RuntimeSpec} runtime the runtime for which the module is analysed | ||
| * @returns {(string[] | ReferencedExport)[]} referenced exports | ||
| * @returns {ReferencedExports} referenced exports | ||
| */ | ||
@@ -201,11 +201,17 @@ getReferencedExports(moduleGraph, runtime) { | ||
| /** | ||
| * @param {string[]=} ids ids | ||
| * @returns {string[][]} referenced exports | ||
| * @param {Ids=} ids ids | ||
| * @returns {RawReferencedExports} referenced exports | ||
| */ | ||
| _getReferencedExportsInDestructuring(ids) { | ||
| if (this.referencedPropertiesInDestructuring) { | ||
| /** @type {string[][]} */ | ||
| /** @type {RawReferencedExports} */ | ||
| const refsInDestructuring = []; | ||
| traverseDestructuringAssignmentProperties( | ||
| this.referencedPropertiesInDestructuring, | ||
| (stack) => refsInDestructuring.push(stack.map((p) => p.id)) | ||
| ); | ||
| /** @type {RawReferencedExports} */ | ||
| const refs = []; | ||
| for (const { id } of this.referencedPropertiesInDestructuring) { | ||
| refs.push(ids ? [...ids, id] : [id]); | ||
| for (const idsInDestructuring of refsInDestructuring) { | ||
| refs.push(ids ? [...ids, ...idsInDestructuring] : idsInDestructuring); | ||
| } | ||
@@ -387,9 +393,19 @@ return refs; | ||
| for (const { | ||
| id, | ||
| shorthand, | ||
| range | ||
| } of dep.referencedPropertiesInDestructuring) { | ||
| /** @type {string[]} */ | ||
| const concatedIds = [...prefixedIds, id]; | ||
| /** @type {{ ids: Ids, range: Range, shorthand: boolean | string }[]} */ | ||
| const replacementsInDestructuring = []; | ||
| traverseDestructuringAssignmentProperties( | ||
| dep.referencedPropertiesInDestructuring, | ||
| undefined, | ||
| (stack) => { | ||
| const property = stack[stack.length - 1]; | ||
| replacementsInDestructuring.push({ | ||
| ids: stack.map((p) => p.id), | ||
| range: property.range, | ||
| shorthand: property.shorthand | ||
| }); | ||
| } | ||
| ); | ||
| for (const { ids, shorthand, range } of replacementsInDestructuring) { | ||
| /** @type {Ids} */ | ||
| const concatedIds = [...prefixedIds, ...ids]; | ||
| const module = /** @type {Module} */ (moduleGraph.getModule(dep)); | ||
@@ -407,6 +423,4 @@ const used = moduleGraph | ||
| source.replace( | ||
| /** @type {Range} */ | ||
| (range)[0], | ||
| /** @type {Range} */ | ||
| (range)[1] - 1, | ||
| range[0], | ||
| range[1] - 1, | ||
| shorthand ? `${key}: ${name}` : `${key}` | ||
@@ -422,3 +436,3 @@ ); | ||
| * @param {DependencyTemplateContext} templateContext context | ||
| * @param {string[]} ids ids | ||
| * @param {Ids} ids ids | ||
| * @returns {string} generated code | ||
@@ -491,1 +505,2 @@ */ | ||
| module.exports = HarmonyImportSpecifierDependency; | ||
| module.exports.idsSymbol = idsSymbol; |
@@ -31,5 +31,5 @@ /* | ||
| /** @typedef {import("../javascript/JavascriptParser")} Parser */ | ||
| /** | ||
| * @typedef HarmonyModulesPluginOptions | ||
| * @property {boolean=} topLevelAwait | ||
| * @typedef {object} HarmonyModulesPluginOptions | ||
| * @property {boolean=} deferImport | ||
@@ -138,3 +138,3 @@ */ | ||
| new HarmonyDetectionParserPlugin(this.options).apply(parser); | ||
| new HarmonyDetectionParserPlugin().apply(parser); | ||
| new HarmonyImportDependencyParserPlugin(parserOptions).apply(parser); | ||
@@ -141,0 +141,0 @@ new HarmonyExportDependencyParserPlugin(parserOptions).apply(parser); |
@@ -14,3 +14,4 @@ /* | ||
| /** @typedef {import("../AsyncDependenciesBlock")} AsyncDependenciesBlock */ | ||
| /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ | ||
| /** @typedef {import("../Dependency").RawReferencedExports} RawReferencedExports */ | ||
| /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */ | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
@@ -30,3 +31,3 @@ /** @typedef {import("../Module")} Module */ | ||
| * @param {Range} range expression range | ||
| * @param {(string[][] | null)=} referencedExports list of referenced exports | ||
| * @param {RawReferencedExports | null=} referencedExports list of referenced exports | ||
| * @param {ImportAttributes=} attributes import attributes | ||
@@ -38,3 +39,3 @@ */ | ||
| this.referencedExports = referencedExports; | ||
| this.assertions = attributes; | ||
| this.attributes = attributes; | ||
| } | ||
@@ -51,6 +52,17 @@ | ||
| /** | ||
| * @returns {string | null} an identifier to merge equal requests | ||
| */ | ||
| getResourceIdentifier() { | ||
| let str = super.getResourceIdentifier(); | ||
| if (this.attributes !== undefined) { | ||
| str += JSON.stringify(this.attributes); | ||
| } | ||
| return str; | ||
| } | ||
| /** | ||
| * Returns list of exports referenced by this dependency | ||
| * @param {ModuleGraph} moduleGraph module graph | ||
| * @param {RuntimeSpec} runtime the runtime for which the module is analysed | ||
| * @returns {(string[] | ReferencedExport)[]} referenced exports | ||
| * @returns {ReferencedExports} referenced exports | ||
| */ | ||
@@ -94,3 +106,3 @@ getReferencedExports(moduleGraph, runtime) { | ||
| context.write(this.referencedExports); | ||
| context.write(this.assertions); | ||
| context.write(this.attributes); | ||
| super.serialize(context); | ||
@@ -105,3 +117,3 @@ } | ||
| this.referencedExports = context.read(); | ||
| this.assertions = context.read(); | ||
| this.attributes = context.read(); | ||
| super.deserialize(context); | ||
@@ -108,0 +120,0 @@ } |
@@ -13,9 +13,8 @@ /* | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
| /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../Module").BuildMeta} BuildMeta */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {ImportDependency.RawReferencedExports} RawReferencedExports */ | ||
@@ -26,3 +25,3 @@ class ImportEagerDependency extends ImportDependency { | ||
| * @param {Range} range expression range | ||
| * @param {(string[][] | null)=} referencedExports list of referenced exports | ||
| * @param {RawReferencedExports | null=} referencedExports list of referenced exports | ||
| * @param {ImportAttributes=} attributes import attributes | ||
@@ -29,0 +28,0 @@ */ |
@@ -18,11 +18,14 @@ /* | ||
| /** @typedef {import("estree").Identifier} Identifier */ | ||
| /** @typedef {import("estree").SourceLocation} SourceLocation */ | ||
| /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("../ContextModule").ContextModuleOptions} ContextModuleOptions */ | ||
| /** @typedef {import("../ContextModule").ContextMode} ContextMode */ | ||
| /** @typedef {import("../Chunk").ChunkName} ChunkName */ | ||
| /** @typedef {import("../ChunkGroup").RawChunkGroupOptions} RawChunkGroupOptions */ | ||
| /** @typedef {import("../Dependency").RawReferencedExports} RawReferencedExports */ | ||
| /** @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?: RawReferencedExports }} ImportMetaContextOptions */ | ||
| /** | ||
@@ -88,3 +91,3 @@ * @param {Property} prop property | ||
| let recursive = true; | ||
| /** @type {ContextModuleOptions["mode"]} */ | ||
| /** @type {ContextMode} */ | ||
| let mode = "sync"; | ||
@@ -97,5 +100,5 @@ /** @type {ContextModuleOptions["include"]} */ | ||
| const groupOptions = {}; | ||
| /** @type {ContextModuleOptions["chunkName"]} */ | ||
| /** @type {ChunkName | undefined} */ | ||
| let chunkName; | ||
| /** @type {ContextModuleOptions["referencedExports"]} */ | ||
| /** @type {RawReferencedExports | undefined} */ | ||
| let exports; | ||
@@ -102,0 +105,0 @@ if (optionsNode) { |
@@ -17,3 +17,2 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").ResolveOptions} ResolveOptions */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
@@ -20,0 +19,0 @@ /** @typedef {import("../javascript/JavascriptParser")} Parser */ |
@@ -33,2 +33,3 @@ /* | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Members} Members */ | ||
@@ -87,3 +88,3 @@ const getCriticalDependencyWarning = memoize(() => | ||
| /** | ||
| * @param {string[]} members members | ||
| * @param {Members} members members | ||
| * @returns {string} error message | ||
@@ -90,0 +91,0 @@ */ |
@@ -11,3 +11,7 @@ /* | ||
| const UnsupportedFeatureWarning = require("../UnsupportedFeatureWarning"); | ||
| const { getImportAttributes } = require("../javascript/JavascriptParser"); | ||
| const { | ||
| VariableInfo, | ||
| getImportAttributes | ||
| } = require("../javascript/JavascriptParser"); | ||
| const traverseDestructuringAssignmentProperties = require("../util/traverseDestructuringAssignmentProperties"); | ||
| const ContextDependencyHelpers = require("./ContextDependencyHelpers"); | ||
@@ -23,2 +27,3 @@ const ImportContextDependency = require("./ImportContextDependency"); | ||
| /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */ | ||
| /** @typedef {import("../Dependency").RawReferencedExports} RawReferencedExports */ | ||
| /** @typedef {import("../Module").BuildMeta} BuildMeta */ | ||
@@ -28,3 +33,136 @@ /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("../javascript/JavascriptParser").ParserState} ParserState */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Members} Members */ | ||
| /** @typedef {import("../javascript/JavascriptParser").MembersOptionals} MembersOptionals */ | ||
| /** @typedef {import("../javascript/JavascriptParser").ArrowFunctionExpression} ArrowFunctionExpression */ | ||
| /** @typedef {import("../javascript/JavascriptParser").FunctionExpression} FunctionExpression */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Identifier} Identifier */ | ||
| /** @typedef {import("../javascript/JavascriptParser").ObjectPattern} ObjectPattern */ | ||
| /** @typedef {import("../javascript/JavascriptParser").CallExpression} CallExpression */ | ||
| /** @typedef {{ references: RawReferencedExports, expression: ImportExpression }} ImportSettings */ | ||
| /** @typedef {WeakMap<ImportExpression, RawReferencedExports>} State */ | ||
| /** @type {WeakMap<ParserState, State>} */ | ||
| const parserStateMap = new WeakMap(); | ||
| const dynamicImportTag = Symbol("import()"); | ||
| /** | ||
| * @param {JavascriptParser} parser javascript parser | ||
| * @returns {State} import parser plugin state | ||
| */ | ||
| function getState(parser) { | ||
| if (!parserStateMap.has(parser.state)) { | ||
| parserStateMap.set(parser.state, new WeakMap()); | ||
| } | ||
| return /** @type {State} */ (parserStateMap.get(parser.state)); | ||
| } | ||
| /** | ||
| * @param {JavascriptParser} parser javascript parser | ||
| * @param {ImportExpression} importCall import expression | ||
| * @param {string} variableName variable name | ||
| */ | ||
| function tagDynamicImportReferenced(parser, importCall, variableName) { | ||
| const state = getState(parser); | ||
| /** @type {RawReferencedExports} */ | ||
| const references = state.get(importCall) || []; | ||
| state.set(importCall, references); | ||
| parser.tagVariable( | ||
| variableName, | ||
| dynamicImportTag, | ||
| /** @type {ImportSettings} */ ({ | ||
| references, | ||
| expression: importCall | ||
| }) | ||
| ); | ||
| } | ||
| /** | ||
| * @param {CallExpression} importThen import().then() call | ||
| * @returns {Identifier | ObjectPattern | undefined} the dynamic imported namespace obj | ||
| */ | ||
| function getFulfilledCallbackNamespaceObj(importThen) { | ||
| const fulfilledCallback = importThen.arguments[0]; | ||
| if ( | ||
| fulfilledCallback && | ||
| (fulfilledCallback.type === "ArrowFunctionExpression" || | ||
| fulfilledCallback.type === "FunctionExpression") && | ||
| fulfilledCallback.params[0] && | ||
| (fulfilledCallback.params[0].type === "Identifier" || | ||
| fulfilledCallback.params[0].type === "ObjectPattern") | ||
| ) { | ||
| return fulfilledCallback.params[0]; | ||
| } | ||
| } | ||
| /** | ||
| * @param {JavascriptParser} parser javascript parser | ||
| * @param {ImportExpression} importCall import expression | ||
| * @param {ArrowFunctionExpression | FunctionExpression} fulfilledCallback the fulfilled callback | ||
| * @param {Identifier | ObjectPattern} namespaceObjArg the argument of namespace object= | ||
| */ | ||
| function walkImportThenFulfilledCallback( | ||
| parser, | ||
| importCall, | ||
| fulfilledCallback, | ||
| namespaceObjArg | ||
| ) { | ||
| const arrow = fulfilledCallback.type === "ArrowFunctionExpression"; | ||
| const wasTopLevel = parser.scope.topLevelScope; | ||
| parser.scope.topLevelScope = arrow ? (wasTopLevel ? "arrow" : false) : false; | ||
| const scopeParams = [...fulfilledCallback.params]; | ||
| // Add function name in scope for recursive calls | ||
| if (!arrow && fulfilledCallback.id) { | ||
| scopeParams.push(fulfilledCallback.id); | ||
| } | ||
| parser.inFunctionScope(!arrow, scopeParams, () => { | ||
| if (namespaceObjArg.type === "Identifier") { | ||
| tagDynamicImportReferenced(parser, importCall, namespaceObjArg.name); | ||
| } else { | ||
| parser.enterDestructuringAssignment(namespaceObjArg, importCall); | ||
| const referencedPropertiesInDestructuring = | ||
| parser.destructuringAssignmentPropertiesFor(importCall); | ||
| if (referencedPropertiesInDestructuring) { | ||
| const state = getState(parser); | ||
| const references = /** @type {RawReferencedExports} */ ( | ||
| state.get(importCall) | ||
| ); | ||
| /** @type {RawReferencedExports} */ | ||
| const refsInDestructuring = []; | ||
| traverseDestructuringAssignmentProperties( | ||
| referencedPropertiesInDestructuring, | ||
| (stack) => refsInDestructuring.push(stack.map((p) => p.id)) | ||
| ); | ||
| for (const ids of refsInDestructuring) { | ||
| references.push(ids); | ||
| } | ||
| } | ||
| } | ||
| for (const param of fulfilledCallback.params) { | ||
| parser.walkPattern(param); | ||
| } | ||
| if (fulfilledCallback.body.type === "BlockStatement") { | ||
| parser.detectMode(fulfilledCallback.body.body); | ||
| const prev = parser.prevStatement; | ||
| parser.preWalkStatement(fulfilledCallback.body); | ||
| parser.prevStatement = prev; | ||
| parser.walkStatement(fulfilledCallback.body); | ||
| } else { | ||
| parser.walkExpression(fulfilledCallback.body); | ||
| } | ||
| }); | ||
| parser.scope.topLevelScope = wasTopLevel; | ||
| } | ||
| /** | ||
| * @template T | ||
| * @param {Iterable<T>} enumerable enumerable | ||
| * @returns {T[][]} array of array | ||
| */ | ||
| const exportsFromEnumerable = (enumerable) => | ||
| Array.from(enumerable, (e) => [e]); | ||
| const PLUGIN_NAME = "ImportParserPlugin"; | ||
@@ -46,8 +184,12 @@ | ||
| /** | ||
| * @template T | ||
| * @param {Iterable<T>} enumerable enumerable | ||
| * @returns {T[][]} array of array | ||
| * @param {Members} members members | ||
| * @param {MembersOptionals} membersOptionals members Optionals | ||
| * @returns {string[]} a non optional part | ||
| */ | ||
| const exportsFromEnumerable = (enumerable) => | ||
| Array.from(enumerable, (e) => [e]); | ||
| function getNonOptionalPart(members, membersOptionals) { | ||
| let i = 0; | ||
| while (i < members.length && membersOptionals[i] === false) i++; | ||
| return i !== members.length ? members.slice(0, i) : members; | ||
| } | ||
| parser.hooks.collectDestructuringAssignmentProperties.tap( | ||
@@ -57,5 +199,69 @@ PLUGIN_NAME, | ||
| if (expr.type === "ImportExpression") return true; | ||
| const nameInfo = parser.getNameForExpression(expr); | ||
| if ( | ||
| nameInfo && | ||
| nameInfo.rootInfo instanceof VariableInfo && | ||
| nameInfo.rootInfo.name && | ||
| parser.getTagData(nameInfo.rootInfo.name, dynamicImportTag) | ||
| ) { | ||
| return true; | ||
| } | ||
| } | ||
| ); | ||
| parser.hooks.importCall.tap(PLUGIN_NAME, (expr) => { | ||
| parser.hooks.preDeclarator.tap(PLUGIN_NAME, (decl) => { | ||
| if ( | ||
| decl.init && | ||
| decl.init.type === "AwaitExpression" && | ||
| decl.init.argument.type === "ImportExpression" && | ||
| decl.id.type === "Identifier" | ||
| ) { | ||
| parser.defineVariable(decl.id.name); | ||
| tagDynamicImportReferenced(parser, decl.init.argument, decl.id.name); | ||
| } | ||
| }); | ||
| parser.hooks.expression.for(dynamicImportTag).tap(PLUGIN_NAME, (expr) => { | ||
| const settings = /** @type {ImportSettings} */ (parser.currentTagData); | ||
| const referencedPropertiesInDestructuring = | ||
| parser.destructuringAssignmentPropertiesFor(expr); | ||
| if (referencedPropertiesInDestructuring) { | ||
| /** @type {RawReferencedExports} */ | ||
| const refsInDestructuring = []; | ||
| traverseDestructuringAssignmentProperties( | ||
| referencedPropertiesInDestructuring, | ||
| (stack) => refsInDestructuring.push(stack.map((p) => p.id)) | ||
| ); | ||
| for (const ids of refsInDestructuring) { | ||
| settings.references.push(ids); | ||
| } | ||
| } else { | ||
| settings.references.push([]); | ||
| } | ||
| return true; | ||
| }); | ||
| parser.hooks.expressionMemberChain | ||
| .for(dynamicImportTag) | ||
| .tap(PLUGIN_NAME, (_expression, members, membersOptionals) => { | ||
| const settings = /** @type {ImportSettings} */ (parser.currentTagData); | ||
| const ids = getNonOptionalPart(members, membersOptionals); | ||
| settings.references.push(ids); | ||
| return true; | ||
| }); | ||
| parser.hooks.callMemberChain | ||
| .for(dynamicImportTag) | ||
| .tap(PLUGIN_NAME, (expression, members, membersOptionals) => { | ||
| const { arguments: args } = expression; | ||
| const settings = /** @type {ImportSettings} */ (parser.currentTagData); | ||
| let ids = getNonOptionalPart(members, membersOptionals); | ||
| const directImport = members.length === 0; | ||
| if ( | ||
| !directImport && | ||
| (this.options.strictThisContextOnImports || ids.length > 1) | ||
| ) { | ||
| ids = ids.slice(0, -1); | ||
| } | ||
| settings.references.push(ids); | ||
| if (args) parser.walkExpressions(args); | ||
| return true; | ||
| }); | ||
| parser.hooks.importCall.tap(PLUGIN_NAME, (expr, importThen) => { | ||
| const param = parser.evaluateExpression(expr.source); | ||
@@ -67,3 +273,3 @@ | ||
| let exclude = null; | ||
| /** @type {string[][] | null} */ | ||
| /** @type {RawReferencedExports | null} */ | ||
| let exports = null; | ||
@@ -254,3 +460,3 @@ /** @type {RawChunkGroupOptions} */ | ||
| (Array.isArray(importOptions.webpackExports) && | ||
| /** @type {string[]} */ (importOptions.webpackExports).every( | ||
| importOptions.webpackExports.every( | ||
| (item) => typeof item === "string" | ||
@@ -291,7 +497,15 @@ )) | ||
| parser.destructuringAssignmentPropertiesFor(expr); | ||
| if (referencedPropertiesInDestructuring) { | ||
| const state = getState(parser); | ||
| const referencedPropertiesInMember = state.get(expr); | ||
| const fulfilledNamespaceObj = | ||
| importThen && getFulfilledCallbackNamespaceObj(importThen); | ||
| if ( | ||
| referencedPropertiesInDestructuring || | ||
| referencedPropertiesInMember || | ||
| fulfilledNamespaceObj | ||
| ) { | ||
| if (exports) { | ||
| parser.state.module.addWarning( | ||
| new UnsupportedFeatureWarning( | ||
| "`webpackExports` could not be used with destructuring assignment.", | ||
| "You don't need `webpackExports` if the usage of dynamic import is statically analyse-able. You can safely remove the `webpackExports` magic comment.", | ||
| /** @type {DependencyLocation} */ (expr.loc) | ||
@@ -302,5 +516,20 @@ ) | ||
| exports = exportsFromEnumerable( | ||
| [...referencedPropertiesInDestructuring].map(({ id }) => id) | ||
| ); | ||
| if (referencedPropertiesInDestructuring) { | ||
| /** @type {RawReferencedExports} */ | ||
| const refsInDestructuring = []; | ||
| traverseDestructuringAssignmentProperties( | ||
| referencedPropertiesInDestructuring, | ||
| (stack) => refsInDestructuring.push(stack.map((p) => p.id)) | ||
| ); | ||
| exports = refsInDestructuring; | ||
| } else if (referencedPropertiesInMember) { | ||
| exports = referencedPropertiesInMember; | ||
| } else { | ||
| /** @type {RawReferencedExports} */ | ||
| const references = []; | ||
| state.set(expr, references); | ||
| exports = references; | ||
| } | ||
| } | ||
@@ -347,35 +576,49 @@ | ||
| } | ||
| return true; | ||
| } else { | ||
| if (mode === "weak") { | ||
| mode = "async-weak"; | ||
| } | ||
| const dep = ContextDependencyHelpers.create( | ||
| ImportContextDependency, | ||
| /** @type {Range} */ (expr.range), | ||
| param, | ||
| expr, | ||
| this.options, | ||
| { | ||
| chunkName, | ||
| groupOptions, | ||
| include, | ||
| exclude, | ||
| mode, | ||
| namespaceObject: | ||
| /** @type {BuildMeta} */ | ||
| (parser.state.module.buildMeta).strictHarmonyModule | ||
| ? "strict" | ||
| : true, | ||
| typePrefix: "import()", | ||
| category: "esm", | ||
| referencedExports: exports, | ||
| attributes: getImportAttributes(expr) | ||
| }, | ||
| parser | ||
| ); | ||
| if (!dep) return; | ||
| dep.loc = /** @type {DependencyLocation} */ (expr.loc); | ||
| dep.optional = Boolean(parser.scope.inTry); | ||
| parser.state.current.addDependency(dep); | ||
| } | ||
| if (mode === "weak") { | ||
| mode = "async-weak"; | ||
| if (fulfilledNamespaceObj) { | ||
| walkImportThenFulfilledCallback( | ||
| parser, | ||
| expr, | ||
| /** @type {ArrowFunctionExpression | FunctionExpression} */ | ||
| (importThen.arguments[0]), | ||
| fulfilledNamespaceObj | ||
| ); | ||
| parser.walkExpressions(importThen.arguments.slice(1)); | ||
| } else if (importThen) { | ||
| parser.walkExpressions(importThen.arguments); | ||
| } | ||
| const dep = ContextDependencyHelpers.create( | ||
| ImportContextDependency, | ||
| /** @type {Range} */ (expr.range), | ||
| param, | ||
| expr, | ||
| this.options, | ||
| { | ||
| chunkName, | ||
| groupOptions, | ||
| include, | ||
| exclude, | ||
| mode, | ||
| namespaceObject: | ||
| /** @type {BuildMeta} */ | ||
| (parser.state.module.buildMeta).strictHarmonyModule | ||
| ? "strict" | ||
| : true, | ||
| typePrefix: "import()", | ||
| category: "esm", | ||
| referencedExports: exports, | ||
| attributes: getImportAttributes(expr) | ||
| }, | ||
| parser | ||
| ); | ||
| if (!dep) return; | ||
| dep.loc = /** @type {DependencyLocation} */ (expr.loc); | ||
| dep.optional = Boolean(parser.scope.inTry); | ||
| parser.state.current.addDependency(dep); | ||
| return true; | ||
@@ -382,0 +625,0 @@ }); |
@@ -13,9 +13,8 @@ /* | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
| /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../Module").BuildMeta} BuildMeta */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {ImportDependency.RawReferencedExports} RawReferencedExports */ | ||
@@ -26,3 +25,3 @@ class ImportWeakDependency extends ImportDependency { | ||
| * @param {Range} range expression range | ||
| * @param {(string[][] | null)=} referencedExports list of referenced exports | ||
| * @param {RawReferencedExports | null=} referencedExports list of referenced exports | ||
| * @param {ImportAttributes=} attributes import attributes | ||
@@ -29,0 +28,0 @@ */ |
@@ -11,3 +11,2 @@ /* | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../Dependency").ExportSpec} ExportSpec */ | ||
@@ -14,0 +13,0 @@ /** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */ |
@@ -12,5 +12,2 @@ /* | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */ | ||
| /** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */ | ||
| /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */ | ||
@@ -17,0 +14,0 @@ class LoaderDependency extends ModuleDependency { |
@@ -12,5 +12,2 @@ /* | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */ | ||
| /** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */ | ||
| /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */ | ||
@@ -17,0 +14,0 @@ class LoaderImportDependency extends ModuleDependency { |
@@ -13,9 +13,8 @@ /* | ||
| /** @typedef {import("../../declarations/LoaderContext").LoaderPluginLoaderContext} LoaderPluginLoaderContext */ | ||
| /** @typedef {import("../Compilation").DepConstructor} DepConstructor */ | ||
| /** @typedef {import("../Compilation").DependencyConstructor} DependencyConstructor */ | ||
| /** @typedef {import("../Compilation").ExecuteModuleExports} ExecuteModuleExports */ | ||
| /** @typedef {import("../Compilation").ExecuteModuleResult} ExecuteModuleResult */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../Module").BuildInfo} BuildInfo */ | ||
| /** @typedef {import("../Module").FileSystemDependencies} FileSystemDependencies */ | ||
@@ -26,2 +25,3 @@ /** | ||
| * @param {ExecuteModuleExports=} exports exports of the evaluated module | ||
| * @returns {void} | ||
| */ | ||
@@ -70,3 +70,4 @@ | ||
| const factory = compilation.dependencyFactories.get( | ||
| /** @type {DepConstructor} */ (dep.constructor) | ||
| /** @type {DependencyConstructor} */ | ||
| (dep.constructor) | ||
| ); | ||
@@ -131,5 +132,9 @@ if (factory === undefined) { | ||
| } | ||
| /** @type {FileSystemDependencies} */ | ||
| const fileDependencies = new LazySet(); | ||
| /** @type {FileSystemDependencies} */ | ||
| const contextDependencies = new LazySet(); | ||
| /** @type {FileSystemDependencies} */ | ||
| const missingDependencies = new LazySet(); | ||
| /** @type {FileSystemDependencies} */ | ||
| const buildDependencies = new LazySet(); | ||
@@ -172,3 +177,4 @@ referencedModule.addCacheDependencies( | ||
| const factory = compilation.dependencyFactories.get( | ||
| /** @type {DepConstructor} */ (dep.constructor) | ||
| /** @type {DependencyConstructor} */ | ||
| (dep.constructor) | ||
| ); | ||
@@ -175,0 +181,0 @@ if (factory === undefined) { |
@@ -15,7 +15,5 @@ /* | ||
| /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ | ||
| /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */ | ||
| /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */ | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| /** @typedef {import("../DependencyTemplates")} DependencyTemplates */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
@@ -61,3 +59,3 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
| * @param {RuntimeSpec} runtime the runtime for which the module is analysed | ||
| * @returns {(string[] | ReferencedExport)[]} referenced exports | ||
| * @returns {ReferencedExports} referenced exports | ||
| */ | ||
@@ -64,0 +62,0 @@ getReferencedExports(moduleGraph, runtime) { |
@@ -14,2 +14,3 @@ /* | ||
| /** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
@@ -26,7 +27,4 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| this.userRequest = request; | ||
| /** @type {Range | undefined} */ | ||
| this.range = undefined; | ||
| // TODO move it to subclasses and rename | ||
| // assertions must be serialized by subclasses that use it | ||
| /** @type {ImportAttributes | undefined} */ | ||
| this.assertions = undefined; | ||
| this._context = undefined; | ||
@@ -46,7 +44,3 @@ } | ||
| getResourceIdentifier() { | ||
| let str = `context${this._context || ""}|module${this.request}`; | ||
| if (this.assertions !== undefined) { | ||
| str += JSON.stringify(this.assertions); | ||
| } | ||
| return str; | ||
| return `context${this._context || ""}|module${this.request}`; | ||
| } | ||
@@ -53,0 +47,0 @@ |
@@ -15,2 +15,4 @@ /* | ||
| /** @typedef {string[]} RawRuntimeRequirements */ | ||
| class NullDependency extends Dependency { | ||
@@ -17,0 +19,0 @@ get type() { |
@@ -10,10 +10,9 @@ /* | ||
| /** @typedef {import("../Dependency").RawReferencedExports} RawReferencedExports */ | ||
| /** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */ | ||
| /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */ | ||
| /** @typedef {string[][]} ReferencedExports */ | ||
| /** | ||
| * @param {RuntimeSpec} runtime the runtime | ||
| * @param {ReferencedExports} referencedExports list of referenced exports, will be added to | ||
| * @param {RawReferencedExports} referencedExports list of referenced exports, will be added to | ||
| * @param {string[]} prefix export prefix | ||
@@ -20,0 +19,0 @@ * @param {ExportInfo=} exportInfo the export info |
@@ -14,10 +14,8 @@ /* | ||
| /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ | ||
| /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */ | ||
| /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */ | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| /** @typedef {import("../DependencyTemplates")} DependencyTemplates */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */ | ||
| /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ | ||
| /** @typedef {import("../ExportsInfo").ExportInfoName} ExportInfoName */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
@@ -30,3 +28,3 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
| /** | ||
| * @param {string[]|null} path the property path array | ||
| * @param {string[] | null} path the property path array | ||
| * @returns {string} the converted path | ||
@@ -43,3 +41,3 @@ */ | ||
| * @param {string} identifier identifier | ||
| * @param {string[]} ids ids | ||
| * @param {ExportInfoName[]} ids ids | ||
| * @param {Range} range range | ||
@@ -67,3 +65,3 @@ */ | ||
| * @param {RuntimeSpec} runtime the runtime for which the module is analysed | ||
| * @returns {(string[] | ReferencedExport)[]} referenced exports | ||
| * @returns {ReferencedExports} referenced exports | ||
| */ | ||
@@ -149,3 +147,3 @@ getReferencedExports(moduleGraph, runtime) { | ||
| runtimeRequirements | ||
| })}${pathToString(/** @type {string[]} */ (usedName))};\n`, | ||
| })}${pathToString(/** @type {string[] | null} */ (usedName))};\n`, | ||
| InitFragment.STAGE_PROVIDES, | ||
@@ -152,0 +150,0 @@ 1, |
@@ -14,3 +14,2 @@ /* | ||
| /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
@@ -17,0 +16,0 @@ /** @typedef {import("../Dependency").RuntimeSpec} RuntimeSpec */ |
@@ -12,3 +12,2 @@ /* | ||
| /** @typedef {import("../AsyncDependenciesBlock").GroupOptions} GroupOptions */ | ||
| /** @typedef {import("../ChunkGroup").ChunkGroupOptions} ChunkGroupOptions */ | ||
| /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */ | ||
@@ -15,0 +14,0 @@ |
@@ -14,3 +14,2 @@ /* | ||
| /** @typedef {import("../AsyncDependenciesBlock").GroupOptions} GroupOptions */ | ||
| /** @typedef {import("../ChunkGroup").ChunkGroupOptions} ChunkGroupOptions */ | ||
| /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */ | ||
@@ -90,3 +89,3 @@ /** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */ | ||
| const old = parser.state.current; | ||
| parser.state.current = /** @type {TODO} */ (depBlock); | ||
| parser.state.current = /** @type {EXPECTED_ANY} */ (depBlock); | ||
| try { | ||
@@ -93,0 +92,0 @@ let failed = false; |
@@ -14,3 +14,3 @@ /* | ||
| /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ | ||
| /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ | ||
| /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */ | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
@@ -36,3 +36,3 @@ /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| * @param {RuntimeSpec} runtime the runtime for which the module is analysed | ||
| * @returns {(string[] | ReferencedExport)[]} referenced exports | ||
| * @returns {ReferencedExports} referenced exports | ||
| */ | ||
@@ -39,0 +39,0 @@ getReferencedExports(moduleGraph, runtime) { |
@@ -13,3 +13,3 @@ /* | ||
| /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ | ||
| /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
@@ -44,3 +44,3 @@ /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| * @param {RuntimeSpec} runtime the runtime for which the module is analysed | ||
| * @returns {(string[] | ReferencedExport)[]} referenced exports | ||
| * @returns {ReferencedExports} referenced exports | ||
| */ | ||
@@ -47,0 +47,0 @@ getReferencedExports(moduleGraph, runtime) { |
@@ -12,7 +12,6 @@ /* | ||
| /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("./NullDependency").RawRuntimeRequirements} RawRuntimeRequirements */ | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
| /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */ | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
@@ -24,3 +23,3 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** | ||
| * @param {string[]} runtimeRequirements runtime requirements | ||
| * @param {RawRuntimeRequirements} runtimeRequirements runtime requirements | ||
| */ | ||
@@ -27,0 +26,0 @@ constructor(runtimeRequirements) { |
@@ -11,14 +11,12 @@ /* | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../Dependency").ExportSpec} ExportSpec */ | ||
| /** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */ | ||
| /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @typedef {import("../util/Hash")} Hash */ | ||
| /** @typedef {string[] | true} Exports */ | ||
| class StaticExportsDependency extends NullDependency { | ||
| /** | ||
| * @param {string[] | true} exports export names | ||
| * @param {Exports} exports export names | ||
| * @param {boolean} canMangle true, if mangling exports names is allowed | ||
@@ -25,0 +23,0 @@ */ |
@@ -18,16 +18,11 @@ /* | ||
| /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
| /** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */ | ||
| /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */ | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */ | ||
| /** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("../optimize/InnerGraph").UsedByExports} UsedByExports */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @typedef {import("../util/Hash")} Hash */ | ||
| /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */ | ||
@@ -50,3 +45,3 @@ const getIgnoredRawDataUrlModule = memoize( | ||
| this.relative = relative || false; | ||
| /** @type {Set<string> | boolean | undefined} */ | ||
| /** @type {UsedByExports | undefined} */ | ||
| this.usedByExports = undefined; | ||
@@ -53,0 +48,0 @@ } |
@@ -20,3 +20,2 @@ /* | ||
| /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */ | ||
| /** @typedef {import("../javascript/JavascriptParser")} Parser */ | ||
@@ -48,3 +47,3 @@ const PLUGIN_NAME = "URLPlugin"; | ||
| /** | ||
| * @param {Parser} parser parser parser | ||
| * @param {JavascriptParser} parser parser parser | ||
| * @param {JavascriptParserOptions} parserOptions parserOptions | ||
@@ -51,0 +50,0 @@ * @returns {void} |
@@ -12,3 +12,3 @@ /* | ||
| /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ | ||
| /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */ | ||
| /** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */ | ||
@@ -48,3 +48,3 @@ /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| * @param {RuntimeSpec} runtime the runtime for which the module is analysed | ||
| * @returns {(string[] | ReferencedExport)[]} referenced exports | ||
| * @returns {ReferencedExports} referenced exports | ||
| */ | ||
@@ -51,0 +51,0 @@ getReferencedExports(moduleGraph, runtime) { |
@@ -13,3 +13,3 @@ /* | ||
| /** @typedef {import("@webassemblyjs/ast").ModuleImportDescription} ModuleImportDescription */ | ||
| /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ | ||
| /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
@@ -50,3 +50,3 @@ /** @typedef {import("../WebpackError")} WebpackError */ | ||
| * @param {RuntimeSpec} runtime the runtime for which the module is analysed | ||
| * @returns {(string[] | ReferencedExport)[]} referenced exports | ||
| * @returns {ReferencedExports} referenced exports | ||
| */ | ||
@@ -53,0 +53,0 @@ getReferencedExports(moduleGraph, runtime) { |
@@ -14,4 +14,3 @@ /* | ||
| /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
| /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ | ||
| /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */ | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
@@ -38,3 +37,3 @@ /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| * @param {RuntimeSpec} runtime the runtime for which the module is analysed | ||
| * @returns {(string[] | ReferencedExport)[]} referenced exports | ||
| * @returns {ReferencedExports} referenced exports | ||
| */ | ||
@@ -41,0 +40,0 @@ getReferencedExports(moduleGraph, runtime) { |
@@ -15,4 +15,3 @@ /* | ||
| /** @typedef {import("../AsyncDependenciesBlock")} AsyncDependenciesBlock */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */ | ||
| /** @typedef {import("../Dependency").ReferencedExports} ReferencedExports */ | ||
| /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */ | ||
@@ -49,3 +48,3 @@ /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| * @param {RuntimeSpec} runtime the runtime for which the module is analysed | ||
| * @returns {(string[] | ReferencedExport)[]} referenced exports | ||
| * @returns {ReferencedExports} referenced exports | ||
| */ | ||
@@ -52,0 +51,0 @@ getReferencedExports(moduleGraph, runtime) { |
@@ -30,3 +30,2 @@ /* | ||
| /** @typedef {import("estree").Expression} Expression */ | ||
| /** @typedef {import("estree").Identifier} Identifier */ | ||
| /** @typedef {import("estree").MemberExpression} MemberExpression */ | ||
@@ -38,3 +37,2 @@ /** @typedef {import("estree").ObjectExpression} ObjectExpression */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").ChunkLoading} ChunkLoading */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */ | ||
@@ -49,3 +47,2 @@ /** @typedef {import("../../declarations/WebpackOptions").OutputModule} OutputModule */ | ||
| /** @typedef {import("../Parser").ParserState} ParserState */ | ||
| /** @typedef {import("../javascript/BasicEvaluatedExpression")} BasicEvaluatedExpression */ | ||
| /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */ | ||
@@ -297,4 +294,4 @@ /** @typedef {import("../javascript/JavascriptParser")} Parser */ | ||
| : { | ||
| /** @type {Record<string, Expression | Pattern>} */ | ||
| expressions: {}, | ||
| expressions: | ||
| /** @type {Record<string, Expression | Pattern>} */ ({}), | ||
| otherElements: [], | ||
@@ -386,6 +383,3 @@ /** @type {Values} */ | ||
| )}|${i}`; | ||
| const hash = createHash( | ||
| /** @type {HashFunction} */ | ||
| (compilation.outputOptions.hashFunction) | ||
| ); | ||
| const hash = createHash(compilation.outputOptions.hashFunction); | ||
| hash.update(name); | ||
@@ -392,0 +386,0 @@ const digest = |
@@ -11,4 +11,2 @@ /* | ||
| /** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */ | ||
| /** @typedef {import("./ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("./ChunkGroup")} ChunkGroup */ | ||
| /** @typedef {import("./Dependency")} Dependency */ | ||
@@ -15,0 +13,0 @@ /** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */ |
+9
-11
@@ -10,6 +10,4 @@ /* | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("./ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("./DependenciesBlock")} DependenciesBlock */ | ||
| /** @typedef {import("./DependencyTemplates")} DependencyTemplates */ | ||
| /** @typedef {import("./Module")} Module */ | ||
@@ -66,6 +64,8 @@ /** @typedef {import("./ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {Set<string>} ExportsSpecExcludeExports */ | ||
| /** | ||
| * @typedef {object} ExportsSpec | ||
| * @property {(string | ExportSpec)[] | true | null} exports exported names, true for unknown exports or null for no exports | ||
| * @property {Set<string>=} excludeExports when exports = true, list of unaffected exports | ||
| * @property {ExportsSpecExcludeExports=} excludeExports when exports = true, list of unaffected exports | ||
| * @property {(Set<string> | null)=} hideExports list of maybe prior exposed, but now hidden exports | ||
@@ -85,2 +85,5 @@ * @property {ModuleGraphConnection=} from when reexported: from which module | ||
| /** @typedef {string[][]} RawReferencedExports */ | ||
| /** @typedef {(string[] | ReferencedExport)[]} ReferencedExports */ | ||
| /** @typedef {(moduleGraphConnection: ModuleGraphConnection, runtime: RuntimeSpec) => ConnectionState} GetConditionFn */ | ||
@@ -111,5 +114,2 @@ | ||
| /** @type {boolean | undefined} */ | ||
| this.defer = false; | ||
| // TODO check if this can be moved into ModuleDependency | ||
| /** @type {boolean | undefined} */ | ||
| this.optional = false; | ||
@@ -237,3 +237,3 @@ this._locSL = 0; | ||
| * @param {RuntimeSpec} runtime the runtime for which the module is analysed | ||
| * @returns {(string[] | ReferencedExport)[]} referenced exports | ||
| * @returns {ReferencedExports} referenced exports | ||
| */ | ||
@@ -323,3 +323,2 @@ getReferencedExports(moduleGraph, runtime) { | ||
| write(this._locN); | ||
| write(this.defer); | ||
| } | ||
@@ -339,9 +338,8 @@ | ||
| this._locN = read(); | ||
| this.defer = read(); | ||
| } | ||
| } | ||
| /** @type {string[][]} */ | ||
| /** @type {RawReferencedExports} */ | ||
| Dependency.NO_EXPORTS_REFERENCED = []; | ||
| /** @type {string[][]} */ | ||
| /** @type {RawReferencedExports} */ | ||
| Dependency.EXPORTS_OBJECT_REFERENCED = [[]]; | ||
@@ -348,0 +346,0 @@ |
@@ -11,8 +11,6 @@ /* | ||
| /** @typedef {import("./Dependency")} Dependency */ | ||
| /** @typedef {import("./Compilation").DependencyConstructor} DependencyConstructor */ | ||
| /** @typedef {import("./DependencyTemplate")} DependencyTemplate */ | ||
| /** @typedef {typeof import("./util/Hash")} Hash */ | ||
| /** @typedef {new (...args: EXPECTED_ANY[]) => Dependency} DependencyConstructor */ | ||
| class DependencyTemplates { | ||
@@ -19,0 +17,0 @@ /** |
+1
-7
@@ -15,9 +15,6 @@ /* | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */ | ||
| /** @typedef {import("./ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */ | ||
| /** @typedef {import("./Compilation")} Compilation */ | ||
| /** @typedef {import("./Dependency")} Dependency */ | ||
| /** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */ | ||
| /** @typedef {import("./DependencyTemplates")} DependencyTemplates */ | ||
| /** @typedef {import("./Generator").SourceTypes} SourceTypes */ | ||
@@ -29,7 +26,4 @@ /** @typedef {import("./Module").BuildCallback} BuildCallback */ | ||
| /** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */ | ||
| /** @typedef {import("./Module").SourceContext} SourceContext */ | ||
| /** @typedef {import("./RequestShortener")} RequestShortener */ | ||
| /** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */ | ||
| /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */ | ||
| /** @typedef {import("./WebpackError")} WebpackError */ | ||
| /** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
@@ -36,0 +30,0 @@ /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ |
@@ -87,3 +87,3 @@ /* | ||
| const manifestPath = makePathsRelative( | ||
| /** @type {string} */ (compiler.options.context), | ||
| compiler.context, | ||
| manifest, | ||
@@ -146,5 +146,3 @@ compiler.root | ||
| scope: this.options.scope, | ||
| context: | ||
| /** @type {string} */ | ||
| (this.options.context || compiler.options.context), | ||
| context: this.options.context || compiler.context, | ||
| content: | ||
@@ -151,0 +149,0 @@ /** @type {DllReferencePluginOptionsContent} */ |
@@ -14,4 +14,2 @@ /* | ||
| /** @typedef {import("../declarations/WebpackOptions").EntryDynamicNormalized} EntryDynamic */ | ||
| /** @typedef {import("../declarations/WebpackOptions").EntryItem} EntryItem */ | ||
| /** @typedef {import("../declarations/WebpackOptions").EntryStaticNormalized} EntryStatic */ | ||
| /** @typedef {import("./Compiler")} Compiler */ | ||
@@ -18,0 +16,0 @@ |
@@ -79,7 +79,2 @@ /* | ||
| }; | ||
| if (desc.layer !== undefined && !compiler.options.experiments.layers) { | ||
| throw new Error( | ||
| "'entryOptions.layer' is only allowed when 'experiments.layers' is enabled" | ||
| ); | ||
| } | ||
| if (desc.chunkLoading) { | ||
@@ -86,0 +81,0 @@ const EnableChunkLoadingPlugin = require("./javascript/EnableChunkLoadingPlugin"); |
@@ -12,6 +12,3 @@ /* | ||
| /** @typedef {import("./Module")} Module */ | ||
| /** @typedef {import("./Compilation")} Compilation */ | ||
| /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */ | ||
| /** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
| /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @typedef {"asyncWebAssembly" | "topLevelAwait" | "external promise" | "external script" | "external import" | "external module"} Feature */ | ||
@@ -18,0 +15,0 @@ |
@@ -26,8 +26,5 @@ /* | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../ChunkGroup")} ChunkGroup */ | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Entrypoint")} Entrypoint */ | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../javascript/JavascriptModulesPlugin").RenderContext} RenderContext */ | ||
@@ -34,0 +31,0 @@ /** |
@@ -14,2 +14,3 @@ /* | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */ | ||
@@ -42,3 +43,3 @@ const PLUGIN_NAME = "ModuleChunkLoadingPlugin"; | ||
| * @param {Chunk} chunk chunk to check | ||
| * @param {Set<string>} set runtime requirements | ||
| * @param {RuntimeRequirements} set runtime requirements | ||
| */ | ||
@@ -45,0 +46,0 @@ const handler = (chunk, set) => { |
@@ -23,3 +23,2 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").Environment} Environment */ | ||
| /** @typedef {import("../Chunk")} Chunk */ | ||
@@ -95,5 +94,3 @@ /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| const chunk = /** @type {Chunk} */ (this.chunk); | ||
| const environment = | ||
| /** @type {Environment} */ | ||
| (compilation.outputOptions.environment); | ||
| const environment = compilation.outputOptions.environment; | ||
| const { | ||
@@ -144,3 +141,3 @@ runtimeTemplate, | ||
| outputName, | ||
| /** @type {string} */ (compilation.outputOptions.path), | ||
| compilation.outputOptions.path, | ||
| true | ||
@@ -401,4 +398,4 @@ ); | ||
| ] | ||
| )} | ||
| loadScript(url, onResolve, onReject);` | ||
| )}`, | ||
| "loadScript(url, onResolve, onReject);" | ||
| ] | ||
@@ -421,2 +418,5 @@ )});` | ||
| "return obj.default;" | ||
| ])}, ${runtimeTemplate.basicFunction("error", [ | ||
| "if(['MODULE_NOT_FOUND', 'ENOENT'].includes(error.code)) return;", | ||
| "throw error;" | ||
| ])});` | ||
@@ -423,0 +423,0 @@ ])};` |
@@ -15,3 +15,4 @@ /* | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("../declarations/WebpackOptions").OutputNormalized} OutputOptions */ | ||
| /** @typedef {import("../declarations/WebpackOptions").DevtoolNamespace} DevtoolNamespace */ | ||
| /** @typedef {import("../declarations/WebpackOptions").DevtoolModuleFilenameTemplate} DevtoolModuleFilenameTemplate */ | ||
| /** @typedef {import("./Compiler")} Compiler */ | ||
@@ -34,5 +35,5 @@ | ||
| * @typedef {object} EvalDevToolModulePluginOptions | ||
| * @property {OutputOptions["devtoolNamespace"]=} namespace namespace | ||
| * @property {DevtoolNamespace=} namespace namespace | ||
| * @property {string=} sourceUrlComment source url comment | ||
| * @property {OutputOptions["devtoolModuleFilenameTemplate"]=} moduleFilenameTemplate module filename template | ||
| * @property {DevtoolModuleFilenameTemplate=} moduleFilenameTemplate module filename template | ||
| */ | ||
@@ -39,0 +40,0 @@ |
@@ -20,3 +20,2 @@ /* | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("../declarations/WebpackOptions").DevTool} DevToolOptions */ | ||
| /** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */ | ||
@@ -43,5 +42,5 @@ /** @typedef {import("./ChunkGraph").ModuleId} ModuleId */ | ||
| /** | ||
| * @param {SourceMapDevToolPluginOptions | string} inputOptions Options object | ||
| * @param {SourceMapDevToolPluginOptions | string=} inputOptions Options object | ||
| */ | ||
| constructor(inputOptions) { | ||
| constructor(inputOptions = {}) { | ||
| /** @type {SourceMapDevToolPluginOptions} */ | ||
@@ -139,3 +138,3 @@ let options; | ||
| sourceMap = { ...sourceMap }; | ||
| const context = /** @type {string} */ (compiler.options.context); | ||
| const context = compiler.context; | ||
| const root = compiler.root; | ||
@@ -142,0 +141,0 @@ const modules = sourceMap.sources.map((source) => { |
+50
-49
@@ -15,2 +15,4 @@ /* | ||
| /** @typedef {import("./Dependency").RuntimeSpec} RuntimeSpec */ | ||
| /** @typedef {import("./Dependency").ExportsSpecExcludeExports} ExportsSpecExcludeExports */ | ||
| /** @typedef {import("./dependencies/HarmonyImportDependency")} HarmonyImportDependency */ | ||
| /** @typedef {import("./Module")} Module */ | ||
@@ -26,2 +28,28 @@ /** @typedef {import("./ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {string} ExportInfoName */ | ||
| /** @typedef {Map<string, RuntimeUsageStateType>} UsedInRuntime */ | ||
| /** @typedef {{ module: Module, export: ExportInfoName[], deferred: boolean }} TargetItemWithoutConnection */ | ||
| /** @typedef {{ module: Module, connection: ModuleGraphConnection, export: ExportInfoName[] | undefined }} TargetItemWithConnection */ | ||
| /** @typedef {(target: TargetItemWithConnection) => boolean} ResolveTargetFilter */ | ||
| /** @typedef {(module: Module) => boolean} ValidTargetModuleFilter */ | ||
| /** @typedef {{ connection: ModuleGraphConnection, export: ExportInfoName[], priority: number }} TargetItem */ | ||
| /** @typedef {Map<Dependency | undefined, TargetItem>} Target */ | ||
| /** @typedef {string | null} ExportInfoUsedName */ | ||
| /** @typedef {boolean | null} ExportInfoProvided */ | ||
| /** @typedef {Map<ExportInfoName, ExportInfo>} Exports */ | ||
| /** @typedef {string | string[] | false} UsedName */ | ||
| /** @typedef {Set<ExportInfo>} AlreadyVisitedExportInfo */ | ||
| /** | ||
| * @typedef {object} RestoreProvidedDataExports | ||
| * @property {ExportInfoName} name | ||
| * @property {ExportInfo["provided"]} provided | ||
| * @property {ExportInfo["canMangleProvide"]} canMangleProvide | ||
| * @property {ExportInfo["terminalBinding"]} terminalBinding | ||
| * @property {RestoreProvidedData | undefined} exportsInfo | ||
| */ | ||
| const UsageState = Object.freeze({ | ||
@@ -39,11 +67,2 @@ Unused: /** @type {0} */ (0), | ||
| /** | ||
| * @typedef {object} RestoreProvidedDataExports | ||
| * @property {ExportInfoName} name | ||
| * @property {ExportInfo["provided"]} provided | ||
| * @property {ExportInfo["canMangleProvide"]} canMangleProvide | ||
| * @property {ExportInfo["terminalBinding"]} terminalBinding | ||
| * @property {RestoreProvidedData | undefined} exportsInfo | ||
| */ | ||
| class RestoreProvidedData { | ||
@@ -93,5 +112,2 @@ /** | ||
| /** @typedef {Map<ExportInfoName, ExportInfo>} Exports */ | ||
| /** @typedef {string | string[] | false} UsedName */ | ||
| class ExportsInfo { | ||
@@ -101,3 +117,3 @@ constructor() { | ||
| this._exports = new Map(); | ||
| this._otherExportsInfo = new ExportInfo(/** @type {TODO} */ (null)); | ||
| this._otherExportsInfo = new ExportInfo(null); | ||
| this._sideEffectsOnlyInfo = new ExportInfo("*side effects only*"); | ||
@@ -179,3 +195,3 @@ this._exportsAreOrdered = false; | ||
| if (exports.size > 1) { | ||
| /** @type {string[]} */ | ||
| /** @type {ExportInfoName[]} */ | ||
| const namesInOrder = []; | ||
@@ -317,3 +333,3 @@ for (const entry of exports.values()) { | ||
| * @param {boolean=} canMangle true, if exports can still be mangled (defaults to false) | ||
| * @param {Set<string>=} excludeExports list of unaffected exports | ||
| * @param {ExportsSpecExcludeExports=} excludeExports list of unaffected exports | ||
| * @param {Dependency=} targetKey use this as key for the target | ||
@@ -515,3 +531,3 @@ * @param {ModuleGraphConnection=} targetModule set this module as target | ||
| * @param {RuntimeSpec} runtime the runtime | ||
| * @returns {SortableSet<string> | boolean | null} set of used exports, or true (when namespace object is used), or false (when unused), or null (when unknown) | ||
| * @returns {SortableSet<ExportInfoName> | boolean | null} set of used exports, or true (when namespace object is used), or false (when unused), or null (when unknown) | ||
| */ | ||
@@ -528,2 +544,3 @@ getUsedExports(runtime) { | ||
| /** @type {ExportInfoName[]} */ | ||
| const array = []; | ||
@@ -560,7 +577,7 @@ if (!this._exportsAreOrdered) this._sortExports(); | ||
| } | ||
| return /** @type {SortableSet<string>} */ (new SortableSet(array)); | ||
| return /** @type {SortableSet<ExportInfoName>} */ (new SortableSet(array)); | ||
| } | ||
| /** | ||
| * @returns {null | true | string[]} list of exports when known | ||
| * @returns {null | true | ExportInfoName[]} list of exports when known | ||
| */ | ||
@@ -577,3 +594,3 @@ getProvidedExports() { | ||
| /** @type {string[]} */ | ||
| /** @type {ExportInfoName[]} */ | ||
| const array = []; | ||
@@ -845,23 +862,5 @@ if (!this._exportsAreOrdered) this._sortExports(); | ||
| /** @typedef {Map<string, RuntimeUsageStateType>} UsedInRuntime */ | ||
| /** @typedef {{ module: Module, export: string[], deferred: boolean }} TargetItemWithoutConnection */ | ||
| /** @typedef {{ module: Module, connection: ModuleGraphConnection, export: string[] | undefined }} TargetItemWithConnection */ | ||
| /** @typedef {(target: TargetItemWithConnection) => boolean} ResolveTargetFilter */ | ||
| /** @typedef {(module: Module) => boolean} ValidTargetModuleFilter */ | ||
| /** @typedef {{ connection: ModuleGraphConnection, export: string[], priority: number }} TargetItem */ | ||
| /** @typedef {Map<Dependency | undefined, TargetItem>} Target */ | ||
| /** @typedef {string} ExportInfoName */ | ||
| /** @typedef {string | null} ExportInfoUsedName */ | ||
| /** @typedef {boolean | null} ExportInfoProvided */ | ||
| class ExportInfo { | ||
| /** | ||
| * @param {ExportInfoName} name the original name of the export | ||
| * @param {ExportInfoName | null} name the original name of the export | ||
| * @param {ExportInfo=} initFrom init values from this ExportInfo | ||
@@ -871,3 +870,3 @@ */ | ||
| /** @type {ExportInfoName} */ | ||
| this.name = name; | ||
| this.name = /** @type {ExportInfoName} */ (name); | ||
| /** | ||
@@ -1074,4 +1073,4 @@ * @private | ||
| let changed = false; | ||
| forEachRuntime(runtime, (_runtime) => { | ||
| const runtime = /** @type {string} */ (_runtime); | ||
| forEachRuntime(runtime, (runtime_) => { | ||
| const runtime = /** @type {string} */ (runtime_); | ||
| const usedInRuntime = | ||
@@ -1165,3 +1164,3 @@ /** @type {UsedInRuntime} */ | ||
| * @param {ModuleGraphConnection} connection the target module if a single one | ||
| * @param {(string[] | null)=} exportName the exported name | ||
| * @param {ExportInfoName[] | null=} exportName the exported name | ||
| * @param {number=} priority priority | ||
@@ -1176,3 +1175,3 @@ * @returns {boolean} true, if something has changed | ||
| connection, | ||
| export: /** @type {string[]} */ (exportName), | ||
| export: /** @type {ExportInfoName[]} */ (exportName), | ||
| priority | ||
@@ -1187,3 +1186,3 @@ }); | ||
| connection, | ||
| export: /** @type {string[]} */ (exportName), | ||
| export: /** @type {ExportInfoName[]} */ (exportName), | ||
| priority | ||
@@ -1202,3 +1201,3 @@ }); | ||
| oldTarget.connection = connection; | ||
| oldTarget.export = /** @type {string[]} */ (exportName); | ||
| oldTarget.export = /** @type {ExportInfoName[]} */ (exportName); | ||
| oldTarget.priority = priority; | ||
@@ -1352,3 +1351,3 @@ this._maxTarget = undefined; | ||
| * @param {ValidTargetModuleFilter} validTargetModuleFilter a valid target module | ||
| * @param {Set<ExportInfo>} alreadyVisited set of already visited export info to avoid circular references | ||
| * @param {AlreadyVisitedExportInfo} alreadyVisited set of already visited export info to avoid circular references | ||
| * @returns {TargetItemWithoutConnection | null | undefined | false} the target, undefined when there is no target, false when no target is valid | ||
@@ -1367,3 +1366,5 @@ */ | ||
| deferred: Boolean( | ||
| rawTarget.connection.dependency && rawTarget.connection.dependency.defer | ||
| rawTarget.connection.dependency && | ||
| /** @type {HarmonyImportDependency} */ | ||
| (rawTarget.connection.dependency).defer | ||
| ) | ||
@@ -1410,3 +1411,3 @@ }; | ||
| * @param {ResolveTargetFilter} resolveTargetFilter filter function to further resolve target | ||
| * @param {Set<ExportInfo> | undefined} alreadyVisited set of already visited export info to avoid circular references | ||
| * @param {AlreadyVisitedExportInfo | undefined} alreadyVisited set of already visited export info to avoid circular references | ||
| * @returns {TargetItemWithConnection | CIRCULAR | undefined} the target | ||
@@ -1417,3 +1418,3 @@ */ | ||
| * @param {TargetItem | undefined | null} inputTarget unresolved target | ||
| * @param {Set<ExportInfo>} alreadyVisited set of already visited export info to avoid circular references | ||
| * @param {AlreadyVisitedExportInfo} alreadyVisited set of already visited export info to avoid circular references | ||
| * @returns {TargetItemWithConnection | CIRCULAR | null} resolved target | ||
@@ -1420,0 +1421,0 @@ */ |
+84
-52
@@ -32,3 +32,3 @@ /* | ||
| /** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */ | ||
| /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */ | ||
| /** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */ | ||
| /** @typedef {import("./Chunk")} Chunk */ | ||
@@ -39,6 +39,6 @@ /** @typedef {import("./ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */ | ||
| /** @typedef {import("./DependencyTemplates")} DependencyTemplates */ | ||
| /** @typedef {import("./ExportsInfo")} ExportsInfo */ | ||
| /** @typedef {import("./Generator").GenerateContext} GenerateContext */ | ||
| /** @typedef {import("./Generator").SourceTypes} SourceTypes */ | ||
| /** @typedef {import("./Module").ModuleId} ModuleId */ | ||
| /** @typedef {import("./Module").BuildCallback} BuildCallback */ | ||
@@ -50,2 +50,3 @@ /** @typedef {import("./Module").BuildInfo} BuildInfo */ | ||
| /** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */ | ||
| /** @typedef {import("./Module").LibIdent} LibIdent */ | ||
| /** @typedef {import("./Module").NeedBuildCallback} NeedBuildCallback */ | ||
@@ -59,3 +60,2 @@ /** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */ | ||
| /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */ | ||
| /** @typedef {import("./WebpackError")} WebpackError */ | ||
| /** @typedef {import("./javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */ | ||
@@ -95,3 +95,3 @@ /** @typedef {import("./javascript/JavascriptParser").ImportAttributes} ImportAttributes */ | ||
| /** | ||
| * @param {string|string[]} variableName the variable name or path | ||
| * @param {string | string[]} variableName the variable name or path | ||
| * @param {string} type the module system | ||
@@ -116,4 +116,6 @@ * @returns {SourceData} the generated source | ||
| /** @typedef {string | string[]} ModuleAndSpecifiers */ | ||
| /** | ||
| * @param {string|string[]} moduleAndSpecifiers the module request | ||
| * @param {ModuleAndSpecifiers} moduleAndSpecifiers the module request | ||
| * @returns {SourceData} the generated source | ||
@@ -137,4 +139,21 @@ */ | ||
| /** | ||
| * @param {string | string[]} moduleAndSpecifiers the module request | ||
| * @param {RuntimeTemplate} runtimeTemplate the runtime template | ||
| * @returns {InitFragment<ChunkRenderContext>} code | ||
| */ | ||
| const getExternalModuleNodeCommonjsInitFragment = (runtimeTemplate) => { | ||
| const importMetaName = runtimeTemplate.outputOptions.importMetaName; | ||
| return new InitFragment( | ||
| `import { createRequire as __WEBPACK_EXTERNAL_createRequire } from ${runtimeTemplate.renderNodePrefixForCoreModule( | ||
| "module" | ||
| )};\n${runtimeTemplate.renderConst()} __WEBPACK_EXTERNAL_createRequire_require = __WEBPACK_EXTERNAL_createRequire(${importMetaName}.url);\n`, | ||
| InitFragment.STAGE_HARMONY_IMPORTS, | ||
| 0, | ||
| "external module node-commonjs" | ||
| ); | ||
| }; | ||
| /** | ||
| * @param {ModuleAndSpecifiers} moduleAndSpecifiers the module request | ||
| * @param {RuntimeTemplate} runtimeTemplate the runtime template | ||
| * @returns {SourceData} the generated source | ||
@@ -146,16 +165,4 @@ */ | ||
| ) => { | ||
| const importMetaName = | ||
| /** @type {string} */ | ||
| (runtimeTemplate.outputOptions.importMetaName); | ||
| // /** @type {boolean} */ | ||
| // (runtimeTemplate.supportNodePrefixForCoreModules()) | ||
| const chunkInitFragments = [ | ||
| new InitFragment( | ||
| `import { createRequire as __WEBPACK_EXTERNAL_createRequire } from ${runtimeTemplate.renderNodePrefixForCoreModule("module")};\n`, | ||
| InitFragment.STAGE_HARMONY_IMPORTS, | ||
| 0, | ||
| "external module node-commonjs" | ||
| ) | ||
| getExternalModuleNodeCommonjsInitFragment(runtimeTemplate) | ||
| ]; | ||
@@ -165,3 +172,3 @@ if (!Array.isArray(moduleAndSpecifiers)) { | ||
| chunkInitFragments, | ||
| expression: `__WEBPACK_EXTERNAL_createRequire(${importMetaName}.url)(${JSON.stringify( | ||
| expression: `__WEBPACK_EXTERNAL_createRequire_require(${JSON.stringify( | ||
| moduleAndSpecifiers | ||
@@ -174,3 +181,3 @@ )})` | ||
| chunkInitFragments, | ||
| expression: `__WEBPACK_EXTERNAL_createRequire(${importMetaName}.url)(${JSON.stringify( | ||
| expression: `__WEBPACK_EXTERNAL_createRequire_require(${JSON.stringify( | ||
| moduleName | ||
@@ -182,3 +189,3 @@ )})${propertyAccess(moduleAndSpecifiers, 1)}` | ||
| /** | ||
| * @param {string|string[]} moduleAndSpecifiers the module request | ||
| * @param {ModuleAndSpecifiers} moduleAndSpecifiers the module request | ||
| * @param {RuntimeTemplate} runtimeTemplate the runtime template | ||
@@ -277,3 +284,2 @@ * @param {ImportDependencyMeta=} dependencyMeta the dependency meta | ||
| const identifier = `__WEBPACK_EXTERNAL_MODULE_${ident}__`; | ||
| super( | ||
@@ -288,4 +294,4 @@ "", | ||
| this._dependencyMeta = dependencyMeta; | ||
| this._imported = imported; | ||
| this._identifier = identifier; | ||
| this._identifier = this.buildIdentifier(ident); | ||
| this._imported = this.buildImported(imported); | ||
| } | ||
@@ -353,2 +359,24 @@ | ||
| } | ||
| /** | ||
| * @param {string} ident ident | ||
| * @returns {string} identifier | ||
| */ | ||
| buildIdentifier(ident) { | ||
| return `__WEBPACK_EXTERNAL_MODULE_${ident}__`; | ||
| } | ||
| /** | ||
| * @param {Imported} imported imported | ||
| * @returns {Imported} normalized imported | ||
| */ | ||
| buildImported(imported) { | ||
| if (Array.isArray(imported)) { | ||
| return imported.map(([name]) => { | ||
| const ident = `${this._ident}_${name}`; | ||
| return [name, this.buildIdentifier(ident)]; | ||
| }); | ||
| } | ||
| return imported; | ||
| } | ||
| } | ||
@@ -415,3 +443,3 @@ | ||
| /** | ||
| * @param {string|string[]} moduleAndSpecifiers the module request | ||
| * @param {ModuleAndSpecifiers} moduleAndSpecifiers the module request | ||
| * @param {ExportsInfo} exportsInfo exports info of this module | ||
@@ -451,17 +479,3 @@ * @param {RuntimeSpec} runtime the runtime | ||
| default: | ||
| imported = []; | ||
| if (exportsInfo.isUsed(runtime) === false) { | ||
| // no used, only | ||
| } | ||
| for (const [name] of usedExports.entries()) { | ||
| let counter = 0; | ||
| let finalName = name; | ||
| if (concatenationScope) { | ||
| while (!concatenationScope.registerUsedName(finalName)) { | ||
| finalName = `${name}_${counter++}`; | ||
| } | ||
| } | ||
| imported.push([name, finalName]); | ||
| } | ||
| imported = [...usedExports.entries()]; | ||
| } | ||
@@ -477,3 +491,20 @@ } | ||
| ); | ||
| const specifiers = imported === true ? undefined : imported; | ||
| const normalizedImported = initFragment.getImported(); | ||
| const specifiers = | ||
| normalizedImported === true | ||
| ? undefined | ||
| : /** @type {[string, string][]} */ ( | ||
| normalizedImported.map(([name, rawFinalName]) => { | ||
| let finalName = rawFinalName; | ||
| let counter = 0; | ||
| if (concatenationScope) { | ||
| while (!concatenationScope.registerUsedName(finalName)) { | ||
| finalName = `${finalName}_${counter++}`; | ||
| } | ||
| } | ||
| return [name, finalName]; | ||
| }) | ||
| ); | ||
| const baseAccess = `${initFragment.getNamespaceIdentifier()}${propertyAccess( | ||
@@ -518,3 +549,3 @@ moduleAndSpecifiers, | ||
| /** | ||
| * @param {string|string[]} urlAndGlobal the script request | ||
| * @param {string | string[]} urlAndGlobal the script request | ||
| * @param {RuntimeTemplate} runtimeTemplate the runtime template | ||
@@ -567,5 +598,5 @@ * @returns {SourceData} the generated source | ||
| /** | ||
| * @param {string|number} id the module id | ||
| * @param {ModuleId | string} id the module id | ||
| * @param {boolean} optional true, if the module is optional | ||
| * @param {string|string[]} request the request path | ||
| * @param {string | string[]} request the request path | ||
| * @param {RuntimeTemplate} runtimeTemplate the runtime template | ||
@@ -597,3 +628,3 @@ * @returns {SourceData} the generated source | ||
| * @param {boolean} optional true, if the module is optional | ||
| * @param {string|string[]} request the request path | ||
| * @param {string | string[]} request the request path | ||
| * @param {RuntimeTemplate} runtimeTemplate the runtime template | ||
@@ -619,6 +650,7 @@ * @returns {SourceData} the generated source | ||
| /** @typedef {Record<string, string | string[]>} RequestRecord */ | ||
| /** @typedef {string | string[] | RequestRecord} ExternalModuleRequest */ | ||
| class ExternalModule extends Module { | ||
| /** | ||
| * @param {string | string[] | RequestRecord} request request | ||
| * @param {ExternalModuleRequest} request request | ||
| * @param {string} type type | ||
@@ -632,3 +664,3 @@ * @param {string} userRequest user request | ||
| // Info from Factory | ||
| /** @type {string | string[] | Record<string, string | string[]>} */ | ||
| /** @type {ExternalModuleRequest} */ | ||
| this.request = request; | ||
@@ -663,3 +695,3 @@ /** @type {string} */ | ||
| * @param {LibIdentOptions} options options | ||
| * @returns {string | null} an identifier for library inclusion | ||
| * @returns {LibIdent | null} an identifier for library inclusion | ||
| */ | ||
@@ -1046,5 +1078,3 @@ libIdent(options) { | ||
| } else if (concatenationScope) { | ||
| sourceString = `${ | ||
| runtimeTemplate.supportsConst() ? "const" : "var" | ||
| } ${ConcatenationScope.NAMESPACE_OBJECT_EXPORT} = ${sourceString};`; | ||
| sourceString = `${runtimeTemplate.renderConst()} ${ConcatenationScope.NAMESPACE_OBJECT_EXPORT} = ${sourceString};`; | ||
| concatenationScope.registerNamespaceExport( | ||
@@ -1153,1 +1183,3 @@ ConcatenationScope.NAMESPACE_OBJECT_EXPORT | ||
| module.exports.ModuleExternalInitFragment = ModuleExternalInitFragment; | ||
| module.exports.getExternalModuleNodeCommonjsInitFragment = | ||
| getExternalModuleNodeCommonjsInitFragment; |
@@ -17,12 +17,29 @@ /* | ||
| /** @typedef {import("../declarations/WebpackOptions").ExternalItemFunctionData} ExternalItemFunctionData */ | ||
| /** @typedef {import("enhanced-resolve").ResolveContext} ResolveContext */ | ||
| /** @typedef {import("../declarations/WebpackOptions").ResolveOptions} ResolveOptions */ | ||
| /** @typedef {import("../declarations/WebpackOptions").ExternalItemValue} ExternalItemValue */ | ||
| /** @typedef {import("../declarations/WebpackOptions").ExternalItemObjectKnown} ExternalItemObjectKnown */ | ||
| /** @typedef {import("../declarations/WebpackOptions").ExternalItemObjectUnknown} ExternalItemObjectUnknown */ | ||
| /** @typedef {import("../declarations/WebpackOptions").Externals} Externals */ | ||
| /** @typedef {import("./Compilation").DepConstructor} DepConstructor */ | ||
| /** @typedef {import("./ExternalModule").DependencyMeta} DependencyMeta */ | ||
| /** @typedef {import("./Module")} Module */ | ||
| /** @typedef {import("./ModuleFactory").IssuerLayer} IssuerLayer */ | ||
| /** @typedef {import("./ModuleFactory").ModuleFactoryCreateDataContextInfo} ModuleFactoryCreateDataContextInfo */ | ||
| /** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */ | ||
| /** @typedef {((context: string, request: string, callback: (err?: Error | null, result?: string | false, resolveRequest?: import('enhanced-resolve').ResolveRequest) => void) => void)} ExternalItemFunctionDataGetResolveCallbackResult */ | ||
| /** @typedef {((context: string, request: string) => Promise<string>)} ExternalItemFunctionDataGetResolveResult */ | ||
| /** @typedef {(options?: ResolveOptions) => ExternalItemFunctionDataGetResolveCallbackResult | ExternalItemFunctionDataGetResolveResult} ExternalItemFunctionDataGetResolve */ | ||
| /** | ||
| * @typedef {object} ExternalItemFunctionData | ||
| * @property {string} context the directory in which the request is placed | ||
| * @property {ModuleFactoryCreateDataContextInfo} contextInfo contextual information | ||
| * @property {string} dependencyType the category of the referencing dependency | ||
| * @property {ExternalItemFunctionDataGetResolve} getResolve get a resolve function with the current resolver options | ||
| * @property {string} request the request as written by the user in the require/import expression/statement | ||
| */ | ||
| /** @typedef {((data: ExternalItemFunctionData, callback: (err?: (Error | null), result?: ExternalItemValue) => void) => void)} ExternalItemFunctionCallback */ | ||
| /** @typedef {((data: import("../lib/ExternalModuleFactoryPlugin").ExternalItemFunctionData) => Promise<ExternalItemValue>)} ExternalItemFunctionPromise */ | ||
| const UNSPECIFIED_EXTERNAL_TYPE_REGEXP = /^[a-z0-9-]+ /; | ||
@@ -83,3 +100,3 @@ const EMPTY_RESOLVE_OPTIONS = {}; | ||
| /** | ||
| * @param {string | undefined} type default external type | ||
| * @param {string} type default external type | ||
| * @param {Externals} externals externals config | ||
@@ -145,3 +162,3 @@ */ | ||
| const resolvedType = /** @type {string} */ (type || globalType); | ||
| const resolvedType = type || globalType; | ||
@@ -165,3 +182,3 @@ // TODO make it pluggable/add hooks to `ExternalModule` to allow output modules own externals? | ||
| dependencyMeta = { | ||
| attributes: dependency.assertions, | ||
| attributes: dependency.attributes, | ||
| externalType | ||
@@ -272,2 +289,3 @@ }; | ||
| getResolve: (options) => (context, request, callback) => { | ||
| /** @type {ResolveContext} */ | ||
| const resolveContext = { | ||
@@ -315,3 +333,5 @@ fileDependencies: data.fileDependencies, | ||
| ); | ||
| if (promise && promise.then) promise.then((r) => cb(null, r), cb); | ||
| if (promise && promise.then) { | ||
| promise.then((r) => cb(null, r), cb); | ||
| } | ||
| } | ||
@@ -318,0 +338,0 @@ return; |
+24
-17
@@ -14,3 +14,3 @@ /* | ||
| /** @typedef {import("./Compiler")} Compiler */ | ||
| /** @typedef {import("./optimize/ConcatenatedModule").ConcatenatedModuleInfo} ConcatenatedModuleInfo */ | ||
| /** @typedef {import("./ExternalModule").Imported} Imported */ | ||
@@ -21,3 +21,3 @@ const PLUGIN_NAME = "ExternalsPlugin"; | ||
| /** | ||
| * @param {string | undefined} type default external type | ||
| * @param {string} type default external type | ||
| * @param {Externals} externals externals config | ||
@@ -46,4 +46,3 @@ */ | ||
| concatenatedModuleInfo.tap(PLUGIN_NAME, (updatedInfo, moduleInfo) => { | ||
| const rawExportMap = | ||
| /** @type {ConcatenatedModuleInfo} */ updatedInfo.rawExportMap; | ||
| const rawExportMap = updatedInfo.rawExportMap; | ||
@@ -54,9 +53,13 @@ if (!rawExportMap) { | ||
| const chunkInitFragments = | ||
| /** @type {ConcatenatedModuleInfo} */ moduleInfo.chunkInitFragments; | ||
| const moduleExternalInitFragments = chunkInitFragments | ||
| ? chunkInitFragments.filter( | ||
| (fragment) => fragment instanceof ModuleExternalInitFragment | ||
| ) | ||
| : []; | ||
| const chunkInitFragments = moduleInfo.chunkInitFragments; | ||
| const moduleExternalInitFragments = | ||
| /** @type {ModuleExternalInitFragment[]} */ | ||
| ( | ||
| chunkInitFragments | ||
| ? /** @type {unknown[]} */ | ||
| (chunkInitFragments).filter( | ||
| (fragment) => fragment instanceof ModuleExternalInitFragment | ||
| ) | ||
| : [] | ||
| ); | ||
@@ -69,8 +72,12 @@ let initFragmentChanged = false; | ||
| if (Array.isArray(imported)) { | ||
| const newImported = imported.map(([specifier, finalName]) => [ | ||
| specifier, | ||
| rawExportMap.has(specifier) | ||
| ? rawExportMap.get(specifier) | ||
| : finalName | ||
| ]); | ||
| const newImported = | ||
| /** @type {Imported} */ | ||
| ( | ||
| imported.map(([specifier, finalName]) => [ | ||
| specifier, | ||
| rawExportMap.has(specifier) | ||
| ? rawExportMap.get(specifier) | ||
| : finalName | ||
| ]) | ||
| ); | ||
| fragment.setImported(newImported); | ||
@@ -77,0 +84,0 @@ initFragmentChanged = true; |
@@ -16,7 +16,6 @@ /* | ||
| /** @typedef {import("./Chunk")} Chunk */ | ||
| /** @typedef {import("./ChunkGroup")} ChunkGroup */ | ||
| /** @typedef {import("./Compiler")} Compiler */ | ||
| /** @typedef {import("./DependenciesBlock")} DependenciesBlock */ | ||
| /** @typedef {import("./Dependency").ReferencedExport} ReferencedExport */ | ||
| /** @typedef {import("./Dependency").ReferencedExports} ReferencedExports */ | ||
| /** @typedef {import("./ExportsInfo")} ExportsInfo */ | ||
@@ -65,3 +64,3 @@ /** @typedef {import("./Module")} Module */ | ||
| * @param {Module} module module to process | ||
| * @param {(string[] | ReferencedExport)[]} usedExports list of used exports | ||
| * @param {ReferencedExports} usedExports list of used exports | ||
| * @param {RuntimeSpec} runtime part of which runtime | ||
@@ -173,3 +172,3 @@ * @param {boolean} forceSideEffects always apply side effects | ||
| const processModule = (module, runtime, forceSideEffects) => { | ||
| /** @type {Map<Module, (string[] | ReferencedExport)[] | Map<string, string[] | ReferencedExport>>} */ | ||
| /** @type {Map<Module, ReferencedExports | Map<string, string[] | ReferencedExport>>} */ | ||
| const map = new Map(); | ||
@@ -176,0 +175,0 @@ |
+2
-13
@@ -11,7 +11,5 @@ /* | ||
| /** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */ | ||
| /** @typedef {import("./Compilation")} Compilation */ | ||
| /** @typedef {import("./Compilation").AssetInfo} AssetInfo */ | ||
| /** @typedef {import("./ConcatenationScope")} ConcatenationScope */ | ||
| /** @typedef {import("./DependencyTemplate")} DependencyTemplate */ | ||
| /** @typedef {import("./DependencyTemplates")} DependencyTemplates */ | ||
| /** @typedef {import("./Module").CodeGenerationResultData} CodeGenerationResultData */ | ||
| /** @typedef {import("./Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */ | ||
@@ -27,11 +25,2 @@ /** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */ | ||
| /** | ||
| * @template T | ||
| * @typedef {import("./InitFragment")<T>} InitFragment | ||
| */ | ||
| /** @typedef {Map<"url", { [key: string]: string }> & Map<"fullContentHash", string> & Map<"contentHash", string> & Map<"filename", string> & Map<"assetInfo", AssetInfo> & Map<"chunkInitFragments", InitFragment<GenerateContext>[]>} KnownGenerateContextData */ | ||
| /** @typedef {KnownGenerateContextData & Record<string, EXPECTED_ANY>} GenerateContextData */ | ||
| /** | ||
| * @typedef {object} GenerateContext | ||
@@ -47,3 +36,3 @@ * @property {DependencyTemplates} dependencyTemplates mapping from dependencies to templates | ||
| * @property {string} type which kind of code should be generated | ||
| * @property {() => GenerateContextData=} getData get access to the code generation data | ||
| * @property {() => CodeGenerationResultData=} getData get access to the code generation data | ||
| */ | ||
@@ -50,0 +39,0 @@ |
@@ -8,7 +8,4 @@ /* | ||
| /** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */ | ||
| /** @typedef {import("./Chunk")} Chunk */ | ||
| /** @typedef {import("./ChunkGroup")} ChunkGroup */ | ||
| /** @typedef {import("./DependenciesBlock")} DependenciesBlock */ | ||
| /** @typedef {import("./Module")} Module */ | ||
| /** @typedef {import(".").Entrypoint} Entrypoint */ | ||
@@ -15,0 +12,0 @@ |
@@ -8,15 +8,15 @@ /* | ||
| /** @typedef {import("http").IncomingMessage} IncomingMessage */ | ||
| /** @typedef {import("http").RequestListener} RequestListener */ | ||
| /** @typedef {import("http").ServerOptions} HttpServerOptions */ | ||
| /** @typedef {import("http").ServerResponse} ServerResponse */ | ||
| /** @typedef {import("http").Server} HttpServer */ | ||
| /** @typedef {import("https").ServerOptions} HttpsServerOptions */ | ||
| /** @typedef {import("https").Server} HttpsServer */ | ||
| /** @typedef {import("net").AddressInfo} AddressInfo */ | ||
| /** @typedef {import("net").Server} Server */ | ||
| /** @typedef {import("./LazyCompilationPlugin").BackendHandler} BackendHandler */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").LazyCompilationDefaultBackendOptions} LazyCompilationDefaultBackendOptions */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("./LazyCompilationPlugin").BackendApi} BackendApi */ | ||
| /** @typedef {import("./LazyCompilationPlugin").BackendHandler} BackendHandler */ | ||
| /** @typedef {HttpServer | HttpsServer} Server */ | ||
| /** @typedef {(server: Server) => void} Listen */ | ||
| /** @typedef {() => Server} CreateServerFunction */ | ||
| /** | ||
@@ -36,2 +36,3 @@ * @param {Omit<LazyCompilationDefaultBackendOptions, "client"> & { client: NonNullable<LazyCompilationDefaultBackendOptions["client"]>}} options additional options for the backend | ||
| /** @type {CreateServerFunction} */ | ||
| const createServer = | ||
@@ -42,3 +43,5 @@ typeof options.server === "function" | ||
| const http = isHttps ? require("https") : require("http"); | ||
| return http.createServer.bind( | ||
| return /** @type {(this: import("http") | import("https"), options: HttpServerOptions | HttpsServerOptions) => Server} */ ( | ||
| http.createServer | ||
| ).bind( | ||
| http, | ||
@@ -49,3 +52,3 @@ /** @type {HttpServerOptions | HttpsServerOptions} */ | ||
| })(); | ||
| /** @type {(server: Server) => void} */ | ||
| /** @type {Listen} */ | ||
| const listen = | ||
@@ -101,3 +104,3 @@ typeof options.listen === "function" | ||
| const server = /** @type {Server} */ (createServer()); | ||
| const server = createServer(); | ||
| server.on("request", requestListener); | ||
@@ -104,0 +107,0 @@ |
@@ -22,3 +22,3 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions")} WebpackOptions */ | ||
| /** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */ | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
@@ -32,2 +32,3 @@ /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */ | ||
| /** @typedef {import("../Module").LibIdent} LibIdent */ | ||
| /** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */ | ||
@@ -40,3 +41,2 @@ /** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */ | ||
| /** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */ | ||
| /** @typedef {import("../WebpackError")} WebpackError */ | ||
| /** @typedef {import("../dependencies/HarmonyImportDependency")} HarmonyImportDependency */ | ||
@@ -167,3 +167,3 @@ /** @typedef {import("../util/Hash")} Hash */ | ||
| * @param {LibIdentOptions} options options | ||
| * @returns {string | null} an identifier for library inclusion | ||
| * @returns {LibIdent | null} an identifier for library inclusion | ||
| */ | ||
@@ -352,2 +352,4 @@ libIdent(options) { | ||
| /** @typedef {(module: Module) => boolean} TestFn */ | ||
| /** | ||
@@ -358,3 +360,3 @@ * @typedef {object} Options options | ||
| * @property {boolean=} imports | ||
| * @property {(RegExp | string | ((module: Module) => boolean))=} test additional filter for lazy compiled entrypoint modules | ||
| * @property {RegExp | string | TestFn=} test additional filter for lazy compiled entrypoint modules | ||
| */ | ||
@@ -361,0 +363,0 @@ |
@@ -10,4 +10,2 @@ /* | ||
| /** @typedef {import("./Module")} Module */ | ||
| /** | ||
@@ -14,0 +12,0 @@ * @template T |
@@ -47,3 +47,2 @@ /* | ||
| /** @typedef {import("estree").SpreadElement} SpreadElement */ | ||
| /** @typedef {import("../declarations/WebpackOptions").OutputNormalized} OutputNormalized */ | ||
| /** @typedef {import("./Chunk")} Chunk */ | ||
@@ -55,2 +54,3 @@ /** @typedef {import("./Chunk").ChunkId} ChunkId */ | ||
| /** @typedef {import("./Compiler")} Compiler */ | ||
| /** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */ | ||
| /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */ | ||
@@ -64,6 +64,8 @@ /** @typedef {import("./Module")} Module */ | ||
| /** @typedef {string[]} Requests */ | ||
| /** | ||
| * @typedef {object} HMRJavascriptParserHooks | ||
| * @property {SyncBailHook<[Expression | SpreadElement, string[]], void>} hotAcceptCallback | ||
| * @property {SyncBailHook<[CallExpression, string[]], void>} hotAcceptWithoutCallback | ||
| * @property {SyncBailHook<[Expression | SpreadElement, Requests], void>} hotAcceptCallback | ||
| * @property {SyncBailHook<[CallExpression, Requests], void>} hotAcceptWithoutCallback | ||
| */ | ||
@@ -153,3 +155,3 @@ | ||
| } | ||
| /** @type {string[]} */ | ||
| /** @type {Requests} */ | ||
| const requests = []; | ||
@@ -407,9 +409,7 @@ if (params.length > 0) { | ||
| const getModuleHash = (module) => { | ||
| if ( | ||
| compilation.codeGenerationResults.has(module, chunk.runtime) | ||
| ) { | ||
| return compilation.codeGenerationResults.getHash( | ||
| module, | ||
| chunk.runtime | ||
| ); | ||
| const codeGenerationResults = | ||
| /** @type {CodeGenerationResults} */ | ||
| (compilation.codeGenerationResults); | ||
| if (codeGenerationResults.has(module, chunk.runtime)) { | ||
| return codeGenerationResults.getHash(module, chunk.runtime); | ||
| } | ||
@@ -508,2 +508,5 @@ nonCodeGeneratedModules.add(module, chunk.runtime); | ||
| } | ||
| const codeGenerationResults = | ||
| /** @type {CodeGenerationResults} */ | ||
| (compilation.codeGenerationResults); | ||
| for (const [module, chunk] of fullHashModules) { | ||
@@ -513,6 +516,3 @@ const key = `${chunk.id}|${module.identifier()}`; | ||
| ? chunkGraph.getModuleHash(module, chunk.runtime) | ||
| : compilation.codeGenerationResults.getHash( | ||
| module, | ||
| chunk.runtime | ||
| ); | ||
| : codeGenerationResults.getHash(module, chunk.runtime); | ||
| if (records.chunkModuleHashes[key] !== hash) { | ||
@@ -537,4 +537,3 @@ updatedModules.add(module, chunk); | ||
| compilation.getPathWithInfo( | ||
| /** @type {NonNullable<OutputNormalized["hotUpdateMainFilename"]>} */ | ||
| (compilation.outputOptions.hotUpdateMainFilename), | ||
| compilation.outputOptions.hotUpdateMainFilename, | ||
| { | ||
@@ -559,3 +558,3 @@ hash: records.hash, | ||
| // Create a list of all active modules to verify which modules are removed completely | ||
| /** @type {Map<number | string, Module>} */ | ||
| /** @type {Map<ModuleId, Module>} */ | ||
| const allModules = new Map(); | ||
@@ -570,3 +569,3 @@ for (const module of compilation.modules) { | ||
| // List of completely removed modules | ||
| /** @type {Set<string | number>} */ | ||
| /** @type {Set<ModuleId>} */ | ||
| const completelyRemovedModules = new Set(); | ||
@@ -659,6 +658,3 @@ | ||
| ? chunkGraph.getModuleHash(module, newRuntime) | ||
| : compilation.codeGenerationResults.getHash( | ||
| module, | ||
| newRuntime | ||
| ); | ||
| : codeGenerationResults.getHash(module, newRuntime); | ||
| if (hash !== oldHash) { | ||
@@ -747,3 +743,5 @@ if (module.type === WEBPACK_MODULE_TYPE_RUNTIME) { | ||
| dependencyTemplates: compilation.dependencyTemplates, | ||
| codeGenerationResults: compilation.codeGenerationResults, | ||
| codeGenerationResults: /** @type {CodeGenerationResults} */ ( | ||
| compilation.codeGenerationResults | ||
| ), | ||
| runtimeTemplate: compilation.runtimeTemplate, | ||
@@ -750,0 +748,0 @@ moduleGraph: compilation.moduleGraph, |
@@ -10,5 +10,2 @@ /* | ||
| /** @typedef {import("./ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("./util/Hash")} Hash */ | ||
| class HotUpdateChunk extends Chunk { | ||
@@ -15,0 +12,0 @@ constructor() { |
@@ -16,3 +16,2 @@ /* | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Module")} Module */ | ||
@@ -19,0 +18,0 @@ /** |
@@ -17,6 +17,3 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} Output */ | ||
| /** @typedef {import("../Chunk")} Chunk */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Module")} Module */ | ||
@@ -47,5 +44,3 @@ /** | ||
| compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => { | ||
| const hashFunction = | ||
| /** @type {NonNullable<Output["hashFunction"]>} */ | ||
| (compilation.outputOptions.hashFunction); | ||
| const hashFunction = compilation.outputOptions.hashFunction; | ||
| compilation.hooks.chunkIds.tap(PLUGIN_NAME, (chunks) => { | ||
@@ -52,0 +47,0 @@ const chunkGraph = compilation.chunkGraph; |
@@ -17,5 +17,3 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} Output */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Module")} Module */ | ||
@@ -45,5 +43,3 @@ /** | ||
| compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => { | ||
| const hashFunction = | ||
| /** @type {NonNullable<Output["hashFunction"]>} */ | ||
| (compilation.outputOptions.hashFunction); | ||
| const hashFunction = compilation.outputOptions.hashFunction; | ||
| compilation.hooks.moduleIds.tap(PLUGIN_NAME, () => { | ||
@@ -50,0 +46,0 @@ const chunkGraph = compilation.chunkGraph; |
@@ -13,3 +13,2 @@ /* | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Module")} Module */ | ||
@@ -16,0 +15,0 @@ const PLUGIN_NAME = "NaturalChunkIdsPlugin"; |
@@ -17,3 +17,2 @@ /* | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Module")} Module */ | ||
@@ -20,0 +19,0 @@ const PLUGIN_NAME = "NaturalModuleIdsPlugin"; |
@@ -15,3 +15,2 @@ /* | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Module")} Module */ | ||
@@ -18,0 +17,0 @@ const validate = createSchemaValidation( |
@@ -20,3 +20,2 @@ /* | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */ | ||
@@ -23,0 +22,0 @@ const validate = createSchemaValidation( |
@@ -13,2 +13,3 @@ /* | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../Module").ModuleId} ModuleId */ | ||
| /** @typedef {import("../util/fs").IntermediateFileSystem} IntermediateFileSystem */ | ||
@@ -46,3 +47,3 @@ | ||
| apply(compiler) { | ||
| /** @type {Map<string, string | number>} */ | ||
| /** @type {Map<string, ModuleId>} */ | ||
| let data; | ||
@@ -75,3 +76,3 @@ let dataChanged = false; | ||
| if (!data || !dataChanged) return callback(); | ||
| /** @type {{[key: string]: string | number}} */ | ||
| /** @type {{[key: string]: ModuleId}} */ | ||
| const json = {}; | ||
@@ -114,3 +115,3 @@ const sorted = [...data].sort(([a], [b]) => (a < b ? -1 : 1)); | ||
| } | ||
| chunkGraph.setModuleId(module, /** @type {string | number} */ (id)); | ||
| chunkGraph.setModuleId(module, /** @type {ModuleId} */ (id)); | ||
| usedIds.add(idAsString); | ||
@@ -117,0 +118,0 @@ } |
@@ -15,2 +15,3 @@ /* | ||
| /** @typedef {import("./NormalModuleFactory").ResolveData} ResolveData */ | ||
| /** @typedef {import("./ContextModuleFactory").BeforeContextResolveData} BeforeContextResolveData */ | ||
@@ -26,2 +27,4 @@ const validate = createSchemaValidation( | ||
| /** @typedef {(resource: string, context: string) => boolean} CheckResourceFn */ | ||
| const PLUGIN_NAME = "IgnorePlugin"; | ||
@@ -41,4 +44,4 @@ | ||
| * Note that if "contextRegExp" is given, both the "resourceRegExp" and "contextRegExp" have to match. | ||
| * @param {ResolveData} resolveData resolve data | ||
| * @returns {false|undefined} returns false when the request should be ignored, otherwise undefined | ||
| * @param {ResolveData | BeforeContextResolveData} resolveData resolve data | ||
| * @returns {false | undefined} returns false when the request should be ignored, otherwise undefined | ||
| */ | ||
@@ -45,0 +48,0 @@ checkIgnore(resolveData) { |
+8
-7
@@ -16,8 +16,2 @@ /* | ||
| /** @typedef {import("../declarations/WebpackOptions").ExternalItemFunction} ExternalItemFunction */ | ||
| /** @typedef {import("../declarations/WebpackOptions").ExternalItemFunctionCallback} ExternalItemFunctionCallback */ | ||
| /** @typedef {import("../declarations/WebpackOptions").ExternalItemFunctionData} ExternalItemFunctionData */ | ||
| /** @typedef {import("../declarations/WebpackOptions").ExternalItemFunctionDataGetResolve} ExternalItemFunctionDataGetResolve */ | ||
| /** @typedef {import("../declarations/WebpackOptions").ExternalItemFunctionDataGetResolveCallbackResult} ExternalItemFunctionDataGetResolveCallbackResult */ | ||
| /** @typedef {import("../declarations/WebpackOptions").ExternalItemFunctionDataGetResolveResult} ExternalItemFunctionDataGetResolveResult */ | ||
| /** @typedef {import("../declarations/WebpackOptions").ExternalItemFunctionPromise} ExternalItemFunctionPromise */ | ||
| /** @typedef {import("../declarations/WebpackOptions").ExternalItemObjectKnown} ExternalItemObjectKnown */ | ||
@@ -46,2 +40,3 @@ /** @typedef {import("../declarations/WebpackOptions").ExternalItemObjectUnknown} ExternalItemObjectUnknown */ | ||
| /** @typedef {import("./ChunkGroup")} ChunkGroup */ | ||
| /** @typedef {import("./Compiler").AssetEmittedInfo} AssetEmittedInfo */ | ||
| /** @typedef {import("./Compilation").Asset} Asset */ | ||
@@ -51,4 +46,10 @@ /** @typedef {import("./Compilation").AssetInfo} AssetInfo */ | ||
| /** @typedef {import("./Compilation").PathData} PathData */ | ||
| /** @typedef {import("./Compiler").AssetEmittedInfo} AssetEmittedInfo */ | ||
| /** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */ | ||
| /** @typedef {import("./Entrypoint")} Entrypoint */ | ||
| /** @typedef {import("./ExternalModuleFactoryPlugin").ExternalItemFunctionCallback} ExternalItemFunctionCallback */ | ||
| /** @typedef {import("./ExternalModuleFactoryPlugin").ExternalItemFunctionData} ExternalItemFunctionData */ | ||
| /** @typedef {import("./ExternalModuleFactoryPlugin").ExternalItemFunctionDataGetResolve} ExternalItemFunctionDataGetResolve */ | ||
| /** @typedef {import("./ExternalModuleFactoryPlugin").ExternalItemFunctionDataGetResolveCallbackResult} ExternalItemFunctionDataGetResolveCallbackResult */ | ||
| /** @typedef {import("./ExternalModuleFactoryPlugin").ExternalItemFunctionDataGetResolveResult} ExternalItemFunctionDataGetResolveResult */ | ||
| /** @typedef {import("./ExternalModuleFactoryPlugin").ExternalItemFunctionPromise} ExternalItemFunctionPromise */ | ||
| /** @typedef {import("./MultiCompiler").MultiCompilerOptions} MultiCompilerOptions */ | ||
@@ -55,0 +56,0 @@ /** @typedef {import("./MultiCompiler").MultiWebpackOptions} MultiConfiguration */ |
+41
-29
@@ -16,7 +16,21 @@ /* | ||
| /** @typedef {string} InitFragmentKey */ | ||
| /** | ||
| * @template GenerateContext | ||
| * @typedef {object} MaybeMergeableInitFragment | ||
| * @property {InitFragmentKey=} key | ||
| * @property {number} stage | ||
| * @property {number} position | ||
| * @property {(context: GenerateContext) => string | Source | undefined} getContent | ||
| * @property {(context: GenerateContext) => string | Source | undefined} getEndContent | ||
| * @property {(fragments: MaybeMergeableInitFragment<GenerateContext>) => MaybeMergeableInitFragment<GenerateContext>=} merge | ||
| * @property {(fragments: MaybeMergeableInitFragment<GenerateContext>[]) => MaybeMergeableInitFragment<GenerateContext>[]=} mergeAll | ||
| */ | ||
| /** | ||
| * @template T | ||
| * @param {InitFragment<T>} fragment the init fragment | ||
| * @param {T} fragment the init fragment | ||
| * @param {number} index index | ||
| * @returns {[InitFragment<T>, number]} tuple with both | ||
| * @returns {[T, number]} tuple with both | ||
| */ | ||
@@ -27,4 +41,4 @@ const extractFragmentIndex = (fragment, index) => [fragment, index]; | ||
| * @template T | ||
| * @param {[InitFragment<T>, number]} a first pair | ||
| * @param {[InitFragment<T>, number]} b second pair | ||
| * @param {[MaybeMergeableInitFragment<T>, number]} a first pair | ||
| * @param {[MaybeMergeableInitFragment<T>, number]} b second pair | ||
| * @returns {number} sort value | ||
@@ -42,2 +56,3 @@ */ | ||
| * @template GenerateContext | ||
| * @implements {MaybeMergeableInitFragment<GenerateContext>} | ||
| */ | ||
@@ -49,3 +64,3 @@ class InitFragment { | ||
| * @param {number} position position in the category (contribute to order) | ||
| * @param {string=} key unique key to avoid emitting the same initialization code twice | ||
| * @param {InitFragmentKey=} key unique key to avoid emitting the same initialization code twice | ||
| * @param {string | Source=} endContent the source code that will be included at the end of the module | ||
@@ -71,3 +86,3 @@ */ | ||
| * @param {GenerateContext} context context | ||
| * @returns {string | Source=} the source code that will be included at the end of the module | ||
| * @returns {string | Source | undefined} the source code that will be included at the end of the module | ||
| */ | ||
@@ -80,5 +95,4 @@ getEndContent(context) { | ||
| * @template Context | ||
| * @template T | ||
| * @param {Source} source sources | ||
| * @param {InitFragment<T>[]} initFragments init fragments | ||
| * @param {MaybeMergeableInitFragment<Context>[]} initFragments init fragments | ||
| * @param {Context} context context | ||
@@ -96,10 +110,6 @@ * @returns {Source} source | ||
| // Deduplicate fragments. If a fragment has no key, it is always included. | ||
| /** @type {Map<InitFragmentKey | symbol, MaybeMergeableInitFragment<Context> | MaybeMergeableInitFragment<Context>[]>} */ | ||
| const keyedFragments = new Map(); | ||
| for (const [fragment] of sortedFragments) { | ||
| if ( | ||
| typeof ( | ||
| /** @type {InitFragment<T> & { mergeAll?: (fragments: InitFragment<Context>[]) => InitFragment<Context>[] }} */ | ||
| (fragment).mergeAll | ||
| ) === "function" | ||
| ) { | ||
| if (typeof fragment.mergeAll === "function") { | ||
| if (!fragment.key) { | ||
@@ -120,5 +130,8 @@ throw new Error( | ||
| } else if (typeof fragment.merge === "function") { | ||
| const oldValue = keyedFragments.get(fragment.key); | ||
| const key = /** @type {InitFragmentKey} */ (fragment.key); | ||
| const oldValue = | ||
| /** @type {MaybeMergeableInitFragment<Context>} */ | ||
| (keyedFragments.get(key)); | ||
| if (oldValue !== undefined) { | ||
| keyedFragments.set(fragment.key, fragment.merge(oldValue)); | ||
| keyedFragments.set(key, fragment.merge(oldValue)); | ||
| continue; | ||
@@ -134,6 +147,15 @@ } | ||
| if (Array.isArray(fragment)) { | ||
| fragment = fragment[0].mergeAll(fragment); | ||
| fragment = | ||
| /** @type {[MaybeMergeableInitFragment<Context> & { mergeAll: (fragments: MaybeMergeableInitFragment<Context>[]) => MaybeMergeableInitFragment<Context>[] }, ...MaybeMergeableInitFragment<Context>[]]} */ | ||
| (fragment)[0].mergeAll(fragment); | ||
| } | ||
| concatSource.add(fragment.getContent(context)); | ||
| const endContent = fragment.getEndContent(context); | ||
| const content = | ||
| /** @type {MaybeMergeableInitFragment<Context>} */ | ||
| (fragment).getContent(context); | ||
| if (content) { | ||
| concatSource.add(content); | ||
| } | ||
| const endContent = | ||
| /** @type {MaybeMergeableInitFragment<Context>} */ | ||
| (fragment).getEndContent(context); | ||
| if (endContent) { | ||
@@ -182,12 +204,2 @@ endContents.push(endContent); | ||
| InitFragment.prototype.merge = | ||
| /** @type {TODO} */ | ||
| (undefined); | ||
| InitFragment.prototype.getImported = | ||
| /** @type {TODO} */ | ||
| (undefined); | ||
| InitFragment.prototype.setImported = | ||
| /** @type {TODO} */ | ||
| (undefined); | ||
| InitFragment.STAGE_CONSTANTS = 10; | ||
@@ -194,0 +206,0 @@ InitFragment.STAGE_ASYNC_BOUNDARY = 20; |
@@ -11,3 +11,2 @@ /* | ||
| /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */ | ||
| /** @typedef {import("./Module")} Module */ | ||
@@ -14,0 +13,0 @@ |
@@ -20,2 +20,3 @@ /* | ||
| /** @typedef {import("../ChunkGraph").EntryModuleWithChunkGroup} EntryModuleWithChunkGroup */ | ||
| /** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */ | ||
@@ -93,3 +94,5 @@ const PLUGIN_NAME = "ArrayPushCallbackChunkFormatPlugin"; | ||
| ...renderContext, | ||
| codeGenerationResults: compilation.codeGenerationResults | ||
| codeGenerationResults: | ||
| /** @type {CodeGenerationResults} */ | ||
| (compilation.codeGenerationResults) | ||
| }) | ||
@@ -96,0 +99,0 @@ ); |
@@ -11,2 +11,5 @@ /* | ||
| /** @typedef {import("./JavascriptParser").VariableInfo} VariableInfo */ | ||
| /** @typedef {import("./JavascriptParser").Members} Members */ | ||
| /** @typedef {import("./JavascriptParser").MembersOptionals} MembersOptionals */ | ||
| /** @typedef {import("./JavascriptParser").MemberRanges} MemberRanges */ | ||
@@ -28,2 +31,6 @@ const TypeUnknown = 0; | ||
| /** @typedef {() => Members} GetMembers */ | ||
| /** @typedef {() => MembersOptionals} GetMembersOptionals */ | ||
| /** @typedef {() => MemberRanges} GetMemberRanges */ | ||
| class BasicEvaluatedExpression { | ||
@@ -72,7 +79,7 @@ constructor() { | ||
| this.rootInfo = undefined; | ||
| /** @type {(() => string[]) | undefined} */ | ||
| /** @type {GetMembers | undefined} */ | ||
| this.getMembers = undefined; | ||
| /** @type {(() => boolean[]) | undefined} */ | ||
| /** @type {GetMembersOptionals | undefined} */ | ||
| this.getMembersOptionals = undefined; | ||
| /** @type {(() => Range[]) | undefined} */ | ||
| /** @type {GetMemberRanges | undefined} */ | ||
| this.getMemberRanges = undefined; | ||
@@ -394,5 +401,5 @@ /** @type {Node | undefined} */ | ||
| * @param {string | VariableInfo} rootInfo root info | ||
| * @param {() => string[]} getMembers members | ||
| * @param {() => boolean[]=} getMembersOptionals optional members | ||
| * @param {() => Range[]=} getMemberRanges ranges of progressively increasing sub-expressions | ||
| * @param {GetMembers} getMembers members | ||
| * @param {GetMembersOptionals=} getMembersOptionals optional members | ||
| * @param {GetMemberRanges=} getMemberRanges ranges of progressively increasing sub-expressions | ||
| * @returns {this} this | ||
@@ -399,0 +406,0 @@ */ |
@@ -21,3 +21,3 @@ /* | ||
| * @param {ChunkGraph} chunkGraph The chunk graph containing the chunk | ||
| * @returns {{entries: Array<[Module, Entrypoint | undefined]>, runtimeChunk: Chunk|null}} Object containing chunk entries and runtime chunk | ||
| * @returns {{ entries: [Module, Entrypoint | undefined][], runtimeChunk: Chunk | null }} Object containing chunk entries and runtime chunk | ||
| */ | ||
@@ -24,0 +24,0 @@ function getChunkInfo(chunk, chunkGraph) { |
@@ -24,3 +24,2 @@ /* | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Entrypoint")} Entrypoint */ | ||
@@ -27,0 +26,0 @@ const PLUGIN_NAME = "CommonJsChunkFormatPlugin"; |
@@ -16,2 +16,3 @@ /* | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("../Compilation").DependencyConstructor} DependencyConstructor */ | ||
| /** @typedef {import("../DependenciesBlock")} DependenciesBlock */ | ||
@@ -21,3 +22,2 @@ /** @typedef {import("../Dependency")} Dependency */ | ||
| /** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */ | ||
| /** @typedef {import("../DependencyTemplates")} DependencyTemplates */ | ||
| /** @typedef {import("../Generator").GenerateContext} GenerateContext */ | ||
@@ -28,3 +28,2 @@ /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../NormalModule")} NormalModule */ | ||
| /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ | ||
@@ -219,3 +218,3 @@ const DEFAULT_SOURCE = { | ||
| const constructor = | ||
| /** @type {new (...args: EXPECTED_ANY[]) => Dependency} */ | ||
| /** @type {DependencyConstructor} */ | ||
| (dependency.constructor); | ||
@@ -222,0 +221,0 @@ const template = generateContext.dependencyTemplates.get(constructor); |
@@ -55,4 +55,3 @@ /* | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").Output} OutputOptions */ | ||
| /** @typedef {import("../config/defaults").OutputNormalizedWithDefaults} OutputOptions */ | ||
| /** @typedef {import("../Chunk")} Chunk */ | ||
@@ -449,3 +448,2 @@ /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| chunkGraph, | ||
| codeGenerationResults, | ||
| moduleGraph, | ||
@@ -460,3 +458,6 @@ runtimeTemplate, | ||
| } = compilation; | ||
| const hash = createHash(/** @type {HashFunction} */ (hashFunction)); | ||
| const codeGenerationResults = | ||
| /** @type {CodeGenerationResults} */ | ||
| (compilation.codeGenerationResults); | ||
| const hash = createHash(hashFunction); | ||
| if (hashSalt) hash.update(hashSalt); | ||
@@ -597,7 +598,7 @@ if (chunk.hasRuntime()) { | ||
| } else if (chunk instanceof HotUpdateChunk) { | ||
| return /** @type {TemplatePath} */ (outputOptions.hotUpdateChunkFilename); | ||
| return outputOptions.hotUpdateChunkFilename; | ||
| } else if (chunk.canBeInitial()) { | ||
| return /** @type {TemplatePath} */ (outputOptions.filename); | ||
| return outputOptions.filename; | ||
| } | ||
| return /** @type {TemplatePath} */ (outputOptions.chunkFilename); | ||
| return outputOptions.chunkFilename; | ||
| } | ||
@@ -1363,2 +1364,12 @@ | ||
| } | ||
| if ( | ||
| result.allowInlineStartup && | ||
| entryRuntimeRequirements.has(RuntimeGlobals.thisAsExports) | ||
| ) { | ||
| buf2.push( | ||
| "// This entry module used `this` as exports so it can't be inlined" | ||
| ); | ||
| result.allowInlineStartup = false; | ||
| } | ||
| if (chunks.length > 0) { | ||
@@ -1382,17 +1393,29 @@ buf2.push( | ||
| if (i === 0) buf2.push(`var ${RuntimeGlobals.exports} = {};`); | ||
| if (requireScopeUsed) { | ||
| buf2.push( | ||
| `__webpack_modules__[${moduleIdExpr}](0, ${ | ||
| i === 0 ? RuntimeGlobals.exports : "{}" | ||
| }, ${RuntimeGlobals.require});` | ||
| ); | ||
| } else if (entryRuntimeRequirements.has(RuntimeGlobals.exports)) { | ||
| buf2.push( | ||
| `__webpack_modules__[${moduleIdExpr}](0, ${ | ||
| i === 0 ? RuntimeGlobals.exports : "{}" | ||
| });` | ||
| ); | ||
| } else { | ||
| buf2.push(`__webpack_modules__[${moduleIdExpr}]();`); | ||
| const needThisAsExports = entryRuntimeRequirements.has( | ||
| RuntimeGlobals.thisAsExports | ||
| ); | ||
| /** @type {string[]} */ | ||
| const args = []; | ||
| if ( | ||
| requireScopeUsed || | ||
| entryRuntimeRequirements.has(RuntimeGlobals.exports) | ||
| ) { | ||
| const exportsArg = i === 0 ? RuntimeGlobals.exports : "{}"; | ||
| args.push("0", exportsArg); | ||
| if (requireScopeUsed) { | ||
| args.push(RuntimeGlobals.require); | ||
| } | ||
| } | ||
| buf2.push( | ||
| Template.asString( | ||
| (() => { | ||
| if (needThisAsExports) { | ||
| const comma = args.length ? "," : ""; | ||
| return `__webpack_modules__[${moduleIdExpr}].call(${RuntimeGlobals.exports}${comma}${args.join(",")});`; | ||
| } | ||
| return `__webpack_modules__[${moduleIdExpr}](${args.join(",")});`; | ||
| })() | ||
| ) | ||
| ); | ||
| } | ||
@@ -1399,0 +1422,0 @@ } |
@@ -13,6 +13,6 @@ /* | ||
| /** @typedef {import("estree").Expression} Expression */ | ||
| /** @typedef {import("estree").Node} Node */ | ||
| /** @typedef {import("estree").SourceLocation} SourceLocation */ | ||
| /** @typedef {import("./JavascriptParser")} JavascriptParser */ | ||
| /** @typedef {import("./JavascriptParser").Range} Range */ | ||
| /** @typedef {import("./BasicEvaluatedExpression").GetMembers} GetMembers */ | ||
@@ -35,3 +35,3 @@ module.exports.approve = () => true; | ||
| * @param {string} rootInfo rootInfo | ||
| * @param {() => string[]} getMembers getMembers | ||
| * @param {GetMembers} getMembers getMembers | ||
| * @param {boolean | null=} truthy is truthy, null if nullish | ||
@@ -38,0 +38,0 @@ * @returns {(expression: Expression) => BasicEvaluatedExpression} callback |
@@ -16,3 +16,2 @@ /* | ||
| /** @typedef {import("../Chunk").ChunkId} ChunkId */ | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
@@ -22,5 +21,3 @@ /** @typedef {import("../ChunkGraph").ModuleId} ModuleId */ | ||
| /** @typedef {import("../ChunkGraph").EntryModuleWithChunkGroup} EntryModuleWithChunkGroup */ | ||
| /** @typedef {import("../ChunkGroup")} ChunkGroup */ | ||
| /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ | ||
| /** @typedef {(string|number)[]} EntryItem */ | ||
@@ -142,5 +139,6 @@ const EXPORT_PREFIX = `var ${RuntimeGlobals.exports} = `; | ||
| * @param {(chunk: Chunk, chunkGraph: ChunkGraph) => boolean} filterFn filter function | ||
| * @returns {Set<number | string>} initially fulfilled chunk ids | ||
| * @returns {Set<ChunkId>} initially fulfilled chunk ids | ||
| */ | ||
| module.exports.getInitialChunkIds = (chunk, chunkGraph, filterFn) => { | ||
| /** @type {Set<ChunkId>} */ | ||
| const initialChunkIds = new Set(chunk.ids); | ||
@@ -147,0 +145,0 @@ for (const c of chunk.getAllInitialChunks()) { |
@@ -13,3 +13,3 @@ /* | ||
| /** @typedef {import("../util/Hash")} Hash */ | ||
| /** @typedef {import("./JsonModulesPlugin").JsonValue} JsonValue */ | ||
| /** @typedef {import("../util/fs").JsonValue} JsonValue */ | ||
@@ -16,0 +16,0 @@ class JsonData { |
@@ -23,6 +23,5 @@ /* | ||
| /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */ | ||
| /** @typedef {import("./JsonData")} JsonData */ | ||
| /** @typedef {import("./JsonModulesPlugin").JsonArray} JsonArray */ | ||
| /** @typedef {import("./JsonModulesPlugin").JsonObject} JsonObject */ | ||
| /** @typedef {import("./JsonModulesPlugin").JsonValue} JsonValue */ | ||
| /** @typedef {import("../util/fs").JsonArray} JsonArray */ | ||
| /** @typedef {import("../util/fs").JsonObject} JsonObject */ | ||
| /** @typedef {import("../util/fs").JsonValue} JsonValue */ | ||
@@ -210,3 +209,3 @@ /** | ||
| if (concatenationScope) { | ||
| content = `${runtimeTemplate.supportsConst() ? "const" : "var"} ${ | ||
| content = `${runtimeTemplate.renderConst()} ${ | ||
| ConcatenationScope.NAMESPACE_OBJECT_EXPORT | ||
@@ -213,0 +212,0 @@ } = ${jsonExpr};`; |
@@ -14,5 +14,2 @@ /* | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../util/fs").JsonArray} JsonArray */ | ||
| /** @typedef {import("../util/fs").JsonObject} JsonObject */ | ||
| /** @typedef {import("../util/fs").JsonValue} JsonValue */ | ||
@@ -19,0 +16,0 @@ const validate = createSchemaValidation( |
@@ -18,4 +18,6 @@ /* | ||
| /** @typedef {import("../Parser").PreparsedAst} PreparsedAst */ | ||
| /** @typedef {import("./JsonModulesPlugin").JsonValue} JsonValue */ | ||
| /** @typedef {import("../util/fs").JsonValue} JsonValue */ | ||
| /** @typedef {(input: string) => Buffer | JsonValue} ParseFn */ | ||
| const getParseJson = memoize(() => require("json-parse-even-better-errors")); | ||
@@ -42,3 +44,3 @@ | ||
| /** @type {NonNullable<JsonModulesPluginParserOptions["parse"]>} */ | ||
| /** @type {ParseFn} */ | ||
| const parseFn = | ||
@@ -45,0 +47,0 @@ typeof this.options.parse === "function" |
@@ -18,8 +18,9 @@ /* | ||
| /** @typedef {import("./Module").BuildMeta} BuildMeta */ | ||
| /** @typedef {import("./ExportsInfo").ExportInfoName} ExportInfoName */ | ||
| /** | ||
| * @typedef {object} ManifestModuleData | ||
| * @property {string | number} id | ||
| * @property {ModuleId} id | ||
| * @property {BuildMeta=} buildMeta | ||
| * @property {boolean | string[]=} exports | ||
| * @property {ExportInfoName[]=} exports | ||
| */ | ||
@@ -96,6 +97,3 @@ | ||
| const ident = module.libIdent({ | ||
| context: | ||
| this.options.context || | ||
| /** @type {string} */ | ||
| (compiler.options.context), | ||
| context: this.options.context || compiler.context, | ||
| associatedObjectForCache: compiler.root | ||
@@ -102,0 +100,0 @@ }); |
@@ -20,5 +20,5 @@ /* | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */ | ||
| /** @typedef {import("../javascript/JavascriptModulesPlugin").RenderContext} RenderContext */ | ||
| /** @typedef {import("../javascript/JavascriptModulesPlugin").StartupRenderContext} StartupRenderContext */ | ||
| /** @typedef {import("../javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */ | ||
| /** @typedef {import("../javascript/JavascriptModulesPlugin").ModuleRenderContext} ModuleRenderContext */ | ||
@@ -277,3 +277,3 @@ /** @typedef {import("../util/Hash")} Hash */ | ||
| * @param {Chunk} chunk the chunk | ||
| * @param {Set<string>} set runtime requirements | ||
| * @param {RuntimeRequirements} set runtime requirements | ||
| * @param {LibraryContext<T>} libraryContext context | ||
@@ -280,0 +280,0 @@ * @returns {void} |
@@ -18,3 +18,2 @@ /* | ||
| /** @typedef {import("../Compilation").ChunkHashContext} ChunkHashContext */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../javascript/JavascriptModulesPlugin").RenderContext} RenderContext */ | ||
@@ -21,0 +20,0 @@ /** @typedef {import("../util/Hash")} Hash */ |
@@ -19,2 +19,3 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").LibraryType} LibraryType */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").LibraryExport} LibraryExport */ | ||
| /** @typedef {import("../Chunk")} Chunk */ | ||
@@ -24,7 +25,13 @@ /** @typedef {import("../Compilation")} Compilation */ | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */ | ||
| /** @typedef {import("../ExportsInfo").ExportInfoName} ExportInfoName */ | ||
| /** @typedef {import("../javascript/JavascriptModulesPlugin").RenderContext} RenderContext */ | ||
| /** @typedef {import("../javascript/JavascriptModulesPlugin").StartupRenderContext} StartupRenderContext */ | ||
| /** @typedef {import("../util/Hash")} Hash */ | ||
| /** @template T @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T> */ | ||
| /** | ||
| * @template T | ||
| * @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T> | ||
| */ | ||
| const KEYWORD_REGEX = | ||
@@ -94,15 +101,19 @@ /^(await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|super|switch|static|this|throw|try|true|typeof|var|void|while|with|yield)$/; | ||
| /** @typedef {string[] | "global"} LibraryPrefix */ | ||
| /** | ||
| * @typedef {object} AssignLibraryPluginOptions | ||
| * @property {LibraryType} type | ||
| * @property {string[] | "global"} prefix name prefix | ||
| * @property {LibraryPrefix} prefix name prefix | ||
| * @property {string | false} declare declare name as variable | ||
| * @property {"error"|"static"|"copy"|"assign"} unnamed behavior for unnamed library name | ||
| * @property {"copy"|"assign"=} named behavior for named library name | ||
| * @property {"error" | "static" | "copy" | "assign"} unnamed behavior for unnamed library name | ||
| * @property {"copy" | "assign"=} named behavior for named library name | ||
| */ | ||
| /** @typedef {string | string[]} LibraryName */ | ||
| /** | ||
| * @typedef {object} AssignLibraryPluginParsed | ||
| * @property {string | string[]} name | ||
| * @property {string | string[] | undefined} export | ||
| * @property {LibraryName} name | ||
| * @property {LibraryExport=} export | ||
| */ | ||
@@ -146,3 +157,3 @@ | ||
| } | ||
| const _name = /** @type {string | string[]} */ (name); | ||
| const _name = /** @type {LibraryName} */ (name); | ||
| return { | ||
@@ -182,3 +193,3 @@ name: _name, | ||
| * @param {Compilation} compilation the compilation | ||
| * @returns {string[]} the prefix | ||
| * @returns {LibraryPrefix} the prefix | ||
| */ | ||
@@ -195,3 +206,3 @@ _getPrefix(compilation) { | ||
| * @param {Compilation} compilation the compilation | ||
| * @returns {Array<string>} the resolved full name | ||
| * @returns {string[]} the resolved full name | ||
| */ | ||
@@ -205,3 +216,3 @@ _getResolvedFullName(options, chunk, compilation) { | ||
| ] | ||
| : prefix; | ||
| : /** @type {string[]} */ (prefix); | ||
| return fullName.map((n) => | ||
@@ -321,3 +332,3 @@ compilation.getPath(n, { | ||
| /** @type {string[]} */ | ||
| /** @type {ExportInfoName[]} */ | ||
| const provided = []; | ||
@@ -403,3 +414,3 @@ for (const exportInfo of exportsInfo.orderedExports) { | ||
| * @param {Chunk} chunk the chunk | ||
| * @param {Set<string>} set runtime requirements | ||
| * @param {RuntimeRequirements} set runtime requirements | ||
| * @param {LibraryContext<T>} libraryContext context | ||
@@ -406,0 +417,0 @@ * @returns {void} |
@@ -8,7 +8,8 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").LibraryOptions} LibraryOptions */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").LibraryType} LibraryType */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @type {WeakMap<Compiler, Set<LibraryType>>} */ | ||
| /** @typedef {Set<LibraryType>} LibraryTypes */ | ||
| /** @type {WeakMap<Compiler, LibraryTypes>} */ | ||
| const enabledTypes = new WeakMap(); | ||
@@ -23,3 +24,3 @@ | ||
| * @param {Compiler} compiler the compiler instance | ||
| * @returns {Set<LibraryType>} enabled types | ||
| * @returns {LibraryTypes} enabled types | ||
| */ | ||
@@ -92,9 +93,6 @@ const getEnabledTypes = (compiler) => { | ||
| const enableExportProperty = () => { | ||
| const ExportPropertyTemplatePlugin = require("./ExportPropertyLibraryPlugin"); | ||
| const ExportPropertyLibraryPlugin = require("./ExportPropertyLibraryPlugin"); | ||
| new ExportPropertyTemplatePlugin({ | ||
| type, | ||
| nsObjectUsed: !["module", "modern-module"].includes(type), | ||
| runtimeExportsUsed: !["module", "modern-module"].includes(type), | ||
| renderStartupUsed: !["module", "modern-module"].includes(type) | ||
| new ExportPropertyLibraryPlugin({ | ||
| type | ||
| }).apply(compiler); | ||
@@ -292,4 +290,2 @@ }; | ||
| case "modern-module": { | ||
| enableExportProperty(); | ||
| const ModuleLibraryPlugin = require("./ModuleLibraryPlugin"); | ||
@@ -296,0 +292,0 @@ |
@@ -18,5 +18,6 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").LibraryType} LibraryType */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").LibraryExport} LibraryExport */ | ||
| /** @typedef {import("../Chunk")} Chunk */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */ | ||
| /** @typedef {import("../javascript/JavascriptModulesPlugin").StartupRenderContext} StartupRenderContext */ | ||
@@ -27,3 +28,3 @@ /** @template T @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T> */ | ||
| * @typedef {object} ExportPropertyLibraryPluginParsed | ||
| * @property {string | string[]} export | ||
| * @property {LibraryExport=} export | ||
| */ | ||
@@ -34,5 +35,2 @@ | ||
| * @property {LibraryType} type | ||
| * @property {boolean} nsObjectUsed the namespace object is used | ||
| * @property {boolean} runtimeExportsUsed runtime exports are used | ||
| * @property {boolean} renderStartupUsed render startup is used | ||
| */ | ||
@@ -47,3 +45,3 @@ /** | ||
| */ | ||
| constructor({ type, nsObjectUsed, runtimeExportsUsed, renderStartupUsed }) { | ||
| constructor({ type }) { | ||
| super({ | ||
@@ -53,5 +51,2 @@ pluginName: "ExportPropertyLibraryPlugin", | ||
| }); | ||
| this.nsObjectUsed = nsObjectUsed; | ||
| this.runtimeExportsUsed = runtimeExportsUsed; | ||
| this.renderStartupUsed = renderStartupUsed; | ||
| } | ||
@@ -65,3 +60,3 @@ | ||
| return { | ||
| export: /** @type {string | string[]} */ (library.export) | ||
| export: library.export | ||
| }; | ||
@@ -91,7 +86,3 @@ } | ||
| const exportsInfo = moduleGraph.getExportsInfo(module); | ||
| if (this.nsObjectUsed) { | ||
| exportsInfo.setUsedInUnknownWay(runtime); | ||
| } else { | ||
| exportsInfo.setAllKnownExportsUsed(runtime); | ||
| } | ||
| exportsInfo.setUsedInUnknownWay(runtime); | ||
| } | ||
@@ -103,3 +94,3 @@ moduleGraph.addExtraReason(module, "used as library export"); | ||
| * @param {Chunk} chunk the chunk | ||
| * @param {Set<string>} set runtime requirements | ||
| * @param {RuntimeRequirements} set runtime requirements | ||
| * @param {LibraryContext<T>} libraryContext context | ||
@@ -109,5 +100,3 @@ * @returns {void} | ||
| runtimeRequirements(chunk, set, libraryContext) { | ||
| if (this.runtimeExportsUsed) { | ||
| set.add(RuntimeGlobals.exports); | ||
| } | ||
| set.add(RuntimeGlobals.exports); | ||
| } | ||
@@ -123,3 +112,2 @@ | ||
| renderStartup(source, module, renderContext, { options }) { | ||
| if (!this.renderStartupUsed) return source; | ||
| if (!options.export) return source; | ||
@@ -126,0 +114,0 @@ const postfix = `${RuntimeGlobals.exports} = ${ |
@@ -16,8 +16,11 @@ /* | ||
| /** @typedef {import("../Compilation").ChunkHashContext} ChunkHashContext */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../javascript/JavascriptModulesPlugin").RenderContext} RenderContext */ | ||
| /** @typedef {import("../util/Hash")} Hash */ | ||
| /** @template T @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T> */ | ||
| /** | ||
| * @template T | ||
| * @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T> | ||
| */ | ||
| /** | ||
| * @typedef {object} JsonpLibraryPluginOptions | ||
@@ -24,0 +27,0 @@ * @property {LibraryType} type |
@@ -9,7 +9,8 @@ /* | ||
| const { ConcatSource } = require("webpack-sources"); | ||
| const { UsageState } = require("../ExportsInfo"); | ||
| const RuntimeGlobals = require("../RuntimeGlobals"); | ||
| const Template = require("../Template"); | ||
| const CommonJsSelfReferenceDependency = require("../dependencies/CommonJsSelfReferenceDependency"); | ||
| const ConcatenatedModule = require("../optimize/ConcatenatedModule"); | ||
| const propertyAccess = require("../util/propertyAccess"); | ||
| const { getEntryRuntime } = require("../util/runtime"); | ||
| const AbstractLibraryPlugin = require("./AbstractLibraryPlugin"); | ||
@@ -20,10 +21,9 @@ | ||
| /** @typedef {import("../../declarations/WebpackOptions").LibraryType} LibraryType */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").LibraryExport} LibraryExport */ | ||
| /** @typedef {import("../Chunk")} Chunk */ | ||
| /** @typedef {import("../Compilation").ChunkHashContext} ChunkHashContext */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../Module").BuildMeta} BuildMeta */ | ||
| /** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */ | ||
| /** @typedef {import("../javascript/JavascriptModulesPlugin").StartupRenderContext} StartupRenderContext */ | ||
| /** @typedef {import("../javascript/JavascriptModulesPlugin").ModuleRenderContext} ModuleRenderContext */ | ||
| /** @typedef {import("../util/Hash")} Hash */ | ||
@@ -43,3 +43,3 @@ /** | ||
| * @property {string} name | ||
| * @property {string | string[]=} export | ||
| * @property {LibraryExport=} export | ||
| */ | ||
@@ -80,2 +80,43 @@ | ||
| /** | ||
| * @param {Module} module the exporting entry module | ||
| * @param {string} entryName the name of the entrypoint | ||
| * @param {LibraryContext<T>} libraryContext context | ||
| * @returns {void} | ||
| */ | ||
| finishEntryModule( | ||
| module, | ||
| entryName, | ||
| { options, compilation, compilation: { moduleGraph } } | ||
| ) { | ||
| const runtime = getEntryRuntime(compilation, entryName); | ||
| if (options.export) { | ||
| const exportsInfo = moduleGraph.getExportInfo( | ||
| module, | ||
| Array.isArray(options.export) ? options.export[0] : options.export | ||
| ); | ||
| exportsInfo.setUsed(UsageState.Used, runtime); | ||
| exportsInfo.canMangleUse = false; | ||
| } else { | ||
| const exportsInfo = moduleGraph.getExportsInfo(module); | ||
| // If the entry module is commonjs, its exports cannot be mangled | ||
| if (module.buildMeta && module.buildMeta.treatAsCommonJs) { | ||
| exportsInfo.setUsedInUnknownWay(runtime); | ||
| } else { | ||
| exportsInfo.setAllKnownExportsUsed(runtime); | ||
| } | ||
| } | ||
| moduleGraph.addExtraReason(module, "used as library export"); | ||
| } | ||
| /** | ||
| * @param {Chunk} chunk the chunk | ||
| * @param {RuntimeRequirements} set runtime requirements | ||
| * @param {LibraryContext<T>} libraryContext context | ||
| * @returns {void} | ||
| */ | ||
| runtimeRequirements(chunk, set, libraryContext) { | ||
| set.add(RuntimeGlobals.exports); | ||
| } | ||
| /** | ||
| * @param {LibraryOptions} library normalized library option | ||
@@ -108,3 +149,10 @@ * @returns {T | false} preprocess as needed by overriding | ||
| module, | ||
| { moduleGraph, chunk, codeGenerationResults, inlined, inlinedInIIFE }, | ||
| { | ||
| moduleGraph, | ||
| chunk, | ||
| codeGenerationResults, | ||
| inlined, | ||
| inlinedInIIFE, | ||
| runtimeTemplate | ||
| }, | ||
| { options, compilation } | ||
@@ -114,12 +162,2 @@ ) { | ||
| if (!module.buildMeta || !module.buildMeta.exportsType) { | ||
| for (const dependency of module.dependencies) { | ||
| if (dependency instanceof CommonJsSelfReferenceDependency) { | ||
| result.add(`export { ${RuntimeGlobals.exports} as default }`); | ||
| break; | ||
| } | ||
| } | ||
| return result; | ||
| } | ||
| const exportsInfo = options.export | ||
@@ -135,5 +173,3 @@ ? [ | ||
| inlined && !inlinedInIIFE | ||
| ? (module.buildMeta && | ||
| /** @type {GenerationMeta} */ module.buildMeta.exportsFinalName) || | ||
| {} | ||
| ? (module.buildMeta && module.buildMeta.exportsFinalName) || {} | ||
| : {}; | ||
@@ -146,2 +182,6 @@ /** @type {string[]} */ | ||
| const treatAsCommonJs = | ||
| module.buildMeta && module.buildMeta.treatAsCommonJs; | ||
| const skipRenderDefaultExport = Boolean(treatAsCommonJs); | ||
| if (isAsync) { | ||
@@ -153,23 +193,20 @@ result.add( | ||
| const varType = compilation.outputOptions.environment.const | ||
| ? "const" | ||
| : "var"; | ||
| for (const exportInfo of exportsInfo) { | ||
| outer: for (const exportInfo of exportsInfo) { | ||
| if (!exportInfo.provided) continue; | ||
| let shouldContinue = false; | ||
| const originalName = exportInfo.name; | ||
| const reexport = exportInfo.findTarget(moduleGraph, (_m) => true); | ||
| if (skipRenderDefaultExport && originalName === "default") continue; | ||
| if (reexport) { | ||
| const exp = moduleGraph.getExportsInfo(reexport.module); | ||
| const target = exportInfo.findTarget(moduleGraph, (_m) => true); | ||
| if (target) { | ||
| const reexportsInfo = moduleGraph.getExportsInfo(target.module); | ||
| for (const reexportInfo of exp.orderedExports) { | ||
| for (const reexportInfo of reexportsInfo.orderedExports) { | ||
| if ( | ||
| reexportInfo.provided === false && | ||
| reexportInfo.name !== "default" && | ||
| reexportInfo.name === /** @type {string[]} */ (reexport.export)[0] | ||
| reexportInfo.name === /** @type {string[]} */ (target.export)[0] | ||
| ) { | ||
| shouldContinue = true; | ||
| continue outer; | ||
| } | ||
@@ -179,5 +216,2 @@ } | ||
| if (shouldContinue) continue; | ||
| const originalName = exportInfo.name; | ||
| const usedName = | ||
@@ -188,11 +222,14 @@ /** @type {string} */ | ||
| const definition = definitions[usedName]; | ||
| const finalName = | ||
| definition || | ||
| `${RuntimeGlobals.exports}${Template.toIdentifier(originalName)}`; | ||
| if (!definition) { | ||
| /** @type {string | undefined} */ | ||
| let finalName; | ||
| if (definition) { | ||
| finalName = definition; | ||
| } else { | ||
| finalName = `${RuntimeGlobals.exports}${Template.toIdentifier(originalName)}`; | ||
| result.add( | ||
| `${varType} ${finalName} = ${RuntimeGlobals.exports}${propertyAccess([ | ||
| usedName | ||
| ])};\n` | ||
| `${runtimeTemplate.renderConst()} ${finalName} = ${RuntimeGlobals.exports}${propertyAccess( | ||
| [usedName] | ||
| )};\n` | ||
| ); | ||
@@ -215,3 +252,5 @@ } | ||
| const name = `${RuntimeGlobals.exports}${Template.toIdentifier(originalName)}`; | ||
| result.add(`${varType} ${name} = ${finalName};\n`); | ||
| result.add( | ||
| `${runtimeTemplate.renderConst()} ${name} = ${finalName};\n` | ||
| ); | ||
| shortHandedExports.push(`${name} as ${originalName}`); | ||
@@ -233,2 +272,6 @@ } else { | ||
| if (treatAsCommonJs) { | ||
| shortHandedExports.push(`${RuntimeGlobals.exports} as default`); | ||
| } | ||
| if (shortHandedExports.length > 0) { | ||
@@ -239,3 +282,5 @@ result.add(`export { ${shortHandedExports.join(", ")} };\n`); | ||
| for (const [exportName, final] of exports) { | ||
| result.add(`export ${varType} ${exportName} = ${final};\n`); | ||
| result.add( | ||
| `export ${runtimeTemplate.renderConst()} ${exportName} = ${final};\n` | ||
| ); | ||
| } | ||
@@ -242,0 +287,0 @@ |
@@ -20,3 +20,2 @@ /* | ||
| /** @typedef {import("../Compilation").ChunkHashContext} ChunkHashContext */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../javascript/JavascriptModulesPlugin").RenderContext} RenderContext */ | ||
@@ -23,0 +22,0 @@ /** @typedef {import("../util/Hash")} Hash */ |
@@ -19,10 +19,8 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").LibraryType} LibraryType */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../javascript/JavascriptModulesPlugin").RenderContext} RenderContext */ | ||
| /** @typedef {import("../ExternalModule").RequestRecord} RequestRecord */ | ||
| /** @typedef {import("../util/Hash")} Hash */ | ||
| /** | ||
| * @template T | ||
| * @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} | ||
| * LibraryContext<T> | ||
| * @typedef {import("./AbstractLibraryPlugin").LibraryContext<T>} LibraryContext<T> | ||
| */ | ||
@@ -37,5 +35,7 @@ | ||
| /** @typedef {string | string[]} Accessor */ | ||
| /** | ||
| * @param {string|undefined} base the path prefix | ||
| * @param {string|string[]} accessor the accessor | ||
| * @param {Accessor} accessor the accessor | ||
| * @param {string=} joinWith the element separator | ||
@@ -60,4 +60,2 @@ * @returns {string} the path | ||
| /** @typedef {string | string[] | LibraryCustomUmdObject} UmdLibraryPluginName */ | ||
| /** | ||
@@ -200,6 +198,5 @@ * @typedef {object} UmdLibraryPluginOptions | ||
| } | ||
| return `root${accessorToObjectAccess( | ||
| /** @type {string[]} */ | ||
| ([...(Array.isArray(request) ? request : [request])]) | ||
| )}`; | ||
| return `root${accessorToObjectAccess([ | ||
| ...(Array.isArray(request) ? request : [request]) | ||
| ])}`; | ||
| }) | ||
@@ -257,3 +254,3 @@ .join(", ") | ||
| /** | ||
| * @param {string| string[]} library library name | ||
| * @param {Accessor} library library name | ||
| * @returns {string} stringified library name | ||
@@ -265,6 +262,3 @@ */ | ||
| /** @type {string} */ | ||
| ( | ||
| /** @type {string[]} */ | ||
| ([...(Array.isArray(library) ? library : [library])]).pop() | ||
| ) | ||
| ([...(Array.isArray(library) ? library : [library])].pop()) | ||
| ) | ||
@@ -333,3 +327,3 @@ ); | ||
| ` exports[${libraryName( | ||
| /** @type {string | string[]} */ | ||
| /** @type {Accessor} */ | ||
| (names.commonjs || names.root) | ||
@@ -342,3 +336,3 @@ )}] = factory(${externalsRequireArray( | ||
| "root", | ||
| /** @type {string | string[]} */ | ||
| /** @type {Accessor} */ | ||
| (names.root || names.commonjs) | ||
@@ -345,0 +339,0 @@ ) |
@@ -14,3 +14,2 @@ /* | ||
| /** @typedef {import("./Compiler")} Compiler */ | ||
| /** @typedef {import("./ModuleFilenameHelpers").Matcher} Matcher */ | ||
| /** @typedef {import("./ModuleFilenameHelpers").MatchObject} MatchObject */ | ||
@@ -43,11 +42,3 @@ | ||
| if (!options.test) { | ||
| /** @type {Partial<RegExp>} */ | ||
| const defaultTrueMockRegExp = { | ||
| test: () => true | ||
| }; | ||
| /** @type {RegExp} */ | ||
| options.test = | ||
| /** @type {RegExp} */ | ||
| (defaultTrueMockRegExp); | ||
| options.test = () => true; | ||
| } | ||
@@ -54,0 +45,0 @@ this.options = options; |
@@ -13,5 +13,6 @@ /* | ||
| /** @typedef {import("./Logger").LogTypeEnum} LogTypeEnum */ | ||
| /** @typedef {import("./Logger").Args} Args */ | ||
| /** @typedef {(item: string) => boolean} FilterFunction */ | ||
| /** @typedef {(value: string, type: LogTypeEnum, args?: EXPECTED_ANY[]) => void} LoggingFunction */ | ||
| /** @typedef {(value: string, type: LogTypeEnum, args?: Args) => void} LoggingFunction */ | ||
@@ -22,14 +23,14 @@ /** | ||
| * @property {() => void} trace | ||
| * @property {(...args: EXPECTED_ANY[]) => void} info | ||
| * @property {(...args: EXPECTED_ANY[]) => void} log | ||
| * @property {(...args: EXPECTED_ANY[]) => void} warn | ||
| * @property {(...args: EXPECTED_ANY[]) => void} error | ||
| * @property {(...args: EXPECTED_ANY[]) => void=} debug | ||
| * @property {(...args: EXPECTED_ANY[]) => void=} group | ||
| * @property {(...args: EXPECTED_ANY[]) => void=} groupCollapsed | ||
| * @property {(...args: EXPECTED_ANY[]) => void=} groupEnd | ||
| * @property {(...args: EXPECTED_ANY[]) => void=} status | ||
| * @property {(...args: EXPECTED_ANY[]) => void=} profile | ||
| * @property {(...args: EXPECTED_ANY[]) => void=} profileEnd | ||
| * @property {(...args: EXPECTED_ANY[]) => void=} logTime | ||
| * @property {(...args: Args) => void} info | ||
| * @property {(...args: Args) => void} log | ||
| * @property {(...args: Args) => void} warn | ||
| * @property {(...args: Args) => void} error | ||
| * @property {(...args: Args) => void=} debug | ||
| * @property {(...args: Args) => void=} group | ||
| * @property {(...args: Args) => void=} groupCollapsed | ||
| * @property {(...args: Args) => void=} groupEnd | ||
| * @property {(...args: Args) => void=} status | ||
| * @property {(...args: Args) => void=} profile | ||
| * @property {(...args: Args) => void=} profileEnd | ||
| * @property {(...args: Args) => void=} logTime | ||
| */ | ||
@@ -99,3 +100,3 @@ | ||
| * @param {LogTypeEnum} type type of the log entry | ||
| * @param {EXPECTED_ANY[]=} args arguments of the log entry | ||
| * @param {Args=} args arguments of the log entry | ||
| * @returns {void} | ||
@@ -102,0 +103,0 @@ */ |
+12
-10
@@ -38,5 +38,7 @@ /* | ||
| /** @typedef {EXPECTED_ANY[]} Args */ | ||
| class WebpackLogger { | ||
| /** | ||
| * @param {(type: LogTypeEnum, args?: EXPECTED_ANY[]) => void} log log function | ||
| * @param {(type: LogTypeEnum, args?: Args) => void} log log function | ||
| * @param {(name: string | (() => string)) => WebpackLogger} getChildLogger function to create child logger | ||
@@ -50,3 +52,3 @@ */ | ||
| /** | ||
| * @param {...EXPECTED_ANY} args args | ||
| * @param {Args} args args | ||
| */ | ||
@@ -58,3 +60,3 @@ error(...args) { | ||
| /** | ||
| * @param {...EXPECTED_ANY} args args | ||
| * @param {Args} args args | ||
| */ | ||
@@ -66,3 +68,3 @@ warn(...args) { | ||
| /** | ||
| * @param {...EXPECTED_ANY} args args | ||
| * @param {Args} args args | ||
| */ | ||
@@ -74,3 +76,3 @@ info(...args) { | ||
| /** | ||
| * @param {...EXPECTED_ANY} args args | ||
| * @param {Args} args args | ||
| */ | ||
@@ -82,3 +84,3 @@ log(...args) { | ||
| /** | ||
| * @param {...EXPECTED_ANY} args args | ||
| * @param {Args} args args | ||
| */ | ||
@@ -91,3 +93,3 @@ debug(...args) { | ||
| * @param {EXPECTED_ANY} assertion assertion | ||
| * @param {...EXPECTED_ANY} args args | ||
| * @param {Args} args args | ||
| */ | ||
@@ -109,3 +111,3 @@ assert(assertion, ...args) { | ||
| /** | ||
| * @param {...EXPECTED_ANY} args args | ||
| * @param {Args} args args | ||
| */ | ||
@@ -117,3 +119,3 @@ status(...args) { | ||
| /** | ||
| * @param {...EXPECTED_ANY} args args | ||
| * @param {Args} args args | ||
| */ | ||
@@ -125,3 +127,3 @@ group(...args) { | ||
| /** | ||
| * @param {...EXPECTED_ANY} args args | ||
| * @param {Args} args args | ||
| */ | ||
@@ -128,0 +130,0 @@ groupCollapsed(...args) { |
@@ -9,3 +9,3 @@ /* | ||
| /** | ||
| * @param {Array<number>} array array of numbers | ||
| * @param {number[]} array array of numbers | ||
| * @returns {number} sum of all numbers in array | ||
@@ -12,0 +12,0 @@ */ |
+8
-19
@@ -14,3 +14,2 @@ /* | ||
| /** @typedef {import("tapable").Tap} Tap */ | ||
| /** @typedef {import("webpack-sources").ConcatSource} ConcatSource */ | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
@@ -23,15 +22,9 @@ /** @typedef {import("../declarations/WebpackOptions").Output} OutputOptions */ | ||
| /** @typedef {import("./Compilation").InterpolatedPathAndAssetInfo} InterpolatedPathAndAssetInfo */ | ||
| /** @typedef {import("./Module")} Module} */ | ||
| /** @typedef {import("./util/Hash")} Hash} */ | ||
| /** @typedef {import("./DependencyTemplates")} DependencyTemplates} */ | ||
| /** @typedef {import("./javascript/JavascriptModulesPlugin").RenderContext} RenderContext} */ | ||
| /** @typedef {import("./javascript/JavascriptModulesPlugin").RenderBootstrapContext} RenderBootstrapContext} */ | ||
| /** @typedef {import("./javascript/JavascriptModulesPlugin").ChunkHashContext} ChunkHashContext} */ | ||
| /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate} */ | ||
| /** @typedef {import("./ModuleGraph")} ModuleGraph} */ | ||
| /** @typedef {import("./ChunkGraph")} ChunkGraph} */ | ||
| /** @typedef {import("./Template").RenderManifestOptions} RenderManifestOptions} */ | ||
| /** @typedef {import("./Template").RenderManifestEntry} RenderManifestEntry} */ | ||
| /** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath} */ | ||
| /** @typedef {import("./TemplatedPathPlugin").PathData} PathData} */ | ||
| /** @typedef {import("./util/Hash")} Hash */ | ||
| /** @typedef {import("./DependencyTemplates")} DependencyTemplates */ | ||
| /** @typedef {import("./javascript/JavascriptModulesPlugin").RenderBootstrapContext} RenderBootstrapContext */ | ||
| /** @typedef {import("./Template").RenderManifestOptions} RenderManifestOptions */ | ||
| /** @typedef {import("./Template").RenderManifestEntry} RenderManifestEntry */ | ||
| /** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */ | ||
| /** @typedef {import("./TemplatedPathPlugin").PathData} PathData */ | ||
| /** | ||
@@ -329,7 +322,3 @@ * @template T | ||
| */ (options) => | ||
| compilation.getAssetPath( | ||
| /** @type {string} */ | ||
| (compilation.outputOptions.publicPath), | ||
| options | ||
| ), | ||
| compilation.getAssetPath(compilation.outputOptions.publicPath, options), | ||
| "MainTemplate.getPublicPath is deprecated (use Compilation.getAssetPath(compilation.outputOptions.publicPath, options) instead)", | ||
@@ -336,0 +325,0 @@ "DEP_WEBPACK_MAIN_TEMPLATE_GET_PUBLIC_PATH" |
+32
-20
@@ -20,3 +20,3 @@ /* | ||
| /** @typedef {import("../declarations/WebpackOptions").ResolveOptions} ResolveOptions */ | ||
| /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */ | ||
| /** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */ | ||
| /** @typedef {import("./Chunk")} Chunk */ | ||
@@ -34,3 +34,2 @@ /** @typedef {import("./ChunkGraph").ModuleId} ModuleId */ | ||
| /** @typedef {import("./DependencyTemplates")} DependencyTemplates */ | ||
| /** @typedef {import("./ExportsInfo").UsageStateType} UsageStateType */ | ||
| /** @typedef {import("./FileSystemInfo")} FileSystemInfo */ | ||
@@ -40,2 +39,3 @@ /** @typedef {import("./FileSystemInfo").Snapshot} Snapshot */ | ||
| /** @typedef {import("./ModuleTypeConstants").ModuleTypes} ModuleTypes */ | ||
| /** @typedef {import("./ModuleGraph").OptimizationBailouts} OptimizationBailouts */ | ||
| /** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */ | ||
@@ -45,2 +45,6 @@ /** @typedef {import("./RequestShortener")} RequestShortener */ | ||
| /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */ | ||
| /** | ||
| * @template T | ||
| * @typedef {import("./InitFragment")<T>} InitFragment | ||
| */ | ||
| /** @typedef {import("./WebpackError")} WebpackError */ | ||
@@ -62,7 +66,2 @@ /** @typedef {import("./json/JsonData")} JsonData */ | ||
| /** | ||
| * @template T | ||
| * @typedef {import("./util/SortableSet")<T>} SortableSet<T> | ||
| */ | ||
| /** | ||
| * @typedef {object} SourceContext | ||
@@ -102,6 +101,12 @@ * @property {DependencyTemplates} dependencyTemplates the dependency templates | ||
| /** @typedef {Map<"topLevelDeclarations", Set<string>> & Map<"chunkInitFragments", InitFragment<EXPECTED_ANY>[]>} KnownCodeGenerationResultDataForJavascriptModules */ | ||
| /** @typedef {Map<"url", { ["css-url"]: string }>} KnownCodeGenerationResultDataForCssModules */ | ||
| /** @typedef {Map<"filename", string> & Map<"assetInfo", AssetInfo> & Map<"fullContentHash", string>} KnownCodeGenerationResultDataForAssetModules */ | ||
| /** @typedef {Map<"share-init", [{ shareScope: string, initStage: number, init: string }]>} KnownCodeGenerationResultForSharing */ | ||
| /** @typedef {KnownCodeGenerationResultDataForJavascriptModules & KnownCodeGenerationResultDataForCssModules & KnownCodeGenerationResultDataForAssetModules & KnownCodeGenerationResultForSharing & Map<string, EXPECTED_ANY>} CodeGenerationResultData */ | ||
| /** | ||
| * @typedef {object} CodeGenerationResult | ||
| * @property {Map<string, Source>} sources the resulting sources for all source types | ||
| * @property {Map<string, TODO>=} data the resulting data for all source types | ||
| * @property {CodeGenerationResultData=} data the resulting data for all source types | ||
| * @property {ReadOnlyRuntimeRequirements | null} runtimeRequirements the runtime requirements | ||
@@ -122,2 +127,3 @@ * @property {string=} hash a hash of the code generation result (will be automatically calculated from sources and runtimeRequirements if not provided) | ||
| * @property {boolean=} strictHarmonyModule | ||
| * @property {boolean=} treatAsCommonJs | ||
| * @property {boolean=} async | ||
@@ -131,2 +137,4 @@ * @property {boolean=} sideEffectFree | ||
| /** @typedef {LazySet<string>} FileSystemDependencies */ | ||
| /** | ||
@@ -142,6 +150,6 @@ * @typedef {object} KnownBuildInfo | ||
| * @property {string=} resourceIntegrity using in HttpUriPlugin | ||
| * @property {LazySet<string>=} fileDependencies using in NormalModule | ||
| * @property {LazySet<string>=} contextDependencies using in NormalModule | ||
| * @property {LazySet<string>=} missingDependencies using in NormalModule | ||
| * @property {LazySet<string>=} buildDependencies using in NormalModule | ||
| * @property {FileSystemDependencies=} fileDependencies using in NormalModule | ||
| * @property {FileSystemDependencies=} contextDependencies using in NormalModule | ||
| * @property {FileSystemDependencies=} missingDependencies using in NormalModule | ||
| * @property {FileSystemDependencies=} buildDependencies using in NormalModule | ||
| * @property {ValueCacheVersions=} valueDependencies using in NormalModule | ||
@@ -163,3 +171,4 @@ * @property {Record<string, Source>=} assets using in NormalModule | ||
| /** @typedef {Map<string, string | Set<string>>} ValueCacheVersions */ | ||
| /** @typedef {string | Set<string>} ValueCacheVersion */ | ||
| /** @typedef {Map<string, ValueCacheVersion>} ValueCacheVersions */ | ||
@@ -206,2 +215,5 @@ /** | ||
| /** @typedef {string} LibIdent */ | ||
| /** @typedef {string} NameForCondition */ | ||
| /** @typedef {(requestShortener: RequestShortener) => string} OptimizationBailoutFunction */ | ||
@@ -426,3 +438,3 @@ | ||
| * @deprecated | ||
| * @returns {(string | OptimizationBailoutFunction)[]} list | ||
| * @returns {OptimizationBailouts} list | ||
| */ | ||
@@ -982,3 +994,3 @@ get optimizationBailout() { | ||
| * @param {LibIdentOptions} options options | ||
| * @returns {string | null} an identifier for library inclusion | ||
| * @returns {LibIdent | null} an identifier for library inclusion | ||
| */ | ||
@@ -990,3 +1002,3 @@ libIdent(options) { | ||
| /** | ||
| * @returns {string | null} absolute path which should be used for condition matching (usually the resource path) | ||
| * @returns {NameForCondition | null} absolute path which should be used for condition matching (usually the resource path) | ||
| */ | ||
@@ -1108,6 +1120,6 @@ nameForCondition() { | ||
| /** | ||
| * @param {LazySet<string>} fileDependencies set where file dependencies are added to | ||
| * @param {LazySet<string>} contextDependencies set where context dependencies are added to | ||
| * @param {LazySet<string>} missingDependencies set where missing dependencies are added to | ||
| * @param {LazySet<string>} buildDependencies set where build dependencies are added to | ||
| * @param {FileSystemDependencies} fileDependencies set where file dependencies are added to | ||
| * @param {FileSystemDependencies} contextDependencies set where context dependencies are added to | ||
| * @param {FileSystemDependencies} missingDependencies set where missing dependencies are added to | ||
| * @param {FileSystemDependencies} buildDependencies set where build dependencies are added to | ||
| */ | ||
@@ -1114,0 +1126,0 @@ addCacheDependencies( |
@@ -26,3 +26,3 @@ /* | ||
| * @property {string} issuer | ||
| * @property {IssuerLayer=} issuerLayer | ||
| * @property {IssuerLayer} issuerLayer | ||
| * @property {string=} compiler | ||
@@ -29,0 +29,0 @@ */ |
@@ -13,3 +13,2 @@ /* | ||
| /** @typedef {import("../declarations/WebpackOptions").DevtoolModuleFilenameTemplate} DevtoolModuleFilenameTemplate */ | ||
| /** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */ | ||
@@ -20,3 +19,3 @@ /** @typedef {import("./ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {string | RegExp | (string | RegExp)[]} Matcher */ | ||
| /** @typedef {string | RegExp | ((str: string) => boolean) | (string | RegExp | ((str: string) => boolean))[]} Matcher */ | ||
| /** @typedef {{ test?: Matcher, include?: Matcher, exclude?: Matcher }} MatchObject */ | ||
@@ -99,6 +98,6 @@ | ||
| * @param {Record<string, () => T>} obj the object to convert to a lazy access object | ||
| * @returns {T} the lazy access object | ||
| * @returns {Record<string, T>} the lazy access object | ||
| */ | ||
| const lazyObject = (obj) => { | ||
| const newObj = /** @type {T} */ ({}); | ||
| const newObj = /** @type {Record<string, T>} */ ({}); | ||
| for (const key of Object.keys(obj)) { | ||
@@ -123,4 +122,17 @@ const fn = obj[key]; | ||
| const SQUARE_BRACKET_TAG_REGEXP = /\[\\*([\w-]+)\\*\]/gi; | ||
| /** @typedef {((context: TODO) => string)} ModuleFilenameTemplateFunction */ | ||
| /** | ||
| * @typedef {object} ModuleFilenameTemplateContext | ||
| * @property {string} identifier the identifier of the module | ||
| * @property {string} shortIdentifier the shortened identifier of the module | ||
| * @property {string} resource the resource of the module request | ||
| * @property {string} resourcePath the resource path of the module request | ||
| * @property {string} absoluteResourcePath the absolute resource path of the module request | ||
| * @property {string} loaders the loaders of the module request | ||
| * @property {string} allLoaders the all loaders of the module request | ||
| * @property {string} query the query of the module identifier | ||
| * @property {string} moduleId the module id of the module | ||
| * @property {string} hash the hash of the module identifier | ||
| * @property {string} namespace the module namespace | ||
| */ | ||
| /** @typedef {((context: ModuleFilenameTemplateContext) => string)} ModuleFilenameTemplateFunction */ | ||
| /** @typedef {string | ModuleFilenameTemplateFunction} ModuleFilenameTemplate */ | ||
@@ -197,15 +209,18 @@ | ||
| return opts.moduleFilenameTemplate( | ||
| lazyObject({ | ||
| identifier, | ||
| shortIdentifier, | ||
| resource, | ||
| resourcePath: memoize(resourcePath), | ||
| absoluteResourcePath: memoize(absoluteResourcePath), | ||
| loaders: memoize(loaders), | ||
| allLoaders: memoize(allLoaders), | ||
| query: memoize(query), | ||
| moduleId: memoize(moduleId), | ||
| hash: memoize(hash), | ||
| namespace: () => opts.namespace | ||
| }) | ||
| /** @type {ModuleFilenameTemplateContext} */ | ||
| ( | ||
| lazyObject({ | ||
| identifier, | ||
| shortIdentifier, | ||
| resource, | ||
| resourcePath: memoize(resourcePath), | ||
| absoluteResourcePath: memoize(absoluteResourcePath), | ||
| loaders: memoize(loaders), | ||
| allLoaders: memoize(allLoaders), | ||
| query: memoize(query), | ||
| moduleId: memoize(moduleId), | ||
| hash: memoize(hash), | ||
| namespace: () => opts.namespace | ||
| }) | ||
| ) | ||
| ); | ||
@@ -327,9 +342,11 @@ } | ||
| if (!test) return true; | ||
| if (Array.isArray(test)) { | ||
| return test.some((test) => matchPart(str, test)); | ||
| } | ||
| if (typeof test === "string") { | ||
| if (test instanceof RegExp) { | ||
| return test.test(str); | ||
| } else if (typeof test === "string") { | ||
| return str.startsWith(test); | ||
| } else if (typeof test === "function") { | ||
| return test(str); | ||
| } | ||
| return test.test(str); | ||
| return test.some((test) => matchPart(str, test)); | ||
| }; | ||
@@ -336,0 +353,0 @@ |
+30
-16
@@ -20,2 +20,3 @@ /* | ||
| /** @typedef {import("./ExportsInfo").ExportInfo} ExportInfo */ | ||
| /** @typedef {import("./ExportsInfo").ExportInfoName} ExportInfoName */ | ||
| /** @typedef {import("./Module")} Module */ | ||
@@ -41,3 +42,3 @@ /** @typedef {import("./ModuleProfile")} ModuleProfile */ | ||
| * @param {(connection: ModuleGraphConnection) => T} getKey function to extract key from connection | ||
| * @returns {readonly Map<T, readonly ModuleGraphConnection[]>} mapped by key | ||
| * @returns {ReadonlyMap<T, ReadonlyArray<ModuleGraphConnection>>} mapped by key | ||
| */ | ||
@@ -73,3 +74,3 @@ const getConnectionsByKey = (set, getKey) => { | ||
| * @param {SortableSet<ModuleGraphConnection>} set input | ||
| * @returns {readonly Map<Module | undefined | null, readonly ModuleGraphConnection[]>} mapped by origin module | ||
| * @returns {ReadonlyMap<Module | undefined | null, ReadonlyArray<ModuleGraphConnection>>} mapped by origin module | ||
| */ | ||
@@ -81,3 +82,3 @@ const getConnectionsByOriginModule = (set) => | ||
| * @param {SortableSet<ModuleGraphConnection>} set input | ||
| * @returns {readonly Map<Module | undefined, readonly ModuleGraphConnection[]>} mapped by module | ||
| * @returns {ReadonlyMap<Module | undefined, ReadonlyArray<ModuleGraphConnection>>} mapped by module | ||
| */ | ||
@@ -89,2 +90,4 @@ const getConnectionsByModule = (set) => | ||
| /** @typedef {SortableSet<ModuleGraphConnection>} OutgoingConnections */ | ||
| /** @typedef {Module | null | undefined} Issuer */ | ||
| /** @typedef {(string | OptimizationBailoutFunction)[]} OptimizationBailouts */ | ||
@@ -97,5 +100,5 @@ class ModuleGraphModule { | ||
| this.outgoingConnections = undefined; | ||
| /** @type {Module | null | undefined} */ | ||
| /** @type {Issuer} */ | ||
| this.issuer = undefined; | ||
| /** @type {(string | OptimizationBailoutFunction)[]} */ | ||
| /** @type {OptimizationBailouts} */ | ||
| this.optimizationBailout = []; | ||
@@ -122,4 +125,15 @@ /** @type {ExportsInfo} */ | ||
| /** @typedef {EXPECTED_OBJECT} MetaKey */ | ||
| /** @typedef {TODO} Meta */ | ||
| /** @typedef {import("./dependencies/CommonJsExportRequireDependency").idsSymbol} CommonJsExportRequireDependencyIDsSymbol */ | ||
| /** @typedef {import("./dependencies/HarmonyImportSpecifierDependency").idsSymbol} HarmonyImportSpecifierDependencyIDsSymbol */ | ||
| /** @typedef {import("./dependencies/HarmonyExportImportedSpecifierDependency").idsSymbol} HarmonyExportImportedSpecifierDependencyIDsSymbol */ | ||
| /** | ||
| * @typedef {object} KnownMeta | ||
| * @property {Map<Module, string>=} importVarMap | ||
| * @property {Map<Module, string>=} deferredImportVarMap | ||
| */ | ||
| /** @typedef {KnownMeta & Record<CommonJsExportRequireDependencyIDsSymbol | HarmonyImportSpecifierDependencyIDsSymbol | HarmonyExportImportedSpecifierDependencyIDsSymbol, string[]> & Record<string, EXPECTED_ANY>} Meta */ | ||
| class ModuleGraph { | ||
@@ -577,3 +591,3 @@ constructor() { | ||
| * @param {Module} module the module | ||
| * @returns {readonly Map<Module | undefined | null, readonly ModuleGraphConnection[]>} reasons why a module is included, in a map by source module | ||
| * @returns {ReadonlyMap<Module | undefined | null, ReadonlyArray<ModuleGraphConnection>>} reasons why a module is included, in a map by source module | ||
| */ | ||
@@ -587,3 +601,3 @@ getIncomingConnectionsByOriginModule(module) { | ||
| * @param {Module} module the module | ||
| * @returns {readonly Map<Module | undefined, readonly ModuleGraphConnection[]> | undefined} connections to modules, in a map by module | ||
| * @returns {ReadonlyMap<Module | undefined, ReadonlyArray<ModuleGraphConnection>> | undefined} connections to modules, in a map by module | ||
| */ | ||
@@ -618,3 +632,3 @@ getOutgoingConnectionsByModule(module) { | ||
| * @param {Module} module the module | ||
| * @returns {Module | null | undefined} the issuer module | ||
| * @returns {Issuer} the issuer module | ||
| */ | ||
@@ -648,3 +662,3 @@ getIssuer(module) { | ||
| * @param {Module} module the module | ||
| * @returns {(string | OptimizationBailoutFunction)[]} optimization bailouts | ||
| * @returns {OptimizationBailouts} optimization bailouts | ||
| */ | ||
@@ -658,3 +672,3 @@ getOptimizationBailout(module) { | ||
| * @param {Module} module the module | ||
| * @returns {true | string[] | null} the provided exports | ||
| * @returns {null | true | ExportInfoName[]} the provided exports | ||
| */ | ||
@@ -668,3 +682,3 @@ getProvidedExports(module) { | ||
| * @param {Module} module the module | ||
| * @param {string | string[]} exportName a name of an export | ||
| * @param {ExportInfoName | ExportInfoName[]} exportName a name of an export | ||
| * @returns {boolean | null} true, if the export is provided by the module. | ||
@@ -867,3 +881,3 @@ * null, if it's unknown. | ||
| if (meta === undefined) { | ||
| meta = Object.create(null); | ||
| meta = /** @type {Meta} */ (Object.create(null)); | ||
| this._metaMap.set(thing, meta); | ||
@@ -896,6 +910,6 @@ } | ||
| /** | ||
| * @template T | ||
| * @template {EXPECTED_ANY[]} T | ||
| * @template R | ||
| * @param {(moduleGraph: ModuleGraph, ...args: T[]) => R} fn computer | ||
| * @param {...T} args arguments | ||
| * @param {(moduleGraph: ModuleGraph, ...args: T) => R} fn computer | ||
| * @param {T} args arguments | ||
| * @returns {R} computed value or cached | ||
@@ -902,0 +916,0 @@ */ |
@@ -21,3 +21,2 @@ /* | ||
| /** @typedef {import("./ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("./ModuleTemplate")} ModuleTemplate */ | ||
| /** @typedef {import("./RequestShortener")} RequestShortener */ | ||
@@ -24,0 +23,0 @@ |
@@ -14,7 +14,5 @@ /* | ||
| /** @typedef {import("./Chunk")} Chunk */ | ||
| /** @typedef {import("./ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("./Compilation")} Compilation */ | ||
| /** @typedef {import("./DependencyTemplates")} DependencyTemplates */ | ||
| /** @typedef {import("./Module")} Module */ | ||
| /** @typedef {import("./ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */ | ||
@@ -21,0 +19,0 @@ /** @typedef {import("./javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */ |
@@ -93,2 +93,8 @@ /* | ||
| /** | ||
| * @type {Readonly<"asset/bytes">} | ||
| * This is the module type used for assets that are imported as Uint8Array. | ||
| */ | ||
| const ASSET_MODULE_TYPE_BYTES = "asset/bytes"; | ||
| /** | ||
| * @type {Readonly<"asset/raw-data-url">} | ||
@@ -141,3 +147,3 @@ * TODO: Document what this asset type is for. See css-loader tests for its usage. | ||
| /** @typedef {"webassembly/async" | "webassembly/sync"} WebAssemblyModuleTypes */ | ||
| /** @typedef {"css" | "css/global" | "css/module"} CSSModuleTypes */ | ||
| /** @typedef {"css" | "css/global" | "css/module" | "css/auto"} CSSModuleTypes */ | ||
| /** @typedef {"asset" | "asset/inline" | "asset/resource" | "asset/source" | "asset/raw-data-url"} AssetModuleTypes */ | ||
@@ -149,2 +155,3 @@ /** @typedef {"runtime" | "fallback-module" | "remote-module" | "provide-module" | "consume-shared-module" | "lazy-compilation-proxy"} WebpackModuleTypes */ | ||
| module.exports.ASSET_MODULE_TYPE = ASSET_MODULE_TYPE; | ||
| module.exports.ASSET_MODULE_TYPE_BYTES = ASSET_MODULE_TYPE_BYTES; | ||
| module.exports.ASSET_MODULE_TYPE_INLINE = ASSET_MODULE_TYPE_INLINE; | ||
@@ -154,2 +161,3 @@ module.exports.ASSET_MODULE_TYPE_RAW_DATA_URL = ASSET_MODULE_TYPE_RAW_DATA_URL; | ||
| module.exports.ASSET_MODULE_TYPE_SOURCE = ASSET_MODULE_TYPE_SOURCE; | ||
| /** @type {CSSModuleTypes[]} */ | ||
| module.exports.CSS_MODULES = [ | ||
@@ -165,2 +173,3 @@ CSS_MODULE_TYPE, | ||
| module.exports.CSS_MODULE_TYPE_MODULE = CSS_MODULE_TYPE_MODULE; | ||
| /** @type {JavaScriptModuleTypes[]} */ | ||
| module.exports.JAVASCRIPT_MODULES = [ | ||
@@ -175,2 +184,3 @@ JAVASCRIPT_MODULE_TYPE_AUTO, | ||
| module.exports.JSON_MODULE_TYPE = JSON_MODULE_TYPE; | ||
| /** @type {WebAssemblyModuleTypes[]} */ | ||
| module.exports.WEBASSEMBLY_MODULES = [ | ||
@@ -177,0 +187,0 @@ WEBASSEMBLY_MODULE_TYPE_SYNC, |
+23
-15
@@ -17,9 +17,21 @@ /* | ||
| /** @template T @typedef {import("tapable").AsyncSeriesHook<T>} AsyncSeriesHook<T> */ | ||
| /** @template T @template R @typedef {import("tapable").SyncBailHook<T, R>} SyncBailHook<T, R> */ | ||
| /** @typedef {import("../declarations/WebpackOptions").WebpackOptions} WebpackOptions */ | ||
| /** | ||
| * @template T | ||
| * @typedef {import("tapable").AsyncSeriesHook<T>} AsyncSeriesHook<T> | ||
| */ | ||
| /** | ||
| * @template T | ||
| * @template R | ||
| * @typedef {import("tapable").SyncBailHook<T, R>} SyncBailHook<T, R> | ||
| */ | ||
| /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */ | ||
| /** @typedef {import("../declarations/WebpackOptions").WatchOptions} WatchOptions */ | ||
| /** @typedef {import("./Compiler")} Compiler */ | ||
| /** | ||
| * @template T | ||
| * @template [R=void] | ||
| * @typedef {import("./webpack").Callback<T, R>} Callback | ||
| */ | ||
| /** @typedef {import("./webpack").ErrorCallback} ErrorCallback */ | ||
| /** @typedef {import("./Stats")} Stats */ | ||
| /** @typedef {import("./Watching")} Watching */ | ||
| /** @typedef {import("./logging/Logger").Logger} Logger */ | ||
@@ -32,12 +44,6 @@ /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */ | ||
| /** | ||
| * @template T | ||
| * @callback Callback | ||
| * @param {Error | null} err | ||
| * @param {T=} result | ||
| */ | ||
| /** | ||
| * @callback RunWithDependenciesHandler | ||
| * @param {Compiler} compiler | ||
| * @param {Callback<MultiStats>} callback | ||
| * @returns {void} | ||
| */ | ||
@@ -586,7 +592,8 @@ | ||
| * @param {Callback<MultiStats>} handler signals when the call finishes | ||
| * @returns {MultiWatching} a compiler watcher | ||
| * @returns {MultiWatching | undefined} a compiler watcher | ||
| */ | ||
| watch(watchOptions, handler) { | ||
| if (this.running) { | ||
| return handler(new ConcurrentCompilationError()); | ||
| handler(new ConcurrentCompilationError()); | ||
| return; | ||
| } | ||
@@ -627,3 +634,4 @@ this.running = true; | ||
| if (this.running) { | ||
| return callback(new ConcurrentCompilationError()); | ||
| callback(new ConcurrentCompilationError()); | ||
| return; | ||
| } | ||
@@ -656,3 +664,3 @@ this.running = true; | ||
| /** | ||
| * @param {Callback<void>} callback signals when the compiler closes | ||
| * @param {ErrorCallback} callback signals when the compiler closes | ||
| * @returns {void} | ||
@@ -659,0 +667,0 @@ */ |
+6
-10
@@ -12,10 +12,4 @@ /* | ||
| /** @typedef {import("./Watching")} Watching */ | ||
| /** @typedef {import("./webpack").ErrorCallback} ErrorCallback */ | ||
| /** | ||
| * @template T | ||
| * @callback Callback | ||
| * @param {(Error | null)=} err | ||
| * @param {T=} result | ||
| */ | ||
| class MultiWatching { | ||
@@ -32,3 +26,3 @@ /** | ||
| /** | ||
| * @param {Callback<void>=} callback signals when the build has completed again | ||
| * @param {ErrorCallback=} callback signals when the build has completed again | ||
| * @returns {void} | ||
@@ -41,3 +35,5 @@ */ | ||
| (watching, callback) => watching.invalidate(callback), | ||
| callback | ||
| (err) => { | ||
| callback(err); | ||
| } | ||
| ); | ||
@@ -64,3 +60,3 @@ } else { | ||
| /** | ||
| * @param {Callback<void>} callback signals when the watcher is closed | ||
| * @param {ErrorCallback} callback signals when the watcher is closed | ||
| * @returns {void} | ||
@@ -67,0 +63,0 @@ */ |
@@ -13,2 +13,3 @@ /* | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */ | ||
@@ -63,3 +64,3 @@ /** | ||
| * @param {Chunk} chunk chunk | ||
| * @param {Set<string>} set runtime requirements | ||
| * @param {RuntimeRequirements} set runtime requirements | ||
| */ | ||
@@ -66,0 +67,0 @@ const handler = (chunk, set) => { |
@@ -11,3 +11,3 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").InfrastructureLogging} InfrastructureLogging */ | ||
| /** @typedef {import("../config/defaults").InfrastructureLoggingNormalizedWithDefaults} InfrastructureLoggingNormalizedWithDefaults */ | ||
| /** @typedef {import("../logging/createConsoleLogger").LoggerConsole} LoggerConsole */ | ||
@@ -21,3 +21,3 @@ | ||
| * @param {boolean=} options.appendOnly append only | ||
| * @param {NonNullable<InfrastructureLogging["stream"]>} options.stream stream | ||
| * @param {InfrastructureLoggingNormalizedWithDefaults["stream"]} options.stream stream | ||
| * @returns {LoggerConsole} logger function | ||
@@ -24,0 +24,0 @@ */ |
@@ -11,6 +11,6 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").WatchOptions} WatchOptions */ | ||
| /** @typedef {import("../FileSystemInfo").FileSystemInfoEntry} FileSystemInfoEntry */ | ||
| /** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */ | ||
| /** @typedef {import("../util/fs").WatchMethod} WatchMethod */ | ||
| /** @typedef {import("../util/fs").Changes} Changes */ | ||
| /** @typedef {import("../util/fs").Removals} Removals */ | ||
@@ -82,4 +82,4 @@ class NodeWatchFileSystem { | ||
| /** | ||
| * @param {Set<string>} changes changes | ||
| * @param {Set<string>} removals removals | ||
| * @param {Changes} changes changes | ||
| * @param {Removals} removals removals | ||
| */ | ||
@@ -86,0 +86,0 @@ (changes, removals) => { |
@@ -94,3 +94,3 @@ /* | ||
| outputName, | ||
| /** @type {string} */ (compilation.outputOptions.path), | ||
| compilation.outputOptions.path, | ||
| false | ||
@@ -268,3 +268,3 @@ ); | ||
| Template.indent([ | ||
| 'if(err.code === "ENOENT") return resolve();', | ||
| 'if(["MODULE_NOT_FOUND", "ENOENT"].includes(err.code)) return resolve();', | ||
| "return reject(err);" | ||
@@ -271,0 +271,0 @@ ]), |
@@ -94,3 +94,3 @@ /* | ||
| outputName, | ||
| /** @type {string} */ (compilation.outputOptions.path), | ||
| compilation.outputOptions.path, | ||
| true | ||
@@ -227,3 +227,6 @@ ); | ||
| ]), | ||
| "})['catch'](function(err) { if(err.code !== 'MODULE_NOT_FOUND') throw err; });" | ||
| `}).catch(${runtimeTemplate.basicFunction("err", [ | ||
| "if(['MODULE_NOT_FOUND', 'ENOENT'].includes(err.code)) return;", | ||
| "throw err;" | ||
| ])});` | ||
| ]), | ||
@@ -230,0 +233,0 @@ "}" |
@@ -24,11 +24,7 @@ /* | ||
| /** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */ | ||
| /** @typedef {import("../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */ | ||
| /** @typedef {import("../declarations/WebpackOptions").NodeOptions} NodeOptions */ | ||
| /** @typedef {import("./Compiler")} Compiler */ | ||
| /** @typedef {import("./Dependency")} Dependency */ | ||
| /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */ | ||
| /** @typedef {import("./DependencyTemplates")} DependencyTemplates */ | ||
| /** @typedef {import("./NormalModule")} NormalModule */ | ||
| /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */ | ||
| /** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */ | ||
@@ -192,5 +188,3 @@ /** @typedef {import("./javascript/JavascriptParser").Range} Range */ | ||
| case "node-module": { | ||
| const importMetaName = | ||
| /** @type {string} */ | ||
| (compilation.outputOptions.importMetaName); | ||
| const importMetaName = compilation.outputOptions.importMetaName; | ||
@@ -235,5 +229,3 @@ setUrlModuleConstant( | ||
| case "node-module": { | ||
| const importMetaName = | ||
| /** @type {string} */ | ||
| (compilation.outputOptions.importMetaName); | ||
| const importMetaName = compilation.outputOptions.importMetaName; | ||
@@ -240,0 +232,0 @@ setUrlModuleConstant( |
+145
-88
@@ -57,25 +57,27 @@ /* | ||
| /** @typedef {import("enhanced-resolve").ResolveContext} ResolveContext */ | ||
| /** @typedef {import("enhanced-resolve").ResolveRequest} ResolveRequest */ | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("webpack-sources").RawSourceMap} RawSourceMap */ | ||
| /** @typedef {import("../declarations/WebpackOptions").Mode} Mode */ | ||
| /** @typedef {import("../declarations/WebpackOptions").ResolveOptions} ResolveOptions */ | ||
| /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */ | ||
| /** @typedef {import("../declarations/WebpackOptions").NoParse} NoParse */ | ||
| /** @typedef {import("./ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("./Compiler")} Compiler */ | ||
| /** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */ | ||
| /** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */ | ||
| /** @typedef {import("./DependencyTemplates")} DependencyTemplates */ | ||
| /** @typedef {import("./Generator")} Generator */ | ||
| /** @typedef {import("./Generator").GenerateErrorFn} GenerateErrorFn */ | ||
| /** @typedef {import("./Generator").GenerateContextData} GenerateContextData */ | ||
| /** @typedef {import("./Module").BuildInfo} BuildInfo */ | ||
| /** @typedef {import("./Module").FileSystemDependencies} FileSystemDependencies */ | ||
| /** @typedef {import("./Module").BuildMeta} BuildMeta */ | ||
| /** @typedef {import("./Module").CodeGenerationContext} CodeGenerationContext */ | ||
| /** @typedef {import("./Module").CodeGenerationResult} CodeGenerationResult */ | ||
| /** @typedef {import("./Module").CodeGenerationResultData} CodeGenerationResultData */ | ||
| /** @typedef {import("./Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */ | ||
| /** @typedef {import("./Module").KnownBuildInfo} KnownBuildInfo */ | ||
| /** @typedef {import("./Module").LibIdentOptions} LibIdentOptions */ | ||
| /** @typedef {import("./Module").LibIdent} LibIdent */ | ||
| /** @typedef {import("./Module").NameForCondition} NameForCondition */ | ||
| /** @typedef {import("./Module").NeedBuildContext} NeedBuildContext */ | ||
| /** @typedef {import("./Module").NeedBuildCallback} NeedBuildCallback */ | ||
| /** @typedef {import("./Module").BuildCallback} BuildCallback */ | ||
| /** @typedef {import("./Module").RuntimeRequirements} RuntimeRequirements */ | ||
| /** @typedef {import("./Generator").SourceTypes} SourceTypes */ | ||
@@ -85,5 +87,4 @@ /** @typedef {import("./Module").UnsafeCacheData} UnsafeCacheData */ | ||
| /** @typedef {import("./ModuleGraphConnection").ConnectionState} ConnectionState */ | ||
| /** @typedef {import("./ModuleTypeConstants").ModuleTypes} ModuleTypes */ | ||
| /** @typedef {import("./NormalModuleFactory")} NormalModuleFactory */ | ||
| /** @typedef {import("./NormalModuleFactory").ResourceDataWithData} ResourceDataWithData */ | ||
| /** @typedef {import("./NormalModuleFactory").NormalModuleTypes} NormalModuleTypes */ | ||
| /** @typedef {import("./NormalModuleFactory").ResourceSchemeData} ResourceSchemeData */ | ||
@@ -93,7 +94,3 @@ /** @typedef {import("./Parser")} Parser */ | ||
| /** @typedef {import("./RequestShortener")} RequestShortener */ | ||
| /** @typedef {import("./ResolverFactory").ResolveContext} ResolveContext */ | ||
| /** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */ | ||
| /** @typedef {import("./ResolverFactory").ResolveRequest} ResolveRequest */ | ||
| /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */ | ||
| /** @typedef {import("./logging/Logger").Logger} WebpackLogger */ | ||
| /** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
@@ -103,7 +100,5 @@ /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */ | ||
| /** @typedef {import("./util/runtime").RuntimeSpec} RuntimeSpec */ | ||
| /** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */ | ||
| /** @typedef {import("./util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */ | ||
| /** @typedef {import("./dependencies/HarmonyImportSideEffectDependency")} HarmonyImportSideEffectDependency */ | ||
| /** @typedef {import("./dependencies/HarmonyImportSpecifierDependency")} HarmonyImportSpecifierDependency */ | ||
| /** @typedef {import("../declarations/WebpackOptions").RuleSetRule["extractSourceMap"]} ExtractSourceMapOptions */ | ||
| /** | ||
@@ -130,2 +125,5 @@ * @template T | ||
| ); | ||
| const getExtractSourceMap = memoize(() => require("./util/extractSourceMap")); | ||
| const getValidate = memoize(() => require("schema-utils").validate); | ||
@@ -139,4 +137,4 @@ | ||
| * @property {string | null | undefined | Record<string, EXPECTED_ANY>} options | ||
| * @property {string?} ident | ||
| * @property {string?} type | ||
| * @property {string | null=} ident | ||
| * @property {string | null=} type | ||
| */ | ||
@@ -235,10 +233,12 @@ | ||
| /** @typedef {LoaderContext<EXPECTED_ANY>} AnyLoaderContext */ | ||
| /** | ||
| * @typedef {object} NormalModuleCompilationHooks | ||
| * @property {SyncHook<[LoaderContext<EXPECTED_ANY>, NormalModule]>} loader | ||
| * @property {SyncHook<[LoaderItem[], NormalModule, LoaderContext<EXPECTED_ANY>]>} beforeLoaders | ||
| * @property {SyncHook<[AnyLoaderContext, NormalModule]>} loader | ||
| * @property {SyncHook<[LoaderItem[], NormalModule, AnyLoaderContext]>} beforeLoaders | ||
| * @property {SyncHook<[NormalModule]>} beforeParse | ||
| * @property {SyncHook<[NormalModule]>} beforeSnapshot | ||
| * @property {HookMap<FakeHook<AsyncSeriesBailHook<[string, NormalModule], string | Buffer | null>>>} readResourceForScheme | ||
| * @property {HookMap<AsyncSeriesBailHook<[LoaderContext<EXPECTED_ANY>], string | Buffer | null>>} readResource | ||
| * @property {HookMap<AsyncSeriesBailHook<[AnyLoaderContext], string | Buffer | null>>} readResource | ||
| * @property {SyncWaterfallHook<[Result, NormalModule]>} processResult | ||
@@ -251,3 +251,3 @@ * @property {AsyncSeriesBailHook<[NormalModule, NeedBuildContext], boolean>} needBuild | ||
| * @property {string=} layer an optional layer in which the module is | ||
| * @property {ModuleTypes | ""} type module type. When deserializing, this is set to an empty string "". | ||
| * @property {NormalModuleTypes | ""} type module type. When deserializing, this is set to an empty string "". | ||
| * @property {string} request request string | ||
@@ -266,4 +266,9 @@ * @property {string} userRequest request intended by user (without loaders from config) | ||
| * @property {ResolveOptions=} resolveOptions options used for resolving requests from this module | ||
| * @property {boolean=} extractSourceMap enable/disable extracting source map | ||
| */ | ||
| /** | ||
| * @typedef {(resourcePath: string, getLoaderContext: (resourcePath: string) => AnyLoaderContext) => Promise<string | Buffer<ArrayBufferLike>>} ReadResource | ||
| */ | ||
| /** @type {WeakMap<Compilation, NormalModuleCompilationHooks>} */ | ||
@@ -354,3 +359,4 @@ const compilationHooksMap = new WeakMap(); | ||
| generatorOptions, | ||
| resolveOptions | ||
| resolveOptions, | ||
| extractSourceMap | ||
| }) { | ||
@@ -387,2 +393,4 @@ super(type, context || getContext(resource), layer); | ||
| } | ||
| /** @type {ExtractSourceMapOptions} */ | ||
| this.extractSourceMap = extractSourceMap; | ||
@@ -414,3 +422,3 @@ // Info from Build | ||
| this._addedSideEffectsBailout = undefined; | ||
| /** @type {GenerateContextData} */ | ||
| /** @type {CodeGenerationResultData} */ | ||
| this._codeGeneratorData = new Map(); | ||
@@ -441,4 +449,11 @@ } | ||
| /** | ||
| * @returns {string | null} return the resource path | ||
| */ | ||
| getResource() { | ||
| return this.matchResource || this.resource; | ||
| } | ||
| /** | ||
| * @param {LibIdentOptions} options options | ||
| * @returns {string | null} an identifier for library inclusion | ||
| * @returns {LibIdent | null} an identifier for library inclusion | ||
| */ | ||
@@ -456,6 +471,6 @@ libIdent(options) { | ||
| /** | ||
| * @returns {string | null} absolute path which should be used for condition matching (usually the resource path) | ||
| * @returns {NameForCondition | null} absolute path which should be used for condition matching (usually the resource path) | ||
| */ | ||
| nameForCondition() { | ||
| const resource = this.matchResource || this.resource; | ||
| const resource = /** @type {string} */ (this.getResource()); | ||
| const idx = resource.indexOf("?"); | ||
@@ -606,3 +621,4 @@ if (idx >= 0) return resource.slice(0, idx); | ||
| const currentLoader = this.getCurrentLoader( | ||
| /** @type {LoaderContext<EXPECTED_ANY>} */ (loaderContext) | ||
| /** @type {AnyLoaderContext} */ | ||
| (loaderContext) | ||
| ); | ||
@@ -618,17 +634,14 @@ if (!currentLoader) return "(not in loader scope)"; | ||
| add: (d) => | ||
| /** @type {LoaderContext<EXPECTED_ANY>} */ ( | ||
| loaderContext | ||
| ).addDependency(d) | ||
| /** @type {AnyLoaderContext} */ | ||
| (loaderContext).addDependency(d) | ||
| }, | ||
| contextDependencies: { | ||
| add: (d) => | ||
| /** @type {LoaderContext<EXPECTED_ANY>} */ ( | ||
| loaderContext | ||
| ).addContextDependency(d) | ||
| /** @type {AnyLoaderContext} */ | ||
| (loaderContext).addContextDependency(d) | ||
| }, | ||
| missingDependencies: { | ||
| add: (d) => | ||
| /** @type {LoaderContext<EXPECTED_ANY>} */ ( | ||
| loaderContext | ||
| ).addMissingDependency(d) | ||
| /** @type {AnyLoaderContext} */ | ||
| (loaderContext).addMissingDependency(d) | ||
| } | ||
@@ -680,9 +693,5 @@ }); | ||
| createHash: (type) => | ||
| createHash( | ||
| type || | ||
| /** @type {HashFunction} */ | ||
| (compilation.outputOptions.hashFunction) | ||
| ) | ||
| createHash(type || compilation.outputOptions.hashFunction) | ||
| }; | ||
| /** @type {import("../declarations/LoaderContext").NormalModuleLoaderContext<T>} */ | ||
| /** @type {NormalModuleLoaderContext<T>} */ | ||
| const loaderContext = { | ||
@@ -696,3 +705,4 @@ version: 2, | ||
| const loader = this.getCurrentLoader( | ||
| /** @type {LoaderContext<EXPECTED_ANY>} */ (loaderContext) | ||
| /** @type {AnyLoaderContext} */ | ||
| (loaderContext) | ||
| ); | ||
@@ -759,3 +769,4 @@ | ||
| const currentLoader = this.getCurrentLoader( | ||
| /** @type {LoaderContext<EXPECTED_ANY>} */ (loaderContext) | ||
| /** @type {AnyLoaderContext} */ | ||
| (loaderContext) | ||
| ); | ||
@@ -816,3 +827,3 @@ return compilation.getLogger(() => | ||
| assets[name] = this.createSourceForAsset( | ||
| /** @type {string} */ (options.context), | ||
| options.context, | ||
| name, | ||
@@ -834,10 +845,10 @@ content, | ||
| utils, | ||
| rootContext: /** @type {string} */ (options.context), | ||
| rootContext: options.context, | ||
| webpack: true, | ||
| sourceMap: Boolean(this.useSourceMap), | ||
| mode: options.mode || "production", | ||
| hashFunction: /** @type {string} */ (options.output.hashFunction), | ||
| hashDigest: /** @type {string} */ (options.output.hashDigest), | ||
| hashDigestLength: /** @type {number} */ (options.output.hashDigestLength), | ||
| hashSalt: /** @type {string} */ (options.output.hashSalt), | ||
| hashFunction: options.output.hashFunction, | ||
| hashDigest: options.output.hashDigest, | ||
| hashDigestLength: options.output.hashDigestLength, | ||
| hashSalt: options.output.hashSalt, | ||
| _module: this, | ||
@@ -851,5 +862,4 @@ _compilation: compilation, | ||
| // After `hooks.loader.call` is called, the loaderContext is typed as LoaderContext<EXPECTED_ANY> | ||
| hooks.loader.call( | ||
| /** @type {LoaderContext<EXPECTED_ANY>} */ | ||
| /** @type {AnyLoaderContext} */ | ||
| (loaderContext), | ||
@@ -859,3 +869,3 @@ this | ||
| return /** @type {LoaderContext<EXPECTED_ANY>} */ (loaderContext); | ||
| return /** @type {AnyLoaderContext} */ (loaderContext); | ||
| } | ||
@@ -865,3 +875,3 @@ | ||
| /** | ||
| * @param {LoaderContext<EXPECTED_ANY>} loaderContext loader context | ||
| * @param {AnyLoaderContext} loaderContext loader context | ||
| * @param {number} index index | ||
@@ -989,3 +999,3 @@ * @returns {LoaderItem | null} loader | ||
| this._source = this.createSource( | ||
| /** @type {string} */ (options.context), | ||
| options.context, | ||
| isBinaryModule ? asBuffer(source) : asString(source), | ||
@@ -1016,3 +1026,3 @@ sourceMap, | ||
| this, | ||
| /** @type {LoaderContext<EXPECTED_ANY>} */ | ||
| /** @type {AnyLoaderContext} */ | ||
| (loaderContext) | ||
@@ -1036,24 +1046,76 @@ ); | ||
| /** | ||
| * @param {LoaderContext<EXPECTED_ANY>} loaderContext the loader context | ||
| * @param {AnyLoaderContext} loaderContext the loader context | ||
| * @param {string} resourcePath the resource Path | ||
| * @param {(err: Error | null, result?: string | Buffer) => void} callback callback | ||
| * @param {(err: Error | null, result?: string | Buffer, sourceMap?: Result[1]) => void} callback callback | ||
| * @returns {Promise<void>} | ||
| */ | ||
| processResource: (loaderContext, resourcePath, callback) => { | ||
| const resource = loaderContext.resource; | ||
| const scheme = getScheme(resource); | ||
| hooks.readResource | ||
| .for(scheme) | ||
| .callAsync(loaderContext, (err, result) => { | ||
| if (err) return callback(err); | ||
| if (typeof result !== "string" && !result) { | ||
| return callback( | ||
| new UnhandledSchemeError( | ||
| /** @type {string} */ | ||
| (scheme), | ||
| resource | ||
| ) | ||
| processResource: async (loaderContext, resourcePath, callback) => { | ||
| /** @type {ReadResource} */ | ||
| const readResource = (resourcePath, getLoaderContext) => { | ||
| const scheme = getScheme(resourcePath); | ||
| return new Promise((resolve, reject) => { | ||
| hooks.readResource | ||
| .for(scheme) | ||
| .callAsync(getLoaderContext(resourcePath), (err, result) => { | ||
| if (err) { | ||
| reject(err); | ||
| } else { | ||
| if (typeof result !== "string" && !result) { | ||
| return reject( | ||
| new UnhandledSchemeError( | ||
| /** @type {string} */ | ||
| (scheme), | ||
| resourcePath | ||
| ) | ||
| ); | ||
| } | ||
| resolve(result); | ||
| } | ||
| }); | ||
| }); | ||
| }; | ||
| try { | ||
| const result = await readResource( | ||
| resourcePath, | ||
| () => loaderContext | ||
| ); | ||
| if ( | ||
| this.extractSourceMap && | ||
| (this.useSourceMap || this.useSimpleSourceMap) | ||
| ) { | ||
| try { | ||
| const { source, sourceMap } = await getExtractSourceMap()( | ||
| result, | ||
| resourcePath, | ||
| /** @type {ReadResource} */ | ||
| (resourcePath) => | ||
| readResource( | ||
| resourcePath, | ||
| (resourcePath) => | ||
| /** @type {AnyLoaderContext} */ | ||
| ({ | ||
| addDependency(dependency) { | ||
| loaderContext.addDependency(dependency); | ||
| }, | ||
| fs: loaderContext.fs, | ||
| _module: undefined, | ||
| resourcePath, | ||
| resource: resourcePath | ||
| }) | ||
| ).catch((err) => { | ||
| throw new Error( | ||
| `Failed to parse source map. ${/** @type {Error} */ (err).message}` | ||
| ); | ||
| }) | ||
| ); | ||
| return callback(null, source, sourceMap); | ||
| } catch (err) { | ||
| this.addWarning(new ModuleWarning(/** @type {Error} */ (err))); | ||
| return callback(null, result); | ||
| } | ||
| return callback(null, result); | ||
| }); | ||
| } | ||
| return callback(null, result); | ||
| } catch (error) { | ||
| return callback(/** @type {Error} */ (error)); | ||
| } | ||
| } | ||
@@ -1171,6 +1233,3 @@ }, | ||
| _initBuildHash(compilation) { | ||
| const hash = createHash( | ||
| /** @type {HashFunction} */ | ||
| (compilation.outputOptions.hashFunction) | ||
| ); | ||
| const hash = createHash(compilation.outputOptions.hashFunction); | ||
| if (this._source) { | ||
@@ -1236,7 +1295,3 @@ hash.update("source"); | ||
| const loaders = this.loaders.map((item) => | ||
| contextify( | ||
| /** @type {string} */ (options.context), | ||
| item.loader, | ||
| compilation.compiler.root | ||
| ) | ||
| contextify(options.context, item.loader, compilation.compiler.root) | ||
| ); | ||
@@ -1478,3 +1533,3 @@ const error = new ModuleParseError(source, e, loaders, this.type); | ||
| }) { | ||
| /** @type {Set<string>} */ | ||
| /** @type {RuntimeRequirements} */ | ||
| const runtimeRequirements = new Set(); | ||
@@ -1637,6 +1692,6 @@ | ||
| /** | ||
| * @param {LazySet<string>} fileDependencies set where file dependencies are added to | ||
| * @param {LazySet<string>} contextDependencies set where context dependencies are added to | ||
| * @param {LazySet<string>} missingDependencies set where missing dependencies are added to | ||
| * @param {LazySet<string>} buildDependencies set where build dependencies are added to | ||
| * @param {FileSystemDependencies} fileDependencies set where file dependencies are added to | ||
| * @param {FileSystemDependencies} contextDependencies set where context dependencies are added to | ||
| * @param {FileSystemDependencies} missingDependencies set where missing dependencies are added to | ||
| * @param {FileSystemDependencies} buildDependencies set where build dependencies are added to | ||
| */ | ||
@@ -1700,2 +1755,3 @@ addCacheDependencies( | ||
| write(this._codeGeneratorData); | ||
| write(this.extractSourceMap); | ||
| super.serialize(context); | ||
@@ -1741,2 +1797,3 @@ } | ||
| this._codeGeneratorData = read(); | ||
| this.extractSourceMap = read(); | ||
| super.deserialize(context); | ||
@@ -1743,0 +1800,0 @@ } |
@@ -37,2 +37,4 @@ /* | ||
| /** @typedef {import("enhanced-resolve").ResolveContext} ResolveContext */ | ||
| /** @typedef {import("enhanced-resolve").ResolveRequest} ResolveRequest */ | ||
| /** @typedef {import("../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptions */ | ||
@@ -51,4 +53,2 @@ /** @typedef {import("../declarations/WebpackOptions").RuleSetRule} RuleSetRule */ | ||
| /** @typedef {import("./ResolverFactory")} ResolverFactory */ | ||
| /** @typedef {import("./ResolverFactory").ResolveContext} ResolveContext */ | ||
| /** @typedef {import("./ResolverFactory").ResolveRequest} ResolveRequest */ | ||
| /** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */ | ||
@@ -61,3 +61,8 @@ /** @typedef {import("./dependencies/ModuleDependency")} ModuleDependency */ | ||
| /** @typedef {Pick<RuleSetRule, 'type' | 'sideEffects' | 'parser' | 'generator' | 'resolve' | 'layer'>} ModuleSettings */ | ||
| /** | ||
| * @template T | ||
| * @typedef {import("./Compiler").Callback<T>} Callback | ||
| */ | ||
| /** @typedef {Pick<RuleSetRule, 'type' | 'sideEffects' | 'parser' | 'generator' | 'resolve' | 'layer' | 'extractSourceMap'>} ModuleSettings */ | ||
| /** @typedef {Partial<NormalModuleCreateData & { settings: ModuleSettings }>} CreateData */ | ||
@@ -71,3 +76,3 @@ | ||
| * @property {string} request | ||
| * @property {ImportAttributes | undefined} assertions | ||
| * @property {ImportAttributes | undefined} attributes | ||
| * @property {ModuleDependency[]} dependencies | ||
@@ -108,10 +113,20 @@ * @property {string} dependencyType | ||
| /** | ||
| * @template T | ||
| * @callback Callback | ||
| * @param {(Error | null)=} err | ||
| * @param {T=} stats | ||
| * @returns {void} | ||
| */ | ||
| /** @typedef {import("./ModuleTypeConstants").JAVASCRIPT_MODULE_TYPE_AUTO} JAVASCRIPT_MODULE_TYPE_AUTO */ | ||
| /** @typedef {import("./ModuleTypeConstants").JAVASCRIPT_MODULE_TYPE_DYNAMIC} JAVASCRIPT_MODULE_TYPE_DYNAMIC */ | ||
| /** @typedef {import("./ModuleTypeConstants").JAVASCRIPT_MODULE_TYPE_ESM} JAVASCRIPT_MODULE_TYPE_ESM */ | ||
| /** @typedef {import("./ModuleTypeConstants").JSON_MODULE_TYPE} JSON_MODULE_TYPE */ | ||
| /** @typedef {import("./ModuleTypeConstants").ASSET_MODULE_TYPE} ASSET_MODULE_TYPE */ | ||
| /** @typedef {import("./ModuleTypeConstants").ASSET_MODULE_TYPE_INLINE} ASSET_MODULE_TYPE_INLINE */ | ||
| /** @typedef {import("./ModuleTypeConstants").ASSET_MODULE_TYPE_RESOURCE} ASSET_MODULE_TYPE_RESOURCE */ | ||
| /** @typedef {import("./ModuleTypeConstants").ASSET_MODULE_TYPE_SOURCE} ASSET_MODULE_TYPE_SOURCE */ | ||
| /** @typedef {import("./ModuleTypeConstants").WEBASSEMBLY_MODULE_TYPE_ASYNC} WEBASSEMBLY_MODULE_TYPE_ASYNC */ | ||
| /** @typedef {import("./ModuleTypeConstants").WEBASSEMBLY_MODULE_TYPE_SYNC} WEBASSEMBLY_MODULE_TYPE_SYNC */ | ||
| /** @typedef {import("./ModuleTypeConstants").CSS_MODULE_TYPE} CSS_MODULE_TYPE */ | ||
| /** @typedef {import("./ModuleTypeConstants").CSS_MODULE_TYPE_GLOBAL} CSS_MODULE_TYPE_GLOBAL */ | ||
| /** @typedef {import("./ModuleTypeConstants").CSS_MODULE_TYPE_MODULE} CSS_MODULE_TYPE_MODULE */ | ||
| /** @typedef {import("./ModuleTypeConstants").CSS_MODULE_TYPE_AUTO} CSS_MODULE_TYPE_AUTO */ | ||
| /** @typedef {JAVASCRIPT_MODULE_TYPE_AUTO | JAVASCRIPT_MODULE_TYPE_DYNAMIC | JAVASCRIPT_MODULE_TYPE_ESM | JSON_MODULE_TYPE | ASSET_MODULE_TYPE | ASSET_MODULE_TYPE_INLINE | ASSET_MODULE_TYPE_RESOURCE | ASSET_MODULE_TYPE_SOURCE | WEBASSEMBLY_MODULE_TYPE_ASYNC | WEBASSEMBLY_MODULE_TYPE_SYNC | CSS_MODULE_TYPE | CSS_MODULE_TYPE_GLOBAL | CSS_MODULE_TYPE_MODULE | CSS_MODULE_TYPE_AUTO} KnownNormalModuleTypes */ | ||
| /** @typedef {KnownNormalModuleTypes | string} NormalModuleTypes */ | ||
| const EMPTY_RESOLVE_OPTIONS = {}; | ||
@@ -235,3 +250,3 @@ /** @type {ParserOptions} */ | ||
| new BasicMatcherRulePlugin("issuerLayer"), | ||
| new ObjectMatcherRulePlugin("assert", "assertions", (value) => { | ||
| new ObjectMatcherRulePlugin("assert", "attributes", (value) => { | ||
| if (value) { | ||
@@ -245,3 +260,3 @@ return ( | ||
| }), | ||
| new ObjectMatcherRulePlugin("with", "assertions", (value) => { | ||
| new ObjectMatcherRulePlugin("with", "attributes", (value) => { | ||
| if (value) { | ||
@@ -259,2 +274,3 @@ return !(/** @type {ImportAttributes} */ (value)._isLegacyAssert); | ||
| new BasicEffectRulePlugin("layer"), | ||
| new BasicEffectRulePlugin("extractSourceMap"), | ||
| new UseEffectRulePlugin() | ||
@@ -271,3 +287,2 @@ ]); | ||
| * @param {AssociatedObjectForCache} param.associatedObjectForCache an object to which the cache will be attached | ||
| * @param {boolean=} param.layers enable layers | ||
| */ | ||
@@ -279,4 +294,3 @@ constructor({ | ||
| options, | ||
| associatedObjectForCache, | ||
| layers = false | ||
| associatedObjectForCache | ||
| }) { | ||
@@ -307,3 +321,3 @@ super(); | ||
| createParser: new HookMap(() => new SyncBailHook(["parserOptions"])), | ||
| /** @type {HookMap<SyncBailHook<[TODO, ParserOptions], void>>} */ | ||
| /** @type {HookMap<SyncBailHook<[EXPECTED_ANY, ParserOptions], void>>} */ | ||
| parser: new HookMap(() => new SyncHook(["parser", "parserOptions"])), | ||
@@ -314,3 +328,3 @@ /** @type {HookMap<SyncBailHook<[GeneratorOptions], Generator | void>>} */ | ||
| ), | ||
| /** @type {HookMap<SyncBailHook<[TODO, GeneratorOptions], void>>} */ | ||
| /** @type {HookMap<SyncBailHook<[EXPECTED_ANY, GeneratorOptions], void>>} */ | ||
| generator: new HookMap( | ||
@@ -445,3 +459,3 @@ () => new SyncHook(["generator", "generatorOptions"]) | ||
| request, | ||
| assertions, | ||
| attributes, | ||
| resolveOptions, | ||
@@ -617,3 +631,3 @@ fileDependencies, | ||
| scheme, | ||
| assertions, | ||
| attributes, | ||
| mimetype: matchResourceData | ||
@@ -700,12 +714,6 @@ ? "" | ||
| } | ||
| const type = /** @type {string} */ (settings.type); | ||
| const type = /** @type {NormalModuleTypes} */ (settings.type); | ||
| const resolveOptions = settings.resolve; | ||
| const layer = settings.layer; | ||
| if (layer !== undefined && !layers) { | ||
| return callback( | ||
| new Error( | ||
| "'Rule.layer' is only allowed when 'experiments.layers' is enabled" | ||
| ) | ||
| ); | ||
| } | ||
| try { | ||
@@ -735,3 +743,4 @@ Object.assign(data.createData, { | ||
| generatorOptions: settings.generator, | ||
| resolveOptions | ||
| resolveOptions, | ||
| extractSourceMap: settings.extractSourceMap || false | ||
| }); | ||
@@ -906,3 +915,5 @@ } catch (createDataErr) { | ||
| const request = dependency.request; | ||
| const assertions = dependency.assertions; | ||
| const attributes = | ||
| /** @type {ModuleDependency & { attributes: ImportAttributes }} */ | ||
| (dependency).attributes; | ||
| const dependencyType = dependency.category || ""; | ||
@@ -919,3 +930,3 @@ const contextInfo = data.contextInfo; | ||
| request, | ||
| assertions, | ||
| attributes, | ||
| dependencies, | ||
@@ -1207,2 +1218,6 @@ dependencyType, | ||
| array, | ||
| /** | ||
| * @param {LoaderItem} item item | ||
| * @param {Callback<LoaderItem>} callback callback | ||
| */ | ||
| (item, callback) => { | ||
@@ -1240,3 +1255,4 @@ resolver.resolve( | ||
| const parsedResult = this._parseResourceWithoutFragment( | ||
| /** @type {string} */ (result) | ||
| /** @type {string} */ | ||
| (result) | ||
| ); | ||
@@ -1251,4 +1267,8 @@ | ||
| ? undefined | ||
| : /** @type {ResolveRequest} */ | ||
| (resolveRequest).descriptionFileData.type; | ||
| : /** @type {string} */ | ||
| ( | ||
| /** @type {ResolveRequest} */ | ||
| (resolveRequest).descriptionFileData.type | ||
| ); | ||
| /** @type {LoaderItem} */ | ||
| const resolved = { | ||
@@ -1263,13 +1283,12 @@ loader: parsedResult.path, | ||
| : item.options, | ||
| ident: | ||
| item.options === undefined | ||
| ? undefined | ||
| : /** @type {string} */ (item.ident) | ||
| ident: item.options === undefined ? undefined : item.ident | ||
| }; | ||
| return callback(null, /** @type {LoaderItem} */ (resolved)); | ||
| return callback(null, resolved); | ||
| } | ||
| ); | ||
| }, | ||
| /** @type {Callback<(LoaderItem | undefined)[]>} */ (callback) | ||
| (err, value) => { | ||
| callback(err, /** @type {(LoaderItem)[]} */ (value)); | ||
| } | ||
| ); | ||
@@ -1276,0 +1295,0 @@ } |
@@ -19,2 +19,3 @@ /* | ||
| /** @typedef {import("../Chunk")} Chunk */ | ||
| /** @typedef {import("../Chunk").ChunkId} ChunkId */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
@@ -131,2 +132,3 @@ /** @typedef {import("../Compiler")} Compiler */ | ||
| // Check used chunk ids | ||
| /** @typedef {Set<ChunkId>} */ | ||
| const usedIds = new Set(); | ||
@@ -133,0 +135,0 @@ for (const chunk of chunks) { |
@@ -11,3 +11,2 @@ /* | ||
| /** @typedef {import("estree").Node} AnyNode */ | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
@@ -17,8 +16,9 @@ /** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */ | ||
| /** @typedef {import("../ModuleGraph")} ModuleGraph */ | ||
| /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */ | ||
| /** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */ | ||
| /** @typedef {import("../Parser").ParserState} ParserState */ | ||
| /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */ | ||
| /** @typedef {Map<TopLevelSymbol | null, Set<string | TopLevelSymbol> | true | undefined>} InnerGraph */ | ||
| /** @typedef {Set<string | TopLevelSymbol>} InnerGraphValueSet */ | ||
| /** @typedef {InnerGraphValueSet | true} InnerGraphValue */ | ||
| /** @typedef {TopLevelSymbol | null} InnerGraphKey */ | ||
| /** @typedef {Map<InnerGraphKey, InnerGraphValue | undefined>} InnerGraph */ | ||
| /** @typedef {(value: boolean | Set<string> | undefined) => void} UsageCallback */ | ||
@@ -33,3 +33,3 @@ | ||
| /** @typedef {false|StateObject} State */ | ||
| /** @typedef {false | StateObject} State */ | ||
@@ -62,3 +62,3 @@ class TopLevelSymbol { | ||
| * @param {TopLevelSymbol | null} symbol the symbol, or null for all symbols | ||
| * @param {string | TopLevelSymbol | true} usage usage data | ||
| * @param {Usage} usage usage data | ||
| * @returns {void} | ||
@@ -82,6 +82,8 @@ */ | ||
| /** @typedef {string | TopLevelSymbol | true} Usage */ | ||
| /** | ||
| * @param {JavascriptParser} parser the parser | ||
| * @param {string} name name of variable | ||
| * @param {string | TopLevelSymbol | true} usage usage data | ||
| * @param {Usage} usage usage data | ||
| * @returns {void} | ||
@@ -123,5 +125,7 @@ */ | ||
| /** @typedef {Set<string> | boolean} UsedByExports */ | ||
| /** | ||
| * @param {Dependency} dependency the dependency | ||
| * @param {Set<string> | boolean | undefined} usedByExports usedByExports info | ||
| * @param {UsedByExports | undefined} usedByExports usedByExports info | ||
| * @param {ModuleGraph} moduleGraph moduleGraph | ||
@@ -155,3 +159,3 @@ * @returns {null | false | GetConditionFn} function to determine if the connection is active | ||
| * @param {ParserState} state parser state | ||
| * @returns {TopLevelSymbol|void} usage data | ||
| * @returns {TopLevelSymbol | void} usage data | ||
| */ | ||
@@ -178,2 +182,3 @@ module.exports.getTopLevelSymbol = (state) => { | ||
| const { innerGraph, usageCallbackMap } = innerGraphState; | ||
| /** @type {Map<InnerGraphKey, InnerGraphValueSet | undefined>} */ | ||
| const processed = new Map(); | ||
@@ -184,3 +189,3 @@ // flatten graph to terminal nodes (string, undefined or true) | ||
| for (const key of nonTerminal) { | ||
| /** @type {Set<string|TopLevelSymbol> | true} */ | ||
| /** @type {InnerGraphValue} */ | ||
| let newSet = new Set(); | ||
@@ -191,2 +196,3 @@ let isTerminal = true; | ||
| if (alreadyProcessed === undefined) { | ||
| /** @type {InnerGraphValueSet} */ | ||
| alreadyProcessed = new Set(); | ||
@@ -267,3 +273,3 @@ processed.set(key, alreadyProcessed); | ||
| * @param {Dependency} dependency the dependency | ||
| * @param {Set<string> | boolean} usedByExports usedByExports info | ||
| * @param {UsedByExports | undefined} usedByExports usedByExports info | ||
| * @param {ModuleGraph} moduleGraph moduleGraph | ||
@@ -270,0 +276,0 @@ * @param {RuntimeSpec} runtime runtime |
@@ -24,8 +24,5 @@ /* | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
| /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */ | ||
| /** @typedef {import("../dependencies/HarmonyImportSpecifierDependency")} HarmonyImportSpecifierDependency */ | ||
| /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("./InnerGraph").InnerGraph} InnerGraph */ | ||
| /** @typedef {import("./InnerGraph").TopLevelSymbol} TopLevelSymbol */ | ||
@@ -32,0 +29,0 @@ |
@@ -393,3 +393,2 @@ /* | ||
| // Create a new ConcatenatedModule | ||
| ConcatenatedModule.getCompilationHooks(compilation); | ||
| const newModule = ConcatenatedModule.create( | ||
@@ -406,3 +405,3 @@ rootModule, | ||
| newModule.build( | ||
| compiler.options, | ||
| compilation.options, | ||
| compilation, | ||
@@ -672,3 +671,3 @@ /** @type {EXPECTED_ANY} */ | ||
| /** @type {Map<Module, readonly ModuleGraph.ModuleGraphConnection[]>} */ | ||
| /** @type {Map<Module, ReadonlyArray<ModuleGraph.ModuleGraphConnection>>} */ | ||
| const incomingConnectionsFromModules = new Map(); | ||
@@ -731,3 +730,3 @@ for (const [originModule, connections] of incomingConnections) { | ||
| /** @type {Map<Module, readonly ModuleGraph.ModuleGraphConnection[]>} */ | ||
| /** @type {Map<Module, ReadonlyArray<ModuleGraph.ModuleGraphConnection>>} */ | ||
| const nonHarmonyConnections = new Map(); | ||
@@ -734,0 +733,0 @@ for (const [originModule, connections] of incomingConnectionsFromModules) { |
@@ -10,3 +10,2 @@ /* | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Entrypoint")} Entrypoint */ | ||
@@ -13,0 +12,0 @@ const PLUGIN_NAME = "RuntimeChunkPlugin"; |
@@ -24,3 +24,2 @@ /* | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
| /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */ | ||
@@ -41,7 +40,3 @@ /** @typedef {import("../Module")} Module */ | ||
| /** | ||
| * @typedef {object} ReexportInfo | ||
| * @property {Map<string, ExportInModule[]>} static | ||
| * @property {Map<Module, Set<string>>} dynamic | ||
| */ | ||
| /** @typedef {string | boolean | string[] | undefined} SideEffectsFlagValue */ | ||
@@ -110,5 +105,3 @@ /** @typedef {Map<string, RegExp>} CacheItem */ | ||
| resolveData.relativePath, | ||
| /** @type {string | boolean | string[] | undefined} */ ( | ||
| sideEffects | ||
| ), | ||
| /** @type {SideEffectsFlagValue} */ (sideEffects), | ||
| /** @type {CacheItem} */ (cache) | ||
@@ -403,3 +396,3 @@ ); | ||
| * @param {string} moduleName the module name | ||
| * @param {undefined | boolean | string | string[]} flagValue the flag value | ||
| * @param {SideEffectsFlagValue} flagValue the flag value | ||
| * @param {Map<string, RegExp>} cache cache for glob to regexp | ||
@@ -406,0 +399,0 @@ * @returns {boolean | undefined} true, when the module has side effects, undefined or false when not |
@@ -24,3 +24,2 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksCacheGroup} OptimizationSplitChunksCacheGroup */ | ||
@@ -30,3 +29,3 @@ /** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksGetCacheGroups} OptimizationSplitChunksGetCacheGroups */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksSizes} OptimizationSplitChunksSizes */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").Output} OutputOptions */ | ||
| /** @typedef {import("../config/defaults").OutputNormalizedWithDefaults} OutputOptions */ | ||
| /** @typedef {import("../Chunk").ChunkName} ChunkName */ | ||
@@ -42,6 +41,4 @@ /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {Record<string, number>} SplitChunksSizes */ | ||
| /** | ||
| * @callback ChunkFilterFunction | ||
| * @callback ChunkFilterFn | ||
| * @param {Chunk} chunk | ||
@@ -58,2 +55,7 @@ * @returns {boolean | undefined} | ||
| /** @typedef {string} SourceType */ | ||
| /** @typedef {SourceType[]} SourceTypes */ | ||
| /** @typedef {SourceType[]} DefaultSizeTypes */ | ||
| /** @typedef {Record<SourceType, number>} SplitChunksSizes */ | ||
| /** | ||
@@ -63,4 +65,4 @@ * @typedef {object} CacheGroupSource | ||
| * @property {number=} priority | ||
| * @property {GetName=} getName | ||
| * @property {ChunkFilterFunction=} chunksFilter | ||
| * @property {GetNameFn=} getName | ||
| * @property {ChunkFilterFn=} chunksFilter | ||
| * @property {boolean=} enforce | ||
@@ -87,4 +89,4 @@ * @property {SplitChunksSizes} minSize | ||
| * @property {number} priority | ||
| * @property {GetName=} getName | ||
| * @property {ChunkFilterFunction} chunksFilter | ||
| * @property {GetNameFn=} getName | ||
| * @property {ChunkFilterFn} chunksFilter | ||
| * @property {SplitChunksSizes} minSize | ||
@@ -112,3 +114,3 @@ * @property {SplitChunksSizes} minSizeReduction | ||
| * @typedef {object} FallbackCacheGroup | ||
| * @property {ChunkFilterFunction} chunksFilter | ||
| * @property {ChunkFilterFn} chunksFilter | ||
| * @property {SplitChunksSizes} minSize | ||
@@ -134,7 +136,7 @@ * @property {SplitChunksSizes} maxAsyncSize | ||
| /** | ||
| * @callback GetName | ||
| * @callback GetNameFn | ||
| * @param {Module} module | ||
| * @param {Chunk[]} chunks | ||
| * @param {string} key | ||
| * @returns {string=} | ||
| * @returns {string | undefined} | ||
| */ | ||
@@ -144,4 +146,4 @@ | ||
| * @typedef {object} SplitChunksOptions | ||
| * @property {ChunkFilterFunction} chunksFilter | ||
| * @property {string[]} defaultSizeTypes | ||
| * @property {ChunkFilterFn} chunksFilter | ||
| * @property {DefaultSizeTypes} defaultSizeTypes | ||
| * @property {SplitChunksSizes} minSize | ||
@@ -160,3 +162,3 @@ * @property {SplitChunksSizes} minSizeReduction | ||
| * @property {GetCacheGroups} getCacheGroups | ||
| * @property {GetName} getName | ||
| * @property {GetNameFn} getName | ||
| * @property {boolean} usedExports | ||
@@ -172,3 +174,3 @@ * @property {FallbackCacheGroup} fallbackCacheGroup | ||
| * @property {string=} name | ||
| * @property {Record<string, number>} sizes | ||
| * @property {Record<SourceType, number>} sizes | ||
| * @property {Set<Chunk>} chunks | ||
@@ -179,3 +181,3 @@ * @property {Set<Chunk>} reusableChunks | ||
| /** @type {GetName} */ | ||
| /** @type {GetNameFn} */ | ||
| const defaultGetName = () => undefined; | ||
@@ -199,3 +201,3 @@ | ||
| ( | ||
| createHash(/** @type {HashFunction} */ (outputOptions.hashFunction)) | ||
| createHash(outputOptions.hashFunction) | ||
| .update(name) | ||
@@ -302,3 +304,3 @@ .digest(outputOptions.hashDigest) | ||
| * @param {OptimizationSplitChunksSizes | undefined} value the sizes | ||
| * @param {string[]} defaultSizeTypes the default size types | ||
| * @param {DefaultSizeTypes} defaultSizeTypes the default size types | ||
| * @returns {SplitChunksSizes} normalized representation | ||
@@ -396,3 +398,3 @@ */ | ||
| * @param {SplitChunksSizes} minSize the min sizes | ||
| * @returns {undefined | string[]} list of size types that are below min size | ||
| * @returns {undefined | SourceTypes} list of size types that are below min size | ||
| */ | ||
@@ -426,3 +428,3 @@ const getViolatingMinSizes = (sizes, minSize) => { | ||
| * @param {OptimizationSplitChunksCacheGroup["name"]} name the chunk name | ||
| * @returns {GetName | undefined} a function to get the name of the chunk | ||
| * @returns {GetNameFn | undefined} a function to get the name of the chunk | ||
| */ | ||
@@ -434,3 +436,3 @@ const normalizeName = (name) => { | ||
| if (typeof name === "function") { | ||
| return /** @type {GetName} */ (name); | ||
| return /** @type {GetNameFn} */ (name); | ||
| } | ||
@@ -441,3 +443,3 @@ }; | ||
| * @param {OptimizationSplitChunksCacheGroup["chunks"]} chunks the chunk filter option | ||
| * @returns {ChunkFilterFunction | undefined} the chunk filter function | ||
| * @returns {ChunkFilterFn | undefined} the chunk filter function | ||
| */ | ||
@@ -464,3 +466,3 @@ const normalizeChunksFilter = (chunks) => { | ||
| * @param {undefined | GetCacheGroups | Record<string, false | string | RegExp | OptimizationSplitChunksGetCacheGroups | OptimizationSplitChunksCacheGroup>} cacheGroups the cache group options | ||
| * @param {string[]} defaultSizeTypes the default size types | ||
| * @param {DefaultSizeTypes} defaultSizeTypes the default size types | ||
| * @returns {GetCacheGroups} a function to get the cache groups | ||
@@ -608,3 +610,3 @@ */ | ||
| * @param {string} key key of cache group | ||
| * @param {string[]} defaultSizeTypes the default size types | ||
| * @param {DefaultSizeTypes} defaultSizeTypes the default size types | ||
| * @returns {CacheGroupSource} the normalized cached group | ||
@@ -676,3 +678,3 @@ */ | ||
| chunksFilter: | ||
| /** @type {ChunkFilterFunction} */ | ||
| /** @type {ChunkFilterFn} */ | ||
| (normalizeChunksFilter(options.chunks || "all")), | ||
@@ -708,3 +710,3 @@ defaultSizeTypes, | ||
| getName: options.name | ||
| ? /** @type {GetName} */ (normalizeName(options.name)) | ||
| ? /** @type {GetNameFn} */ (normalizeName(options.name)) | ||
| : defaultGetName, | ||
@@ -715,3 +717,3 @@ automaticNameDelimiter: options.automaticNameDelimiter || "-", | ||
| chunksFilter: | ||
| /** @type {ChunkFilterFunction} */ | ||
| /** @type {ChunkFilterFn} */ | ||
| ( | ||
@@ -973,2 +975,4 @@ normalizeChunksFilter( | ||
| /** @typedef {Map<number, Set<Chunk>[]>} ChunkSetsByCount */ | ||
| // group these set of chunks by count | ||
@@ -979,6 +983,6 @@ // to allow to check less sets via isSubset | ||
| * @param {IterableIterator<Set<Chunk>>} chunkSets set of sets of chunks | ||
| * @returns {Map<number, Array<Set<Chunk>>>} map of sets of chunks by count | ||
| * @returns {ChunkSetsByCount} map of sets of chunks by count | ||
| */ | ||
| const groupChunkSetsByCount = (chunkSets) => { | ||
| /** @type {Map<number, Array<Set<Chunk>>>} */ | ||
| /** @type {ChunkSetsByCount} */ | ||
| const chunkSetsByCount = new Map(); | ||
@@ -1007,2 +1011,4 @@ for (const chunksSet of chunkSets) { | ||
| /** @typedef {(Set<Chunk> | Chunk)[]} Combinations */ | ||
| // Create a list of possible combinations | ||
@@ -1013,3 +1019,3 @@ /** | ||
| * @param {Map<number, Set<Chunk>[]>} chunkSetsByCount chunk sets by count | ||
| * @returns {(key: bigint | Chunk) => (Set<Chunk> | Chunk)[]} combinations | ||
| * @returns {(key: bigint | Chunk) => Combinations} combinations | ||
| */ | ||
@@ -1021,3 +1027,3 @@ const createGetCombinations = ( | ||
| ) => { | ||
| /** @type {Map<bigint | Chunk, (Set<Chunk> | Chunk)[]>} */ | ||
| /** @type {Map<bigint | Chunk, Combinations>} */ | ||
| const combinationsCache = new Map(); | ||
@@ -1036,3 +1042,3 @@ | ||
| (chunkSets.get(key)); | ||
| /** @type {(Set<Chunk> | Chunk)[]} */ | ||
| /** @type {Combinations} */ | ||
| const array = [chunksSet]; | ||
@@ -1070,3 +1076,3 @@ for (const [count, setArray] of chunkSetsByCount) { | ||
| * @param {bigint | Chunk} key key | ||
| * @returns {(Set<Chunk> | Chunk)[]} combinations by key | ||
| * @returns {Combinations} combinations by key | ||
| */ | ||
@@ -1086,3 +1092,3 @@ const getCombinations = (key) => getCombinationsFactory()(key); | ||
| * @param {bigint | Chunk} key key | ||
| * @returns {(Set<Chunk> | Chunk)[]} exports combinations by key | ||
| * @returns {Combinations} exports combinations by key | ||
| */ | ||
@@ -1098,3 +1104,3 @@ const getExportsCombinations = (key) => | ||
| /** @type {WeakMap<Set<Chunk> | Chunk, WeakMap<ChunkFilterFunction, SelectedChunksResult>>} */ | ||
| /** @type {WeakMap<Set<Chunk> | Chunk, WeakMap<ChunkFilterFn, SelectedChunksResult>>} */ | ||
| const selectedChunksCacheByChunksSet = new WeakMap(); | ||
@@ -1106,3 +1112,3 @@ | ||
| * @param {Set<Chunk> | Chunk} chunks list of chunks | ||
| * @param {ChunkFilterFunction} chunkFilter filter function for chunks | ||
| * @param {ChunkFilterFn} chunkFilter filter function for chunks | ||
| * @returns {SelectedChunksResult} list and key | ||
@@ -1168,3 +1174,3 @@ */ | ||
| const name = | ||
| /** @type {GetName} */ | ||
| /** @type {GetNameFn} */ | ||
| (cacheGroup.getName)(module, selectedChunks, cacheGroup.key); | ||
@@ -1331,3 +1337,3 @@ // Check if the name is ok | ||
| chunkCombination, | ||
| /** @type {ChunkFilterFunction} */ | ||
| /** @type {ChunkFilterFn} */ | ||
| (cacheGroup.chunksFilter) | ||
@@ -1354,3 +1360,3 @@ ); | ||
| * @param {ChunksInfoItem} info entry | ||
| * @param {string[]} sourceTypes source types to be removed | ||
| * @param {SourceTypes} sourceTypes source types to be removed | ||
| */ | ||
@@ -1357,0 +1363,0 @@ const removeModulesWithSourceType = (info, sourceTypes) => { |
@@ -8,3 +8,3 @@ /* | ||
| /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */ | ||
| /** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */ | ||
| /** @typedef {import("./Compiler")} Compiler */ | ||
@@ -11,0 +11,0 @@ |
+1
-1
@@ -8,3 +8,3 @@ /* | ||
| /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */ | ||
| /** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */ | ||
| /** @typedef {import("./Compilation")} Compilation */ | ||
@@ -11,0 +11,0 @@ /** @typedef {import("./NormalModule")} NormalModule */ |
@@ -34,2 +34,3 @@ /* | ||
| /** @type {WeakSet<Entrypoint | ChunkGroup | Source>} */ | ||
| const isOverSizeLimitSet = new WeakSet(); | ||
@@ -59,3 +60,3 @@ | ||
| /** | ||
| * @param {ChunkGroup | Source} thing the resource to test | ||
| * @param {Entrypoint | ChunkGroup | Source} thing the resource to test | ||
| * @returns {boolean} true if over the limit | ||
@@ -62,0 +63,0 @@ */ |
@@ -11,13 +11,11 @@ /* | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
| /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ | ||
| class ChunkPrefetchFunctionRuntimeModule extends RuntimeModule { | ||
| /** | ||
| * @param {string} childType TODO | ||
| * @param {string} runtimeFunction TODO | ||
| * @param {string} runtimeHandlers TODO | ||
| * @param {"prefetch" | "preload"} type "prefetch" or "preload" chunk type function | ||
| * @param {string} runtimeFunction the runtime function name | ||
| * @param {string} runtimeHandlers the runtime handlers | ||
| */ | ||
| constructor(childType, runtimeFunction, runtimeHandlers) { | ||
| super(`chunk ${childType} function`); | ||
| this.childType = childType; | ||
| constructor(type, runtimeFunction, runtimeHandlers) { | ||
| super(`chunk ${type} function`); | ||
| this.runtimeFunction = runtimeFunction; | ||
@@ -24,0 +22,0 @@ this.runtimeHandlers = runtimeHandlers; |
@@ -14,4 +14,2 @@ /* | ||
| /** @typedef {import("../Chunk")} Chunk */ | ||
| /** @typedef {import("../ChunkGroup").RawChunkGroupOptions} RawChunkGroupOptions */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
@@ -18,0 +16,0 @@ |
@@ -13,3 +13,2 @@ /* | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
| /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ | ||
@@ -16,0 +15,0 @@ class ChunkPrefetchStartupRuntimeModule extends RuntimeModule { |
@@ -12,7 +12,7 @@ /* | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
| /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ | ||
| /** @typedef {import("../Chunk").ChunkChildIdsByOrdersMap} ChunkChildIdsByOrdersMap */ | ||
| class ChunkPrefetchTriggerRuntimeModule extends RuntimeModule { | ||
| /** | ||
| * @param {Record<string|number, (string|number)[]>} chunkMap map from chunk to | ||
| * @param {ChunkChildIdsByOrdersMap} chunkMap map from chunk to | ||
| */ | ||
@@ -19,0 +19,0 @@ constructor(chunkMap) { |
@@ -12,7 +12,7 @@ /* | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
| /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ | ||
| /** @typedef {import("../Chunk").ChunkChildIdsByOrdersMap} ChunkChildIdsByOrdersMap */ | ||
| class ChunkPreloadTriggerRuntimeModule extends RuntimeModule { | ||
| /** | ||
| * @param {Record<string|number, (string|number)[]>} chunkMap map from chunk to chunks | ||
| * @param {ChunkChildIdsByOrdersMap} chunkMap map from chunk to chunks | ||
| */ | ||
@@ -19,0 +19,0 @@ constructor(chunkMap) { |
@@ -19,5 +19,3 @@ /* | ||
| */ | ||
| /** @typedef {import("../declarations/plugins/ProgressPlugin").HandlerFunction} HandlerFunction */ | ||
| /** @typedef {import("../declarations/plugins/ProgressPlugin").ProgressPluginArgument} ProgressPluginArgument */ | ||
| /** @typedef {import("../declarations/plugins/ProgressPlugin").ProgressPluginOptions} ProgressPluginOptions */ | ||
| /** @typedef {import("./Compilation").FactorizeModuleOptions} FactorizeModuleOptions */ | ||
@@ -58,6 +56,8 @@ /** @typedef {import("./Dependency")} Dependency */ | ||
| /** @typedef {(percentage: number, msg: string, ...args: string[]) => void} HandlerFn */ | ||
| /** | ||
| * @param {boolean | null | undefined} profile need profile | ||
| * @param {Logger} logger logger | ||
| * @returns {defaultHandler} default handler | ||
| * @returns {HandlerFn} default handler | ||
| */ | ||
@@ -68,7 +68,3 @@ const createDefaultHandler = (profile, logger) => { | ||
| /** | ||
| * @param {number} percentage percentage | ||
| * @param {string} msg message | ||
| * @param {...string} args additional arguments | ||
| */ | ||
| /** @type {HandlerFn} */ | ||
| const defaultHandler = (percentage, msg, ...args) => { | ||
@@ -205,3 +201,3 @@ if (profile) { | ||
| * @param {MultiCompiler} compiler webpack multi-compiler | ||
| * @param {HandlerFunction} handler function that executes for every progress step | ||
| * @param {HandlerFn} handler function that executes for every progress step | ||
| * @returns {void} | ||
@@ -225,3 +221,3 @@ */ | ||
| * @param {Compiler} compiler webpack compiler | ||
| * @param {HandlerFunction} handler function that executes for every progress step | ||
| * @param {HandlerFn} handler function that executes for every progress step | ||
| * @returns {void} | ||
@@ -228,0 +224,0 @@ */ |
@@ -62,9 +62,7 @@ /* | ||
| for (const name of Object.keys(definitions)) { | ||
| const request = | ||
| /** @type {string[]} */ | ||
| ([ | ||
| ...(Array.isArray(definitions[name]) | ||
| ? definitions[name] | ||
| : [definitions[name]]) | ||
| ]); | ||
| const request = [ | ||
| ...(Array.isArray(definitions[name]) | ||
| ? definitions[name] | ||
| : [definitions[name]]) | ||
| ]; | ||
| const splittedName = name.split("."); | ||
@@ -71,0 +69,0 @@ if (splittedName.length > 0) { |
+1
-6
@@ -14,8 +14,5 @@ /* | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */ | ||
| /** @typedef {import("./ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */ | ||
| /** @typedef {import("./Compilation")} Compilation */ | ||
| /** @typedef {import("./Dependency").UpdateHashContext} UpdateHashContext */ | ||
| /** @typedef {import("./DependencyTemplates")} DependencyTemplates */ | ||
| /** @typedef {import("./Generator").SourceTypes} SourceTypes */ | ||
@@ -32,4 +29,2 @@ /** @typedef {import("./Module").BuildCallback} BuildCallback */ | ||
| /** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */ | ||
| /** @typedef {import("./RuntimeTemplate")} RuntimeTemplate */ | ||
| /** @typedef {import("./WebpackError")} WebpackError */ | ||
| /** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
@@ -36,0 +31,0 @@ /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ |
@@ -39,2 +39,4 @@ /* | ||
| /** @typedef {Set<number>} UsedIds */ | ||
| const PLUGIN_NAME = "RecordIdsPlugin"; | ||
@@ -79,3 +81,3 @@ | ||
| if (!records.modules.byIdentifier) records.modules.byIdentifier = {}; | ||
| /** @type {Set<number>} */ | ||
| /** @type {UsedIds} */ | ||
| const usedIds = new Set(); | ||
@@ -95,3 +97,3 @@ for (const module of modules) { | ||
| const chunkGraph = compilation.chunkGraph; | ||
| /** @type {Set<number>} */ | ||
| /** @type {UsedIds} */ | ||
| const usedIds = new Set(); | ||
@@ -114,8 +116,10 @@ for (const module of modules) { | ||
| /** @typedef {string[]} ChunkSources */ | ||
| /** | ||
| * @param {Chunk} chunk the chunk | ||
| * @returns {string[]} sources of the chunk | ||
| * @returns {ChunkSources} sources of the chunk | ||
| */ | ||
| const getChunkSources = (chunk) => { | ||
| /** @type {string[]} */ | ||
| /** @type {ChunkSources} */ | ||
| const sources = []; | ||
@@ -163,3 +167,3 @@ for (const chunkGroup of chunk.groupsIterable) { | ||
| if (!records.chunks.bySource) records.chunks.bySource = {}; | ||
| /** @type {Set<number>} */ | ||
| /** @type {UsedIds} */ | ||
| const usedIds = new Set(); | ||
@@ -180,3 +184,3 @@ for (const chunk of chunks) { | ||
| if (!records.chunks) return; | ||
| /** @type {Set<number>} */ | ||
| /** @type {UsedIds} */ | ||
| const usedIds = new Set(); | ||
@@ -183,0 +187,0 @@ if (records.chunks.byName) { |
@@ -16,5 +16,3 @@ /* | ||
| /** @typedef {import("enhanced-resolve").ResolveContext} ResolveContext */ | ||
| /** @typedef {import("enhanced-resolve").ResolveOptions} ResolveOptions */ | ||
| /** @typedef {import("enhanced-resolve").ResolveRequest} ResolveRequest */ | ||
| /** @typedef {import("enhanced-resolve").Resolver} Resolver */ | ||
@@ -21,0 +19,0 @@ /** @typedef {import("../declarations/WebpackOptions").ResolveOptions} WebpackResolveOptions */ |
@@ -10,6 +10,4 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").RuleSetConditionOrConditionsAbsolute} RuleSetConditionOrConditionsAbsolute */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").RuleSetLoaderOptions} RuleSetLoaderOptions */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */ | ||
| /** @typedef {import("./RuleSetCompiler")} RuleSetCompiler */ | ||
| /** @typedef {import("./RuleSetCompiler").RuleCondition} RuleCondition */ | ||
@@ -16,0 +14,0 @@ /** |
@@ -12,3 +12,2 @@ /* | ||
| /** @typedef {import("./RuleSetCompiler").EffectData} EffectData */ | ||
| /** @typedef {import("./RuleSetCompiler").RuleCondition} RuleCondition */ | ||
| /** @typedef {import("./RuleSetCompiler").RuleConditionFunction} RuleConditionFunction */ | ||
@@ -15,0 +14,0 @@ |
@@ -10,6 +10,6 @@ /* | ||
| /** @typedef {import("enhanced-resolve").ResolveRequest} ResolveRequest */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").Falsy} Falsy */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").RuleSetLoaderOptions} RuleSetLoaderOptions */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").RuleSetRule} RuleSetRule */ | ||
| /** @typedef {import("../NormalModule").LoaderItem} LoaderItem */ | ||
@@ -42,6 +42,6 @@ /** @typedef {(Falsy | RuleSetRule)[]} RuleSetRules */ | ||
| * @property {string=} scheme | ||
| * @property {ImportAttributes=} assertions | ||
| * @property {ImportAttributes=} attributes | ||
| * @property {string=} mimetype | ||
| * @property {string} dependency | ||
| * @property {Record<string, EXPECTED_ANY>=} descriptionData | ||
| * @property {ResolveRequest["descriptionFileData"]=} descriptionData | ||
| * @property {string=} compiler | ||
@@ -90,2 +90,4 @@ * @property {string} issuer | ||
| /** @typedef {Set<string>} UnhandledProperties */ | ||
| /** @typedef {{ apply: (ruleSetCompiler: RuleSetCompiler) => void }} RuleSetPlugin */ | ||
@@ -99,3 +101,3 @@ | ||
| this.hooks = Object.freeze({ | ||
| /** @type {SyncHook<[string, RuleSetRule, Set<string>, CompiledRule, References]>} */ | ||
| /** @type {SyncHook<[string, RuleSetRule, UnhandledProperties, CompiledRule, References]>} */ | ||
| rule: new SyncHook([ | ||
@@ -134,3 +136,3 @@ "path", | ||
| if (Array.isArray(p)) { | ||
| /** @type {EffectData | EffectData[keyof EffectData] | undefined} */ | ||
| /** @type {EXPECTED_ANY} */ | ||
| let current = data; | ||
@@ -227,3 +229,3 @@ for (const subProperty of p) { | ||
| compileRule(path, rule, refs) { | ||
| /** @type {Set<string>} */ | ||
| /** @type {UnhandledProperties} */ | ||
| const unhandledProperties = new Set( | ||
@@ -230,0 +232,0 @@ Object.keys(rule).filter( |
@@ -11,3 +11,3 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").EntryDescriptionNormalized} EntryDescriptionNormalized */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").EntryDescriptionNormalized} EntryDescription */ | ||
| /** @typedef {import("../Chunk")} Chunk */ | ||
@@ -26,3 +26,3 @@ | ||
| const options = | ||
| /** @type {EntryDescriptionNormalized} */ | ||
| /** @type {EntryDescription} */ | ||
| (chunk.getEntryOptions()); | ||
@@ -29,0 +29,0 @@ return `${RuntimeGlobals.baseURI} = ${ |
@@ -13,3 +13,2 @@ /* | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
| /** @typedef {import("../MainTemplate")} MainTemplate */ | ||
@@ -16,0 +15,0 @@ class CompatRuntimeModule extends RuntimeModule { |
@@ -16,3 +16,2 @@ /* | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
| /** @typedef {import("../Compilation").AssetInfo} AssetInfo */ | ||
| /** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */ | ||
@@ -129,3 +128,3 @@ | ||
| /** | ||
| * @param {string | number} value a value | ||
| * @param {ChunkId} value a value | ||
| * @returns {string} string to put in quotes | ||
@@ -199,6 +198,6 @@ */ | ||
| const createMap = (fn) => { | ||
| /** @type {Record<number | string, number | string>} */ | ||
| /** @type {Record<ChunkId, ChunkId>} */ | ||
| const obj = {}; | ||
| let useId = false; | ||
| /** @type {number | string | undefined} */ | ||
| /** @type {ChunkId | undefined} */ | ||
| let lastKey; | ||
@@ -211,4 +210,4 @@ let entries = 0; | ||
| } else { | ||
| obj[/** @type {number | string} */ (c.id)] = value; | ||
| lastKey = /** @type {number | string} */ (c.id); | ||
| obj[/** @type {ChunkId} */ (c.id)] = value; | ||
| lastKey = /** @type {ChunkId} */ (c.id); | ||
| entries++; | ||
@@ -221,5 +220,5 @@ } | ||
| ? `(chunkId === ${JSON.stringify(lastKey)} ? ${JSON.stringify( | ||
| obj[/** @type {number | string} */ (lastKey)] | ||
| obj[/** @type {ChunkId} */ (lastKey)] | ||
| )} : chunkId)` | ||
| : JSON.stringify(obj[/** @type {number | string} */ (lastKey)]); | ||
| : JSON.stringify(obj[/** @type {ChunkId} */ (lastKey)]); | ||
| } | ||
@@ -256,3 +255,3 @@ return useId | ||
| ), | ||
| name: mapExpr((c) => c.name || /** @type {number | string} */ (c.id)), | ||
| name: mapExpr((c) => c.name || /** @type {ChunkId} */ (c.id)), | ||
| contentHash: { | ||
@@ -259,0 +258,0 @@ [contentType]: mapExpr((c) => c.contentHash[contentType]) |
@@ -14,3 +14,2 @@ /* | ||
| /** @typedef {import("../Chunk")} Chunk */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
@@ -78,3 +77,2 @@ /** | ||
| charset ? "script.charset = 'utf-8';" : "", | ||
| `script.timeout = ${/** @type {number} */ (loadTimeout) / 1000};`, | ||
| `if (${RuntimeGlobals.scriptNonce}) {`, | ||
@@ -81,0 +79,0 @@ Template.indent( |
@@ -177,3 +177,3 @@ /* | ||
| init, | ||
| `var keys = Reflect.ownKeys(ns).filter(${runtimeTemplate.expressionFunction('x !== "then"', "x")}).concat([Symbol.toStringTag]);`, | ||
| `var keys = Reflect.ownKeys(ns).filter(${runtimeTemplate.expressionFunction('x !== "then" && x !== Symbol.toStringTag', "x")}).concat([Symbol.toStringTag]);`, | ||
| "return keys;" | ||
@@ -180,0 +180,0 @@ ])},`, |
@@ -10,3 +10,3 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} OutputOptions */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").PublicPath} PublicPath */ | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
@@ -16,3 +16,3 @@ | ||
| /** | ||
| * @param {OutputOptions["publicPath"]} publicPath public path | ||
| * @param {PublicPath} publicPath public path | ||
| */ | ||
@@ -19,0 +19,0 @@ constructor(publicPath) { |
@@ -11,3 +11,2 @@ /* | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
| /** @typedef {import("../MainTemplate")} MainTemplate */ | ||
@@ -14,0 +13,0 @@ class StartupEntrypointRuntimeModule extends RuntimeModule { |
@@ -10,4 +10,2 @@ /* | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
| class SystemContextRuntimeModule extends RuntimeModule { | ||
@@ -14,0 +12,0 @@ constructor() { |
@@ -420,2 +420,7 @@ /* | ||
| /** | ||
| * to binary helper, convert base64 to Uint8Array | ||
| */ | ||
| module.exports.toBinary = "__webpack_require__.tb"; | ||
| /** | ||
| * the uncaught error handler for the webpack runtime | ||
@@ -422,0 +427,0 @@ */ |
@@ -14,4 +14,3 @@ /* | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */ | ||
| /** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */ | ||
| /** @typedef {import("./Chunk")} Chunk */ | ||
@@ -29,3 +28,2 @@ /** @typedef {import("./ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("./ResolverFactory").ResolverWithOptions} ResolverWithOptions */ | ||
| /** @typedef {import("./WebpackError")} WebpackError */ | ||
| /** @typedef {import("./util/Hash")} Hash */ | ||
@@ -32,0 +30,0 @@ /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */ |
+26
-22
@@ -9,3 +9,2 @@ /* | ||
| const RuntimeGlobals = require("./RuntimeGlobals"); | ||
| const { getChunkFilenameTemplate } = require("./css/CssModulesPlugin"); | ||
| const RuntimeRequirementsDependency = require("./dependencies/RuntimeRequirementsDependency"); | ||
@@ -37,2 +36,3 @@ const JavascriptModulesPlugin = require("./javascript/JavascriptModulesPlugin"); | ||
| const SystemContextRuntimeModule = require("./runtime/SystemContextRuntimeModule"); | ||
| const ToBinaryRuntimeModule = require("./runtime/ToBinaryRuntimeModule"); | ||
| const ShareRuntimeModule = require("./sharing/ShareRuntimeModule"); | ||
@@ -43,7 +43,4 @@ const StringXor = require("./util/StringXor"); | ||
| /** @typedef {import("../declarations/WebpackOptions").LibraryOptions} LibraryOptions */ | ||
| /** @typedef {import("../declarations/WebpackOptions").OutputNormalized} OutputNormalized */ | ||
| /** @typedef {import("./Chunk")} Chunk */ | ||
| /** @typedef {import("./Compiler")} Compiler */ | ||
| /** @typedef {import("./Module")} Module */ | ||
| /** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */ | ||
@@ -316,8 +313,6 @@ const getJavascriptModulesPlugin = memoize(() => | ||
| getJavascriptModulesPlugin().chunkHasJs(chunk, chunkGraph) && | ||
| /** @type {TemplatePath} */ ( | ||
| chunk.filenameTemplate || | ||
| (chunk.canBeInitial() | ||
| ? compilation.outputOptions.filename | ||
| : compilation.outputOptions.chunkFilename) | ||
| ), | ||
| (chunk.filenameTemplate || | ||
| (chunk.canBeInitial() | ||
| ? compilation.outputOptions.filename | ||
| : compilation.outputOptions.chunkFilename)), | ||
| set.has(RuntimeGlobals.hmrDownloadUpdateHandlers) | ||
@@ -345,5 +340,13 @@ ) | ||
| RuntimeGlobals.getChunkCssFilename, | ||
| (chunk) => | ||
| getCssModulesPlugin().chunkHasCss(chunk, chunkGraph) && | ||
| getChunkFilenameTemplate(chunk, compilation.outputOptions), | ||
| (chunk) => { | ||
| const cssModulePlugin = getCssModulesPlugin(); | ||
| return ( | ||
| cssModulePlugin.chunkHasCss(chunk, chunkGraph) && | ||
| cssModulePlugin.getChunkFilenameTemplate( | ||
| chunk, | ||
| compilation.outputOptions | ||
| ) | ||
| ); | ||
| }, | ||
| set.has(RuntimeGlobals.hmrDownloadUpdateHandlers) | ||
@@ -359,4 +362,3 @@ ) | ||
| /\[(full)?hash(:\d+)?\]/.test( | ||
| /** @type {NonNullable<OutputNormalized["hotUpdateChunkFilename"]>} */ | ||
| (compilation.outputOptions.hotUpdateChunkFilename) | ||
| compilation.outputOptions.hotUpdateChunkFilename | ||
| ) | ||
@@ -372,5 +374,3 @@ ) { | ||
| RuntimeGlobals.getChunkUpdateScriptFilename, | ||
| (_chunk) => | ||
| /** @type {NonNullable<OutputNormalized["hotUpdateChunkFilename"]>} */ | ||
| (compilation.outputOptions.hotUpdateChunkFilename), | ||
| (_chunk) => compilation.outputOptions.hotUpdateChunkFilename, | ||
| true | ||
@@ -386,4 +386,3 @@ ) | ||
| /\[(full)?hash(:\d+)?\]/.test( | ||
| /** @type {NonNullable<OutputNormalized["hotUpdateMainFilename"]>} */ | ||
| (compilation.outputOptions.hotUpdateMainFilename) | ||
| compilation.outputOptions.hotUpdateMainFilename | ||
| ) | ||
@@ -398,4 +397,3 @@ ) { | ||
| RuntimeGlobals.getUpdateManifestFilename, | ||
| /** @type {NonNullable<OutputNormalized["hotUpdateMainFilename"]>} */ | ||
| (compilation.outputOptions.hotUpdateMainFilename) | ||
| compilation.outputOptions.hotUpdateMainFilename | ||
| ) | ||
@@ -504,2 +502,8 @@ ); | ||
| }); | ||
| compilation.hooks.runtimeRequirementInTree | ||
| .for(RuntimeGlobals.toBinary) | ||
| .tap(PLUGIN_NAME, (chunk) => { | ||
| compilation.addRuntimeModule(chunk, new ToBinaryRuntimeModule()); | ||
| return true; | ||
| }); | ||
| // TODO webpack 6: remove CompatRuntimeModule | ||
@@ -506,0 +510,0 @@ compilation.hooks.additionalTreeRuntimeRequirements.tap( |
+12
-11
@@ -23,9 +23,6 @@ /* | ||
| /** @typedef {import("../declarations/WebpackOptions").Environment} Environment */ | ||
| /** @typedef {import("../declarations/WebpackOptions").OutputNormalized} OutputOptions */ | ||
| /** @typedef {import("./config/defaults").OutputNormalizedWithDefaults} OutputOptions */ | ||
| /** @typedef {import("./AsyncDependenciesBlock")} AsyncDependenciesBlock */ | ||
| /** @typedef {import("./Chunk")} Chunk */ | ||
| /** @typedef {import("./ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */ | ||
| /** @typedef {import("./CodeGenerationResults").CodeGenerationResult} CodeGenerationResult */ | ||
| /** @typedef {import("./Compilation")} Compilation */ | ||
@@ -101,6 +98,3 @@ /** @typedef {import("./Dependency")} Dependency */ | ||
| (getGlobalObject(outputOptions.globalObject)); | ||
| this.contentHashReplacement = "X".repeat( | ||
| /** @type {NonNullable<OutputOptions["hashDigestLength"]>} */ | ||
| (outputOptions.hashDigestLength) | ||
| ); | ||
| this.contentHashReplacement = "X".repeat(outputOptions.hashDigestLength); | ||
| } | ||
@@ -118,3 +112,3 @@ | ||
| return ( | ||
| !this.outputOptions.environment.document && | ||
| !this.compilation.compiler.platform.web && | ||
| !this.compilation.compiler.platform.node | ||
@@ -179,2 +173,9 @@ ); | ||
| /** | ||
| * @returns {"const" | "var"} return `const` when it is supported, otherwise `var` | ||
| */ | ||
| renderConst() { | ||
| return this.supportsConst() ? "const" : "var"; | ||
| } | ||
| /** | ||
| * @param {string} returnValue return value | ||
@@ -202,3 +203,3 @@ * @param {string} args arguments | ||
| /** | ||
| * @param {Array<string|{expr: string}>} args args | ||
| * @param {(string | { expr: string })[]} args args | ||
| * @returns {string} result expression | ||
@@ -252,3 +253,3 @@ */ | ||
| /** | ||
| * @param {Array<string|{expr: string}>} args args (len >= 2) | ||
| * @param {(string | { expr: string })[]} args args (len >= 2) | ||
| * @returns {string} result expression | ||
@@ -255,0 +256,0 @@ * @private |
@@ -9,33 +9,6 @@ /* | ||
| const NormalModule = require("../NormalModule"); | ||
| const { URIRegEx, decodeDataURI } = require("../util/dataURL"); | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| // data URL scheme: "data:text/javascript;charset=utf-8;base64,some-string" | ||
| // http://www.ietf.org/rfc/rfc2397.txt | ||
| const URIRegEx = /^data:([^;,]+)?((?:;[^;,]+)*?)(?:;(base64)?)?,(.*)$/i; | ||
| /** | ||
| * @param {string} uri data URI | ||
| * @returns {Buffer | null} decoded data | ||
| */ | ||
| const decodeDataURI = (uri) => { | ||
| const match = URIRegEx.exec(uri); | ||
| if (!match) return null; | ||
| const isBase64 = match[3]; | ||
| const body = match[4]; | ||
| if (isBase64) { | ||
| return Buffer.from(body, "base64"); | ||
| } | ||
| // CSS allows to use `data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg"><rect width="100%" height="100%" style="stroke: rgb(223,224,225); stroke-width: 2px; fill: none; stroke-dasharray: 6px 3px" /></svg>` | ||
| // so we return original body if we can't `decodeURIComponent` | ||
| try { | ||
| return Buffer.from(decodeURIComponent(body), "ascii"); | ||
| } catch (_) { | ||
| return Buffer.from(body, "ascii"); | ||
| } | ||
| }; | ||
| const PLUGIN_NAME = "DataUriPlugin"; | ||
@@ -66,2 +39,3 @@ | ||
| }); | ||
| NormalModule.getCompilationHooks(compilation) | ||
@@ -68,0 +42,0 @@ .readResourceForScheme.for("data") |
@@ -43,4 +43,7 @@ /* | ||
| const { resourcePath } = loaderContext; | ||
| loaderContext.addDependency(resourcePath); | ||
| loaderContext.fs.readFile(resourcePath, callback); | ||
| loaderContext.fs.readFile(resourcePath, (err, result) => { | ||
| if (err) return callback(err); | ||
| loaderContext.addDependency(resourcePath); | ||
| callback(null, result); | ||
| }); | ||
| }); | ||
@@ -47,0 +50,0 @@ } |
@@ -1202,4 +1202,6 @@ /* | ||
| const result = /** @type {Info} */ (_result); | ||
| /** @type {BuildInfo} */ | ||
| (module.buildInfo).resourceIntegrity = result.entry.integrity; | ||
| if (module) { | ||
| /** @type {BuildInfo} */ | ||
| (module.buildInfo).resourceIntegrity = result.entry.integrity; | ||
| } | ||
| callback(null, result.content); | ||
@@ -1206,0 +1208,0 @@ }) |
@@ -14,5 +14,2 @@ /* | ||
| /** @typedef {import("../NormalModule")} NormalModule */ | ||
| /** @typedef {import("../Module").BuildInfo} BuildInfo */ | ||
| /** @typedef {import("../Module").ValueCacheVersions} ValueCacheVersions */ | ||
| /** @typedef {string | Set<string>} ValueCacheVersion */ | ||
@@ -27,14 +24,17 @@ /** | ||
| /** @typedef {(loaderContext: LoaderContext<EXPECTED_ANY>) => Promise<string | Buffer> | string | Buffer} SourceFn */ | ||
| /** @typedef {() => string} VersionFn */ | ||
| /** | ||
| * @typedef {object} VirtualModuleConfig | ||
| * @property {string=} type - The module type | ||
| * @property {(loaderContext: LoaderContext<EXPECTED_ANY>) => Promise<string> | string} source - The source function | ||
| * @property {(() => string) | true | string=} version - Optional version function or value | ||
| * @property {string=} type the module type | ||
| * @property {SourceFn} source the source function | ||
| * @property {VersionFn | true | string=} version optional version function or value | ||
| */ | ||
| /** | ||
| * @typedef {string | ((loaderContext: LoaderContext<EXPECTED_ANY>) => Promise<string> | string) | VirtualModuleConfig} VirtualModuleInput | ||
| * @typedef {string | SourceFn | VirtualModuleConfig} VirtualModuleInput | ||
| */ | ||
| /** @typedef {{[key: string]: VirtualModuleInput}} VirtualModules */ | ||
| /** @typedef {{ [key: string]: VirtualModuleInput }} VirtualModules */ | ||
@@ -67,3 +67,3 @@ /** | ||
| * @param {string} scheme The URL scheme to use | ||
| * @returns {{[key: string]: VirtualModuleConfig}} The normalized virtual modules | ||
| * @returns {{ [key: string]: VirtualModuleConfig }} The normalized virtual modules | ||
| */ | ||
@@ -74,3 +74,3 @@ function normalizeModules(virtualConfigs, scheme) { | ||
| return pre; | ||
| }, /** @type {{[key: string]: VirtualModuleConfig}} */ ({})); | ||
| }, /** @type {{ [key: string]: VirtualModuleConfig }} */ ({})); | ||
| } | ||
@@ -214,3 +214,3 @@ | ||
| * Get the cache version for a given version value | ||
| * @param {(() => string) | true | string} version The version value or function | ||
| * @param {VersionFn | true | string} version The version value or function | ||
| * @returns {string | undefined} The cache version | ||
@@ -217,0 +217,0 @@ */ |
@@ -10,2 +10,4 @@ /* | ||
| /** @typedef {string[]} Keys */ | ||
| class NullPrototypeObjectSerializer { | ||
@@ -18,3 +20,3 @@ /** | ||
| serialize(obj, context) { | ||
| /** @type {string[]} */ | ||
| /** @type {Keys} */ | ||
| const keys = Object.keys(obj); | ||
@@ -38,5 +40,5 @@ for (const key of keys) { | ||
| const obj = Object.create(null); | ||
| /** @type {string[]} */ | ||
| /** @type {Keys} */ | ||
| const keys = []; | ||
| /** @type {string | null} */ | ||
| /** @type {Keys[number] | null} */ | ||
| let key = context.read(); | ||
@@ -43,0 +45,0 @@ while (key !== null) { |
@@ -59,3 +59,3 @@ /* | ||
| */ | ||
| /** @typedef {TODO} Value */ | ||
| /** @typedef {EXPECTED_OBJECT | string} ReferenceableItem */ | ||
@@ -65,8 +65,8 @@ | ||
| * @typedef {object} ObjectSerializerContext | ||
| * @property {(value: Value) => void} write | ||
| * @property {(value: EXPECTED_ANY) => void} write | ||
| * @property {(value: ReferenceableItem) => void} setCircularReference | ||
| * @property {() => ObjectSerializerSnapshot} snapshot | ||
| * @property {(snapshot: ObjectSerializerSnapshot) => void} rollback | ||
| * @property {((item: Value | (() => Value)) => void)=} writeLazy | ||
| * @property {((item: (Value | (() => Value)), obj: LazyOptions | undefined) => import("./SerializerMiddleware").LazyFunction<EXPECTED_ANY, EXPECTED_ANY, EXPECTED_ANY, LazyOptions>)=} writeSeparate | ||
| * @property {((item: EXPECTED_ANY | (() => EXPECTED_ANY)) => void)=} writeLazy | ||
| * @property {((item: (EXPECTED_ANY | (() => EXPECTED_ANY)), obj: LazyOptions | undefined) => import("./SerializerMiddleware").LazyFunction<EXPECTED_ANY, EXPECTED_ANY, EXPECTED_ANY, LazyOptions>)=} writeSeparate | ||
| */ | ||
@@ -76,3 +76,3 @@ | ||
| * @typedef {object} ObjectDeserializerContext | ||
| * @property {() => Value} read | ||
| * @property {() => EXPECTED_ANY} read | ||
| * @property {(value: ReferenceableItem) => void} setCircularReference | ||
@@ -83,4 +83,4 @@ */ | ||
| * @typedef {object} ObjectSerializer | ||
| * @property {(value: Value, context: ObjectSerializerContext) => void} serialize | ||
| * @property {(context: ObjectDeserializerContext) => Value} deserialize | ||
| * @property {(value: EXPECTED_ANY, context: ObjectSerializerContext) => void} serialize | ||
| * @property {(context: ObjectDeserializerContext) => EXPECTED_ANY} deserialize | ||
| */ | ||
@@ -137,3 +137,3 @@ | ||
| /** @type {Map<Constructor, SerializerConfig>} */ | ||
| /** @type {Map<Constructor | null, SerializerConfig>} */ | ||
| const serializers = new Map(); | ||
@@ -148,2 +148,3 @@ /** @type {Map<string | number, ObjectSerializer>} */ | ||
| /** @type {Map<Constructor | null, ObjectSerializer>} */ | ||
| const jsTypes = new Map(); | ||
@@ -344,3 +345,3 @@ | ||
| serialize(data, context) { | ||
| /** @type {Value[]} */ | ||
| /** @type {PrimitiveSerializableType[]} */ | ||
| let result = [CURRENT_VERSION]; | ||
@@ -422,3 +423,3 @@ let currentPos = 0; | ||
| /** | ||
| * @param {Value} item item to stack | ||
| * @param {ComplexSerializableType} item item to stack | ||
| * @returns {string} stack | ||
@@ -522,3 +523,3 @@ */ | ||
| /** | ||
| * @param {Value} item item to serialize | ||
| * @param {ComplexSerializableType} item item to serialize | ||
| */ | ||
@@ -545,3 +546,3 @@ const process = (item) => { | ||
| result.push(item); | ||
| result.push(/** @type {Buffer} */ (item)); | ||
| } else if (item === ESCAPE) { | ||
@@ -566,4 +567,6 @@ result.push(ESCAPE, ESCAPE_ESCAPE_VALUE); | ||
| const { request, name, serializer } = | ||
| ObjectMiddleware.getSerializerFor(item); | ||
| const { request, name, serializer } = ObjectMiddleware.getSerializerFor( | ||
| /** @type {Constructor} */ | ||
| (item) | ||
| ); | ||
| const key = `${request}/${name}`; | ||
@@ -630,5 +633,9 @@ const lastIndex = objectTypeLookup.get(key); | ||
| } else { | ||
| const data = SerializerMiddleware.serializeLazy(item, (data) => | ||
| this.serialize([data], context) | ||
| ); | ||
| const data = | ||
| /** @type {() => PrimitiveSerializableType[] | Promise<PrimitiveSerializableType[]>} */ | ||
| ( | ||
| SerializerMiddleware.serializeLazy(item, (data) => | ||
| this.serialize([data], context) | ||
| ) | ||
| ); | ||
| SerializerMiddleware.setLazySerializedValue(item, data); | ||
@@ -692,3 +699,3 @@ result.push(data); | ||
| /** | ||
| * @param {Value} item referenceable item | ||
| * @param {ReferenceableItem} item referenceable item | ||
| */ | ||
@@ -702,2 +709,3 @@ const addReferenceable = (item) => { | ||
| let objectTypeLookup = []; | ||
| /** @type {ComplexSerializableType[]} */ | ||
| let result = []; | ||
@@ -715,2 +723,5 @@ /** @type {ObjectDeserializerContext} */ | ||
| this.extendContext(ctx); | ||
| /** | ||
| * @returns {ComplexSerializableType} deserialize value | ||
| */ | ||
| const decodeValue = () => { | ||
@@ -807,3 +818,3 @@ const item = read(); | ||
| : !serializerEntry[1].request | ||
| ? serializerEntry[0].name | ||
| ? /** @type {Constructor[]} */ (serializerEntry)[0].name | ||
| : serializerEntry[1].name | ||
@@ -810,0 +821,0 @@ ? `${serializerEntry[1].request} ${serializerEntry[1].name}` |
@@ -99,3 +99,2 @@ /* | ||
| * @template {Record<string, EXPECTED_ANY>} TLazyOptions | ||
| * @template TLazySerializedValue | ||
| * @param {LazyFunction<TLazyInputValue, TLazyOutputValue, TLazyTarget, TLazyOptions>} fn lazy function | ||
@@ -127,3 +126,3 @@ * @returns {LazyOptions | undefined} options | ||
| * @template {LazyOptions} TLazyOptions | ||
| * @param {LazyFunction<TLazyInputValue, TLazyOutputValue, LazyTarget, LazyOptions>} fn lazy function | ||
| * @param {LazyFunction<TLazyInputValue, TLazyOutputValue, TLazyTarget, TLazyOptions>} fn lazy function | ||
| * @param {TLazyOutputValue} value serialized value | ||
@@ -173,3 +172,2 @@ * @returns {void} | ||
| * @template TLazyOutputValue DeserializedValue | ||
| * @template SerializedValue | ||
| * @template {LazyTarget} TLazyTarget | ||
@@ -176,0 +174,0 @@ * @template {LazyOptions | undefined} TLazyOptions |
@@ -7,3 +7,3 @@ /* | ||
| /** @typedef {undefined | null | number | string | boolean | Buffer | EXPECTED_OBJECT | (() => ComplexSerializableType[] | Promise<ComplexSerializableType[]>)} ComplexSerializableType */ | ||
| /** @typedef {undefined | null | number | bigint | string | boolean | Buffer | EXPECTED_OBJECT | (() => ComplexSerializableType[] | Promise<ComplexSerializableType[]>)} ComplexSerializableType */ | ||
@@ -10,0 +10,0 @@ /** @typedef {undefined | null | number | bigint | string | boolean | Buffer | (() => PrimitiveSerializableType[] | Promise<PrimitiveSerializableType[]>)} PrimitiveSerializableType */ |
@@ -20,5 +20,3 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../ChunkGroup")} ChunkGroup */ | ||
| /** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */ | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
@@ -30,2 +28,3 @@ /** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */ | ||
| /** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */ | ||
| /** @typedef {import("../Module").LibIdent} LibIdent */ | ||
| /** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */ | ||
@@ -36,3 +35,2 @@ /** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */ | ||
| /** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */ | ||
| /** @typedef {import("../WebpackError")} WebpackError */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
@@ -110,3 +108,3 @@ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| * @param {LibIdentOptions} options options | ||
| * @returns {string | null} an identifier for library inclusion | ||
| * @returns {LibIdent | null} an identifier for library inclusion | ||
| */ | ||
@@ -113,0 +111,0 @@ libIdent(options) { |
@@ -26,4 +26,4 @@ /* | ||
| /** @typedef {import("enhanced-resolve").ResolveContext} ResolveContext */ | ||
| /** @typedef {import("../../declarations/plugins/sharing/ConsumeSharedPlugin").ConsumeSharedPluginOptions} ConsumeSharedPluginOptions */ | ||
| /** @typedef {import("../../declarations/plugins/sharing/ConsumeSharedPlugin").ConsumesConfig} ConsumesConfig */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
@@ -172,8 +172,6 @@ /** @typedef {import("../ResolverFactory").ResolveOptionsWithDependencyType} ResolveOptionsWithDependencyType */ | ||
| } | ||
| /** @typedef {ResolveContext} */ | ||
| const resolveContext = { | ||
| /** @type {LazySet<string>} */ | ||
| fileDependencies: new LazySet(), | ||
| /** @type {LazySet<string>} */ | ||
| contextDependencies: new LazySet(), | ||
| /** @type {LazySet<string>} */ | ||
| missingDependencies: new LazySet() | ||
@@ -180,0 +178,0 @@ }; |
@@ -26,3 +26,3 @@ /* | ||
| /** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */ | ||
| /** @typedef {import("./ConsumeSharedModule")} ConsumeSharedModule */ | ||
| /** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */ | ||
@@ -44,8 +44,11 @@ class ConsumeSharedRuntimeModule extends RuntimeModule { | ||
| const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph); | ||
| const { runtimeTemplate, codeGenerationResults } = compilation; | ||
| /** @type {Record<ChunkId, (string | number)[]>} */ | ||
| const codeGenerationResults = | ||
| /** @type {CodeGenerationResults} */ | ||
| (compilation.codeGenerationResults); | ||
| const { runtimeTemplate } = compilation; | ||
| /** @type {Record<ChunkId, ModuleId[]>} */ | ||
| const chunkToModuleMapping = {}; | ||
| /** @type {Map<string | number, Source>} */ | ||
| /** @type {Map<ModuleId, Source>} */ | ||
| const moduleIdToSourceMapping = new Map(); | ||
| /** @type {(string | number)[]} */ | ||
| /** @type {ModuleId[]} */ | ||
| const initialConsumes = []; | ||
@@ -55,3 +58,3 @@ /** | ||
| * @param {Chunk} chunk the chunk | ||
| * @param {(string | number)[]} list list of ids | ||
| * @param {ModuleId[]} list list of ids | ||
| */ | ||
@@ -58,0 +61,0 @@ const addModules = (modules, chunk, list) => { |
@@ -16,6 +16,3 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */ | ||
| /** @typedef {import("../Chunk")} Chunk */ | ||
| /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../ChunkGroup")} ChunkGroup */ | ||
| /** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */ | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
@@ -26,2 +23,3 @@ /** @typedef {import("../Module").BuildCallback} BuildCallback */ | ||
| /** @typedef {import("../Module").LibIdentOptions} LibIdentOptions */ | ||
| /** @typedef {import("../Module").LibIdent} LibIdent */ | ||
| /** @typedef {import("../Module").NeedBuildCallback} NeedBuildCallback */ | ||
@@ -32,6 +30,4 @@ /** @typedef {import("../Module").NeedBuildContext} NeedBuildContext */ | ||
| /** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */ | ||
| /** @typedef {import("../WebpackError")} WebpackError */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */ | ||
| /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */ | ||
| /** @typedef {import("../util/Hash")} Hash */ | ||
| /** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */ | ||
@@ -75,3 +71,3 @@ | ||
| * @param {LibIdentOptions} options options | ||
| * @returns {string | null} an identifier for library inclusion | ||
| * @returns {LibIdent | null} an identifier for library inclusion | ||
| */ | ||
@@ -78,0 +74,0 @@ libIdent(options) { |
@@ -11,2 +11,3 @@ /* | ||
| /** @typedef {import("enhanced-resolve").ResolveContext} ResolveContext */ | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
@@ -39,8 +40,6 @@ /** @typedef {import("../ResolverFactory").ResolveOptionsWithDependencyType} ResolveOptionsWithDependencyType */ | ||
| const prefixed = new Map(); | ||
| /** @type {ResolveContext} */ | ||
| const resolveContext = { | ||
| /** @type {LazySet<string>} */ | ||
| fileDependencies: new LazySet(), | ||
| /** @type {LazySet<string>} */ | ||
| contextDependencies: new LazySet(), | ||
| /** @type {LazySet<string>} */ | ||
| missingDependencies: new LazySet() | ||
@@ -89,7 +88,16 @@ }; | ||
| ).then(() => { | ||
| compilation.contextDependencies.addAll(resolveContext.contextDependencies); | ||
| compilation.fileDependencies.addAll(resolveContext.fileDependencies); | ||
| compilation.missingDependencies.addAll(resolveContext.missingDependencies); | ||
| compilation.contextDependencies.addAll( | ||
| /** @type {LazySet<string>} */ | ||
| (resolveContext.contextDependencies) | ||
| ); | ||
| compilation.fileDependencies.addAll( | ||
| /** @type {LazySet<string>} */ | ||
| (resolveContext.fileDependencies) | ||
| ); | ||
| compilation.missingDependencies.addAll( | ||
| /** @type {LazySet<string>} */ | ||
| (resolveContext.missingDependencies) | ||
| ); | ||
| return { resolved, unresolved, prefixed }; | ||
| }); | ||
| }; |
@@ -13,5 +13,3 @@ /* | ||
| /** @typedef {import("../../declarations/plugins/sharing/ConsumeSharedPlugin").ConsumeSharedPluginOptions} ConsumeSharedPluginOptions */ | ||
| /** @typedef {import("../../declarations/plugins/sharing/ConsumeSharedPlugin").ConsumesConfig} ConsumesConfig */ | ||
| /** @typedef {import("../../declarations/plugins/sharing/ProvideSharedPlugin").ProvideSharedPluginOptions} ProvideSharedPluginOptions */ | ||
| /** @typedef {import("../../declarations/plugins/sharing/ProvideSharedPlugin").ProvidesConfig} ProvidesConfig */ | ||
@@ -18,0 +16,0 @@ /** @typedef {import("../../declarations/plugins/sharing/SharePlugin").SharePluginOptions} SharePluginOptions */ |
@@ -19,2 +19,3 @@ /* | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
| /** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */ | ||
@@ -33,5 +34,7 @@ class ShareRuntimeModule extends RuntimeModule { | ||
| runtimeTemplate, | ||
| codeGenerationResults, | ||
| outputOptions: { uniqueName, ignoreBrowserWarnings } | ||
| } = compilation; | ||
| const codeGenerationResults = | ||
| /** @type {CodeGenerationResults} */ | ||
| (compilation.codeGenerationResults); | ||
| const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph); | ||
@@ -38,0 +41,0 @@ /** @type {Map<string, Map<number, Set<string>>>} */ |
@@ -154,3 +154,2 @@ /* | ||
| * extract commit hash from parsed url | ||
| * @inner | ||
| * @param {URL} urlParsed parsed url | ||
@@ -185,3 +184,2 @@ * @returns {string} commithash | ||
| * make url right for URL parse | ||
| * @inner | ||
| * @param {string} gitUrl git url | ||
@@ -198,3 +196,2 @@ * @returns {string} fixed url | ||
| * make url protocol right for URL parse | ||
| * @inner | ||
| * @param {string} gitUrl git url | ||
@@ -219,3 +216,2 @@ * @returns {string} fixed url | ||
| * extract git dep version from hash | ||
| * @inner | ||
| * @param {string} hash hash | ||
@@ -232,3 +228,2 @@ * @returns {string} git dep version | ||
| * if string can be decoded | ||
| * @inner | ||
| * @param {string} str str to be checked | ||
@@ -249,3 +244,2 @@ * @returns {boolean} if can be decoded | ||
| * get right dep version from git url | ||
| * @inner | ||
| * @param {string} gitUrl git url | ||
@@ -252,0 +246,0 @@ * @returns {string} dep version |
@@ -17,5 +17,5 @@ /* | ||
| /** | ||
| * @param {SourceMapDevToolPluginOptions} options options | ||
| * @param {SourceMapDevToolPluginOptions=} options options | ||
| */ | ||
| constructor(options) { | ||
| constructor(options = {}) { | ||
| this.options = options; | ||
@@ -22,0 +22,0 @@ } |
@@ -22,5 +22,3 @@ /* | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("../declarations/WebpackOptions").HashFunction} HashFunction */ | ||
| /** @typedef {import("../declarations/plugins/SourceMapDevToolPlugin").SourceMapDevToolPluginOptions} SourceMapDevToolPluginOptions */ | ||
| /** @typedef {import("./Cache").Etag} Etag */ | ||
| /** @typedef {import("./CacheFacade").ItemCacheFacade} ItemCacheFacade */ | ||
@@ -113,3 +111,3 @@ /** @typedef {import("./Chunk")} Chunk */ | ||
| if (!sourceMap || typeof source !== "string") return; | ||
| const context = /** @type {string} */ (compilation.options.context); | ||
| const context = compilation.options.context; | ||
| const root = compilation.compiler.root; | ||
@@ -167,5 +165,5 @@ const cachedAbsolutify = makePathsAbsolute.bindContextCache(context, root); | ||
| apply(compiler) { | ||
| const outputFs = /** @type {OutputFileSystem} */ ( | ||
| compiler.outputFileSystem | ||
| ); | ||
| const outputFs = | ||
| /** @type {OutputFileSystem} */ | ||
| (compiler.outputFileSystem); | ||
| const sourceMapFilename = this.sourceMapFilename; | ||
@@ -367,3 +365,3 @@ const sourceMappingURLComment = this.sourceMappingURLComment; | ||
| * all modules in defined order (longest identifier first) | ||
| * @type {Array<string | Module>} | ||
| * @type {(string | Module)[]} | ||
| */ | ||
@@ -495,6 +493,3 @@ const allModules = [...moduleToSourceNameMapping.keys()].sort( | ||
| usesContentHash && | ||
| createHash( | ||
| /** @type {HashFunction} */ | ||
| (compilation.outputOptions.hashFunction) | ||
| ) | ||
| createHash(compilation.outputOptions.hashFunction) | ||
| .update(sourceMapString) | ||
@@ -501,0 +496,0 @@ .digest("hex") |
+0
-1
@@ -10,3 +10,2 @@ /* | ||
| /** @typedef {import("./Compilation")} Compilation */ | ||
| /** @typedef {import("./Compilation").NormalizedStatsOptions} NormalizedStatsOptions */ | ||
| /** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsCompilation} StatsCompilation */ | ||
@@ -13,0 +12,0 @@ |
@@ -288,5 +288,10 @@ /* | ||
| /** | ||
| * @template T | ||
| * @typedef {(value: T, ...args: EXPECTED_ANY[]) => boolean} NormalizeFunction | ||
| */ | ||
| /** | ||
| * @template {string} T | ||
| * @param {string | ({ test: (value: T) => boolean }) | ((value: T, ...args: EXPECTED_ANY[]) => boolean) | boolean} item item to normalize | ||
| * @returns {(value: T, ...args: EXPECTED_ANY[]) => boolean} normalize fn | ||
| * @param {string | ({ test: (value: T) => boolean }) | NormalizeFunction<T> | boolean} item item to normalize | ||
| * @returns {NormalizeFunction<T>} normalize fn | ||
| */ | ||
@@ -307,3 +312,3 @@ const normalizeFilter = (item) => { | ||
| return /** @type {(value: T, ...args: EXPECTED_ANY[]) => boolean} */ (item); | ||
| return /** @type {NormalizeFunction<T>} */ (item); | ||
| }; | ||
@@ -314,2 +319,9 @@ | ||
| /** | ||
| * @callback WarningFilterFn | ||
| * @param {StatsError} warning warning | ||
| * @param {string} warningString warning string | ||
| * @returns {boolean} result | ||
| */ | ||
| /** @type {Normalizers} */ | ||
@@ -335,8 +347,2 @@ const NORMALIZER = { | ||
| } | ||
| /** | ||
| * @callback WarningFilterFn | ||
| * @param {StatsError} warning warning | ||
| * @param {string} warningString warning string | ||
| * @returns {boolean} result | ||
| */ | ||
| return value.map( | ||
@@ -343,0 +349,0 @@ /** |
@@ -13,5 +13,2 @@ /* | ||
| /** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsAsset} KnownStatsAsset */ | ||
| /** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsAssetChunk} KnownStatsAssetChunk */ | ||
| /** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsAssetChunkIdHint} KnownStatsAssetChunkIdHint */ | ||
| /** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsAssetChunkName} KnownStatsAssetChunkName */ | ||
| /** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsChunk} KnownStatsChunk */ | ||
@@ -132,3 +129,3 @@ /** @typedef {import("./DefaultStatsFactoryPlugin").KnownStatsChunkGroup} KnownStatsChunkGroup */ | ||
| * @template T | ||
| * @param {Array<T> | undefined} list of items | ||
| * @param {T[] | undefined} list of items | ||
| * @param {number} count number of items to show | ||
@@ -166,3 +163,3 @@ * @returns {string} string representation of list | ||
| * @template {string} B | ||
| * @typedef {K extends string ? Exclude<O[K], undefined> extends EXPECTED_ANY[] ? never : `${B}.${K}` : never} PropertyName | ||
| * @typedef {K extends string ? `${B}.${K}` : never} PropertyName | ||
| */ | ||
@@ -174,3 +171,3 @@ | ||
| * @template {string} B | ||
| * @typedef {K extends string ? NonNullable<O[K]> extends EXPECTED_ANY[] ? `${B}.${K}[]` : never : never} ArrayPropertyName | ||
| * @typedef {K extends string ? `${B}.${K}[]` : never} ArrayPropertyName | ||
| */ | ||
@@ -180,9 +177,2 @@ | ||
| * @template {object} O | ||
| * @template {keyof O} K | ||
| * @template {string} B | ||
| * @typedef {K extends string ? Exclude<O[K], undefined> extends EXPECTED_ANY[] ? `${B}.${K}` : never : never} MultiplePropertyName | ||
| */ | ||
| /** | ||
| * @template {object} O | ||
| * @template {string} K | ||
@@ -198,5 +188,3 @@ * @template {string} E | ||
| * @typedef {{ [K in keyof O as PropertyName<O, K, B>]?: SimplePrinter<O[K], R> } & | ||
| * { [K in keyof O as ArrayPropertyName<O, K, B>]?: Exclude<O[K], undefined> extends (infer I)[] ? SimplePrinter<I, R> : never } & | ||
| * { [K in keyof O as MultiplePropertyName<O, K, B>]?: SimplePrinter<O[K], R> } | ||
| * } Printers | ||
| * { [K in keyof O as ArrayPropertyName<O, K, B>]?: Exclude<O[K], undefined> extends (infer I)[] ? SimplePrinter<I, R> : never }} Printers | ||
| */ | ||
@@ -430,5 +418,5 @@ | ||
| * { ["asset.filteredChildren"]?: SimplePrinter<number, "asset"> } & | ||
| * { assetChunk?: SimplePrinter<KnownStatsAssetChunk, "asset"> } & | ||
| * { assetChunkName?: SimplePrinter<KnownStatsAssetChunkName, "asset"> } & | ||
| * { assetChunkIdHint?: SimplePrinter<KnownStatsAssetChunkIdHint, "asset"> }} AssetSimplePrinters | ||
| * { assetChunk?: SimplePrinter<ChunkId, "asset"> } & | ||
| * { assetChunkName?: SimplePrinter<ChunkName, "asset"> } & | ||
| * { assetChunkIdHint?: SimplePrinter<string, "asset"> }} AssetSimplePrinters | ||
| */ | ||
@@ -483,3 +471,2 @@ | ||
| assetChunk: (id, { formatChunkId }) => formatChunkId(id), | ||
| assetChunkName: (name) => name || undefined, | ||
@@ -1474,4 +1461,9 @@ assetChunkIdHint: (name) => name || undefined | ||
| /** @typedef {Required<{ [Key in keyof KnownStatsPrinterFormatters]: (value: Parameters<NonNullable<KnownStatsPrinterFormatters[Key]>>[0], options: Required<KnownStatsPrinterColorFunctions> & StatsPrinterContextWithExtra, ...args: Tail<Parameters<NonNullable<KnownStatsPrinterFormatters[Key]>>>) => string }>} AvailableFormats */ | ||
| /** | ||
| * @template {(...args: EXPECTED_ANY[]) => EXPECTED_ANY} T | ||
| * @typedef {T extends (firstArg: EXPECTED_ANY, ...rest: infer R) => EXPECTED_ANY ? R : never} TailParameters | ||
| */ | ||
| /** @typedef {{ [Key in keyof KnownStatsPrinterFormatters]: (value: Parameters<NonNullable<KnownStatsPrinterFormatters[Key]>>[0], options: Required<KnownStatsPrinterColorFunctions> & StatsPrinterContextWithExtra, ...args: TailParameters<NonNullable<KnownStatsPrinterFormatters[Key]>>) => string }} AvailableFormats */ | ||
| /** @type {AvailableFormats} */ | ||
@@ -1651,12 +1643,10 @@ const AVAILABLE_FORMATS = { | ||
| } | ||
| for (const _format of Object.keys(AVAILABLE_FORMATS)) { | ||
| const format = | ||
| /** @type {keyof KnownStatsPrinterFormatters} */ | ||
| (_format); | ||
| for (const format of /** @type {(keyof KnownStatsPrinterFormatters)[]} */ ( | ||
| Object.keys(AVAILABLE_FORMATS) | ||
| )) { | ||
| context[format] = | ||
| /** @type {(content: Parameters<NonNullable<KnownStatsPrinterFormatters[keyof KnownStatsPrinterFormatters]>>[0], ...args: Tail<Parameters<NonNullable<KnownStatsPrinterFormatters[keyof KnownStatsPrinterFormatters]>>>) => string} */ | ||
| (content, ...args) => | ||
| /** @type {TODO} */ | ||
| (AVAILABLE_FORMATS)[format]( | ||
| /** @type {EXPECTED_ANY} */ | ||
| (AVAILABLE_FORMATS[format])( | ||
| content, | ||
@@ -1671,11 +1661,8 @@ /** @type {StatsPrinterContext & Required<KnownStatsPrinterColorFunctions>} */ | ||
| for (const key of Object.keys(COMPILATION_SIMPLE_PRINTERS)) { | ||
| for (const key of /** @type {(keyof CompilationSimplePrinters)[]} */ ( | ||
| Object.keys(COMPILATION_SIMPLE_PRINTERS) | ||
| )) { | ||
| stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) => | ||
| /** @type {TODO} */ | ||
| ( | ||
| COMPILATION_SIMPLE_PRINTERS[ | ||
| /** @type {keyof CompilationSimplePrinters} */ | ||
| (key) | ||
| ] | ||
| )( | ||
| /** @type {EXPECTED_ANY} */ | ||
| (COMPILATION_SIMPLE_PRINTERS)[key]( | ||
| obj, | ||
@@ -1689,11 +1676,8 @@ /** @type {DefineStatsPrinterContext<"compilation">} */ | ||
| for (const key of Object.keys(ASSET_SIMPLE_PRINTERS)) { | ||
| for (const key of /** @type {(keyof AssetSimplePrinters)[]} */ ( | ||
| Object.keys(ASSET_SIMPLE_PRINTERS) | ||
| )) { | ||
| stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) => | ||
| /** @type {NonNullable<AssetSimplePrinters[keyof AssetSimplePrinters]>} */ | ||
| ( | ||
| ASSET_SIMPLE_PRINTERS[ | ||
| /** @type {keyof AssetSimplePrinters} */ | ||
| (key) | ||
| ] | ||
| )( | ||
| (ASSET_SIMPLE_PRINTERS[key])( | ||
| obj, | ||
@@ -1707,11 +1691,8 @@ /** @type {DefineStatsPrinterContext<"asset" | "asset.info">} */ | ||
| for (const key of Object.keys(MODULE_SIMPLE_PRINTERS)) { | ||
| for (const key of /** @type {(keyof ModuleSimplePrinters)[]} */ ( | ||
| Object.keys(MODULE_SIMPLE_PRINTERS) | ||
| )) { | ||
| stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) => | ||
| /** @type {TODO} */ | ||
| ( | ||
| MODULE_SIMPLE_PRINTERS[ | ||
| /** @type {keyof ModuleSimplePrinters} */ | ||
| (key) | ||
| ] | ||
| )( | ||
| /** @type {EXPECTED_ANY} */ | ||
| (MODULE_SIMPLE_PRINTERS)[key]( | ||
| obj, | ||
@@ -1725,11 +1706,8 @@ /** @type {DefineStatsPrinterContext<"module">} */ | ||
| for (const key of Object.keys(MODULE_ISSUER_PRINTERS)) { | ||
| for (const key of /** @type {(keyof ModuleIssuerPrinters)[]} */ ( | ||
| Object.keys(MODULE_ISSUER_PRINTERS) | ||
| )) { | ||
| stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) => | ||
| /** @type {NonNullable<ModuleIssuerPrinters[keyof ModuleIssuerPrinters]>} */ | ||
| ( | ||
| MODULE_ISSUER_PRINTERS[ | ||
| /** @type {keyof ModuleIssuerPrinters} */ | ||
| (key) | ||
| ] | ||
| )( | ||
| (MODULE_ISSUER_PRINTERS[key])( | ||
| obj, | ||
@@ -1743,11 +1721,8 @@ /** @type {DefineStatsPrinterContext<"moduleIssuer">} */ | ||
| for (const key of Object.keys(MODULE_REASON_PRINTERS)) { | ||
| for (const key of /** @type {(keyof ModuleReasonsPrinters)[]} */ ( | ||
| Object.keys(MODULE_REASON_PRINTERS) | ||
| )) { | ||
| stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) => | ||
| /** @type {TODO} */ | ||
| ( | ||
| MODULE_REASON_PRINTERS[ | ||
| /** @type {keyof ModuleReasonsPrinters} */ | ||
| (key) | ||
| ] | ||
| )( | ||
| /** @type {EXPECTED_ANY} */ | ||
| (MODULE_REASON_PRINTERS)[key]( | ||
| obj, | ||
@@ -1761,11 +1736,8 @@ /** @type {DefineStatsPrinterContext<"moduleReason">} */ | ||
| for (const key of Object.keys(MODULE_PROFILE_PRINTERS)) { | ||
| for (const key of /** @type {(keyof ModuleProfilePrinters)[]} */ ( | ||
| Object.keys(MODULE_PROFILE_PRINTERS) | ||
| )) { | ||
| stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) => | ||
| /** @type {NonNullable<ModuleProfilePrinters[keyof ModuleProfilePrinters]>} */ | ||
| ( | ||
| MODULE_PROFILE_PRINTERS[ | ||
| /** @type {keyof ModuleProfilePrinters} */ | ||
| (key) | ||
| ] | ||
| )( | ||
| (MODULE_PROFILE_PRINTERS[key])( | ||
| obj, | ||
@@ -1779,11 +1751,8 @@ /** @type {DefineStatsPrinterContext<"profile">} */ | ||
| for (const key of Object.keys(CHUNK_GROUP_PRINTERS)) { | ||
| for (const key of /** @type {(keyof ChunkGroupPrinters)[]} */ ( | ||
| Object.keys(CHUNK_GROUP_PRINTERS) | ||
| )) { | ||
| stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) => | ||
| /** @type {TODO} */ | ||
| ( | ||
| CHUNK_GROUP_PRINTERS[ | ||
| /** @type {keyof ChunkGroupPrinters} */ | ||
| (key) | ||
| ] | ||
| )( | ||
| /** @type {EXPECTED_ANY} */ | ||
| (CHUNK_GROUP_PRINTERS)[key]( | ||
| obj, | ||
@@ -1797,6 +1766,8 @@ /** @type {DefineStatsPrinterContext<"chunkGroupKind" | "chunkGroup">} */ | ||
| for (const key of Object.keys(CHUNK_PRINTERS)) { | ||
| for (const key of /** @type {(keyof ChunkPrinters)[]} */ ( | ||
| Object.keys(CHUNK_PRINTERS) | ||
| )) { | ||
| stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) => | ||
| /** @type {TODO} */ | ||
| (CHUNK_PRINTERS[/** @type {keyof ChunkPrinters} */ (key)])( | ||
| /** @type {EXPECTED_ANY} */ | ||
| (CHUNK_PRINTERS)[key]( | ||
| obj, | ||
@@ -1810,6 +1781,8 @@ /** @type {DefineStatsPrinterContext<"chunk">} */ | ||
| for (const key of Object.keys(ERROR_PRINTERS)) { | ||
| for (const key of /** @type {(keyof ErrorPrinters)[]} */ ( | ||
| Object.keys(ERROR_PRINTERS) | ||
| )) { | ||
| stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) => | ||
| /** @type {TODO} */ | ||
| (ERROR_PRINTERS[/** @type {keyof ErrorPrinters} */ (key)])( | ||
| /** @type {EXPECTED_ANY} */ | ||
| (ERROR_PRINTERS)[key]( | ||
| obj, | ||
@@ -1823,11 +1796,8 @@ /** @type {DefineStatsPrinterContext<"error">} */ | ||
| for (const key of Object.keys(LOG_ENTRY_PRINTERS)) { | ||
| for (const key of /** @type {(keyof LogEntryPrinters)[]} */ ( | ||
| Object.keys(LOG_ENTRY_PRINTERS) | ||
| )) { | ||
| stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) => | ||
| /** @type {TODO} */ | ||
| ( | ||
| LOG_ENTRY_PRINTERS[ | ||
| /** @type {keyof LogEntryPrinters} */ | ||
| (key) | ||
| ] | ||
| )( | ||
| /** @type {EXPECTED_ANY} */ | ||
| (LOG_ENTRY_PRINTERS)[key]( | ||
| obj, | ||
@@ -1841,11 +1811,8 @@ /** @type {DefineStatsPrinterContext<"logging">} */ | ||
| for (const key of Object.keys(MODULE_TRACE_DEPENDENCY_PRINTERS)) { | ||
| for (const key of /** @type {(keyof ModuleTraceDependencyPrinters)[]} */ ( | ||
| Object.keys(MODULE_TRACE_DEPENDENCY_PRINTERS) | ||
| )) { | ||
| stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) => | ||
| /** @type {NonNullable<ModuleTraceDependencyPrinters[keyof ModuleTraceDependencyPrinters]>} */ | ||
| ( | ||
| MODULE_TRACE_DEPENDENCY_PRINTERS[ | ||
| /** @type {keyof ModuleTraceDependencyPrinters} */ | ||
| (key) | ||
| ] | ||
| )( | ||
| (MODULE_TRACE_DEPENDENCY_PRINTERS[key])( | ||
| obj, | ||
@@ -1859,11 +1826,8 @@ /** @type {DefineStatsPrinterContext<"moduleTraceDependency">} */ | ||
| for (const key of Object.keys(MODULE_TRACE_ITEM_PRINTERS)) { | ||
| for (const key of /** @type {(keyof ModuleTraceItemPrinters)[]} */ ( | ||
| Object.keys(MODULE_TRACE_ITEM_PRINTERS) | ||
| )) { | ||
| stats.hooks.print.for(key).tap(PLUGIN_NAME, (obj, ctx) => | ||
| /** @type {NonNullable<ModuleTraceItemPrinters[keyof ModuleTraceItemPrinters]>} */ | ||
| ( | ||
| MODULE_TRACE_ITEM_PRINTERS[ | ||
| /** @type {keyof ModuleTraceItemPrinters} */ | ||
| (key) | ||
| ] | ||
| )( | ||
| (MODULE_TRACE_ITEM_PRINTERS[key])( | ||
| obj, | ||
@@ -1902,6 +1866,6 @@ /** @type {DefineStatsPrinterContext<"moduleTraceItem">} */ | ||
| for (const key of Object.keys(SIMPLE_ELEMENT_JOINERS)) { | ||
| const joiner = SIMPLE_ELEMENT_JOINERS[key]; | ||
| stats.hooks.printElements | ||
| .for(key) | ||
| .tap(PLUGIN_NAME, /** @type {TODO} */ (joiner)); | ||
| const joiner = | ||
| /** @type {(items: Item[], context: StatsPrinterContext) => string} */ | ||
| (SIMPLE_ELEMENT_JOINERS[key]); | ||
| stats.hooks.printElements.for(key).tap(PLUGIN_NAME, joiner); | ||
| } | ||
@@ -1908,0 +1872,0 @@ |
@@ -24,3 +24,6 @@ /* | ||
| /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */ | ||
| /** @typedef {import("../util/smartGrouping").GroupConfig<EXPECTED_ANY, EXPECTED_OBJECT>} GroupConfig */ | ||
| /** | ||
| * @template T, R | ||
| * @typedef {import("../util/smartGrouping").GroupConfig<T, R>} GroupConfig | ||
| */ | ||
| /** @typedef {import("./DefaultStatsFactoryPlugin").ChunkGroupInfoWithName} ChunkGroupInfoWithName */ | ||
@@ -45,4 +48,4 @@ /** @typedef {import("./DefaultStatsFactoryPlugin").ModuleIssuerPath} ModuleIssuerPath */ | ||
| * @property {string} type | ||
| * @property {Compilation} compilation | ||
| * @property {(path: string) => string} makePathsRelative | ||
| * @property {Compilation} compilation | ||
| * @property {Set<Module>} rootModules | ||
@@ -52,4 +55,4 @@ * @property {Map<string, Chunk[]>} compilationFileToChunks | ||
| * @property {RuntimeSpec} runtime | ||
| * @property {(compilation: Compilation) => WebpackError[]} cachedGetErrors | ||
| * @property {(compilation: Compilation) => WebpackError[]} cachedGetWarnings | ||
| * @property {(compilation: Compilation) => Error[]} cachedGetErrors | ||
| * @property {(compilation: Compilation) => Error[]} cachedGetWarnings | ||
| */ | ||
@@ -73,6 +76,6 @@ | ||
| /** @typedef {TODO} FactoryData */ | ||
| /** @typedef {TODO} FactoryDataItem */ | ||
| /** @typedef {TODO} Result */ | ||
| /** @typedef {Record<string, TODO>} ObjectForExtract */ | ||
| /** @typedef {EXPECTED_ANY} ObjectForExtract */ | ||
| /** @typedef {EXPECTED_ANY} FactoryData */ | ||
| /** @typedef {EXPECTED_ANY} FactoryDataItem */ | ||
| /** @typedef {EXPECTED_ANY} Result */ | ||
@@ -85,3 +88,3 @@ /** | ||
| * @property {HookMap<SyncBailHook<[FactoryDataItem, StatsFactoryContext, number, number], boolean | void>>} filterSorted | ||
| * @property {HookMap<SyncBailHook<[GroupConfig[], StatsFactoryContext], void>>} groupResults | ||
| * @property {HookMap<SyncBailHook<[GroupConfig<EXPECTED_ANY, EXPECTED_ANY>[], StatsFactoryContext], void>>} groupResults | ||
| * @property {HookMap<SyncBailHook<[Comparator[], StatsFactoryContext], void>>} sortResults | ||
@@ -206,3 +209,3 @@ * @property {HookMap<SyncBailHook<[FactoryDataItem, StatsFactoryContext, number, number], boolean | void>>} filterResults | ||
| * @param {string} type type | ||
| * @param {Array<FactoryData>} items items | ||
| * @param {FactoryData[]} items items | ||
| * @param {(hook: H, item: R, idx: number, i: number) => R | undefined} fn fn | ||
@@ -350,3 +353,3 @@ * @param {boolean} forceClone force clone | ||
| // group result items | ||
| /** @type {GroupConfig[]} */ | ||
| /** @type {GroupConfig<EXPECTED_ANY, EXPECTED_ANY>[]} */ | ||
| const groupConfigs = []; | ||
@@ -353,0 +356,0 @@ this._forEachLevel( |
+6
-11
@@ -13,3 +13,3 @@ /* | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("../declarations/WebpackOptions").Output} OutputOptions */ | ||
| /** @typedef {import("./config/defaults").OutputNormalizedWithDefaults} OutputOptions */ | ||
| /** @typedef {import("./Chunk")} Chunk */ | ||
@@ -53,3 +53,3 @@ /** @typedef {import("./ChunkGraph")} ChunkGraph */ | ||
| * @property {CodeGenerationResults} codeGenerationResults | ||
| * @property {{javascript: ModuleTemplate}} moduleTemplates | ||
| * @property {{ javascript: ModuleTemplate }} moduleTemplates | ||
| * @property {DependencyTemplates} dependencyTemplates | ||
@@ -85,7 +85,2 @@ * @property {RuntimeTemplate} runtimeTemplate | ||
| /** | ||
| * @typedef {object} HasId | ||
| * @property {number | string} id | ||
| */ | ||
| /** | ||
| * @typedef {(module: Module) => boolean} ModuleFilterPredicate | ||
@@ -232,3 +227,3 @@ */ | ||
| /** | ||
| * @param {string|string[]} s string to create prefix for | ||
| * @param {string | string[]} s string to create prefix for | ||
| * @param {string} prefix prefix to compose | ||
@@ -245,3 +240,3 @@ * @returns {string} returns new prefix string | ||
| /** | ||
| * @param {string|string[]} str string or string collection | ||
| * @param {string | string[]} str string or string collection | ||
| * @returns {string} returns a single string from array | ||
@@ -303,3 +298,3 @@ */ | ||
| } | ||
| /** @type {{id: string|number, source: Source|string}[]} */ | ||
| /** @type {{ id: ModuleId, source: Source | "false" }[]} */ | ||
| const allModules = modules.map((module) => ({ | ||
@@ -318,3 +313,3 @@ id: /** @type {ModuleId} */ (chunkGraph.getModuleId(module)), | ||
| source.add("[\n"); | ||
| /** @type {Map<string|number, {id: string|number, source: Source|string}>} */ | ||
| /** @type {Map<ModuleId, { id: ModuleId, source: Source | "false" }>} */ | ||
| const modules = new Map(); | ||
@@ -321,0 +316,0 @@ for (const module of allModules) { |
@@ -136,3 +136,4 @@ /* | ||
| /** @typedef {string | ((pathData: PathData, assetInfo?: AssetInfo) => string)} TemplatePath */ | ||
| /** @typedef {(pathData: PathData, assetInfo?: AssetInfo) => string} TemplatePathFn */ | ||
| /** @typedef {string | TemplatePathFn} TemplatePath */ | ||
@@ -139,0 +140,0 @@ /** |
@@ -23,7 +23,5 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */ | ||
| /** @typedef {import("../ContextModule").ContextMode} ContextMode */ | ||
| /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */ | ||
| /** @typedef {import("../NormalModule")} NormalModule */ | ||
| /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */ | ||
| /** @typedef {import("../javascript/JavascriptParser")} Parser */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
@@ -40,3 +38,3 @@ | ||
| /** | ||
| * @param {Parser} parser parser parser | ||
| * @param {JavascriptParser} parser parser parser | ||
| * @param {MemberExpression} arg arg | ||
@@ -68,3 +66,3 @@ * @returns {boolean} true when it is `meta.url`, otherwise false | ||
| * @param {NewExpressionNode} expr expression | ||
| * @param {Parser} parser parser parser | ||
| * @param {JavascriptParser} parser parser parser | ||
| * @returns {BasicEvaluatedExpression | undefined} basic evaluated expression | ||
@@ -71,0 +69,0 @@ */ |
@@ -26,5 +26,5 @@ /* | ||
| * @template T | ||
| * @param {Array<T>} arr Array of values to be partitioned | ||
| * @param {T[]} arr Array of values to be partitioned | ||
| * @param {(value: T) => boolean} fn Partition function which partitions based on truthiness of result. | ||
| * @returns {[Array<T>, Array<T>]} returns the values of `arr` partitioned into two new arrays based on fn predicate. | ||
| * @returns {[T[], T[]]} returns the values of `arr` partitioned into two new arrays based on fn predicate. | ||
| */ | ||
@@ -38,5 +38,5 @@ module.exports.groupBy = ( | ||
| /** | ||
| * @param {[Array<T>, Array<T>]} groups An accumulator storing already partitioned values returned from previous call. | ||
| * @param {[T[], T[]]} groups An accumulator storing already partitioned values returned from previous call. | ||
| * @param {T} value The value of the current element | ||
| * @returns {[Array<T>, Array<T>]} returns an array of partitioned groups accumulator resulting from calling a predicate on the current value. | ||
| * @returns {[T[], T[]]} returns an array of partitioned groups accumulator resulting from calling a predicate on the current value. | ||
| */ | ||
@@ -43,0 +43,0 @@ (groups, value) => { |
@@ -24,2 +24,3 @@ /* | ||
| * @param {(T | null)=} result | ||
| * @returns {void} | ||
| */ | ||
@@ -26,0 +27,0 @@ |
@@ -13,2 +13,4 @@ /* | ||
| /** @typedef {Range[]} IdRanges */ | ||
| /** | ||
@@ -22,3 +24,3 @@ * @summary Get the subset of ids and their corresponding range in an id chain that should be re-rendered by webpack. | ||
| * @param {Range} untrimmedRange range encompassing allIds | ||
| * @param {Range[] | undefined} ranges cumulative range of ids for each of allIds | ||
| * @param {IdRanges | undefined} ranges cumulative range of ids for each of allIds | ||
| * @param {ModuleGraph} moduleGraph moduleGraph | ||
@@ -25,0 +27,0 @@ * @param {Dependency} dependency dependency |
+15
-18
@@ -95,3 +95,3 @@ /* | ||
| * @property {T[keyof T] | undefined} base base value | ||
| * @property {string | undefined} byProperty the name of the selector property | ||
| * @property {`by${string}` | undefined} byProperty the name of the selector property | ||
| * @property {ByValues | undefined} byValues value depending on selector property, merged with base | ||
@@ -109,3 +109,3 @@ */ | ||
| * @template {object} T | ||
| * @typedef {{ byProperty: string, fn: DynamicFunction }} ParsedObjectDynamic | ||
| * @typedef {{ byProperty: `by${string}`, fn: DynamicFunction }} ParsedObjectDynamic | ||
| */ | ||
@@ -174,3 +174,3 @@ | ||
| if (entry.byProperty === undefined) { | ||
| entry.byProperty = byProperty; | ||
| entry.byProperty = /** @type {`by${string}`} */ (byProperty); | ||
| entry.byValues = new Map(); | ||
@@ -202,3 +202,3 @@ } else if (entry.byProperty !== byProperty) { | ||
| dynamicInfo = { | ||
| byProperty: key, | ||
| byProperty: /** @type {`by${string}`} */ (key), | ||
| fn: byObj | ||
@@ -229,13 +229,12 @@ }; | ||
| * @param {ParsedObjectStatic<T>} info static properties (key is property name) | ||
| * @param {{ byProperty: string, fn: DynamicFunction } | undefined} dynamicInfo dynamic part | ||
| * @param {{ byProperty: `by${string}`, fn: DynamicFunction } | undefined} dynamicInfo dynamic part | ||
| * @returns {T} the object | ||
| */ | ||
| const serializeObject = (info, dynamicInfo) => { | ||
| const obj = /** @type {T} */ ({}); | ||
| const obj = /** @type {EXPECTED_ANY} */ ({}); | ||
| // Setup byProperty structure | ||
| for (const entry of info.values()) { | ||
| if (entry.byProperty !== undefined) { | ||
| const byProperty = /** @type {keyof T} */ (entry.byProperty); | ||
| const byObj = (obj[byProperty] = | ||
| obj[byProperty] || /** @type {TODO} */ ({})); | ||
| const byProperty = entry.byProperty; | ||
| const byObj = (obj[byProperty] = obj[byProperty] || {}); | ||
| for (const byValue of /** @type {ByValues} */ (entry.byValues).keys()) { | ||
@@ -248,9 +247,8 @@ byObj[byValue] = byObj[byValue] || {}; | ||
| if (entry.base !== undefined) { | ||
| obj[/** @type {keyof T} */ (key)] = entry.base; | ||
| obj[key] = entry.base; | ||
| } | ||
| // Fill byProperty structure | ||
| if (entry.byProperty !== undefined) { | ||
| const byProperty = /** @type {keyof T} */ (entry.byProperty); | ||
| const byObj = (obj[byProperty] = | ||
| obj[byProperty] || /** @type {TODO} */ ({})); | ||
| const byProperty = entry.byProperty; | ||
| const byObj = (obj[byProperty] = obj[byProperty] || {}); | ||
| for (const byValue of Object.keys(byObj)) { | ||
@@ -267,4 +265,3 @@ const value = getFromByValues( | ||
| if (dynamicInfo !== undefined) { | ||
| /** @type {TODO} */ | ||
| (obj)[dynamicInfo.byProperty] = dynamicInfo.fn; | ||
| obj[dynamicInfo.byProperty] = dynamicInfo.fn; | ||
| } | ||
@@ -394,3 +391,3 @@ return obj; | ||
| * @param {boolean} internalCaching should parsing of objects and nested merges be cached | ||
| * @returns {ObjectParsedPropertyEntry<TODO>} new entry | ||
| * @returns {ObjectParsedPropertyEntry<T> | ObjectParsedPropertyEntry<O> | ObjectParsedPropertyEntry<T & O>} new entry | ||
| */ | ||
@@ -490,3 +487,3 @@ const mergeEntries = (firstEntry, secondEntry, internalCaching) => { | ||
| return { | ||
| base: newBase, | ||
| base: /** @type {T[keyof T] & O[keyof O]} */ (newBase), | ||
| byProperty: firstEntry.byProperty, | ||
@@ -511,3 +508,3 @@ byValues: intermediateByValues | ||
| return { | ||
| base: newBase, | ||
| base: /** @type {T[keyof T] & O[keyof O]} */ (newBase), | ||
| byProperty: firstEntry.byProperty, | ||
@@ -514,0 +511,0 @@ byValues: newByValues |
@@ -11,2 +11,3 @@ /* | ||
| /** @typedef {import("../Chunk")} Chunk */ | ||
| /** @typedef {import("../Chunk").ChunkName} ChunkName */ | ||
| /** @typedef {import("../Chunk").ChunkId} ChunkId */ | ||
@@ -494,6 +495,3 @@ /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| return concatComparators( | ||
| compareSelect( | ||
| (chunk) => /** @type {string|number} */ (chunk.name), | ||
| compareIds | ||
| ), | ||
| compareSelect((chunk) => /** @type {ChunkName} */ (chunk.name), compareIds), | ||
| compareSelect((chunk) => chunk.runtime, compareRuntime), | ||
@@ -500,0 +498,0 @@ compareSelect( |
@@ -59,10 +59,12 @@ /* | ||
| /** @typedef {string[][]} ListOfCommonItems */ | ||
| /** | ||
| * @param {Set<string>} itemsSet items set | ||
| * @param {(str: string) => string | false} getKey get key function | ||
| * @param {(str: Array<string>) => boolean} condition condition | ||
| * @returns {Array<Array<string>>} list of common items | ||
| * @param {(str: string[]) => boolean} condition condition | ||
| * @returns {ListOfCommonItems} list of common items | ||
| */ | ||
| const popCommonItems = (itemsSet, getKey, condition) => { | ||
| /** @type {Map<string, Array<string>>} */ | ||
| /** @type {Map<string, string[]>} */ | ||
| const map = new Map(); | ||
@@ -74,3 +76,3 @@ for (const item of itemsSet) { | ||
| if (list === undefined) { | ||
| /** @type {Array<string>} */ | ||
| /** @type {string[]} */ | ||
| list = []; | ||
@@ -82,3 +84,3 @@ map.set(key, list); | ||
| } | ||
| /** @type {Array<Array<string>>} */ | ||
| /** @type {ListOfCommonItems} */ | ||
| const result = []; | ||
@@ -97,3 +99,3 @@ for (const list of map.values()) { | ||
| /** | ||
| * @param {Array<string>} items items | ||
| * @param {string[]} items items | ||
| * @returns {string} common prefix | ||
@@ -116,3 +118,3 @@ */ | ||
| /** | ||
| * @param {Array<string>} items items | ||
| * @param {string[]} items items | ||
| * @returns {string} common suffix | ||
@@ -135,3 +137,3 @@ */ | ||
| /** | ||
| * @param {Array<string>} itemsArr array of items | ||
| * @param {string[]} itemsArr array of items | ||
| * @returns {string} regexp | ||
@@ -143,3 +145,3 @@ */ | ||
| } | ||
| /** @type {Array<string>} */ | ||
| /** @type {string[]} */ | ||
| const finishedItems = []; | ||
@@ -146,0 +148,0 @@ |
@@ -15,3 +15,2 @@ /* | ||
| /** @typedef {import("../javascript/JavascriptParser").Range} Range */ | ||
| /** @typedef {import("../javascript/JavascriptParser").Program} Program */ | ||
| /** @typedef {Set<string>} UsedNames */ | ||
@@ -76,3 +75,3 @@ | ||
| const keys = | ||
| /** @type {Array<keyof Node>} */ | ||
| /** @type {(keyof Node)[]} */ | ||
| (Object.keys(ast)); | ||
@@ -79,0 +78,0 @@ for (let i = 0; i < keys.length; i++) { |
@@ -12,3 +12,2 @@ /* | ||
| /** @typedef {import("schema-utils/declarations/validate").ValidationErrorConfiguration} ValidationErrorConfiguration */ | ||
| /** @typedef {import("./fs").JsonObject} JsonObject */ | ||
@@ -15,0 +14,0 @@ const getValidate = memoize(() => require("schema-utils").validate); |
+29
-31
@@ -78,3 +78,3 @@ /* | ||
| * @template T | ||
| * @typedef {Set<T> & {[Symbol.isConcatSpreadable]?: boolean} & { push?: (...items: T[]) => void } & { [P in DISABLED_METHODS_NAMES]?: () => void } & { [P in COPY_METHODS_NAMES]?: () => TODO }} SetWithDeprecatedArrayMethods | ||
| * @typedef {Set<T> & { [Symbol.isConcatSpreadable]: boolean } & { push: (...items: T[]) => void, length?: number } & { [P in DISABLED_METHODS_NAMES]: () => void } & { [P in COPY_METHODS_NAMES]: P extends keyof Array<T> ? () => Pick<Array<T>, P> : never }} SetWithDeprecatedArrayMethods | ||
| */ | ||
@@ -84,3 +84,3 @@ | ||
| * @template T | ||
| * @param {SetWithDeprecatedArrayMethods<T>} set new set | ||
| * @param {Set<T>} set new set | ||
| * @param {string} name property name | ||
@@ -91,3 +91,3 @@ * @returns {void} | ||
| for (const method of COPY_METHODS) { | ||
| if (set[method]) continue; | ||
| if (/** @type {SetWithDeprecatedArrayMethods<T>} */ (set)[method]) continue; | ||
| const d = createDeprecation( | ||
@@ -97,18 +97,17 @@ `${name} was changed from Array to Set (using Array method '${method}' is deprecated)`, | ||
| ); | ||
| /** | ||
| * @deprecated | ||
| * @this {Set<T>} | ||
| * @returns {number} count | ||
| */ | ||
| // eslint-disable-next-line func-names | ||
| set[method] = function () { | ||
| d(); | ||
| // eslint-disable-next-line unicorn/prefer-spread | ||
| const array = Array.from(this); | ||
| return Array.prototype[/** @type {keyof COPY_METHODS} */ (method)].apply( | ||
| array, | ||
| // eslint-disable-next-line prefer-rest-params | ||
| arguments | ||
| ); | ||
| }; | ||
| /** @type {EXPECTED_ANY} */ | ||
| (set)[method] = | ||
| // eslint-disable-next-line func-names | ||
| function () { | ||
| d(); | ||
| // eslint-disable-next-line unicorn/prefer-spread | ||
| const array = Array.from(this); | ||
| return Array.prototype[ | ||
| /** @type {keyof COPY_METHODS} */ (method) | ||
| ].apply( | ||
| array, | ||
| // eslint-disable-next-line prefer-rest-params | ||
| arguments | ||
| ); | ||
| }; | ||
| } | ||
@@ -127,8 +126,4 @@ const dPush = createDeprecation( | ||
| ); | ||
| /** | ||
| * @deprecated | ||
| * @this {Set<T>} | ||
| * @returns {number} count | ||
| */ | ||
| set.push = function push() { | ||
| /** @type {SetWithDeprecatedArrayMethods<T>} */ | ||
| (set).push = function push() { | ||
| dPush(); | ||
@@ -142,5 +137,6 @@ // eslint-disable-next-line prefer-rest-params, unicorn/prefer-spread | ||
| for (const method of DISABLED_METHODS) { | ||
| if (set[method]) continue; | ||
| if (/** @type {SetWithDeprecatedArrayMethods<T>} */ (set)[method]) continue; | ||
| set[method] = () => { | ||
| /** @type {SetWithDeprecatedArrayMethods<T>} */ | ||
| (set)[method] = () => { | ||
| throw new Error( | ||
@@ -200,3 +196,4 @@ `${name} was changed from Array to Set (using Array method '${method}' is not possible)` | ||
| }); | ||
| set[Symbol.isConcatSpreadable] = true; | ||
| /** @type {SetWithDeprecatedArrayMethods<T>} */ | ||
| (set)[Symbol.isConcatSpreadable] = true; | ||
| }; | ||
@@ -207,3 +204,3 @@ | ||
| * @param {string} name name | ||
| * @returns {{ new <T = any>(values?: readonly T[] | null): SetDeprecatedArray<T> }} SetDeprecatedArray | ||
| * @returns {{ new <T = any>(values?: ReadonlyArray<T> | null): SetDeprecatedArray<T> }} SetDeprecatedArray | ||
| */ | ||
@@ -218,3 +215,3 @@ module.exports.createArrayToSetDeprecationSet = (name) => { | ||
| /** | ||
| * @param {readonly T[] | null=} items items | ||
| * @param {ReadonlyArray<T> | null=} items items | ||
| */ | ||
@@ -226,3 +223,4 @@ constructor(items) { | ||
| module.exports.arrayToSetDeprecation( | ||
| SetDeprecatedArray.prototype, | ||
| /** @type {SetWithDeprecatedArrayMethods<T>} */ | ||
| (SetDeprecatedArray.prototype), | ||
| name | ||
@@ -229,0 +227,0 @@ ); |
@@ -73,5 +73,7 @@ /* | ||
| /** @typedef {Record<string, number>} Sizes */ | ||
| /** | ||
| * @param {Record<string, number>} total total size | ||
| * @param {Record<string, number>} size single size | ||
| * @param {Sizes} total total size | ||
| * @param {Sizes} size single size | ||
| * @returns {void} | ||
@@ -86,4 +88,4 @@ */ | ||
| /** | ||
| * @param {Record<string, number>} total total size | ||
| * @param {Record<string, number>} size single size | ||
| * @param {Sizes} total total size | ||
| * @param {Sizes} size single size | ||
| * @returns {void} | ||
@@ -100,3 +102,3 @@ */ | ||
| * @param {Iterable<Node<T>>} nodes some nodes | ||
| * @returns {Record<string, number>} total size | ||
| * @returns {Sizes} total size | ||
| */ | ||
@@ -112,4 +114,4 @@ const sumSize = (nodes) => { | ||
| /** | ||
| * @param {Record<string, number>} size size | ||
| * @param {Record<string, number>} maxSize minimum size | ||
| * @param {Sizes} size size | ||
| * @param {Sizes} maxSize minimum size | ||
| * @returns {boolean} true, when size is too big | ||
@@ -128,4 +130,4 @@ */ | ||
| /** | ||
| * @param {Record<string, number>} size size | ||
| * @param {Record<string, number>} minSize minimum size | ||
| * @param {Sizes} size size | ||
| * @param {Sizes} minSize minimum size | ||
| * @returns {boolean} true, when size is too small | ||
@@ -144,4 +146,4 @@ */ | ||
| /** | ||
| * @param {Record<string, number>} size size | ||
| * @param {Record<string, number>} minSize minimum size | ||
| * @param {Sizes} size size | ||
| * @param {Sizes} minSize minimum size | ||
| * @returns {Set<string>} set of types that are too small | ||
@@ -175,3 +177,3 @@ */ | ||
| /** | ||
| * @param {Record<string, number>} size size | ||
| * @param {Sizes} size size | ||
| * @param {Set<string>} types types | ||
@@ -195,3 +197,3 @@ * @returns {number} selective size sum | ||
| * @param {string} key key | ||
| * @param {Record<string, number>} size size | ||
| * @param {Sizes} size size | ||
| */ | ||
@@ -205,2 +207,4 @@ constructor(item, key, size) { | ||
| /** @typedef {number[]} Similarities */ | ||
| /** | ||
@@ -212,4 +216,4 @@ * @template T | ||
| * @param {Node<T>[]} nodes nodes | ||
| * @param {number[] | null} similarities similarities between the nodes (length = nodes.length - 1) | ||
| * @param {Record<string, number>=} size size of the group | ||
| * @param {Similarities | null} similarities similarities between the nodes (length = nodes.length - 1) | ||
| * @param {Sizes=} size size of the group | ||
| */ | ||
@@ -241,3 +245,3 @@ constructor(nodes, similarities, size) { | ||
| lastNode === this.nodes[i - 1] | ||
| ? /** @type {number[]} */ (this.similarities)[i - 1] | ||
| ? /** @type {Similarities} */ (this.similarities)[i - 1] | ||
| : similarity(/** @type {Node<T>} */ (lastNode).key, node.key) | ||
@@ -261,7 +265,7 @@ ); | ||
| * @param {Iterable<Node<T>>} nodes nodes | ||
| * @returns {number[]} similarities | ||
| * @returns {Similarities} similarities | ||
| */ | ||
| const getSimilarities = (nodes) => { | ||
| // calculate similarities between lexically adjacent nodes | ||
| /** @type {number[]} */ | ||
| /** @type {Similarities} */ | ||
| const similarities = []; | ||
@@ -283,3 +287,3 @@ let last; | ||
| * @property {T[]} items | ||
| * @property {Record<string, number>} size | ||
| * @property {Sizes} size | ||
| */ | ||
@@ -290,6 +294,6 @@ | ||
| * @typedef {object} Options | ||
| * @property {Record<string, number>} maxSize maximum size of a group | ||
| * @property {Record<string, number>} minSize minimum size of a group (preferred over maximum size) | ||
| * @property {Sizes} maxSize maximum size of a group | ||
| * @property {Sizes} minSize minimum size of a group (preferred over maximum size) | ||
| * @property {Iterable<T>} items a list of items | ||
| * @property {(item: T) => Record<string, number>} getSize function to get size of an item | ||
| * @property {(item: T) => Sizes} getSize function to get size of an item | ||
| * @property {(item: T) => string} getKey function to get the key of an item | ||
@@ -337,3 +341,3 @@ */ | ||
| * @param {Group<T>} group group | ||
| * @param {Record<string, number>} consideredSize size of the group to consider | ||
| * @param {Sizes} consideredSize size of the group to consider | ||
| * @returns {boolean} true, if the group was modified | ||
@@ -473,5 +477,5 @@ */ | ||
| while (pos <= right + 1) { | ||
| const similarity = /** @type {number[]} */ (group.similarities)[ | ||
| pos - 1 | ||
| ]; | ||
| const similarity = | ||
| /** @type {Similarities} */ | ||
| (group.similarities)[pos - 1]; | ||
| if ( | ||
@@ -503,7 +507,7 @@ similarity < bestSimilarity && | ||
| const rightNodes = [group.nodes[right + 1]]; | ||
| /** @type {number[]} */ | ||
| /** @type {Similarities} */ | ||
| const rightSimilarities = []; | ||
| for (let i = right + 2; i < group.nodes.length; i++) { | ||
| rightSimilarities.push( | ||
| /** @type {number[]} */ (group.similarities)[i - 1] | ||
| /** @type {Similarities} */ (group.similarities)[i - 1] | ||
| ); | ||
@@ -515,7 +519,7 @@ rightNodes.push(group.nodes[i]); | ||
| const leftNodes = [group.nodes[0]]; | ||
| /** @type {number[]} */ | ||
| /** @type {Similarities} */ | ||
| const leftSimilarities = []; | ||
| for (let i = 1; i < left; i++) { | ||
| leftSimilarities.push( | ||
| /** @type {number[]} */ (group.similarities)[i - 1] | ||
| /** @type {Similarities} */ (group.similarities)[i - 1] | ||
| ); | ||
@@ -522,0 +526,0 @@ leftNodes.push(group.nodes[i]); |
@@ -16,3 +16,13 @@ /* | ||
| * @template T | ||
| * @typedef {Set<Node<T>>} Nodes | ||
| */ | ||
| /** | ||
| * @template T | ||
| * @typedef {Set<Cycle<T>>} Cycles | ||
| */ | ||
| /** | ||
| * @template T | ||
| */ | ||
| class Node { | ||
@@ -24,3 +34,3 @@ /** | ||
| this.item = item; | ||
| /** @type {Set<Node<T>>} */ | ||
| /** @type {Nodes<T>} */ | ||
| this.dependencies = new Set(); | ||
@@ -39,3 +49,3 @@ this.marker = NO_MARKER; | ||
| constructor() { | ||
| /** @type {Set<Node<T>>} */ | ||
| /** @type {Nodes<T>} */ | ||
| this.nodes = new Set(); | ||
@@ -81,3 +91,3 @@ } | ||
| // items will be removed if a new reference to it has been found | ||
| /** @type {Set<Node<T>>} */ | ||
| /** @type {Nodes<T>} */ | ||
| const roots = new Set(); | ||
@@ -88,3 +98,3 @@ | ||
| // that is not part of the cycle | ||
| /** @type {Set<Cycle<T>>} */ | ||
| /** @type {Cycles<T>} */ | ||
| const rootCycles = new Set(); | ||
@@ -209,3 +219,3 @@ | ||
| let max = 0; | ||
| /** @type {Set<Node<T>>} */ | ||
| /** @type {Nodes<T>} */ | ||
| const cycleRoots = new Set(); | ||
@@ -212,0 +222,0 @@ const nodes = cycle.nodes; |
+29
-8
@@ -88,6 +88,9 @@ /* | ||
| /** @typedef {Set<string>} Changes */ | ||
| /** @typedef {Set<string>} Removals */ | ||
| /** | ||
| * @typedef {object} WatcherInfo | ||
| * @property {Set<string> | null} changes get current aggregated changes that have not yet send to callback | ||
| * @property {Set<string> | null} removals get current aggregated removals that have not yet send to callback | ||
| * @property {Changes | null} changes get current aggregated changes that have not yet send to callback | ||
| * @property {Removals | null} removals get current aggregated removals that have not yet send to callback | ||
| * @property {TimeInfoEntries} fileTimeInfoEntries get info about files | ||
@@ -97,5 +100,2 @@ * @property {TimeInfoEntries} contextTimeInfoEntries get info about directories | ||
| /** @typedef {Set<string>} Changes */ | ||
| /** @typedef {Set<string>} Removals */ | ||
| // TODO webpack 6 deprecate missing getInfo | ||
@@ -351,7 +351,19 @@ /** | ||
| /** | ||
| * @typedef {FSImplementation & { read: (...args: EXPECTED_ANY[]) => EXPECTED_ANY }} CreateReadStreamFSImplementation | ||
| */ | ||
| /** | ||
| * @typedef {StreamOptions & { fs?: CreateReadStreamFSImplementation | null | undefined, end?: number | undefined }} ReadStreamOptions | ||
| */ | ||
| /** | ||
| * @typedef {(path: PathLike, options?: BufferEncoding | ReadStreamOptions) => NodeJS.ReadableStream} CreateReadStream | ||
| */ | ||
| /** | ||
| * @typedef {object} OutputFileSystem | ||
| * @property {WriteFile} writeFile | ||
| * @property {Mkdir} mkdir | ||
| * @property {Readdir=} readdir | ||
| * @property {Rmdir=} rmdir | ||
| * @property {WriteFile} writeFile | ||
| * @property {Unlink=} unlink | ||
@@ -361,2 +373,3 @@ * @property {Stat} stat | ||
| * @property {ReadFile} readFile | ||
| * @property {CreateReadStream=} createReadStream | ||
| * @property {((path1: string, path2: string) => string)=} join | ||
@@ -403,3 +416,3 @@ * @property {((from: string, to: string) => string)=} relative | ||
| /** | ||
| * @typedef {StreamOptions & { fs?: CreateWriteStreamFSImplementation | null | undefined }} WriteStreamOptions | ||
| * @typedef {StreamOptions & { fs?: CreateWriteStreamFSImplementation | null | undefined, flush?: boolean | undefined }} WriteStreamOptions | ||
| */ | ||
@@ -469,3 +482,3 @@ | ||
| /** | ||
| * @param {InputFileSystem|OutputFileSystem|undefined} fs a file system | ||
| * @param {InputFileSystem | OutputFileSystem|undefined} fs a file system | ||
| * @param {string} rootPath the root path | ||
@@ -658,3 +671,11 @@ * @param {string} targetPath the target path | ||
| /** | ||
| * @param {string} pathname a path | ||
| * @returns {boolean} is absolute | ||
| */ | ||
| const isAbsolute = (pathname) => | ||
| path.posix.isAbsolute(pathname) || path.win32.isAbsolute(pathname); | ||
| module.exports.dirname = dirname; | ||
| module.exports.isAbsolute = isAbsolute; | ||
| module.exports.join = join; | ||
@@ -661,0 +682,0 @@ module.exports.lstatReadlinkAbsolute = lstatReadlinkAbsolute; |
@@ -27,3 +27,3 @@ /* | ||
| * @param {Set<Iterable<T>>} targetSet set where iterables should be added | ||
| * @param {Array<LazySet<T>>} toDeepMerge lazy sets to be flattened | ||
| * @param {LazySet<T>[]} toDeepMerge lazy sets to be flattened | ||
| * @returns {void} | ||
@@ -63,3 +63,3 @@ */ | ||
| this._toMerge = new Set(); | ||
| /** @type {Array<LazySet<T>>} */ | ||
| /** @type {LazySet<T>[]} */ | ||
| this._toDeepMerge = []; | ||
@@ -66,0 +66,0 @@ this._needMerge = false; |
@@ -9,3 +9,4 @@ /* | ||
| /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ | ||
| /** @typedef {string | number | undefined} SemVerRangeItem */ | ||
| /** @typedef {string | number} VersionValue */ | ||
| /** @typedef {VersionValue | undefined} SemVerRangeItem */ | ||
| /** @typedef {(SemVerRangeItem | SemVerRangeItem[])[]} SemVerRange */ | ||
@@ -20,3 +21,3 @@ | ||
| * @param {str} str str | ||
| * @returns {(string | number)[]} result | ||
| * @returns {VersionValue[]} result | ||
| */ | ||
@@ -26,3 +27,3 @@ var splitAndConvert = function (str) { | ||
| // eslint-disable-next-line eqeqeq | ||
| return +item == /** @type {EXPECTED_ANY} */ (item) ? +item : item; | ||
| return +item == /** @type {string | number} */ (item) ? +item : item; | ||
| }); | ||
@@ -35,3 +36,3 @@ }; | ||
| /** @type {(string | number | undefined | [])[]} */ | ||
| /** @type {(VersionValue | undefined | [])[]} */ | ||
| var ver = match[1] ? splitAndConvert(match[1]) : []; | ||
@@ -110,3 +111,3 @@ | ||
| * @param {string} str str | ||
| * @returns {(string | number)[]} result | ||
| * @returns {VersionValue[]} result | ||
| */ | ||
@@ -437,3 +438,3 @@ const splitAndConvert = (str) => { | ||
| /** @type {number | string | undefined} */ | ||
| /** @type {VersionValue | undefined} */ | ||
| var versionValue; | ||
@@ -479,4 +480,4 @@ /** @type {"n" | "s" | "u" | "o" | undefined} */ | ||
| negated | ||
| ? versionValue > /** @type {(number | string)[]} */ (range)[j] | ||
| : versionValue < /** @type {(number | string)[]} */ (range)[j] | ||
| ? versionValue > /** @type {VersionValue[]} */ (range)[j] | ||
| : versionValue < /** @type {VersionValue[]} */ (range)[j] | ||
| ) { | ||
@@ -483,0 +484,0 @@ return false; |
@@ -16,38 +16,49 @@ /* | ||
| /** | ||
| * @template T | ||
| * @template R | ||
| * @template I | ||
| * @template G | ||
| * @typedef {object} GroupConfig | ||
| * @property {(item: T) => string[] | undefined} getKeys | ||
| * @property {(key: string, children: (R | T)[], items: T[]) => R} createGroup | ||
| * @property {(name: string, items: T[]) => GroupOptions=} getOptions | ||
| * @property {(item: I) => string[] | undefined} getKeys | ||
| * @property {(name: string, items: I[]) => GroupOptions=} getOptions | ||
| * @property {(key: string, children: I[], items: I[]) => G} createGroup | ||
| */ | ||
| /** | ||
| * @template T | ||
| * @template R | ||
| * @template I | ||
| * @template G | ||
| * @typedef {{ config: GroupConfig<I, G>, name: string, alreadyGrouped: boolean, items: Items<I, G> | undefined }} Group | ||
| */ | ||
| /** | ||
| * @template I, G | ||
| * @typedef {Set<Group<I, G>>} Groups | ||
| */ | ||
| /** | ||
| * @template I | ||
| * @template G | ||
| * @typedef {object} ItemWithGroups | ||
| * @property {T} item | ||
| * @property {Set<Group<T, R>>} groups | ||
| * @property {I} item | ||
| * @property {Groups<I, G>} groups | ||
| */ | ||
| /** | ||
| * @template T | ||
| * @template R | ||
| * @typedef {{ config: GroupConfig<T, R>, name: string, alreadyGrouped: boolean, items: Set<ItemWithGroups<T, R>> | undefined }} Group | ||
| * @template T, G | ||
| * @typedef {Set<ItemWithGroups<T, G>>} Items | ||
| */ | ||
| /** | ||
| * @template T | ||
| * @template I | ||
| * @template G | ||
| * @template R | ||
| * @param {T[]} items the list of items | ||
| * @param {GroupConfig<T, R>[]} groupConfigs configuration | ||
| * @returns {(R | T)[]} grouped items | ||
| * @param {I[]} items the list of items | ||
| * @param {GroupConfig<I, G>[]} groupConfigs configuration | ||
| * @returns {(I | G)[]} grouped items | ||
| */ | ||
| const smartGrouping = (items, groupConfigs) => { | ||
| /** @type {Set<ItemWithGroups<T, R>>} */ | ||
| /** @type {Items<I, G>} */ | ||
| const itemsWithGroups = new Set(); | ||
| /** @type {Map<string, Group<T, R>>} */ | ||
| /** @type {Map<string, Group<I, G>>} */ | ||
| const allGroups = new Map(); | ||
| for (const item of items) { | ||
| /** @type {Set<Group<T, R>>} */ | ||
| /** @type {Groups<I, G>} */ | ||
| const groups = new Set(); | ||
@@ -81,5 +92,6 @@ for (let i = 0; i < groupConfigs.length; i++) { | ||
| } | ||
| /** | ||
| * @param {Set<ItemWithGroups<T, R>>} itemsWithGroups input items with groups | ||
| * @returns {(T | R)[]} groups items | ||
| * @param {Items<I, G>} itemsWithGroups input items with groups | ||
| * @returns {(I | G)[]} groups items | ||
| */ | ||
@@ -99,3 +111,3 @@ const runGrouping = (itemsWithGroups) => { | ||
| } | ||
| /** @type {Map<Group<T, R>, { items: Set<ItemWithGroups<T, R>>, options: GroupOptions | false | undefined, used: boolean }>} */ | ||
| /** @type {Map<Group<I, G>, { items: Items<I, G>, options: GroupOptions | false | undefined, used: boolean }>} */ | ||
| const groupMap = new Map(); | ||
@@ -113,9 +125,11 @@ for (const group of allGroups.values()) { | ||
| } | ||
| /** @type {(T | R)[]} */ | ||
| /** @type {(I | G)[]} */ | ||
| const results = []; | ||
| for (;;) { | ||
| /** @type {Group<T, R> | undefined} */ | ||
| /** @type {Group<I, G> | undefined} */ | ||
| let bestGroup; | ||
| let bestGroupSize = -1; | ||
| /** @type {Items<I, G> | undefined} */ | ||
| let bestGroupItems; | ||
| /** @type {GroupOptions | false | undefined} */ | ||
| let bestGroupOptions; | ||
@@ -199,4 +213,5 @@ for (const [group, state] of groupMap) { | ||
| bestGroup.alreadyGrouped = false; | ||
| results.push(groupConfig.createGroup(key, children, allItems)); | ||
| results.push( | ||
| groupConfig.createGroup(key, /** @type {I[]} */ (children), allItems) | ||
| ); | ||
| } | ||
@@ -203,0 +218,0 @@ for (const { item } of itemsWithGroups) { |
@@ -8,4 +8,2 @@ /* | ||
| new Map().entries(); | ||
| /** | ||
@@ -12,0 +10,0 @@ * The StackedCacheMap is a data structure designed as an alternative to a Map |
@@ -115,5 +115,10 @@ /* | ||
| [Symbol.iterator]() { | ||
| /** | ||
| * @template T, V | ||
| * @typedef {MapIterator<[T, InnerMap<T, V> | Set<V>]>} IteratorStack | ||
| */ | ||
| // This is difficult to type because we can have a map inside a map inside a map, etc. where the end is a set (each key is an argument) | ||
| // But in basic use we only have 2 arguments in our methods, so we have `Map<K, Set<V>>` | ||
| /** @type {MapIterator<[T, InnerMap<T, V> | Set<V>]>[]} */ | ||
| /** @type {IteratorStack<T, V>[]} */ | ||
| const iteratorStack = []; | ||
@@ -126,3 +131,3 @@ /** @type {[T?, V?, ...EXPECTED_ANY]} */ | ||
| /** | ||
| * @param {MapIterator<[T, InnerMap<T, V> | Set<V>]>} it iterator | ||
| * @param {IteratorStack<T, V>} it iterator | ||
| * @returns {boolean} result | ||
@@ -136,3 +141,3 @@ */ | ||
| return next( | ||
| /** @type {MapIterator<[T, InnerMap<T, V> | Set<V>]>} */ | ||
| /** @type {IteratorStack<T, V>} */ | ||
| (iteratorStack.pop()) | ||
@@ -161,3 +166,3 @@ ); | ||
| !next( | ||
| /** @type {MapIterator<[T, InnerMap<T, V> | Set<V>]>} */ | ||
| /** @type {IteratorStack<T, V>} */ | ||
| (iteratorStack.pop()) | ||
@@ -164,0 +169,0 @@ ) |
@@ -8,3 +8,2 @@ /* | ||
| /** @typedef {import("./fs").InputFileSystem} InputFileSystem */ | ||
| /** @typedef {(error: Error|null, result?: Buffer) => void} ErrorFirstCallback */ | ||
@@ -11,0 +10,0 @@ |
@@ -28,3 +28,3 @@ /* | ||
| * @template {unknown[]} T | ||
| * @typedef {T extends readonly (infer ElementType)[] ? ElementType : never} ArrayElement | ||
| * @typedef {T extends ReadonlyArray<infer ElementType> ? ElementType : never} ArrayElement | ||
| */ | ||
@@ -31,0 +31,0 @@ |
@@ -79,3 +79,7 @@ /* | ||
| const getStreaming = () => { | ||
| const concat = (/** @type {string[]} */ ...text) => text.join(""); | ||
| /** | ||
| * @param {string[]} text text | ||
| * @returns {string} merged text | ||
| */ | ||
| const concat = (...text) => text.join(""); | ||
| return [ | ||
@@ -82,0 +86,0 @@ this.generateBeforeLoadBinaryCode |
@@ -17,4 +17,2 @@ /* | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} OutputOptions */ | ||
| /** @typedef {import("../DependencyTemplates")} DependencyTemplates */ | ||
| /** @typedef {import("../Generator").GenerateContext} GenerateContext */ | ||
@@ -24,3 +22,2 @@ /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../NormalModule")} NormalModule */ | ||
| /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ | ||
@@ -33,10 +30,2 @@ /** | ||
| /** | ||
| * @param {OutputOptions["webassemblyModuleFilename"]} filenameTemplate template for the WebAssembly module filename | ||
| */ | ||
| constructor(filenameTemplate) { | ||
| super(); | ||
| this.filenameTemplate = filenameTemplate; | ||
| } | ||
| /** | ||
| * @param {NormalModule} module fresh module | ||
@@ -75,3 +64,3 @@ * @returns {SourceTypes} available types (do not mutate) | ||
| runtimeRequirements.add(RuntimeGlobals.instantiateWasm); | ||
| /** @type {InitFragment<InitFragment<string>>[]} */ | ||
| /** @type {InitFragment<GenerateContext>[]} */ | ||
| const initFragments = []; | ||
@@ -100,3 +89,3 @@ /** @type {Map<Module, ImportObjRequestItem>} */ | ||
| /** @type {Array<string>} */ | ||
| /** @type {string[]} */ | ||
| const promises = []; | ||
@@ -103,0 +92,0 @@ |
@@ -18,3 +18,2 @@ /* | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} OutputOptions */ | ||
| /** @typedef {import("../Chunk")} Chunk */ | ||
@@ -28,4 +27,2 @@ /** @typedef {import("../ChunkGraph")} ChunkGraph */ | ||
| /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ | ||
| /** @typedef {import("../Template").RenderManifestEntry} RenderManifestEntry */ | ||
| /** @typedef {import("../Template").RenderManifestOptions} RenderManifestOptions */ | ||
| /** @typedef {import("../WebpackError")} WebpackError */ | ||
@@ -131,5 +128,3 @@ | ||
| return Generator.byType({ | ||
| javascript: new AsyncWebAssemblyJavascriptGenerator( | ||
| compilation.outputOptions.webassemblyModuleFilename | ||
| ), | ||
| javascript: new AsyncWebAssemblyJavascriptGenerator(), | ||
| webassembly: new AsyncWebAssemblyGenerator(this.options) | ||
@@ -153,5 +148,3 @@ }); | ||
| if (module.type === WEBASSEMBLY_MODULE_TYPE_ASYNC) { | ||
| const filenameTemplate = | ||
| /** @type {NonNullable<OutputOptions["webassemblyModuleFilename"]>} */ | ||
| (outputOptions.webassemblyModuleFilename); | ||
| const filenameTemplate = outputOptions.webassemblyModuleFilename; | ||
@@ -158,0 +151,0 @@ result.push({ |
@@ -63,4 +63,5 @@ /* | ||
| const module = program.body[0]; | ||
| /** @type {Array<string>} */ | ||
| /** @type {string[]} */ | ||
| const exports = []; | ||
| t.traverse(module, { | ||
@@ -67,0 +68,0 @@ ModuleExport({ node }) { |
@@ -49,2 +49,4 @@ /* | ||
| /** @typedef {string[]} Declarations */ | ||
| /** | ||
@@ -55,3 +57,3 @@ * generates the import object function for a module | ||
| * @param {boolean | undefined} mangle mangle imports | ||
| * @param {string[]} declarations array where declarations are pushed to | ||
| * @param {Declarations} declarations array where declarations are pushed to | ||
| * @param {RuntimeSpec} runtime the runtime | ||
@@ -68,3 +70,3 @@ * @returns {string} source code | ||
| const moduleGraph = chunkGraph.moduleGraph; | ||
| /** @type {Map<string, string | number>} */ | ||
| /** @type {Map<string, ModuleId>} */ | ||
| const waitForInstances = new Map(); | ||
@@ -152,3 +154,3 @@ const properties = []; | ||
| } else { | ||
| /** @type {Map<string, Array<{ name: string, value: string }>>} */ | ||
| /** @type {Map<string, { name: string, value: string }[]>} */ | ||
| const propertiesByModule = new Map(); | ||
@@ -260,3 +262,3 @@ for (const p of properties) { | ||
| const { mangleImports } = this; | ||
| /** @type {string[]} */ | ||
| /** @type {Declarations} */ | ||
| const declarations = []; | ||
@@ -263,0 +265,0 @@ const importObjects = wasmModules.map((module) => |
@@ -19,3 +19,2 @@ /* | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("../DependencyTemplates")} DependencyTemplates */ | ||
| /** @typedef {import("../Generator").GenerateContext} GenerateContext */ | ||
@@ -26,3 +25,2 @@ /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../NormalModule")} NormalModule */ | ||
| /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ | ||
| /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */ | ||
@@ -180,3 +178,3 @@ /** @typedef {import("./WebAssemblyUtils").UsedWasmDependency} UsedWasmDependency */ | ||
| const additionalInitCode = state.additionalInitCode; | ||
| /** @type {Array<t.Global>} */ | ||
| /** @type {t.Global[]} */ | ||
| const newGlobals = []; | ||
@@ -183,0 +181,0 @@ |
@@ -20,4 +20,2 @@ /* | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("../Dependency")} Dependency */ | ||
| /** @typedef {import("../DependencyTemplates")} DependencyTemplates */ | ||
| /** @typedef {import("../Generator").GenerateContext} GenerateContext */ | ||
@@ -27,3 +25,2 @@ /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../NormalModule")} NormalModule */ | ||
| /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ | ||
@@ -61,3 +58,3 @@ class WebAssemblyJavascriptGenerator extends Generator { | ||
| } = generateContext; | ||
| /** @type {InitFragment<InitFragment<string>>[]} */ | ||
| /** @type {InitFragment<GenerateContext>[]} */ | ||
| const initFragments = []; | ||
@@ -64,0 +61,0 @@ |
@@ -16,8 +16,4 @@ /* | ||
| /** @typedef {import("webpack-sources").Source} Source */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").OutputNormalized} OutputOptions */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../ModuleTemplate")} ModuleTemplate */ | ||
| /** @typedef {import("../javascript/JavascriptModulesPlugin").RenderContext} RenderContext */ | ||
@@ -96,5 +92,3 @@ const getWebAssemblyGenerator = memoize(() => | ||
| if (module.type === WEBASSEMBLY_MODULE_TYPE_SYNC) { | ||
| const filenameTemplate = | ||
| /** @type {NonNullable<OutputOptions["webassemblyModuleFilename"]>} */ | ||
| (outputOptions.webassemblyModuleFilename); | ||
| const filenameTemplate = outputOptions.webassemblyModuleFilename; | ||
@@ -128,2 +122,3 @@ result.push({ | ||
| const chunkGraph = compilation.chunkGraph; | ||
| /** @type {Set<Module>} */ | ||
| const initialWasmModules = new Set(); | ||
@@ -130,0 +125,0 @@ for (const chunk of compilation.chunks) { |
@@ -17,4 +17,2 @@ /* | ||
| /** @typedef {import("@webassemblyjs/ast").ModuleImport} ModuleImport */ | ||
| /** @typedef {import("@webassemblyjs/ast").NumberLiteral} NumberLiteral */ | ||
| /** @typedef {import("../Module")} Module */ | ||
| /** @typedef {import("../Module").BuildInfo} BuildInfo */ | ||
@@ -136,4 +134,3 @@ /** @typedef {import("../Module").BuildMeta} BuildMeta */ | ||
| if (node.descr && node.descr.exportType === "Global") { | ||
| const refNode = | ||
| importedGlobals[/** @type {NumberLiteral} */ (node.descr.id).value]; | ||
| const refNode = importedGlobals[node.descr.id.value]; | ||
| if (refNode) { | ||
@@ -140,0 +137,0 @@ const dep = new WebAssemblyExportImportedDependency( |
@@ -8,6 +8,7 @@ /* | ||
| /** @typedef {import("../../declarations/WebpackOptions").LibraryOptions} LibraryOptions */ | ||
| /** @typedef {import("../../declarations/WebpackOptions").WasmLoadingType} WasmLoadingType */ | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {Set<WasmLoadingType>} WasmLoadingTypes */ | ||
| /** @type {WeakMap<Compiler, Set<WasmLoadingType>>} */ | ||
@@ -18,3 +19,3 @@ const enabledTypes = new WeakMap(); | ||
| * @param {Compiler} compiler compiler instance | ||
| * @returns {Set<WasmLoadingType>} enabled types | ||
| * @returns {WasmLoadingTypes} enabled types | ||
| */ | ||
@@ -21,0 +22,0 @@ const getEnabledTypes = (compiler) => { |
@@ -12,3 +12,2 @@ /* | ||
| /** @typedef {import("../declarations/plugins/WatchIgnorePlugin").WatchIgnorePluginOptions} WatchIgnorePluginOptions */ | ||
| /** @typedef {import("../declarations/WebpackOptions").WatchOptions} WatchOptions */ | ||
| /** @typedef {import("./Compiler")} Compiler */ | ||
@@ -55,3 +54,3 @@ /** @typedef {import("./util/fs").TimeInfoEntries} TimeInfoEntries */ | ||
| const [ignoredFiles, notIgnoredFiles] = groupBy( | ||
| /** @type {Array<string>} */ | ||
| /** @type {string[]} */ | ||
| (files), | ||
@@ -61,3 +60,3 @@ ignored | ||
| const [ignoredDirs, notIgnoredDirs] = groupBy( | ||
| /** @type {Array<string>} */ | ||
| /** @type {string[]} */ | ||
| (dirs), | ||
@@ -64,0 +63,0 @@ ignored |
+15
-15
@@ -13,3 +13,3 @@ /* | ||
| /** @typedef {import("./Compiler")} Compiler */ | ||
| /** @typedef {import("./FileSystemInfo").FileSystemInfoEntry} FileSystemInfoEntry */ | ||
| /** @typedef {import("./Compiler").ErrorCallback} ErrorCallback */ | ||
| /** @typedef {import("./WebpackError")} WebpackError */ | ||
@@ -19,11 +19,11 @@ /** @typedef {import("./logging/Logger").Logger} Logger */ | ||
| /** @typedef {import("./util/fs").WatchFileSystem} WatchFileSystem */ | ||
| /** @typedef {import("./util/fs").Watcher} Watcher */ | ||
| /** | ||
| * @template T | ||
| * @callback Callback | ||
| * @param {Error | null} err | ||
| * @param {T=} result | ||
| * @template [R=void] | ||
| * @typedef {import("./webpack").Callback<T, R>} Callback | ||
| */ | ||
| /** @typedef {Set<string>} CollectedFiles */ | ||
| class Watching { | ||
@@ -39,5 +39,5 @@ /** | ||
| this.handler = handler; | ||
| /** @type {Callback<void>[]} */ | ||
| /** @type {ErrorCallback[]} */ | ||
| this.callbacks = []; | ||
| /** @type {Callback<void>[] | undefined} */ | ||
| /** @type {ErrorCallback[] | undefined} */ | ||
| this._closeCallbacks = undefined; | ||
@@ -72,5 +72,5 @@ this.closed = false; | ||
| this.pausedWatcher = undefined; | ||
| /** @type {Set<string> | undefined} */ | ||
| /** @type {CollectedFiles | undefined} */ | ||
| this._collectedChangedFiles = undefined; | ||
| /** @type {Set<string> | undefined} */ | ||
| /** @type {CollectedFiles | undefined} */ | ||
| this._collectedRemovedFiles = undefined; | ||
@@ -95,3 +95,3 @@ this._done = this._done.bind(this); | ||
| this._collectedChangedFiles.add(file); | ||
| /** @type {Set<string>} */ | ||
| /** @type {CollectedFiles} */ | ||
| (this._collectedRemovedFiles).delete(file); | ||
@@ -101,3 +101,3 @@ } | ||
| this._collectedChangedFiles.delete(file); | ||
| /** @type {Set<string>} */ | ||
| /** @type {CollectedFiles} */ | ||
| (this._collectedRemovedFiles).add(file); | ||
@@ -271,3 +271,3 @@ } | ||
| * @param {Error} err error | ||
| * @param {Callback<void>[]=} cbs callbacks | ||
| * @param {ErrorCallback[]=} cbs callbacks | ||
| */ | ||
@@ -403,3 +403,3 @@ const handleError = (err, cbs) => { | ||
| /** | ||
| * @param {Callback<void>=} callback signals when the build has completed again | ||
| * @param {ErrorCallback=} callback signals when the build has completed again | ||
| * @returns {void} | ||
@@ -462,3 +462,3 @@ */ | ||
| /** | ||
| * @param {Callback<void>} callback signals when the watcher is closed | ||
| * @param {ErrorCallback} callback signals when the watcher is closed | ||
| * @returns {void} | ||
@@ -493,3 +493,3 @@ */ | ||
| const closeCallbacks = | ||
| /** @type {Callback<void>[]} */ | ||
| /** @type {ErrorCallback[]} */ | ||
| (this._closeCallbacks); | ||
@@ -496,0 +496,0 @@ this._closeCallbacks = undefined; |
@@ -13,2 +13,3 @@ /* | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */ | ||
@@ -41,3 +42,3 @@ const PLUGIN_NAME = "JsonpChunkLoadingPlugin"; | ||
| * @param {Chunk} chunk chunk | ||
| * @param {Set<string>} set runtime requirements | ||
| * @param {RuntimeRequirements} set runtime requirements | ||
| */ | ||
@@ -44,0 +45,0 @@ const handler = (chunk, set) => { |
@@ -72,3 +72,3 @@ /* | ||
| } | ||
| return `${RuntimeGlobals.baseURI} = document.baseURI || self.location.href;`; | ||
| return `${RuntimeGlobals.baseURI} = (document && document.baseURI) || self.location.href;`; | ||
| } | ||
@@ -75,0 +75,0 @@ |
@@ -12,3 +12,2 @@ /* | ||
| /** @typedef {import("../Chunk")} Chunk */ | ||
| /** @typedef {import("../Compilation")} Compilation */ | ||
@@ -15,0 +14,0 @@ /** @typedef {import("../Compiler")} Compiler */ |
+21
-8
@@ -24,2 +24,3 @@ /* | ||
| /** @typedef {import("../declarations/WebpackOptions").WebpackPluginFunction} WebpackPluginFunction */ | ||
| /** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptionsNormalizedWithDefaults */ | ||
| /** @typedef {import("./Compiler").WatchOptions} WatchOptions */ | ||
@@ -35,8 +36,11 @@ /** @typedef {import("./MultiCompiler").MultiCompilerOptions} MultiCompilerOptions */ | ||
| * @template T | ||
| * @template [R=void] | ||
| * @callback Callback | ||
| * @param {Error | null} err | ||
| * @param {T=} stats | ||
| * @returns {void} | ||
| * @param {T=} result | ||
| * @returns {R} | ||
| */ | ||
| /** @typedef {Callback<void>} ErrorCallback */ | ||
| /** | ||
@@ -97,3 +101,7 @@ * @param {ReadonlyArray<WebpackOptions>} childOptions options array | ||
| compiler.hooks.afterEnvironment.call(); | ||
| new WebpackOptionsApply().process(options, compiler); | ||
| new WebpackOptionsApply().process( | ||
| /** @type {WebpackOptionsNormalizedWithDefaults} */ | ||
| (options), | ||
| compiler | ||
| ); | ||
| compiler.hooks.initialize.call(); | ||
@@ -119,4 +127,4 @@ return compiler; | ||
| * @template T | ||
| * @param {Array<T> | T} options options | ||
| * @returns {Array<T>} array of options | ||
| * @param {T[] | T} options options | ||
| * @returns {T[]} array of options | ||
| */ | ||
@@ -137,3 +145,7 @@ const asArray = (options) => | ||
| const create = () => { | ||
| if (!asArray(options).every(webpackOptionsSchemaCheck)) { | ||
| if ( | ||
| !asArray(/** @type {WebpackOptions} */ (options)).every( | ||
| webpackOptionsSchemaCheck | ||
| ) | ||
| ) { | ||
| getValidateSchema()(webpackOptionsSchema, options); | ||
@@ -150,3 +162,3 @@ util.deprecate( | ||
| let watch = false; | ||
| /** @type {WatchOptions|WatchOptions[]} */ | ||
| /** @type {WatchOptions | WatchOptions[]} */ | ||
| let watchOptions; | ||
@@ -157,3 +169,4 @@ if (Array.isArray(options)) { | ||
| options, | ||
| /** @type {MultiCompilerOptions} */ (options) | ||
| /** @type {MultiCompilerOptions} */ | ||
| (options) | ||
| ); | ||
@@ -160,0 +173,0 @@ watch = options.some((options) => options.watch); |
@@ -19,6 +19,4 @@ /* | ||
| /** @typedef {import("enhanced-resolve").Resolver} Resolver */ | ||
| /** @typedef {import("./Compiler")} Compiler */ | ||
| /** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */ | ||
| /** @typedef {import("./Module")} Module */ | ||
| /** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */ | ||
@@ -25,0 +23,0 @@ /** @typedef {import("./javascript/JavascriptParser").Range} Range */ |
+74
-107
@@ -76,5 +76,4 @@ /* | ||
| /** @typedef {import("../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */ | ||
| /** @typedef {import("../declarations/WebpackOptions").WebpackPluginFunction} WebpackPluginFunction */ | ||
| /** @typedef {import("../declarations/WebpackOptions").WebpackPluginInstance} WebpackPluginInstance */ | ||
| /** @typedef {import("./config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */ | ||
| /** @typedef {import("./Compiler")} Compiler */ | ||
@@ -97,3 +96,3 @@ /** @typedef {import("./util/fs").InputFileSystem} InputFileSystem */ | ||
| process(options, compiler) { | ||
| compiler.outputPath = /** @type {string} */ (options.output.path); | ||
| compiler.outputPath = options.output.path; | ||
| compiler.recordsInputPath = options.recordsInputPath || null; | ||
@@ -116,111 +115,88 @@ compiler.recordsOutputPath = options.recordsOutputPath || null; | ||
| new NodeTargetPlugin().apply(compiler); | ||
| } | ||
| if (options.externalsPresets.electronMain) { | ||
| // @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 | ||
| const ElectronTargetPlugin = require("./electron/ElectronTargetPlugin"); | ||
| new ElectronTargetPlugin("main").apply(compiler); | ||
| } | ||
| if (options.externalsPresets.electronPreload) { | ||
| // @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 | ||
| const ElectronTargetPlugin = require("./electron/ElectronTargetPlugin"); | ||
| // Handle external CSS `@import` and `url()` | ||
| if (options.experiments.css) { | ||
| // @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 | ||
| const ExternalsPlugin = require("./ExternalsPlugin"); | ||
| new ElectronTargetPlugin("preload").apply(compiler); | ||
| } | ||
| if (options.externalsPresets.electronRenderer) { | ||
| // @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 | ||
| const ElectronTargetPlugin = require("./electron/ElectronTargetPlugin"); | ||
| new ExternalsPlugin( | ||
| "module", | ||
| ({ request, dependencyType, contextInfo }, callback) => { | ||
| if ( | ||
| /\.css(\?|$)/.test(contextInfo.issuer) && | ||
| /^(\/\/|https?:\/\/|#)/.test(request) | ||
| ) { | ||
| if (dependencyType === "url") { | ||
| return callback(null, `asset ${request}`); | ||
| } else if ( | ||
| dependencyType === "css-import" && | ||
| options.experiments.css | ||
| ) { | ||
| return callback(null, `css-import ${request}`); | ||
| } | ||
| } | ||
| new ElectronTargetPlugin("renderer").apply(compiler); | ||
| callback(); | ||
| } | ||
| ).apply(compiler); | ||
| } | ||
| } | ||
| if ( | ||
| options.externalsPresets.electron && | ||
| !options.externalsPresets.electronMain && | ||
| !options.externalsPresets.electronPreload && | ||
| !options.externalsPresets.electronRenderer | ||
| ) { | ||
| // @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 | ||
| const ElectronTargetPlugin = require("./electron/ElectronTargetPlugin"); | ||
| if (options.externalsPresets.webAsync || options.externalsPresets.web) { | ||
| const type = options.externalsPresets.webAsync ? "import" : "module"; | ||
| new ElectronTargetPlugin().apply(compiler); | ||
| } | ||
| if (options.externalsPresets.nwjs) { | ||
| // @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 | ||
| const ExternalsPlugin = require("./ExternalsPlugin"); | ||
| new ExternalsPlugin("node-commonjs", "nw.gui").apply(compiler); | ||
| } | ||
| if (options.externalsPresets.webAsync) { | ||
| // @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 | ||
| const ExternalsPlugin = require("./ExternalsPlugin"); | ||
| new ExternalsPlugin("import", ({ request, dependencyType }, callback) => { | ||
| if (dependencyType === "url") { | ||
| if (/^(\/\/|https?:\/\/|#)/.test(/** @type {string} */ (request))) { | ||
| new ExternalsPlugin(type, ({ request, dependencyType }, callback) => { | ||
| if (/^(\/\/|https?:\/\/|#|std:|jsr:|npm:)/.test(request)) { | ||
| if (dependencyType === "url") { | ||
| return callback(null, `asset ${request}`); | ||
| } | ||
| } else if (options.experiments.css && dependencyType === "css-import") { | ||
| if (/^(\/\/|https?:\/\/|#)/.test(/** @type {string} */ (request))) { | ||
| } else if ( | ||
| dependencyType === "css-import" && | ||
| options.experiments.css | ||
| ) { | ||
| return callback(null, `css-import ${request}`); | ||
| } else if (/^(\/\/|https?:\/\/|std:|jsr:|npm:)/.test(request)) { | ||
| return callback(null, `${type} ${request}`); | ||
| } | ||
| } else if ( | ||
| options.experiments.css && | ||
| /^(\/\/|https?:\/\/|std:)/.test(/** @type {string} */ (request)) | ||
| ) { | ||
| if (/^\.css(\?|$)/.test(/** @type {string} */ (request))) { | ||
| return callback(null, `css-import ${request}`); | ||
| } | ||
| return callback(null, `import ${request}`); | ||
| } | ||
| callback(); | ||
| }).apply(compiler); | ||
| } else if (options.externalsPresets.web) { | ||
| // @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 | ||
| const ExternalsPlugin = require("./ExternalsPlugin"); | ||
| } | ||
| if (options.externalsPresets.electron) { | ||
| if (options.externalsPresets.electronMain) { | ||
| // @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 | ||
| const ElectronTargetPlugin = require("./electron/ElectronTargetPlugin"); | ||
| new ExternalsPlugin("module", ({ request, dependencyType }, callback) => { | ||
| if (dependencyType === "url") { | ||
| if (/^(\/\/|https?:\/\/|#)/.test(/** @type {string} */ (request))) { | ||
| return callback(null, `asset ${request}`); | ||
| } | ||
| } else if (options.experiments.css && dependencyType === "css-import") { | ||
| if (/^(\/\/|https?:\/\/|#)/.test(/** @type {string} */ (request))) { | ||
| return callback(null, `css-import ${request}`); | ||
| } | ||
| } else if ( | ||
| /^(\/\/|https?:\/\/|std:)/.test(/** @type {string} */ (request)) | ||
| ) { | ||
| if ( | ||
| options.experiments.css && | ||
| /^\.css((\?)|$)/.test(/** @type {string} */ (request)) | ||
| ) { | ||
| return callback(null, `css-import ${request}`); | ||
| } | ||
| return callback(null, `module ${request}`); | ||
| } | ||
| callback(); | ||
| }).apply(compiler); | ||
| } else if (options.externalsPresets.node && options.experiments.css) { | ||
| new ElectronTargetPlugin("main").apply(compiler); | ||
| } | ||
| if (options.externalsPresets.electronPreload) { | ||
| // @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 | ||
| const ElectronTargetPlugin = require("./electron/ElectronTargetPlugin"); | ||
| new ElectronTargetPlugin("preload").apply(compiler); | ||
| } | ||
| if (options.externalsPresets.electronRenderer) { | ||
| // @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 | ||
| const ElectronTargetPlugin = require("./electron/ElectronTargetPlugin"); | ||
| new ElectronTargetPlugin("renderer").apply(compiler); | ||
| } | ||
| if ( | ||
| !options.externalsPresets.electronMain && | ||
| !options.externalsPresets.electronPreload && | ||
| !options.externalsPresets.electronRenderer | ||
| ) { | ||
| // @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 | ||
| const ElectronTargetPlugin = require("./electron/ElectronTargetPlugin"); | ||
| new ElectronTargetPlugin().apply(compiler); | ||
| } | ||
| } | ||
| if (options.externalsPresets.nwjs) { | ||
| // @ts-expect-error https://github.com/microsoft/TypeScript/issues/41697 | ||
| const ExternalsPlugin = require("./ExternalsPlugin"); | ||
| new ExternalsPlugin("module", ({ request, dependencyType }, callback) => { | ||
| if (dependencyType === "url") { | ||
| if (/^(\/\/|https?:\/\/|#)/.test(/** @type {string} */ (request))) { | ||
| return callback(null, `asset ${request}`); | ||
| } | ||
| } else if (dependencyType === "css-import") { | ||
| if (/^(\/\/|https?:\/\/|#)/.test(/** @type {string} */ (request))) { | ||
| return callback(null, `css-import ${request}`); | ||
| } | ||
| } else if ( | ||
| /^(\/\/|https?:\/\/|std:)/.test(/** @type {string} */ (request)) | ||
| ) { | ||
| if (/^\.css(\?|$)/.test(/** @type {string} */ (request))) { | ||
| return callback(null, `css-import ${request}`); | ||
| } | ||
| return callback(null, `module ${request}`); | ||
| } | ||
| callback(); | ||
| }).apply(compiler); | ||
| new ExternalsPlugin("node-commonjs", "nw.gui").apply(compiler); | ||
| } | ||
@@ -452,7 +428,3 @@ | ||
| new EntryOptionPlugin().apply(compiler); | ||
| compiler.hooks.entryOption.call( | ||
| /** @type {string} */ | ||
| (options.context), | ||
| options.entry | ||
| ); | ||
| compiler.hooks.entryOption.call(options.context, options.entry); | ||
@@ -468,3 +440,2 @@ new RuntimePlugin().apply(compiler); | ||
| new HarmonyModulesPlugin({ | ||
| topLevelAwait: options.experiments.topLevelAwait, | ||
| deferImport: options.experiments.deferImport | ||
@@ -486,5 +457,3 @@ }).apply(compiler); | ||
| } | ||
| new APIPlugin({ | ||
| module: options.output.module | ||
| }).apply(compiler); | ||
| new APIPlugin().apply(compiler); | ||
| new ExportsInfoApiPlugin().apply(compiler); | ||
@@ -712,5 +681,3 @@ new WebpackIsIncludedPlugin().apply(compiler); | ||
| if (options.optimization.minimize) { | ||
| for (const minimizer of /** @type {(WebpackPluginInstance | WebpackPluginFunction | "...")[]} */ ( | ||
| options.optimization.minimizer | ||
| )) { | ||
| for (const minimizer of options.optimization.minimizer) { | ||
| if (typeof minimizer === "function") { | ||
@@ -820,3 +787,3 @@ /** @type {WebpackPluginFunction} */ | ||
| (compiler.intermediateFileSystem), | ||
| context: /** @type {string} */ (options.context), | ||
| context: options.context, | ||
| cacheLocation: | ||
@@ -823,0 +790,0 @@ /** @type {string} */ |
@@ -14,2 +14,3 @@ /* | ||
| /** @typedef {import("../Compiler")} Compiler */ | ||
| /** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */ | ||
@@ -46,3 +47,3 @@ const PLUGIN_NAME = "ImportScriptsChunkLoadingPlugin"; | ||
| * @param {Chunk} chunk chunk | ||
| * @param {Set<string>} set runtime requirements | ||
| * @param {RuntimeRequirements} set runtime requirements | ||
| */ | ||
@@ -49,0 +50,0 @@ const handler = (chunk, set) => { |
@@ -57,3 +57,3 @@ /* | ||
| outputName, | ||
| /** @type {string} */ (compilation.outputOptions.path), | ||
| compilation.outputOptions.path, | ||
| false | ||
@@ -60,0 +60,0 @@ ); |
+12
-12
| { | ||
| "name": "webpack", | ||
| "version": "5.101.3", | ||
| "version": "5.102.0", | ||
| "description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.", | ||
@@ -92,3 +92,3 @@ "homepage": "https://github.com/webpack/webpack", | ||
| "acorn-import-phases": "^1.0.3", | ||
| "browserslist": "^4.24.0", | ||
| "browserslist": "^4.24.5", | ||
| "chrome-trace-event": "^1.0.2", | ||
@@ -106,5 +106,5 @@ "enhanced-resolve": "^5.17.3", | ||
| "schema-utils": "^4.3.2", | ||
| "tapable": "^2.1.1", | ||
| "tapable": "^2.2.3", | ||
| "terser-webpack-plugin": "^5.3.11", | ||
| "watchpack": "^2.4.1", | ||
| "watchpack": "^2.4.4", | ||
| "webpack-sources": "^3.3.3" | ||
@@ -125,3 +125,3 @@ }, | ||
| "@types/xxhashjs": "^0.2.4", | ||
| "assemblyscript": "^0.28.2", | ||
| "assemblyscript": "^0.28.5", | ||
| "babel-loader": "^10.0.0", | ||
@@ -145,3 +145,3 @@ "bundle-loader": "^0.5.6", | ||
| "eslint-plugin-prettier": "^5.5.0", | ||
| "eslint-plugin-unicorn": "^60.0.0", | ||
| "eslint-plugin-unicorn": "^61.0.1", | ||
| "file-loader": "^6.0.0", | ||
@@ -153,7 +153,7 @@ "fork-ts-checker-webpack-plugin": "^9.0.2", | ||
| "istanbul": "^0.4.5", | ||
| "jest": "^30.0.5", | ||
| "jest-circus": "^30.0.5", | ||
| "jest-cli": "^30.0.5", | ||
| "jest-diff": "^30.0.5", | ||
| "jest-environment-node": "^30.0.5", | ||
| "jest": "^30.1.2", | ||
| "jest-circus": "^30.1.2", | ||
| "jest-cli": "^30.1.2", | ||
| "jest-diff": "^30.1.2", | ||
| "jest-environment-node": "^30.1.2", | ||
| "jest-junit": "^16.0.0", | ||
@@ -187,3 +187,3 @@ "json-loader": "^0.5.7", | ||
| "terser": "^5.43.1", | ||
| "three": "^0.179.1", | ||
| "three": "^0.180.0", | ||
| "tinybench": "^5.0.0", | ||
@@ -190,0 +190,0 @@ "toml": "^3.0.0", |
@@ -6,2 +6,2 @@ /* | ||
| */ | ||
| "use strict";function n(t,{instancePath:e="",parentData:s,parentDataProperty:l,rootData:a=t}={}){let r=null,o=0;const u=o;let i=!1;const p=o;if(o===p)if(Array.isArray(t)){const n=t.length;for(let e=0;e<n;e++){let n=t[e];const s=o,l=o;let a=!1,u=null;const i=o,p=o;let f=!1;const h=o;if(!(n instanceof RegExp)){const n={params:{}};null===r?r=[n]:r.push(n),o++}var c=h===o;if(f=f||c,!f){const t=o;if(o===t)if("string"==typeof n){if(n.length<1){const n={params:{}};null===r?r=[n]:r.push(n),o++}}else{const n={params:{type:"string"}};null===r?r=[n]:r.push(n),o++}c=t===o,f=f||c}if(f)o=p,null!==r&&(p?r.length=p:r=null);else{const n={params:{}};null===r?r=[n]:r.push(n),o++}if(i===o&&(a=!0,u=0),a)o=l,null!==r&&(l?r.length=l:r=null);else{const n={params:{passingSchemas:u}};null===r?r=[n]:r.push(n),o++}if(s!==o)break}}else{const n={params:{type:"array"}};null===r?r=[n]:r.push(n),o++}var f=p===o;if(i=i||f,!i){const n=o,e=o;let s=!1;const l=o;if(!(t instanceof RegExp)){const n={params:{}};null===r?r=[n]:r.push(n),o++}var h=l===o;if(s=s||h,!s){const n=o;if(o===n)if("string"==typeof t){if(t.length<1){const n={params:{}};null===r?r=[n]:r.push(n),o++}}else{const n={params:{type:"string"}};null===r?r=[n]:r.push(n),o++}h=n===o,s=s||h}if(s)o=e,null!==r&&(e?r.length=e:r=null);else{const n={params:{}};null===r?r=[n]:r.push(n),o++}f=n===o,i=i||f}if(!i){const t={params:{}};return null===r?r=[t]:r.push(t),o++,n.errors=r,!1}return o=u,null!==r&&(u?r.length=u:r=null),n.errors=r,0===o}function t(e,{instancePath:s="",parentData:l,parentDataProperty:a,rootData:r=e}={}){let o=null,u=0;const i=u;let p=!1;const c=u;if(u===c)if("string"==typeof e){if(e.length<1){const n={params:{}};null===o?o=[n]:o.push(n),u++}}else{const n={params:{type:"string"}};null===o?o=[n]:o.push(n),u++}var f=c===u;if(p=p||f,!p){const t=u;if(u===t)if(e&&"object"==typeof e&&!Array.isArray(e)){let t;if(void 0===e.banner&&(t="banner")){const n={params:{missingProperty:t}};null===o?o=[n]:o.push(n),u++}else{const t=u;for(const n in e)if("banner"!==n&&"entryOnly"!==n&&"exclude"!==n&&"footer"!==n&&"include"!==n&&"raw"!==n&&"stage"!==n&&"test"!==n){const t={params:{additionalProperty:n}};null===o?o=[t]:o.push(t),u++;break}if(t===u){if(void 0!==e.banner){let n=e.banner;const t=u,s=u;let l=!1;const a=u;if("string"!=typeof n){const n={params:{type:"string"}};null===o?o=[n]:o.push(n),u++}var h=a===u;if(l=l||h,!l){const t=u;if(!(n instanceof Function)){const n={params:{}};null===o?o=[n]:o.push(n),u++}h=t===u,l=l||h}if(l)u=s,null!==o&&(s?o.length=s:o=null);else{const n={params:{}};null===o?o=[n]:o.push(n),u++}var m=t===u}else m=!0;if(m){if(void 0!==e.entryOnly){const n=u;if("boolean"!=typeof e.entryOnly){const n={params:{type:"boolean"}};null===o?o=[n]:o.push(n),u++}m=n===u}else m=!0;if(m){if(void 0!==e.exclude){const t=u,l=u;let a=!1,i=null;const p=u;if(n(e.exclude,{instancePath:s+"/exclude",parentData:e,parentDataProperty:"exclude",rootData:r})||(o=null===o?n.errors:o.concat(n.errors),u=o.length),p===u&&(a=!0,i=0),a)u=l,null!==o&&(l?o.length=l:o=null);else{const n={params:{passingSchemas:i}};null===o?o=[n]:o.push(n),u++}m=t===u}else m=!0;if(m){if(void 0!==e.footer){const n=u;if("boolean"!=typeof e.footer){const n={params:{type:"boolean"}};null===o?o=[n]:o.push(n),u++}m=n===u}else m=!0;if(m){if(void 0!==e.include){const t=u,l=u;let a=!1,i=null;const p=u;if(n(e.include,{instancePath:s+"/include",parentData:e,parentDataProperty:"include",rootData:r})||(o=null===o?n.errors:o.concat(n.errors),u=o.length),p===u&&(a=!0,i=0),a)u=l,null!==o&&(l?o.length=l:o=null);else{const n={params:{passingSchemas:i}};null===o?o=[n]:o.push(n),u++}m=t===u}else m=!0;if(m){if(void 0!==e.raw){const n=u;if("boolean"!=typeof e.raw){const n={params:{type:"boolean"}};null===o?o=[n]:o.push(n),u++}m=n===u}else m=!0;if(m){if(void 0!==e.stage){const n=u;if("number"!=typeof e.stage){const n={params:{type:"number"}};null===o?o=[n]:o.push(n),u++}m=n===u}else m=!0;if(m)if(void 0!==e.test){const t=u,l=u;let a=!1,i=null;const p=u;if(n(e.test,{instancePath:s+"/test",parentData:e,parentDataProperty:"test",rootData:r})||(o=null===o?n.errors:o.concat(n.errors),u=o.length),p===u&&(a=!0,i=0),a)u=l,null!==o&&(l?o.length=l:o=null);else{const n={params:{passingSchemas:i}};null===o?o=[n]:o.push(n),u++}m=t===u}else m=!0}}}}}}}}}else{const n={params:{type:"object"}};null===o?o=[n]:o.push(n),u++}if(f=t===u,p=p||f,!p){const n=u;if(!(e instanceof Function)){const n={params:{}};null===o?o=[n]:o.push(n),u++}f=n===u,p=p||f}}if(!p){const n={params:{}};return null===o?o=[n]:o.push(n),u++,t.errors=o,!1}return u=i,null!==o&&(i?o.length=i:o=null),t.errors=o,0===u}module.exports=t,module.exports.default=t; | ||
| "use strict";function n(t,{instancePath:s="",parentData:e,parentDataProperty:l,rootData:a=t}={}){let o=null,r=0;const u=r;let i=!1;const p=r;if(r===p)if(Array.isArray(t)){const n=t.length;for(let s=0;s<n;s++){let n=t[s];const e=r,l=r;let a=!1,u=null;const i=r,p=r;let f=!1;const h=r;if(!(n instanceof RegExp)){const n={params:{}};null===o?o=[n]:o.push(n),r++}var c=h===r;if(f=f||c,!f){const t=r;if(r===t)if("string"==typeof n){if(n.length<1){const n={params:{}};null===o?o=[n]:o.push(n),r++}}else{const n={params:{type:"string"}};null===o?o=[n]:o.push(n),r++}if(c=t===r,f=f||c,!f){const t=r;if(!(n instanceof Function)){const n={params:{}};null===o?o=[n]:o.push(n),r++}c=t===r,f=f||c}}if(f)r=p,null!==o&&(p?o.length=p:o=null);else{const n={params:{}};null===o?o=[n]:o.push(n),r++}if(i===r&&(a=!0,u=0),a)r=l,null!==o&&(l?o.length=l:o=null);else{const n={params:{passingSchemas:u}};null===o?o=[n]:o.push(n),r++}if(e!==r)break}}else{const n={params:{type:"array"}};null===o?o=[n]:o.push(n),r++}var f=p===r;if(i=i||f,!i){const n=r,s=r;let e=!1;const l=r;if(!(t instanceof RegExp)){const n={params:{}};null===o?o=[n]:o.push(n),r++}var h=l===r;if(e=e||h,!e){const n=r;if(r===n)if("string"==typeof t){if(t.length<1){const n={params:{}};null===o?o=[n]:o.push(n),r++}}else{const n={params:{type:"string"}};null===o?o=[n]:o.push(n),r++}if(h=n===r,e=e||h,!e){const n=r;if(!(t instanceof Function)){const n={params:{}};null===o?o=[n]:o.push(n),r++}h=n===r,e=e||h}}if(e)r=s,null!==o&&(s?o.length=s:o=null);else{const n={params:{}};null===o?o=[n]:o.push(n),r++}f=n===r,i=i||f}if(!i){const t={params:{}};return null===o?o=[t]:o.push(t),r++,n.errors=o,!1}return r=u,null!==o&&(u?o.length=u:o=null),n.errors=o,0===r}function t(s,{instancePath:e="",parentData:l,parentDataProperty:a,rootData:o=s}={}){let r=null,u=0;const i=u;let p=!1;const c=u;if(u===c)if("string"==typeof s){if(s.length<1){const n={params:{}};null===r?r=[n]:r.push(n),u++}}else{const n={params:{type:"string"}};null===r?r=[n]:r.push(n),u++}var f=c===u;if(p=p||f,!p){const t=u;if(u===t)if(s&&"object"==typeof s&&!Array.isArray(s)){let t;if(void 0===s.banner&&(t="banner")){const n={params:{missingProperty:t}};null===r?r=[n]:r.push(n),u++}else{const t=u;for(const n in s)if("banner"!==n&&"entryOnly"!==n&&"exclude"!==n&&"footer"!==n&&"include"!==n&&"raw"!==n&&"stage"!==n&&"test"!==n){const t={params:{additionalProperty:n}};null===r?r=[t]:r.push(t),u++;break}if(t===u){if(void 0!==s.banner){let n=s.banner;const t=u,e=u;let l=!1;const a=u;if("string"!=typeof n){const n={params:{type:"string"}};null===r?r=[n]:r.push(n),u++}var h=a===u;if(l=l||h,!l){const t=u;if(!(n instanceof Function)){const n={params:{}};null===r?r=[n]:r.push(n),u++}h=t===u,l=l||h}if(l)u=e,null!==r&&(e?r.length=e:r=null);else{const n={params:{}};null===r?r=[n]:r.push(n),u++}var m=t===u}else m=!0;if(m){if(void 0!==s.entryOnly){const n=u;if("boolean"!=typeof s.entryOnly){const n={params:{type:"boolean"}};null===r?r=[n]:r.push(n),u++}m=n===u}else m=!0;if(m){if(void 0!==s.exclude){const t=u,l=u;let a=!1,i=null;const p=u;if(n(s.exclude,{instancePath:e+"/exclude",parentData:s,parentDataProperty:"exclude",rootData:o})||(r=null===r?n.errors:r.concat(n.errors),u=r.length),p===u&&(a=!0,i=0),a)u=l,null!==r&&(l?r.length=l:r=null);else{const n={params:{passingSchemas:i}};null===r?r=[n]:r.push(n),u++}m=t===u}else m=!0;if(m){if(void 0!==s.footer){const n=u;if("boolean"!=typeof s.footer){const n={params:{type:"boolean"}};null===r?r=[n]:r.push(n),u++}m=n===u}else m=!0;if(m){if(void 0!==s.include){const t=u,l=u;let a=!1,i=null;const p=u;if(n(s.include,{instancePath:e+"/include",parentData:s,parentDataProperty:"include",rootData:o})||(r=null===r?n.errors:r.concat(n.errors),u=r.length),p===u&&(a=!0,i=0),a)u=l,null!==r&&(l?r.length=l:r=null);else{const n={params:{passingSchemas:i}};null===r?r=[n]:r.push(n),u++}m=t===u}else m=!0;if(m){if(void 0!==s.raw){const n=u;if("boolean"!=typeof s.raw){const n={params:{type:"boolean"}};null===r?r=[n]:r.push(n),u++}m=n===u}else m=!0;if(m){if(void 0!==s.stage){const n=u;if("number"!=typeof s.stage){const n={params:{type:"number"}};null===r?r=[n]:r.push(n),u++}m=n===u}else m=!0;if(m)if(void 0!==s.test){const t=u,l=u;let a=!1,i=null;const p=u;if(n(s.test,{instancePath:e+"/test",parentData:s,parentDataProperty:"test",rootData:o})||(r=null===r?n.errors:r.concat(n.errors),u=r.length),p===u&&(a=!0,i=0),a)u=l,null!==r&&(l?r.length=l:r=null);else{const n={params:{passingSchemas:i}};null===r?r=[n]:r.push(n),u++}m=t===u}else m=!0}}}}}}}}}else{const n={params:{type:"object"}};null===r?r=[n]:r.push(n),u++}if(f=t===u,p=p||f,!p){const n=u;if(!(s instanceof Function)){const n={params:{}};null===r?r=[n]:r.push(n),u++}f=n===u,p=p||f}}if(!p){const n={params:{}};return null===r?r=[n]:r.push(n),u++,t.errors=r,!1}return u=i,null!==r&&(i?r.length=i:r=null),t.errors=r,0===u}module.exports=t,module.exports.default=t; |
@@ -18,2 +18,6 @@ { | ||
| "minLength": 1 | ||
| }, | ||
| { | ||
| "instanceof": "Function", | ||
| "tsType": "((str: string) => boolean)" | ||
| } | ||
@@ -20,0 +24,0 @@ ] |
@@ -28,3 +28,3 @@ { | ||
| "instanceof": "Function", | ||
| "tsType": "((resource: string, context: string) => boolean)" | ||
| "tsType": "(import(\"../../lib/IgnorePlugin\").CheckResourceFn)" | ||
| } | ||
@@ -31,0 +31,0 @@ }, |
@@ -6,3 +6,3 @@ { | ||
| "instanceof": "Function", | ||
| "tsType": "((percentage: number, msg: string, ...args: string[]) => void)" | ||
| "tsType": "(import(\"../../lib/ProgressPlugin\").HandlerFn)" | ||
| }, | ||
@@ -9,0 +9,0 @@ "ProgressPluginOptions": { |
@@ -11,3 +11,3 @@ { | ||
| "instanceof": "Function", | ||
| "tsType": "((loaderContext: import('webpack').LoaderContext<EXPECTED_ANY>) => Promise<string> | string)" | ||
| "tsType": "(import('../../../lib/schemes/VirtualUrlPlugin').SourceFn)" | ||
| }, | ||
@@ -30,3 +30,3 @@ "type": { | ||
| "instanceof": "Function", | ||
| "tsType": "(() => string | undefined)" | ||
| "tsType": "(import('../../../lib/schemes/VirtualUrlPlugin').VersionFn)" | ||
| } | ||
@@ -46,3 +46,3 @@ ] | ||
| "instanceof": "Function", | ||
| "tsType": "((loaderContext: import('webpack').LoaderContext<EXPECTED_ANY>) => Promise<string> | string)" | ||
| "tsType": "(import('../../../lib/schemes/VirtualUrlPlugin').SourceFn)" | ||
| }, | ||
@@ -49,0 +49,0 @@ { |
@@ -6,2 +6,2 @@ /* | ||
| */ | ||
| const e=/^(?:[A-Za-z]:[\\/]|\\\\|\/)/;module.exports=l,module.exports.default=l;const n={definitions:{rule:{anyOf:[{instanceof:"RegExp"},{type:"string",minLength:1}]},rules:{anyOf:[{type:"array",items:{oneOf:[{$ref:"#/definitions/rule"}]}},{$ref:"#/definitions/rule"}]}},type:"object",additionalProperties:!1,properties:{append:{anyOf:[{enum:[!1,null]},{type:"string",minLength:1},{instanceof:"Function"}]},columns:{type:"boolean"},debugIds:{type:"boolean"},exclude:{oneOf:[{$ref:"#/definitions/rules"}]},fallbackModuleFilenameTemplate:{anyOf:[{type:"string",minLength:1},{instanceof:"Function"}]},fileContext:{type:"string"},filename:{anyOf:[{enum:[!1,null]},{type:"string",absolutePath:!1,minLength:1}]},include:{oneOf:[{$ref:"#/definitions/rules"}]},module:{type:"boolean"},moduleFilenameTemplate:{anyOf:[{type:"string",minLength:1},{instanceof:"Function"}]},namespace:{type:"string"},noSources:{type:"boolean"},publicPath:{type:"string"},sourceRoot:{type:"string"},test:{$ref:"#/definitions/rules"}}},t=Object.prototype.hasOwnProperty;function s(e,{instancePath:n="",parentData:t,parentDataProperty:l,rootData:r=e}={}){let o=null,a=0;const i=a;let u=!1;const p=a;if(a===p)if(Array.isArray(e)){const n=e.length;for(let t=0;t<n;t++){let n=e[t];const s=a,l=a;let r=!1,i=null;const u=a,p=a;let c=!1;const m=a;if(!(n instanceof RegExp)){const e={params:{}};null===o?o=[e]:o.push(e),a++}var f=m===a;if(c=c||f,!c){const e=a;if(a===e)if("string"==typeof n){if(n.length<1){const e={params:{}};null===o?o=[e]:o.push(e),a++}}else{const e={params:{type:"string"}};null===o?o=[e]:o.push(e),a++}f=e===a,c=c||f}if(c)a=p,null!==o&&(p?o.length=p:o=null);else{const e={params:{}};null===o?o=[e]:o.push(e),a++}if(u===a&&(r=!0,i=0),r)a=l,null!==o&&(l?o.length=l:o=null);else{const e={params:{passingSchemas:i}};null===o?o=[e]:o.push(e),a++}if(s!==a)break}}else{const e={params:{type:"array"}};null===o?o=[e]:o.push(e),a++}var c=p===a;if(u=u||c,!u){const n=a,t=a;let s=!1;const l=a;if(!(e instanceof RegExp)){const e={params:{}};null===o?o=[e]:o.push(e),a++}var m=l===a;if(s=s||m,!s){const n=a;if(a===n)if("string"==typeof e){if(e.length<1){const e={params:{}};null===o?o=[e]:o.push(e),a++}}else{const e={params:{type:"string"}};null===o?o=[e]:o.push(e),a++}m=n===a,s=s||m}if(s)a=t,null!==o&&(t?o.length=t:o=null);else{const e={params:{}};null===o?o=[e]:o.push(e),a++}c=n===a,u=u||c}if(!u){const e={params:{}};return null===o?o=[e]:o.push(e),a++,s.errors=o,!1}return a=i,null!==o&&(i?o.length=i:o=null),s.errors=o,0===a}function l(r,{instancePath:o="",parentData:a,parentDataProperty:i,rootData:u=r}={}){let p=null,f=0;if(0===f){if(!r||"object"!=typeof r||Array.isArray(r))return l.errors=[{params:{type:"object"}}],!1;{const a=f;for(const e in r)if(!t.call(n.properties,e))return l.errors=[{params:{additionalProperty:e}}],!1;if(a===f){if(void 0!==r.append){let e=r.append;const n=f,t=f;let s=!1;const o=f;if(!1!==e&&null!==e){const e={params:{}};null===p?p=[e]:p.push(e),f++}var c=o===f;if(s=s||c,!s){const n=f;if(f===n)if("string"==typeof e){if(e.length<1){const e={params:{}};null===p?p=[e]:p.push(e),f++}}else{const e={params:{type:"string"}};null===p?p=[e]:p.push(e),f++}if(c=n===f,s=s||c,!s){const n=f;if(!(e instanceof Function)){const e={params:{}};null===p?p=[e]:p.push(e),f++}c=n===f,s=s||c}}if(!s){const e={params:{}};return null===p?p=[e]:p.push(e),f++,l.errors=p,!1}f=t,null!==p&&(t?p.length=t:p=null);var m=n===f}else m=!0;if(m){if(void 0!==r.columns){const e=f;if("boolean"!=typeof r.columns)return l.errors=[{params:{type:"boolean"}}],!1;m=e===f}else m=!0;if(m){if(void 0!==r.debugIds){const e=f;if("boolean"!=typeof r.debugIds)return l.errors=[{params:{type:"boolean"}}],!1;m=e===f}else m=!0;if(m){if(void 0!==r.exclude){const e=f,n=f;let t=!1,a=null;const i=f;if(s(r.exclude,{instancePath:o+"/exclude",parentData:r,parentDataProperty:"exclude",rootData:u})||(p=null===p?s.errors:p.concat(s.errors),f=p.length),i===f&&(t=!0,a=0),!t){const e={params:{passingSchemas:a}};return null===p?p=[e]:p.push(e),f++,l.errors=p,!1}f=n,null!==p&&(n?p.length=n:p=null),m=e===f}else m=!0;if(m){if(void 0!==r.fallbackModuleFilenameTemplate){let e=r.fallbackModuleFilenameTemplate;const n=f,t=f;let s=!1;const o=f;if(f===o)if("string"==typeof e){if(e.length<1){const e={params:{}};null===p?p=[e]:p.push(e),f++}}else{const e={params:{type:"string"}};null===p?p=[e]:p.push(e),f++}var h=o===f;if(s=s||h,!s){const n=f;if(!(e instanceof Function)){const e={params:{}};null===p?p=[e]:p.push(e),f++}h=n===f,s=s||h}if(!s){const e={params:{}};return null===p?p=[e]:p.push(e),f++,l.errors=p,!1}f=t,null!==p&&(t?p.length=t:p=null),m=n===f}else m=!0;if(m){if(void 0!==r.fileContext){const e=f;if("string"!=typeof r.fileContext)return l.errors=[{params:{type:"string"}}],!1;m=e===f}else m=!0;if(m){if(void 0!==r.filename){let n=r.filename;const t=f,s=f;let o=!1;const a=f;if(!1!==n&&null!==n){const e={params:{}};null===p?p=[e]:p.push(e),f++}var y=a===f;if(o=o||y,!o){const t=f;if(f===t)if("string"==typeof n){if(n.includes("!")||!1!==e.test(n)){const e={params:{}};null===p?p=[e]:p.push(e),f++}else if(n.length<1){const e={params:{}};null===p?p=[e]:p.push(e),f++}}else{const e={params:{type:"string"}};null===p?p=[e]:p.push(e),f++}y=t===f,o=o||y}if(!o){const e={params:{}};return null===p?p=[e]:p.push(e),f++,l.errors=p,!1}f=s,null!==p&&(s?p.length=s:p=null),m=t===f}else m=!0;if(m){if(void 0!==r.include){const e=f,n=f;let t=!1,a=null;const i=f;if(s(r.include,{instancePath:o+"/include",parentData:r,parentDataProperty:"include",rootData:u})||(p=null===p?s.errors:p.concat(s.errors),f=p.length),i===f&&(t=!0,a=0),!t){const e={params:{passingSchemas:a}};return null===p?p=[e]:p.push(e),f++,l.errors=p,!1}f=n,null!==p&&(n?p.length=n:p=null),m=e===f}else m=!0;if(m){if(void 0!==r.module){const e=f;if("boolean"!=typeof r.module)return l.errors=[{params:{type:"boolean"}}],!1;m=e===f}else m=!0;if(m){if(void 0!==r.moduleFilenameTemplate){let e=r.moduleFilenameTemplate;const n=f,t=f;let s=!1;const o=f;if(f===o)if("string"==typeof e){if(e.length<1){const e={params:{}};null===p?p=[e]:p.push(e),f++}}else{const e={params:{type:"string"}};null===p?p=[e]:p.push(e),f++}var g=o===f;if(s=s||g,!s){const n=f;if(!(e instanceof Function)){const e={params:{}};null===p?p=[e]:p.push(e),f++}g=n===f,s=s||g}if(!s){const e={params:{}};return null===p?p=[e]:p.push(e),f++,l.errors=p,!1}f=t,null!==p&&(t?p.length=t:p=null),m=n===f}else m=!0;if(m){if(void 0!==r.namespace){const e=f;if("string"!=typeof r.namespace)return l.errors=[{params:{type:"string"}}],!1;m=e===f}else m=!0;if(m){if(void 0!==r.noSources){const e=f;if("boolean"!=typeof r.noSources)return l.errors=[{params:{type:"boolean"}}],!1;m=e===f}else m=!0;if(m){if(void 0!==r.publicPath){const e=f;if("string"!=typeof r.publicPath)return l.errors=[{params:{type:"string"}}],!1;m=e===f}else m=!0;if(m){if(void 0!==r.sourceRoot){const e=f;if("string"!=typeof r.sourceRoot)return l.errors=[{params:{type:"string"}}],!1;m=e===f}else m=!0;if(m)if(void 0!==r.test){const e=f;s(r.test,{instancePath:o+"/test",parentData:r,parentDataProperty:"test",rootData:u})||(p=null===p?s.errors:p.concat(s.errors),f=p.length),m=e===f}else m=!0}}}}}}}}}}}}}}}}return l.errors=p,0===f} | ||
| const e=/^(?:[A-Za-z]:[\\/]|\\\\|\/)/;module.exports=l,module.exports.default=l;const n={definitions:{rule:{anyOf:[{instanceof:"RegExp"},{type:"string",minLength:1},{instanceof:"Function"}]},rules:{anyOf:[{type:"array",items:{oneOf:[{$ref:"#/definitions/rule"}]}},{$ref:"#/definitions/rule"}]}},type:"object",additionalProperties:!1,properties:{append:{anyOf:[{enum:[!1,null]},{type:"string",minLength:1},{instanceof:"Function"}]},columns:{type:"boolean"},debugIds:{type:"boolean"},exclude:{oneOf:[{$ref:"#/definitions/rules"}]},fallbackModuleFilenameTemplate:{anyOf:[{type:"string",minLength:1},{instanceof:"Function"}]},fileContext:{type:"string"},filename:{anyOf:[{enum:[!1,null]},{type:"string",absolutePath:!1,minLength:1}]},include:{oneOf:[{$ref:"#/definitions/rules"}]},module:{type:"boolean"},moduleFilenameTemplate:{anyOf:[{type:"string",minLength:1},{instanceof:"Function"}]},namespace:{type:"string"},noSources:{type:"boolean"},publicPath:{type:"string"},sourceRoot:{type:"string"},test:{$ref:"#/definitions/rules"}}},t=Object.prototype.hasOwnProperty;function s(e,{instancePath:n="",parentData:t,parentDataProperty:l,rootData:r=e}={}){let o=null,a=0;const i=a;let u=!1;const p=a;if(a===p)if(Array.isArray(e)){const n=e.length;for(let t=0;t<n;t++){let n=e[t];const s=a,l=a;let r=!1,i=null;const u=a,p=a;let c=!1;const m=a;if(!(n instanceof RegExp)){const e={params:{}};null===o?o=[e]:o.push(e),a++}var f=m===a;if(c=c||f,!c){const e=a;if(a===e)if("string"==typeof n){if(n.length<1){const e={params:{}};null===o?o=[e]:o.push(e),a++}}else{const e={params:{type:"string"}};null===o?o=[e]:o.push(e),a++}if(f=e===a,c=c||f,!c){const e=a;if(!(n instanceof Function)){const e={params:{}};null===o?o=[e]:o.push(e),a++}f=e===a,c=c||f}}if(c)a=p,null!==o&&(p?o.length=p:o=null);else{const e={params:{}};null===o?o=[e]:o.push(e),a++}if(u===a&&(r=!0,i=0),r)a=l,null!==o&&(l?o.length=l:o=null);else{const e={params:{passingSchemas:i}};null===o?o=[e]:o.push(e),a++}if(s!==a)break}}else{const e={params:{type:"array"}};null===o?o=[e]:o.push(e),a++}var c=p===a;if(u=u||c,!u){const n=a,t=a;let s=!1;const l=a;if(!(e instanceof RegExp)){const e={params:{}};null===o?o=[e]:o.push(e),a++}var m=l===a;if(s=s||m,!s){const n=a;if(a===n)if("string"==typeof e){if(e.length<1){const e={params:{}};null===o?o=[e]:o.push(e),a++}}else{const e={params:{type:"string"}};null===o?o=[e]:o.push(e),a++}if(m=n===a,s=s||m,!s){const n=a;if(!(e instanceof Function)){const e={params:{}};null===o?o=[e]:o.push(e),a++}m=n===a,s=s||m}}if(s)a=t,null!==o&&(t?o.length=t:o=null);else{const e={params:{}};null===o?o=[e]:o.push(e),a++}c=n===a,u=u||c}if(!u){const e={params:{}};return null===o?o=[e]:o.push(e),a++,s.errors=o,!1}return a=i,null!==o&&(i?o.length=i:o=null),s.errors=o,0===a}function l(r,{instancePath:o="",parentData:a,parentDataProperty:i,rootData:u=r}={}){let p=null,f=0;if(0===f){if(!r||"object"!=typeof r||Array.isArray(r))return l.errors=[{params:{type:"object"}}],!1;{const a=f;for(const e in r)if(!t.call(n.properties,e))return l.errors=[{params:{additionalProperty:e}}],!1;if(a===f){if(void 0!==r.append){let e=r.append;const n=f,t=f;let s=!1;const o=f;if(!1!==e&&null!==e){const e={params:{}};null===p?p=[e]:p.push(e),f++}var c=o===f;if(s=s||c,!s){const n=f;if(f===n)if("string"==typeof e){if(e.length<1){const e={params:{}};null===p?p=[e]:p.push(e),f++}}else{const e={params:{type:"string"}};null===p?p=[e]:p.push(e),f++}if(c=n===f,s=s||c,!s){const n=f;if(!(e instanceof Function)){const e={params:{}};null===p?p=[e]:p.push(e),f++}c=n===f,s=s||c}}if(!s){const e={params:{}};return null===p?p=[e]:p.push(e),f++,l.errors=p,!1}f=t,null!==p&&(t?p.length=t:p=null);var m=n===f}else m=!0;if(m){if(void 0!==r.columns){const e=f;if("boolean"!=typeof r.columns)return l.errors=[{params:{type:"boolean"}}],!1;m=e===f}else m=!0;if(m){if(void 0!==r.debugIds){const e=f;if("boolean"!=typeof r.debugIds)return l.errors=[{params:{type:"boolean"}}],!1;m=e===f}else m=!0;if(m){if(void 0!==r.exclude){const e=f,n=f;let t=!1,a=null;const i=f;if(s(r.exclude,{instancePath:o+"/exclude",parentData:r,parentDataProperty:"exclude",rootData:u})||(p=null===p?s.errors:p.concat(s.errors),f=p.length),i===f&&(t=!0,a=0),!t){const e={params:{passingSchemas:a}};return null===p?p=[e]:p.push(e),f++,l.errors=p,!1}f=n,null!==p&&(n?p.length=n:p=null),m=e===f}else m=!0;if(m){if(void 0!==r.fallbackModuleFilenameTemplate){let e=r.fallbackModuleFilenameTemplate;const n=f,t=f;let s=!1;const o=f;if(f===o)if("string"==typeof e){if(e.length<1){const e={params:{}};null===p?p=[e]:p.push(e),f++}}else{const e={params:{type:"string"}};null===p?p=[e]:p.push(e),f++}var h=o===f;if(s=s||h,!s){const n=f;if(!(e instanceof Function)){const e={params:{}};null===p?p=[e]:p.push(e),f++}h=n===f,s=s||h}if(!s){const e={params:{}};return null===p?p=[e]:p.push(e),f++,l.errors=p,!1}f=t,null!==p&&(t?p.length=t:p=null),m=n===f}else m=!0;if(m){if(void 0!==r.fileContext){const e=f;if("string"!=typeof r.fileContext)return l.errors=[{params:{type:"string"}}],!1;m=e===f}else m=!0;if(m){if(void 0!==r.filename){let n=r.filename;const t=f,s=f;let o=!1;const a=f;if(!1!==n&&null!==n){const e={params:{}};null===p?p=[e]:p.push(e),f++}var y=a===f;if(o=o||y,!o){const t=f;if(f===t)if("string"==typeof n){if(n.includes("!")||!1!==e.test(n)){const e={params:{}};null===p?p=[e]:p.push(e),f++}else if(n.length<1){const e={params:{}};null===p?p=[e]:p.push(e),f++}}else{const e={params:{type:"string"}};null===p?p=[e]:p.push(e),f++}y=t===f,o=o||y}if(!o){const e={params:{}};return null===p?p=[e]:p.push(e),f++,l.errors=p,!1}f=s,null!==p&&(s?p.length=s:p=null),m=t===f}else m=!0;if(m){if(void 0!==r.include){const e=f,n=f;let t=!1,a=null;const i=f;if(s(r.include,{instancePath:o+"/include",parentData:r,parentDataProperty:"include",rootData:u})||(p=null===p?s.errors:p.concat(s.errors),f=p.length),i===f&&(t=!0,a=0),!t){const e={params:{passingSchemas:a}};return null===p?p=[e]:p.push(e),f++,l.errors=p,!1}f=n,null!==p&&(n?p.length=n:p=null),m=e===f}else m=!0;if(m){if(void 0!==r.module){const e=f;if("boolean"!=typeof r.module)return l.errors=[{params:{type:"boolean"}}],!1;m=e===f}else m=!0;if(m){if(void 0!==r.moduleFilenameTemplate){let e=r.moduleFilenameTemplate;const n=f,t=f;let s=!1;const o=f;if(f===o)if("string"==typeof e){if(e.length<1){const e={params:{}};null===p?p=[e]:p.push(e),f++}}else{const e={params:{type:"string"}};null===p?p=[e]:p.push(e),f++}var g=o===f;if(s=s||g,!s){const n=f;if(!(e instanceof Function)){const e={params:{}};null===p?p=[e]:p.push(e),f++}g=n===f,s=s||g}if(!s){const e={params:{}};return null===p?p=[e]:p.push(e),f++,l.errors=p,!1}f=t,null!==p&&(t?p.length=t:p=null),m=n===f}else m=!0;if(m){if(void 0!==r.namespace){const e=f;if("string"!=typeof r.namespace)return l.errors=[{params:{type:"string"}}],!1;m=e===f}else m=!0;if(m){if(void 0!==r.noSources){const e=f;if("boolean"!=typeof r.noSources)return l.errors=[{params:{type:"boolean"}}],!1;m=e===f}else m=!0;if(m){if(void 0!==r.publicPath){const e=f;if("string"!=typeof r.publicPath)return l.errors=[{params:{type:"string"}}],!1;m=e===f}else m=!0;if(m){if(void 0!==r.sourceRoot){const e=f;if("string"!=typeof r.sourceRoot)return l.errors=[{params:{type:"string"}}],!1;m=e===f}else m=!0;if(m)if(void 0!==r.test){const e=f;s(r.test,{instancePath:o+"/test",parentData:r,parentDataProperty:"test",rootData:u})||(p=null===p?s.errors:p.concat(s.errors),f=p.length),m=e===f}else m=!0}}}}}}}}}}}}}}}}return l.errors=p,0===f} |
@@ -13,2 +13,6 @@ { | ||
| "minLength": 1 | ||
| }, | ||
| { | ||
| "instanceof": "Function", | ||
| "tsType": "((str: string) => boolean)" | ||
| } | ||
@@ -54,3 +58,3 @@ ] | ||
| "instanceof": "Function", | ||
| "tsType": "((pathData: import(\"../../lib/Compilation\").PathData, assetInfo?: import(\"../../lib/Compilation\").AssetInfo) => string)" | ||
| "tsType": "(import(\"../../lib/TemplatedPathPlugin\").TemplatePathFn)" | ||
| } | ||
@@ -57,0 +61,0 @@ ] |
| # Reporting Security Issues | ||
| If you discover a security issue in webpack, please report it by sending an | ||
| email to [webpack@opencollective.com](mailto:webpack@opencollective.com). | ||
| This will allow us to assess the risk, and make a fix available before we add a | ||
| bug report to the GitHub repository. | ||
| Thanks for helping make webpack safe for everyone. |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 5 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 3 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 5 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 3 instances in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 5 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
5525709
1.05%706
0.71%158271
1.19%675
-0.74%224
1.36%56
1.82%Updated
Updated
Updated