Enhance refactor commands with controller-aware Route() updates and fix code quality violations
Add semantic token highlighting for 'that' variable and comment file references in VS Code extension Add Phone_Text_Input and Currency_Input components with formatting utilities Implement client widgets, form standardization, and soft delete functionality Add modal scroll lock and update documentation Implement comprehensive modal system with form integration and validation Fix modal component instantiation using jQuery plugin API Implement modal system with responsive sizing, queuing, and validation support Implement form submission with validation, error handling, and loading states Implement country/state selectors with dynamic data loading and Bootstrap styling Revert Rsx::Route() highlighting in Blade/PHP files Target specific PHP scopes for Rsx::Route() highlighting in Blade Expand injection selector for Rsx::Route() highlighting Add custom syntax highlighting for Rsx::Route() and Rsx.Route() calls Update jqhtml packages to v2.2.165 Add bundle path validation for common mistakes (development mode only) Create Ajax_Select_Input widget and Rsx_Reference_Data controller Create Country_Select_Input widget with default country support Initialize Tom Select on Select_Input widgets Add Tom Select bundle for enhanced select dropdowns Implement ISO 3166 geographic data system for country/region selection Implement widget-based form system with disabled state support 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2
node_modules/webpack/lib/optimize/AggressiveSplittingPlugin.js
generated
vendored
2
node_modules/webpack/lib/optimize/AggressiveSplittingPlugin.js
generated
vendored
@@ -16,6 +16,7 @@ const identifierUtils = require("../util/identifier");
|
||||
|
||||
/** @typedef {import("../../declarations/plugins/optimize/AggressiveSplittingPlugin").AggressiveSplittingPluginOptions} AggressiveSplittingPluginOptions */
|
||||
/** @typedef {import("../Chunk")} Chunk */
|
||||
/** @typedef {import("../Chunk").ChunkId} ChunkId */
|
||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
/** @typedef {import("../Module")} Module */
|
||||
@@ -127,6 +128,7 @@ class AggressiveSplittingPlugin {
|
||||
}
|
||||
|
||||
// Check used chunk ids
|
||||
/** @typedef {Set<ChunkId>} */
|
||||
const usedIds = new Set();
|
||||
for (const chunk of chunks) {
|
||||
usedIds.add(chunk.id);
|
||||
|
||||
242
node_modules/webpack/lib/optimize/ConcatenatedModule.js
generated
vendored
242
node_modules/webpack/lib/optimize/ConcatenatedModule.js
generated
vendored
@@ -23,6 +23,7 @@ const Template = require("../Template");
|
||||
const { DEFAULTS } = require("../config/defaults");
|
||||
const HarmonyImportDependency = require("../dependencies/HarmonyImportDependency");
|
||||
const HarmonyImportSideEffectDependency = require("../dependencies/HarmonyImportSideEffectDependency");
|
||||
const HarmonyImportSpecifierDependency = require("../dependencies/HarmonyImportSpecifierDependency");
|
||||
const JavascriptParser = require("../javascript/JavascriptParser");
|
||||
const {
|
||||
getMakeDeferredNamespaceModeFromExportsType,
|
||||
@@ -57,33 +58,31 @@ const {
|
||||
/** @typedef {import("eslint-scope").Scope} Scope */
|
||||
/** @typedef {import("eslint-scope").Variable} Variable */
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").WebpackOptionsNormalized} WebpackOptions */
|
||||
/** @typedef {import("../config/defaults").WebpackOptionsNormalizedWithDefaults} WebpackOptions */
|
||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("../CodeGenerationResults")} CodeGenerationResults */
|
||||
/** @typedef {import("../Compilation")} Compilation */
|
||||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../Dependency").UpdateHashContext} UpdateHashContext */
|
||||
/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
|
||||
/** @typedef {import("../DependencyTemplates")} DependencyTemplates */
|
||||
/** @typedef {import("../ExportsInfo").ExportInfo} ExportInfo */
|
||||
/** @typedef {import("../ExternalModule")} ExternalModule */
|
||||
/** @typedef {import("../Module").BuildCallback} BuildCallback */
|
||||
/** @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").LibIdentOptions} LibIdentOptions */
|
||||
/** @typedef {import("../Module").LibIdent} LibIdent */
|
||||
/** @typedef {import("../Module").NameForCondition} NameForCondition */
|
||||
/** @typedef {import("../Module").ReadOnlyRuntimeRequirements} ReadOnlyRuntimeRequirements */
|
||||
/** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
|
||||
/** @typedef {import("../Module").SourceTypes} SourceTypes */
|
||||
/** @typedef {import("../ModuleGraph")} ModuleGraph */
|
||||
/** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
|
||||
/** @typedef {import("../ModuleGraphConnection").ConnectionState} ConnectionState */
|
||||
/** @typedef {import("../ModuleParseError")} ModuleParseError */
|
||||
/** @typedef {import("../RequestShortener")} RequestShortener */
|
||||
/** @typedef {import("../ResolverFactory").ResolverWithOptions} ResolverWithOptions */
|
||||
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
|
||||
/** @typedef {import("../WebpackError")} WebpackError */
|
||||
/** @typedef {import("../javascript/JavascriptModulesPlugin").ChunkRenderContext} ChunkRenderContext */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Program} Program */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
@@ -91,7 +90,6 @@ const {
|
||||
/** @typedef {import("../util/Hash")} Hash */
|
||||
/** @typedef {typeof import("../util/Hash")} HashConstructor */
|
||||
/** @typedef {import("../util/concatenate").ScopeInfo} ScopeInfo */
|
||||
/** @typedef {import("../util/concatenate").UsedNames} UsedNames */
|
||||
/** @typedef {import("../util/fs").InputFileSystem} InputFileSystem */
|
||||
/** @typedef {import("../util/identifier").AssociatedObjectForCache} AssociatedObjectForCache */
|
||||
/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
||||
@@ -107,27 +105,23 @@ const {
|
||||
|
||||
// fix eslint-scope to support class properties correctly
|
||||
// cspell:word Referencer
|
||||
const ReferencerClass = /** @type {EXPECTED_ANY} */ (Referencer);
|
||||
const ReferencerClass = Referencer;
|
||||
if (!ReferencerClass.prototype.PropertyDefinition) {
|
||||
ReferencerClass.prototype.PropertyDefinition =
|
||||
ReferencerClass.prototype.Property;
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {object} ReexportInfo
|
||||
* @property {Module} module
|
||||
* @property {string[]} export
|
||||
*/
|
||||
|
||||
/** @typedef {RawBinding | SymbolBinding} Binding */
|
||||
|
||||
/** @typedef {string[]} ExportName */
|
||||
|
||||
/**
|
||||
* @typedef {object} RawBinding
|
||||
* @property {ModuleInfo} info
|
||||
* @property {string} rawName
|
||||
* @property {string=} comment
|
||||
* @property {string[]} ids
|
||||
* @property {string[]} exportName
|
||||
* @property {ExportName} ids
|
||||
* @property {ExportName} exportName
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -135,8 +129,8 @@ if (!ReferencerClass.prototype.PropertyDefinition) {
|
||||
* @property {ConcatenatedModuleInfo} info
|
||||
* @property {string} name
|
||||
* @property {string=} comment
|
||||
* @property {string[]} ids
|
||||
* @property {string[]} exportName
|
||||
* @property {ExportName} ids
|
||||
* @property {ExportName} exportName
|
||||
*/
|
||||
|
||||
/** @typedef {ConcatenatedModuleInfo | ExternalModuleInfo } ModuleInfo */
|
||||
@@ -238,6 +232,8 @@ const moveDeferToLast = (
|
||||
return -1;
|
||||
};
|
||||
|
||||
const INITIAL_USED_NAMES = new Set(RESERVED_NAMES);
|
||||
|
||||
/**
|
||||
* @param {Iterable<string>} iterable iterable object
|
||||
* @returns {string} joined iterable object
|
||||
@@ -265,15 +261,19 @@ const joinIterableWithComma = (iterable) => {
|
||||
* @property {RuntimeSpec | boolean} runtimeCondition
|
||||
*/
|
||||
|
||||
/** @typedef {Set<ConcatenatedModuleInfo>} NeededNamespaceObjects */
|
||||
|
||||
/** @typedef {Map<Module, ModuleInfo>} ModuleToInfoMap */
|
||||
|
||||
/**
|
||||
* @param {ModuleGraph} moduleGraph the module graph
|
||||
* @param {ModuleInfo} info module info
|
||||
* @param {string[]} exportName exportName
|
||||
* @param {Map<Module, ModuleInfo>} moduleToInfoMap moduleToInfoMap
|
||||
* @param {ExportName} exportName exportName
|
||||
* @param {ModuleToInfoMap} moduleToInfoMap moduleToInfoMap
|
||||
* @param {RuntimeSpec} runtime for which runtime
|
||||
* @param {RequestShortener} requestShortener the request shortener
|
||||
* @param {RuntimeTemplate} runtimeTemplate the runtime template
|
||||
* @param {Set<ConcatenatedModuleInfo>} neededNamespaceObjects modules for which a namespace object should be generated
|
||||
* @param {NeededNamespaceObjects} neededNamespaceObjects modules for which a namespace object should be generated
|
||||
* @param {boolean} asCall asCall
|
||||
* @param {boolean} depDeferred the dependency is deferred
|
||||
* @param {boolean | undefined} strictHarmonyModule strictHarmonyModule
|
||||
@@ -477,7 +477,7 @@ const getFinalBinding = (
|
||||
}
|
||||
const directExport = info.exportMap && info.exportMap.get(exportId);
|
||||
if (directExport) {
|
||||
const usedName = /** @type {string[]} */ (
|
||||
const usedName = /** @type {ExportName} */ (
|
||||
exportsInfo.getUsedName(exportName, runtime)
|
||||
);
|
||||
if (!usedName) {
|
||||
@@ -540,7 +540,7 @@ const getFinalBinding = (
|
||||
);
|
||||
}
|
||||
if (info.namespaceExportSymbol) {
|
||||
const usedName = /** @type {string[]} */ (
|
||||
const usedName = /** @type {ExportName} */ (
|
||||
exportsInfo.getUsedName(exportName, runtime)
|
||||
);
|
||||
return {
|
||||
@@ -558,7 +558,7 @@ const getFinalBinding = (
|
||||
}
|
||||
|
||||
case "external": {
|
||||
const used = /** @type {string[]} */ (
|
||||
const used = /** @type {ExportName} */ (
|
||||
exportsInfo.getUsedName(exportName, runtime)
|
||||
);
|
||||
if (!used) {
|
||||
@@ -588,12 +588,12 @@ const getFinalBinding = (
|
||||
/**
|
||||
* @param {ModuleGraph} moduleGraph the module graph
|
||||
* @param {ModuleInfo} info module info
|
||||
* @param {string[]} exportName exportName
|
||||
* @param {Map<Module, ModuleInfo>} moduleToInfoMap moduleToInfoMap
|
||||
* @param {ExportName} exportName exportName
|
||||
* @param {ModuleToInfoMap} moduleToInfoMap moduleToInfoMap
|
||||
* @param {RuntimeSpec} runtime for which runtime
|
||||
* @param {RequestShortener} requestShortener the request shortener
|
||||
* @param {RuntimeTemplate} runtimeTemplate the runtime template
|
||||
* @param {Set<ConcatenatedModuleInfo>} neededNamespaceObjects modules for which a namespace object should be generated
|
||||
* @param {NeededNamespaceObjects} neededNamespaceObjects modules for which a namespace object should be generated
|
||||
* @param {boolean} asCall asCall
|
||||
* @param {boolean} depDeferred the dependency is deferred
|
||||
* @param {boolean | undefined} callContext callContext
|
||||
@@ -672,6 +672,8 @@ const getFinalName = (
|
||||
* @property {SyncBailHook<[Partial<ConcatenatedModuleInfo>, ConcatenatedModuleInfo], boolean | void>} concatenatedModuleInfo
|
||||
*/
|
||||
|
||||
/** @typedef {BuildInfo["topLevelDeclarations"]} TopLevelDeclarations */
|
||||
|
||||
/** @type {WeakMap<Compilation, ConcatenateModuleHooks>} */
|
||||
const compilationHooksMap = new WeakMap();
|
||||
|
||||
@@ -747,7 +749,7 @@ class ConcatenatedModule extends Module {
|
||||
this._modules = modules;
|
||||
this._runtime = runtime;
|
||||
this.factoryMeta = rootModule && rootModule.factoryMeta;
|
||||
/** @type {Compilation | undefined} */
|
||||
/** @type {Compilation} */
|
||||
this.compilation = compilation;
|
||||
}
|
||||
|
||||
@@ -792,14 +794,14 @@ class ConcatenatedModule extends Module {
|
||||
|
||||
/**
|
||||
* @param {LibIdentOptions} options options
|
||||
* @returns {string | null} an identifier for library inclusion
|
||||
* @returns {LibIdent | null} an identifier for library inclusion
|
||||
*/
|
||||
libIdent(options) {
|
||||
return this.rootModule.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() {
|
||||
return this.rootModule.nameForCondition();
|
||||
@@ -831,13 +833,9 @@ class ConcatenatedModule extends Module {
|
||||
cacheable: true,
|
||||
moduleArgument,
|
||||
exportsArgument,
|
||||
/** @type {LazySet<string>} */
|
||||
fileDependencies: new LazySet(),
|
||||
/** @type {LazySet<string>} */
|
||||
contextDependencies: new LazySet(),
|
||||
/** @type {LazySet<string>} */
|
||||
missingDependencies: new LazySet(),
|
||||
/** @type {Set<string>} */
|
||||
topLevelDeclarations: new Set(),
|
||||
assets: undefined
|
||||
};
|
||||
@@ -884,7 +882,7 @@ class ConcatenatedModule extends Module {
|
||||
}
|
||||
}
|
||||
|
||||
const { assets, assetsInfo, topLevelDeclarations } =
|
||||
const { assets, assetsInfo, topLevelDeclarations, needCreateRequire } =
|
||||
/** @type {BuildInfo} */ (m.buildInfo);
|
||||
|
||||
const buildInfo = /** @type {BuildInfo} */ (this.buildInfo);
|
||||
@@ -901,6 +899,11 @@ class ConcatenatedModule extends Module {
|
||||
buildInfo.topLevelDeclarations = undefined;
|
||||
}
|
||||
|
||||
// populate needCreateRequire
|
||||
if (needCreateRequire) {
|
||||
this.buildInfo.needCreateRequire = true;
|
||||
}
|
||||
|
||||
// populate assets
|
||||
if (assets) {
|
||||
if (buildInfo.assets === undefined) {
|
||||
@@ -950,9 +953,7 @@ class ConcatenatedModule extends Module {
|
||||
const list = [];
|
||||
/** @type {Map<Module, RuntimeSpec | true>} */
|
||||
const existingEntries = new Map();
|
||||
const deferEnabled =
|
||||
/** @type {Compilation} */
|
||||
(this.compilation).options.experiments.deferImport;
|
||||
const deferEnabled = this.compilation.options.experiments.deferImport;
|
||||
|
||||
/**
|
||||
* @param {Module} module a module
|
||||
@@ -966,7 +967,7 @@ class ConcatenatedModule extends Module {
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @type {Array<{ connection: ModuleGraphConnection, sourceOrder: number, rangeStart: number, defer?: boolean }>}
|
||||
* @type {{ connection: ModuleGraphConnection, sourceOrder: number, rangeStart: number | undefined, defer?: boolean }[]}
|
||||
*/
|
||||
const references = connections
|
||||
.filter((connection) => {
|
||||
@@ -981,9 +982,9 @@ class ConcatenatedModule extends Module {
|
||||
);
|
||||
})
|
||||
.map((connection) => {
|
||||
const dep = /** @type {HarmonyImportDependency} */ (
|
||||
connection.dependency
|
||||
);
|
||||
const dep =
|
||||
/** @type {HarmonyImportDependency} */
|
||||
(connection.dependency);
|
||||
return {
|
||||
connection,
|
||||
sourceOrder: dep.sourceOrder,
|
||||
@@ -1154,10 +1155,10 @@ class ConcatenatedModule extends Module {
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
addCacheDependencies(
|
||||
fileDependencies,
|
||||
@@ -1188,7 +1189,7 @@ class ConcatenatedModule extends Module {
|
||||
codeGenerationResults
|
||||
}) {
|
||||
const { concatenatedModuleInfo } = ConcatenatedModule.getCompilationHooks(
|
||||
/** @type {Compilation} */ (this.compilation)
|
||||
this.compilation
|
||||
);
|
||||
|
||||
/** @type {RuntimeRequirements} */
|
||||
@@ -1203,11 +1204,21 @@ class ConcatenatedModule extends Module {
|
||||
);
|
||||
|
||||
// Set with modules that need a generated namespace object
|
||||
/** @type {Set<ConcatenatedModuleInfo>} */
|
||||
/** @type {NeededNamespaceObjects} */
|
||||
const neededNamespaceObjects = new Set();
|
||||
|
||||
// List of all used names to avoid conflicts
|
||||
const allUsedNames = new Set(RESERVED_NAMES);
|
||||
// Default disallowed names
|
||||
const allUsedNames = new Set(INITIAL_USED_NAMES);
|
||||
const chunks = chunkGraph.getModuleChunks(this);
|
||||
|
||||
// Add names already used in the current chunk scope
|
||||
for (const chunk of chunks) {
|
||||
if (ConcatenationScope.chunkUsedNames.has(chunk)) {
|
||||
for (const name of ConcatenationScope.chunkUsedNames.get(chunk) || []) {
|
||||
allUsedNames.add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Generate source code and analyse scopes
|
||||
// Prepare a ReplaceSource for the final source
|
||||
@@ -1226,8 +1237,25 @@ class ConcatenatedModule extends Module {
|
||||
);
|
||||
}
|
||||
|
||||
// Record the names registered by the current ConcatenatedModule into the chunk scope
|
||||
if (INITIAL_USED_NAMES.size !== allUsedNames.size) {
|
||||
for (const name of allUsedNames) {
|
||||
if (INITIAL_USED_NAMES.has(name)) continue;
|
||||
|
||||
for (const chunk of chunks) {
|
||||
if (!ConcatenationScope.chunkUsedNames.has(chunk)) {
|
||||
ConcatenationScope.chunkUsedNames.set(chunk, new Set([name]));
|
||||
} else {
|
||||
/** @type {Set<string>} */ (
|
||||
ConcatenationScope.chunkUsedNames.get(chunk)
|
||||
).add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Updated Top level declarations are created by renaming
|
||||
/** @type {Set<string>} */
|
||||
/** @type {TopLevelDeclarations} */
|
||||
const topLevelDeclarations = new Set();
|
||||
|
||||
// List of additional names in scope for module references
|
||||
@@ -1683,9 +1711,11 @@ class ConcatenatedModule extends Module {
|
||||
|
||||
// add harmony compatibility flag (must be first because of possible circular dependencies)
|
||||
let shouldAddHarmonyFlag = false;
|
||||
const rootExportsInfo = moduleGraph.getExportsInfo(this);
|
||||
if (
|
||||
moduleGraph.getExportsInfo(this).otherExportsInfo.getUsed(runtime) !==
|
||||
UsageState.Unused
|
||||
rootExportsInfo.otherExportsInfo.getUsed(runtime) !== UsageState.Unused ||
|
||||
rootExportsInfo.getReadOnlyExportInfo("__esModule").getUsed(runtime) !==
|
||||
UsageState.Unused
|
||||
) {
|
||||
shouldAddHarmonyFlag = true;
|
||||
}
|
||||
@@ -1702,10 +1732,7 @@ class ConcatenatedModule extends Module {
|
||||
}
|
||||
|
||||
const { onDemandExportsGeneration } =
|
||||
ConcatenatedModule.getCompilationHooks(
|
||||
/** @type {Compilation} */
|
||||
(this.compilation)
|
||||
);
|
||||
ConcatenatedModule.getCompilationHooks(this.compilation);
|
||||
|
||||
runtimeRequirements.add(RuntimeGlobals.exports);
|
||||
runtimeRequirements.add(RuntimeGlobals.definePropertyGetters);
|
||||
@@ -1806,13 +1833,30 @@ ${defineGetters}`
|
||||
if (!source) continue;
|
||||
result.add(source);
|
||||
}
|
||||
|
||||
if (info.type === "external" && info.deferred) {
|
||||
const moduleId = JSON.stringify(chunkGraph.getModuleId(info.module));
|
||||
const loader = getOptimizedDeferredModule(
|
||||
runtimeTemplate,
|
||||
info.module.getExportsType(
|
||||
moduleGraph,
|
||||
/** @type {BuildMeta} */
|
||||
(this.rootModule.buildMeta).strictHarmonyModule
|
||||
),
|
||||
moduleId,
|
||||
// an async module will opt-out of the concat module optimization.
|
||||
[]
|
||||
);
|
||||
runtimeRequirements.add(RuntimeGlobals.require);
|
||||
result.add(
|
||||
`\n// DEFERRED EXTERNAL MODULE: ${info.module.readableIdentifier(requestShortener)}\nvar ${info.deferredName} = ${loader};`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/** @type {InitFragment<ChunkRenderContext>[]} */
|
||||
const chunkInitFragments = [];
|
||||
const deferEnabled =
|
||||
/** @type {Compilation} */
|
||||
(this.compilation).options.experiments.deferImport;
|
||||
const deferEnabled = this.compilation.options.experiments.deferImport;
|
||||
|
||||
// evaluate modules in order
|
||||
for (const rawInfo of modulesWithInfo) {
|
||||
@@ -1830,11 +1874,20 @@ ${defineGetters}`
|
||||
if (deferEnabled) {
|
||||
for (const dep of info.module.dependencies) {
|
||||
if (
|
||||
!dep.defer &&
|
||||
dep instanceof HarmonyImportSideEffectDependency
|
||||
!(/** @type {HarmonyImportDependency} */ (dep).defer) &&
|
||||
(dep instanceof HarmonyImportSideEffectDependency ||
|
||||
dep instanceof HarmonyImportSpecifierDependency)
|
||||
) {
|
||||
const referredModule = moduleGraph.getModule(dep);
|
||||
if (!referredModule) continue;
|
||||
if (!referredModule) {
|
||||
if (dep instanceof HarmonyImportSideEffectDependency) {
|
||||
continue;
|
||||
} else {
|
||||
throw new Error(
|
||||
"Deferred module used, but no module in the graph."
|
||||
);
|
||||
}
|
||||
}
|
||||
if (moduleGraph.isDeferred(referredModule)) {
|
||||
const deferredModuleInfo = /** @type {ExternalModuleInfo} */ (
|
||||
modulesWithInfo.find(
|
||||
@@ -1863,41 +1916,30 @@ ${defineGetters}`
|
||||
break;
|
||||
}
|
||||
case "external": {
|
||||
result.add(
|
||||
`\n// EXTERNAL MODULE: ${info.module.readableIdentifier(
|
||||
requestShortener
|
||||
)}\n`
|
||||
);
|
||||
runtimeRequirements.add(RuntimeGlobals.require);
|
||||
const { runtimeCondition } =
|
||||
/** @type {ExternalModuleInfo | ReferenceToModuleInfo} */
|
||||
(rawInfo);
|
||||
const condition = runtimeTemplate.runtimeConditionExpression({
|
||||
chunkGraph,
|
||||
runtimeCondition,
|
||||
runtime,
|
||||
runtimeRequirements
|
||||
});
|
||||
if (condition !== "true") {
|
||||
isConditional = true;
|
||||
result.add(`if (${condition}) {\n`);
|
||||
}
|
||||
const moduleId = JSON.stringify(chunkGraph.getModuleId(info.module));
|
||||
if (info.deferred) {
|
||||
const loader = getOptimizedDeferredModule(
|
||||
runtimeTemplate,
|
||||
info.module.getExportsType(
|
||||
moduleGraph,
|
||||
/** @type {BuildMeta} */
|
||||
(this.rootModule.buildMeta).strictHarmonyModule
|
||||
),
|
||||
moduleId,
|
||||
// an async module will opt-out of the concat module optimization.
|
||||
[]
|
||||
// deferred case is handled in the "const info of modulesWithInfo" loop above
|
||||
if (!info.deferred) {
|
||||
result.add(
|
||||
`\n// EXTERNAL MODULE: ${info.module.readableIdentifier(
|
||||
requestShortener
|
||||
)}\n`
|
||||
);
|
||||
runtimeRequirements.add(RuntimeGlobals.require);
|
||||
const { runtimeCondition } =
|
||||
/** @type {ExternalModuleInfo | ReferenceToModuleInfo} */
|
||||
(rawInfo);
|
||||
const condition = runtimeTemplate.runtimeConditionExpression({
|
||||
chunkGraph,
|
||||
runtimeCondition,
|
||||
runtime,
|
||||
runtimeRequirements
|
||||
});
|
||||
if (condition !== "true") {
|
||||
isConditional = true;
|
||||
result.add(`if (${condition}) {\n`);
|
||||
}
|
||||
const moduleId = JSON.stringify(
|
||||
chunkGraph.getModuleId(info.module)
|
||||
);
|
||||
result.add(`var ${info.deferredName} = ${loader};`);
|
||||
name = info.deferredName;
|
||||
} else {
|
||||
result.add(`var ${info.name} = __webpack_require__(${moduleId});`);
|
||||
name = info.name;
|
||||
}
|
||||
@@ -1959,7 +2001,7 @@ ${defineGetters}`
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Map<Module, ModuleInfo>} modulesMap modulesMap
|
||||
* @param {ModuleToInfoMap} modulesMap modulesMap
|
||||
* @param {ModuleInfo} info info
|
||||
* @param {DependencyTemplates} dependencyTemplates dependencyTemplates
|
||||
* @param {RuntimeTemplate} runtimeTemplate runtimeTemplate
|
||||
@@ -2061,7 +2103,7 @@ ${defineGetters}`
|
||||
/**
|
||||
* @param {ModuleGraph} moduleGraph the module graph
|
||||
* @param {RuntimeSpec} runtime the runtime
|
||||
* @returns {[ModuleInfoOrReference[], Map<Module, ModuleInfo>]} module info items
|
||||
* @returns {[ModuleInfoOrReference[], ModuleToInfoMap]} module info items
|
||||
*/
|
||||
_getModulesWithInfo(moduleGraph, runtime) {
|
||||
const orderedConcatenationList = this._createConcatenationList(
|
||||
@@ -2070,7 +2112,7 @@ ${defineGetters}`
|
||||
runtime,
|
||||
moduleGraph
|
||||
);
|
||||
/** @type {Map<Module, ModuleInfo>} */
|
||||
/** @type {ModuleToInfoMap} */
|
||||
const map = new Map();
|
||||
const list = orderedConcatenationList.map((info, index) => {
|
||||
let item = map.get(info.module);
|
||||
|
||||
28
node_modules/webpack/lib/optimize/InnerGraph.js
generated
vendored
28
node_modules/webpack/lib/optimize/InnerGraph.js
generated
vendored
@@ -8,17 +8,17 @@
|
||||
const { UsageState } = require("../ExportsInfo");
|
||||
const JavascriptParser = require("../javascript/JavascriptParser");
|
||||
|
||||
/** @typedef {import("estree").Node} AnyNode */
|
||||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../Dependency").GetConditionFn} GetConditionFn */
|
||||
/** @typedef {import("../Module")} Module */
|
||||
/** @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 */
|
||||
|
||||
/**
|
||||
@@ -28,7 +28,7 @@ const JavascriptParser = require("../javascript/JavascriptParser");
|
||||
* @property {Map<TopLevelSymbol, Set<UsageCallback>>} usageCallbackMap
|
||||
*/
|
||||
|
||||
/** @typedef {false|StateObject} State */
|
||||
/** @typedef {false | StateObject} State */
|
||||
|
||||
class TopLevelSymbol {
|
||||
/**
|
||||
@@ -56,7 +56,7 @@ function getState(parserState) {
|
||||
/**
|
||||
* @param {ParserState} state parser state
|
||||
* @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}
|
||||
*/
|
||||
module.exports.addUsage = (state, symbol, usage) => {
|
||||
@@ -75,10 +75,12 @@ module.exports.addUsage = (state, symbol, usage) => {
|
||||
}
|
||||
};
|
||||
|
||||
/** @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}
|
||||
*/
|
||||
module.exports.addVariableUsage = (parser, name, usage) => {
|
||||
@@ -115,9 +117,11 @@ module.exports.enable = (parserState) => {
|
||||
});
|
||||
};
|
||||
|
||||
/** @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
|
||||
* @returns {null | false | GetConditionFn} function to determine if the connection is active
|
||||
*/
|
||||
@@ -146,7 +150,7 @@ module.exports.getDependencyUsedByExportsCondition = (
|
||||
|
||||
/**
|
||||
* @param {ParserState} state parser state
|
||||
* @returns {TopLevelSymbol|void} usage data
|
||||
* @returns {TopLevelSymbol | void} usage data
|
||||
*/
|
||||
module.exports.getTopLevelSymbol = (state) => {
|
||||
const innerGraphState = getState(state);
|
||||
@@ -168,17 +172,19 @@ module.exports.inferDependencyUsage = (state) => {
|
||||
}
|
||||
|
||||
const { innerGraph, usageCallbackMap } = innerGraphState;
|
||||
/** @type {Map<InnerGraphKey, InnerGraphValueSet | undefined>} */
|
||||
const processed = new Map();
|
||||
// flatten graph to terminal nodes (string, undefined or true)
|
||||
const nonTerminal = new Set(innerGraph.keys());
|
||||
while (nonTerminal.size > 0) {
|
||||
for (const key of nonTerminal) {
|
||||
/** @type {Set<string|TopLevelSymbol> | true} */
|
||||
/** @type {InnerGraphValue} */
|
||||
let newSet = new Set();
|
||||
let isTerminal = true;
|
||||
const value = innerGraph.get(key);
|
||||
let alreadyProcessed = processed.get(key);
|
||||
if (alreadyProcessed === undefined) {
|
||||
/** @type {InnerGraphValueSet} */
|
||||
alreadyProcessed = new Set();
|
||||
processed.set(key, alreadyProcessed);
|
||||
}
|
||||
@@ -254,7 +260,7 @@ module.exports.inferDependencyUsage = (state) => {
|
||||
|
||||
/**
|
||||
* @param {Dependency} dependency the dependency
|
||||
* @param {Set<string> | boolean} usedByExports usedByExports info
|
||||
* @param {UsedByExports | undefined} usedByExports usedByExports info
|
||||
* @param {ModuleGraph} moduleGraph moduleGraph
|
||||
* @param {RuntimeSpec} runtime runtime
|
||||
* @returns {boolean} false, when unused. Otherwise true
|
||||
|
||||
3
node_modules/webpack/lib/optimize/InnerGraphPlugin.js
generated
vendored
3
node_modules/webpack/lib/optimize/InnerGraphPlugin.js
generated
vendored
@@ -21,12 +21,9 @@ const InnerGraph = require("./InnerGraph");
|
||||
/** @typedef {import("estree").VariableDeclarator} VariableDeclarator */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
||||
/** @typedef {import("../dependencies/HarmonyImportSpecifierDependency")} HarmonyImportSpecifierDependency */
|
||||
/** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
|
||||
/** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
||||
/** @typedef {import("./InnerGraph").InnerGraph} InnerGraph */
|
||||
/** @typedef {import("./InnerGraph").TopLevelSymbol} TopLevelSymbol */
|
||||
|
||||
const { topLevelSymbolTag } = InnerGraph;
|
||||
|
||||
7
node_modules/webpack/lib/optimize/ModuleConcatenationPlugin.js
generated
vendored
7
node_modules/webpack/lib/optimize/ModuleConcatenationPlugin.js
generated
vendored
@@ -390,7 +390,6 @@ class ModuleConcatenationPlugin {
|
||||
}
|
||||
|
||||
// Create a new ConcatenatedModule
|
||||
ConcatenatedModule.getCompilationHooks(compilation);
|
||||
const newModule = ConcatenatedModule.create(
|
||||
rootModule,
|
||||
modules,
|
||||
@@ -402,7 +401,7 @@ class ModuleConcatenationPlugin {
|
||||
|
||||
const build = () => {
|
||||
newModule.build(
|
||||
compiler.options,
|
||||
compilation.options,
|
||||
compilation,
|
||||
/** @type {EXPECTED_ANY} */
|
||||
(null),
|
||||
@@ -667,7 +666,7 @@ class ModuleConcatenationPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
/** @type {Map<Module, readonly ModuleGraph.ModuleGraphConnection[]>} */
|
||||
/** @type {Map<Module, ReadonlyArray<ModuleGraph.ModuleGraphConnection>>} */
|
||||
const incomingConnectionsFromModules = new Map();
|
||||
for (const [originModule, connections] of incomingConnections) {
|
||||
if (originModule) {
|
||||
@@ -725,7 +724,7 @@ class ModuleConcatenationPlugin {
|
||||
return problem;
|
||||
}
|
||||
|
||||
/** @type {Map<Module, readonly ModuleGraph.ModuleGraphConnection[]>} */
|
||||
/** @type {Map<Module, ReadonlyArray<ModuleGraph.ModuleGraphConnection>>} */
|
||||
const nonHarmonyConnections = new Map();
|
||||
for (const [originModule, connections] of incomingConnectionsFromModules) {
|
||||
const selected = connections.filter(
|
||||
|
||||
8
node_modules/webpack/lib/optimize/RealContentHashPlugin.js
generated
vendored
8
node_modules/webpack/lib/optimize/RealContentHashPlugin.js
generated
vendored
@@ -12,6 +12,8 @@ const WebpackError = require("../WebpackError");
|
||||
const { compareSelect, compareStrings } = require("../util/comparators");
|
||||
const createHash = require("../util/createHash");
|
||||
|
||||
/** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").HashDigest} HashDigest */
|
||||
/** @typedef {import("webpack-sources").Source} Source */
|
||||
/** @typedef {import("../Cache").Etag} Etag */
|
||||
/** @typedef {import("../Compilation").AssetInfo} AssetInfo */
|
||||
@@ -109,8 +111,8 @@ const compilationHooksMap = new WeakMap();
|
||||
|
||||
/**
|
||||
* @typedef {object} RealContentHashPluginOptions
|
||||
* @property {string | Hash} hashFunction the hash function to use
|
||||
* @property {string=} hashDigest the hash digest to use
|
||||
* @property {HashFunction} hashFunction the hash function to use
|
||||
* @property {HashDigest} hashDigest the hash digest to use
|
||||
*/
|
||||
|
||||
const PLUGIN_NAME = "RealContentHashPlugin";
|
||||
@@ -432,7 +434,7 @@ ${referencingAssets
|
||||
hash.update(content);
|
||||
}
|
||||
const digest = hash.digest(this._hashDigest);
|
||||
newHash = /** @type {string} */ (digest.slice(0, oldHash.length));
|
||||
newHash = digest.slice(0, oldHash.length);
|
||||
}
|
||||
hashToNewHash.set(oldHash, newHash);
|
||||
}
|
||||
|
||||
1
node_modules/webpack/lib/optimize/RuntimeChunkPlugin.js
generated
vendored
1
node_modules/webpack/lib/optimize/RuntimeChunkPlugin.js
generated
vendored
@@ -7,7 +7,6 @@
|
||||
|
||||
/** @typedef {import("../Compilation").EntryData} EntryData */
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
/** @typedef {import("../Entrypoint")} Entrypoint */
|
||||
|
||||
const PLUGIN_NAME = "RuntimeChunkPlugin";
|
||||
|
||||
|
||||
13
node_modules/webpack/lib/optimize/SideEffectsFlagPlugin.js
generated
vendored
13
node_modules/webpack/lib/optimize/SideEffectsFlagPlugin.js
generated
vendored
@@ -21,7 +21,6 @@ const formatLocation = require("../formatLocation");
|
||||
/** @typedef {import("estree").ModuleDeclaration} ModuleDeclaration */
|
||||
/** @typedef {import("estree").Statement} Statement */
|
||||
/** @typedef {import("../Compiler")} Compiler */
|
||||
/** @typedef {import("../Dependency")} Dependency */
|
||||
/** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
|
||||
/** @typedef {import("../Module")} Module */
|
||||
/** @typedef {import("../Module").BuildMeta} BuildMeta */
|
||||
@@ -37,11 +36,7 @@ const formatLocation = require("../formatLocation");
|
||||
* @property {boolean} checked if the export is conditional
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} ReexportInfo
|
||||
* @property {Map<string, ExportInModule[]>} static
|
||||
* @property {Map<Module, Set<string>>} dynamic
|
||||
*/
|
||||
/** @typedef {string | boolean | string[] | undefined} SideEffectsFlagValue */
|
||||
|
||||
/** @typedef {Map<string, RegExp>} CacheItem */
|
||||
|
||||
@@ -105,9 +100,7 @@ class SideEffectsFlagPlugin {
|
||||
}
|
||||
const hasSideEffects = SideEffectsFlagPlugin.moduleHasSideEffects(
|
||||
resolveData.relativePath,
|
||||
/** @type {string | boolean | string[] | undefined} */ (
|
||||
sideEffects
|
||||
),
|
||||
/** @type {SideEffectsFlagValue} */ (sideEffects),
|
||||
/** @type {CacheItem} */ (cache)
|
||||
);
|
||||
module.factoryMeta.sideEffectFree = !hasSideEffects;
|
||||
@@ -397,7 +390,7 @@ class SideEffectsFlagPlugin {
|
||||
|
||||
/**
|
||||
* @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
|
||||
* @returns {boolean | undefined} true, when the module has side effects, undefined or false when not
|
||||
*/
|
||||
|
||||
86
node_modules/webpack/lib/optimize/SplitChunksPlugin.js
generated
vendored
86
node_modules/webpack/lib/optimize/SplitChunksPlugin.js
generated
vendored
@@ -21,12 +21,11 @@ const { makePathsRelative } = require("../util/identifier");
|
||||
const memoize = require("../util/memoize");
|
||||
const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
||||
|
||||
/** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksCacheGroup} OptimizationSplitChunksCacheGroup */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksGetCacheGroups} OptimizationSplitChunksGetCacheGroups */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksOptions} OptimizationSplitChunksOptions */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").OptimizationSplitChunksSizes} OptimizationSplitChunksSizes */
|
||||
/** @typedef {import("../../declarations/WebpackOptions").Output} OutputOptions */
|
||||
/** @typedef {import("../config/defaults").OutputNormalizedWithDefaults} OutputOptions */
|
||||
/** @typedef {import("../Chunk").ChunkName} ChunkName */
|
||||
/** @typedef {import("../ChunkGraph")} ChunkGraph */
|
||||
/** @typedef {import("../ChunkGroup")} ChunkGroup */
|
||||
@@ -37,10 +36,8 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
||||
/** @typedef {import("../util/deterministicGrouping").GroupedItems<Module>} DeterministicGroupingGroupedItemsForModule */
|
||||
/** @typedef {import("../util/deterministicGrouping").Options<Module>} DeterministicGroupingOptionsForModule */
|
||||
|
||||
/** @typedef {Record<string, number>} SplitChunksSizes */
|
||||
|
||||
/**
|
||||
* @callback ChunkFilterFunction
|
||||
* @callback ChunkFilterFn
|
||||
* @param {Chunk} chunk
|
||||
* @returns {boolean | undefined}
|
||||
*/
|
||||
@@ -52,12 +49,17 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
||||
* @returns {number}
|
||||
*/
|
||||
|
||||
/** @typedef {string} SourceType */
|
||||
/** @typedef {SourceType[]} SourceTypes */
|
||||
/** @typedef {SourceType[]} DefaultSizeTypes */
|
||||
/** @typedef {Record<SourceType, number>} SplitChunksSizes */
|
||||
|
||||
/**
|
||||
* @typedef {object} CacheGroupSource
|
||||
* @property {string} key
|
||||
* @property {number=} priority
|
||||
* @property {GetName=} getName
|
||||
* @property {ChunkFilterFunction=} chunksFilter
|
||||
* @property {GetNameFn=} getName
|
||||
* @property {ChunkFilterFn=} chunksFilter
|
||||
* @property {boolean=} enforce
|
||||
* @property {SplitChunksSizes} minSize
|
||||
* @property {SplitChunksSizes} minSizeReduction
|
||||
@@ -79,8 +81,8 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
||||
* @typedef {object} CacheGroup
|
||||
* @property {string} key
|
||||
* @property {number} priority
|
||||
* @property {GetName=} getName
|
||||
* @property {ChunkFilterFunction} chunksFilter
|
||||
* @property {GetNameFn=} getName
|
||||
* @property {ChunkFilterFn} chunksFilter
|
||||
* @property {SplitChunksSizes} minSize
|
||||
* @property {SplitChunksSizes} minSizeReduction
|
||||
* @property {SplitChunksSizes} minRemainingSize
|
||||
@@ -103,7 +105,7 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
||||
|
||||
/**
|
||||
* @typedef {object} FallbackCacheGroup
|
||||
* @property {ChunkFilterFunction} chunksFilter
|
||||
* @property {ChunkFilterFn} chunksFilter
|
||||
* @property {SplitChunksSizes} minSize
|
||||
* @property {SplitChunksSizes} maxAsyncSize
|
||||
* @property {SplitChunksSizes} maxInitialSize
|
||||
@@ -124,17 +126,17 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
||||
*/
|
||||
|
||||
/**
|
||||
* @callback GetName
|
||||
* @callback GetNameFn
|
||||
* @param {Module} module
|
||||
* @param {Chunk[]} chunks
|
||||
* @param {string} key
|
||||
* @returns {string=}
|
||||
* @returns {string | undefined}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {object} SplitChunksOptions
|
||||
* @property {ChunkFilterFunction} chunksFilter
|
||||
* @property {string[]} defaultSizeTypes
|
||||
* @property {ChunkFilterFn} chunksFilter
|
||||
* @property {DefaultSizeTypes} defaultSizeTypes
|
||||
* @property {SplitChunksSizes} minSize
|
||||
* @property {SplitChunksSizes} minSizeReduction
|
||||
* @property {SplitChunksSizes} minRemainingSize
|
||||
@@ -148,7 +150,7 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
||||
* @property {TemplatePath=} filename
|
||||
* @property {string} automaticNameDelimiter
|
||||
* @property {GetCacheGroups} getCacheGroups
|
||||
* @property {GetName} getName
|
||||
* @property {GetNameFn} getName
|
||||
* @property {boolean} usedExports
|
||||
* @property {FallbackCacheGroup} fallbackCacheGroup
|
||||
*/
|
||||
@@ -159,13 +161,13 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
|
||||
* @property {CacheGroup} cacheGroup
|
||||
* @property {number} cacheGroupIndex
|
||||
* @property {string=} name
|
||||
* @property {Record<string, number>} sizes
|
||||
* @property {Record<SourceType, number>} sizes
|
||||
* @property {Set<Chunk>} chunks
|
||||
* @property {Set<Chunk>} reusableChunks
|
||||
* @property {Set<bigint | Chunk>} chunksKeys
|
||||
*/
|
||||
|
||||
/** @type {GetName} */
|
||||
/** @type {GetNameFn} */
|
||||
const defaultGetName = () => undefined;
|
||||
|
||||
const deterministicGroupingForModules =
|
||||
@@ -184,7 +186,7 @@ const hashFilename = (name, outputOptions) => {
|
||||
const digest =
|
||||
/** @type {string} */
|
||||
(
|
||||
createHash(/** @type {HashFunction} */ (outputOptions.hashFunction))
|
||||
createHash(outputOptions.hashFunction)
|
||||
.update(name)
|
||||
.digest(outputOptions.hashDigest)
|
||||
);
|
||||
@@ -286,7 +288,7 @@ const ALL_CHUNK_FILTER = (_chunk) => true;
|
||||
|
||||
/**
|
||||
* @param {OptimizationSplitChunksSizes | undefined} value the sizes
|
||||
* @param {string[]} defaultSizeTypes the default size types
|
||||
* @param {DefaultSizeTypes} defaultSizeTypes the default size types
|
||||
* @returns {SplitChunksSizes} normalized representation
|
||||
*/
|
||||
const normalizeSizes = (value, defaultSizeTypes) => {
|
||||
@@ -379,7 +381,7 @@ const checkMinSizeReduction = (sizes, minSizeReduction, chunkCount) => {
|
||||
/**
|
||||
* @param {SplitChunksSizes} sizes the sizes
|
||||
* @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
|
||||
*/
|
||||
const getViolatingMinSizes = (sizes, minSize) => {
|
||||
let list;
|
||||
@@ -408,20 +410,20 @@ const totalSize = (sizes) => {
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
const normalizeName = (name) => {
|
||||
if (typeof name === "string") {
|
||||
return () => name;
|
||||
}
|
||||
if (typeof name === "function") {
|
||||
return /** @type {GetName} */ (name);
|
||||
return /** @type {GetNameFn} */ (name);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {OptimizationSplitChunksCacheGroup["chunks"]} chunks the chunk filter option
|
||||
* @returns {ChunkFilterFunction | undefined} the chunk filter function
|
||||
* @returns {ChunkFilterFn | undefined} the chunk filter function
|
||||
*/
|
||||
const normalizeChunksFilter = (chunks) => {
|
||||
if (chunks === "initial") {
|
||||
@@ -443,7 +445,7 @@ 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
|
||||
*/
|
||||
const normalizeCacheGroups = (cacheGroups, defaultSizeTypes) => {
|
||||
@@ -586,7 +588,7 @@ const checkModuleLayer = (test, module) => {
|
||||
/**
|
||||
* @param {OptimizationSplitChunksCacheGroup} options the group options
|
||||
* @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
|
||||
*/
|
||||
const createCacheGroupSource = (options, key, defaultSizeTypes) => {
|
||||
@@ -653,7 +655,7 @@ module.exports = class SplitChunksPlugin {
|
||||
/** @type {SplitChunksOptions} */
|
||||
this.options = {
|
||||
chunksFilter:
|
||||
/** @type {ChunkFilterFunction} */
|
||||
/** @type {ChunkFilterFn} */
|
||||
(normalizeChunksFilter(options.chunks || "all")),
|
||||
defaultSizeTypes,
|
||||
minSize,
|
||||
@@ -684,13 +686,13 @@ module.exports = class SplitChunksPlugin {
|
||||
defaultSizeTypes
|
||||
),
|
||||
getName: options.name
|
||||
? /** @type {GetName} */ (normalizeName(options.name))
|
||||
? /** @type {GetNameFn} */ (normalizeName(options.name))
|
||||
: defaultGetName,
|
||||
automaticNameDelimiter: options.automaticNameDelimiter || "-",
|
||||
usedExports: options.usedExports || false,
|
||||
fallbackCacheGroup: {
|
||||
chunksFilter:
|
||||
/** @type {ChunkFilterFunction} */
|
||||
/** @type {ChunkFilterFn} */
|
||||
(
|
||||
normalizeChunksFilter(
|
||||
fallbackCacheGroup.chunks || options.chunks || "all"
|
||||
@@ -947,15 +949,17 @@ module.exports = class SplitChunksPlugin {
|
||||
return { chunkSetsInGraph, singleChunkSets };
|
||||
});
|
||||
|
||||
/** @typedef {Map<number, Set<Chunk>[]>} ChunkSetsByCount */
|
||||
|
||||
// group these set of chunks by count
|
||||
// to allow to check less sets via isSubset
|
||||
// (only smaller sets can be subset)
|
||||
/**
|
||||
* @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();
|
||||
for (const chunksSet of chunkSets) {
|
||||
const count = chunksSet.size;
|
||||
@@ -979,19 +983,21 @@ module.exports = class SplitChunksPlugin {
|
||||
)
|
||||
);
|
||||
|
||||
/** @typedef {(Set<Chunk> | Chunk)[]} Combinations */
|
||||
|
||||
// Create a list of possible combinations
|
||||
/**
|
||||
* @param {Map<bigint | Chunk, Set<Chunk>>} chunkSets chunk sets
|
||||
* @param {Set<Chunk>} singleChunkSets single chunks sets
|
||||
* @param {Map<number, Set<Chunk>[]>} chunkSetsByCount chunk sets by count
|
||||
* @returns {(key: bigint | Chunk) => (Set<Chunk> | Chunk)[]} combinations
|
||||
* @returns {(key: bigint | Chunk) => Combinations} combinations
|
||||
*/
|
||||
const createGetCombinations = (
|
||||
chunkSets,
|
||||
singleChunkSets,
|
||||
chunkSetsByCount
|
||||
) => {
|
||||
/** @type {Map<bigint | Chunk, (Set<Chunk> | Chunk)[]>} */
|
||||
/** @type {Map<bigint | Chunk, Combinations>} */
|
||||
const combinationsCache = new Map();
|
||||
|
||||
return (key) => {
|
||||
@@ -1005,7 +1011,7 @@ module.exports = class SplitChunksPlugin {
|
||||
const chunksSet =
|
||||
/** @type {Set<Chunk>} */
|
||||
(chunkSets.get(key));
|
||||
/** @type {(Set<Chunk> | Chunk)[]} */
|
||||
/** @type {Combinations} */
|
||||
const array = [chunksSet];
|
||||
for (const [count, setArray] of chunkSetsByCount) {
|
||||
// "equal" is not needed because they would have been merge in the first step
|
||||
@@ -1038,7 +1044,7 @@ module.exports = class SplitChunksPlugin {
|
||||
|
||||
/**
|
||||
* @param {bigint | Chunk} key key
|
||||
* @returns {(Set<Chunk> | Chunk)[]} combinations by key
|
||||
* @returns {Combinations} combinations by key
|
||||
*/
|
||||
const getCombinations = (key) => getCombinationsFactory()(key);
|
||||
|
||||
@@ -1053,7 +1059,7 @@ module.exports = class SplitChunksPlugin {
|
||||
});
|
||||
/**
|
||||
* @param {bigint | Chunk} key key
|
||||
* @returns {(Set<Chunk> | Chunk)[]} exports combinations by key
|
||||
* @returns {Combinations} exports combinations by key
|
||||
*/
|
||||
const getExportsCombinations = (key) =>
|
||||
getExportsCombinationsFactory()(key);
|
||||
@@ -1064,14 +1070,14 @@ module.exports = class SplitChunksPlugin {
|
||||
* @property {bigint | Chunk} key a key of the list
|
||||
*/
|
||||
|
||||
/** @type {WeakMap<Set<Chunk> | Chunk, WeakMap<ChunkFilterFunction, SelectedChunksResult>>} */
|
||||
/** @type {WeakMap<Set<Chunk> | Chunk, WeakMap<ChunkFilterFn, SelectedChunksResult>>} */
|
||||
const selectedChunksCacheByChunksSet = new WeakMap();
|
||||
|
||||
/**
|
||||
* get list and key by applying the filter function to the list
|
||||
* It is cached for performance reasons
|
||||
* @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
|
||||
*/
|
||||
const getSelectedChunks = (chunks, chunkFilter) => {
|
||||
@@ -1132,7 +1138,7 @@ module.exports = class SplitChunksPlugin {
|
||||
// Determine name for split chunk
|
||||
|
||||
const name =
|
||||
/** @type {GetName} */
|
||||
/** @type {GetNameFn} */
|
||||
(cacheGroup.getName)(module, selectedChunks, cacheGroup.key);
|
||||
// Check if the name is ok
|
||||
const existingChunk = name && compilation.namedChunks.get(name);
|
||||
@@ -1294,7 +1300,7 @@ module.exports = class SplitChunksPlugin {
|
||||
const { chunks: selectedChunks, key: selectedChunksKey } =
|
||||
getSelectedChunks(
|
||||
chunkCombination,
|
||||
/** @type {ChunkFilterFunction} */
|
||||
/** @type {ChunkFilterFn} */
|
||||
(cacheGroup.chunksFilter)
|
||||
);
|
||||
|
||||
@@ -1316,7 +1322,7 @@ module.exports = class SplitChunksPlugin {
|
||||
|
||||
/**
|
||||
* @param {ChunksInfoItem} info entry
|
||||
* @param {string[]} sourceTypes source types to be removed
|
||||
* @param {SourceTypes} sourceTypes source types to be removed
|
||||
*/
|
||||
const removeModulesWithSourceType = (info, sourceTypes) => {
|
||||
for (const module of info.modules) {
|
||||
|
||||
Reference in New Issue
Block a user