| | |
| | | |
| | | /** @typedef {import("./Dependency")} Dependency */ |
| | | /** @typedef {import("./Dependency").RuntimeSpec} RuntimeSpec */ |
| | | /** @typedef {import("./Dependency").ExportInfoName} ExportInfoName */ |
| | | /** @typedef {import("./Dependency").ExportsSpecExcludeExports} ExportsSpecExcludeExports */ |
| | | /** @typedef {import("./dependencies/HarmonyImportDependency")} HarmonyImportDependency */ |
| | | /** @typedef {import("./Module")} Module */ |
| | |
| | | |
| | | /** @typedef {typeof UsageState.OnlyPropertiesUsed | typeof UsageState.NoInfo | typeof UsageState.Unknown | typeof UsageState.Used} RuntimeUsageStateType */ |
| | | /** @typedef {typeof UsageState.Unused | RuntimeUsageStateType} UsageStateType */ |
| | | |
| | | /** @typedef {string} ExportInfoName */ |
| | | |
| | | /** @typedef {Map<string, RuntimeUsageStateType>} UsedInRuntime */ |
| | | /** @typedef {{ module: Module, export: ExportInfoName[], deferred: boolean }} TargetItemWithoutConnection */ |
| | |
| | | /** @typedef {Set<ExportInfo>} AlreadyVisitedExportInfo */ |
| | | |
| | | /** |
| | | * Defines the restore provided data exports type used by this module. |
| | | * @typedef {object} RestoreProvidedDataExports |
| | | * @property {ExportInfoName} name |
| | | * @property {ExportInfo["provided"]} provided |
| | |
| | | |
| | | class RestoreProvidedData { |
| | | /** |
| | | * Creates an instance of RestoreProvidedData. |
| | | * @param {RestoreProvidedDataExports[]} exports exports |
| | | * @param {ExportInfo["provided"]} otherProvided other provided |
| | | * @param {ExportInfo["canMangleProvide"]} otherCanMangleProvide other can mangle provide |
| | |
| | | } |
| | | |
| | | /** |
| | | * Serializes this instance into the provided serializer context. |
| | | * @param {ObjectSerializerContext} context context |
| | | */ |
| | | serialize({ write }) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Restores this instance from the provided deserializer context. |
| | | * @param {ObjectDeserializerContext} context context |
| | | * @returns {RestoreProvidedData} RestoreProvidedData |
| | | */ |
| | |
| | | constructor() { |
| | | /** @type {Exports} */ |
| | | this._exports = new Map(); |
| | | /** @type {ExportInfo} */ |
| | | this._otherExportsInfo = new ExportInfo(null); |
| | | /** @type {ExportInfo} */ |
| | | this._sideEffectsOnlyInfo = new ExportInfo("*side effects only*"); |
| | | /** @type {boolean} */ |
| | | this._exportsAreOrdered = false; |
| | | /** @type {ExportsInfo=} */ |
| | | this._redirectTo = undefined; |
| | | } |
| | | |
| | | /** |
| | | * Gets owned exports. |
| | | * @returns {Iterable<ExportInfo>} all owned exports in any order |
| | | */ |
| | | get ownedExports() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets ordered owned exports. |
| | | * @returns {Iterable<ExportInfo>} all owned exports in order |
| | | */ |
| | | get orderedOwnedExports() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns all exports in any order. |
| | | * @returns {Iterable<ExportInfo>} all exports in any order |
| | | */ |
| | | get exports() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets ordered exports. |
| | | * @returns {Iterable<ExportInfo>} all exports in order |
| | | */ |
| | | get orderedExports() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets other exports info. |
| | | * @returns {ExportInfo} the export info of unlisted exports |
| | | */ |
| | | get otherExportsInfo() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes the provided export. |
| | | * @param {Exports} exports exports |
| | | * @private |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets redirect named to. |
| | | * @param {ExportsInfo | undefined} exportsInfo exports info |
| | | * @returns {boolean} result |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets own export info. |
| | | * @param {ExportInfoName} name export name |
| | | * @returns {ExportInfo} export info for this name |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns export info for this name. |
| | | * @param {ExportInfoName} name export name |
| | | * @returns {ExportInfo} export info for this name |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets read only export info. |
| | | * @param {ExportInfoName} name export name |
| | | * @returns {ExportInfo} export info for this name |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets read only export info recursive. |
| | | * @param {ExportInfoName[]} name export name |
| | | * @returns {ExportInfo | undefined} export info for this name |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets nested exports info. |
| | | * @param {ExportInfoName[]=} name the export name |
| | | * @returns {ExportsInfo | undefined} the nested exports info |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets unknown exports provided. |
| | | * @param {boolean=} canMangle true, if exports can still be mangled (defaults to false) |
| | | * @param {ExportsSpecExcludeExports=} excludeExports list of unaffected exports |
| | | * @param {Dependency=} targetKey use this as key for the target |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets used in unknown way. |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @returns {boolean} true, when something changed |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets used without info. |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @returns {boolean} true, when something changed |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets all known exports used. |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @returns {boolean} true, when something changed |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets used for side effects only. |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @returns {boolean} true, when something changed |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Checks whether this exports info is used. |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @returns {boolean} true, when the module exports are used in any way |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Checks whether this exports info is module used. |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @returns {boolean} true, when the module is used in any way |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns set of used exports, or true (when namespace object is used), or false (when unused), or null (when unknown). |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @returns {SortableSet<ExportInfoName> | boolean | null} set of used exports, or true (when namespace object is used), or false (when unused), or null (when unknown) |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets provided exports. |
| | | * @returns {null | true | ExportInfoName[]} list of exports when known |
| | | */ |
| | | getProvidedExports() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets relevant exports. |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @returns {ExportInfo[]} exports that are relevant (not unused and potential provided) |
| | | */ |
| | | getRelevantExports(runtime) { |
| | | /** @type {ExportInfo[]} */ |
| | | const list = []; |
| | | for (const exportInfo of this._exports.values()) { |
| | | const used = exportInfo.getUsed(runtime); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Checks whether this exports info is export provided. |
| | | * @param {ExportInfoName | ExportInfoName[]} name the name of the export |
| | | * @returns {boolean | undefined | null} if the export is provided |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns key representing the usage. |
| | | * @param {RuntimeSpec} runtime runtime |
| | | * @returns {string} key representing the usage |
| | | */ |
| | | getUsageKey(runtime) { |
| | | /** @type {(string | number)[]} */ |
| | | const key = []; |
| | | if (this._redirectTo !== undefined) { |
| | | key.push(this._redirectTo.getUsageKey(runtime)); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Checks whether this exports info is equally used. |
| | | * @param {RuntimeSpec} runtimeA first runtime |
| | | * @param {RuntimeSpec} runtimeB second runtime |
| | | * @returns {boolean} true, when equally used |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns usage status. |
| | | * @param {ExportInfoName | ExportInfoName[]} name export name |
| | | * @param {RuntimeSpec} runtime check usage for this runtime only |
| | | * @returns {UsageStateType} usage status |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the used name. |
| | | * @param {ExportInfoName | ExportInfoName[]} name the export name |
| | | * @param {RuntimeSpec} runtime check usage for this runtime only |
| | | * @returns {UsedName} the used name |
| | |
| | | } |
| | | |
| | | /** |
| | | * Updates the hash with the data contributed by this instance. |
| | | * @param {Hash} hash the hash |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Updates hash using the provided hash. |
| | | * @param {Hash} hash the hash |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @param {Set<ExportsInfo>} alreadyVisitedExportsInfo for circular references |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets restore provided data. |
| | | * @returns {RestoreProvidedData} restore provided data |
| | | */ |
| | | getRestoreProvidedData() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes the provided data. |
| | | * @param {RestoreProvidedData} data data |
| | | */ |
| | | restoreProvided({ |
| | |
| | | |
| | | class ExportInfo { |
| | | /** |
| | | * Creates an instance of ExportInfo. |
| | | * @param {ExportInfoName | null} name the original name of the export |
| | | * @param {ExportInfo=} initFrom init values from this ExportInfo |
| | | */ |
| | |
| | | /** @type {Target | undefined} */ |
| | | this._target = undefined; |
| | | if (initFrom && initFrom._target) { |
| | | this._target = new Map(); |
| | | this._target = /** @type {Target} */ (new Map()); |
| | | for (const [key, value] of initFrom._target) { |
| | | this._target.set(key, { |
| | | connection: value.connection, |
| | |
| | | } |
| | | /** @type {Target | undefined} */ |
| | | this._maxTarget = undefined; |
| | | } |
| | | |
| | | // TODO webpack 5 remove |
| | | /** |
| | | * @private |
| | | * @param {EXPECTED_ANY} v v |
| | | */ |
| | | set used(v) { |
| | | throw new Error("REMOVED"); |
| | | } |
| | | |
| | | // TODO webpack 5 remove |
| | | /** @private */ |
| | | get used() { |
| | | throw new Error("REMOVED"); |
| | | } |
| | | |
| | | // TODO webpack 5 remove |
| | | /** |
| | | * @private |
| | | * @param {EXPECTED_ANY} v v |
| | | */ |
| | | set usedName(v) { |
| | | throw new Error("REMOVED"); |
| | | } |
| | | |
| | | // TODO webpack 5 remove |
| | | /** @private */ |
| | | get usedName() { |
| | | throw new Error("REMOVED"); |
| | | } |
| | | |
| | | get canMangle() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets used in unknown way. |
| | | * @param {RuntimeSpec} runtime only apply to this runtime |
| | | * @returns {boolean} true, when something changed |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets used without info. |
| | | * @param {RuntimeSpec} runtime only apply to this runtime |
| | | * @returns {boolean} true, when something changed |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets used conditionally. |
| | | * @param {(condition: UsageStateType) => boolean} condition compare with old value |
| | | * @param {UsageStateType} newValue set when condition is true |
| | | * @param {RuntimeSpec} runtime only apply to this runtime |
| | |
| | | } |
| | | |
| | | /** |
| | | * Updates used using the provided new value. |
| | | * @param {UsageStateType} newValue new value of the used state |
| | | * @param {RuntimeSpec} runtime only apply to this runtime |
| | | * @returns {boolean} true when something has changed |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns true, if something has changed. |
| | | * @param {Dependency} key the key |
| | | * @returns {boolean} true, if something has changed |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Updates target using the provided key. |
| | | * @param {Dependency} key the key |
| | | * @param {ModuleGraphConnection} connection the target module if a single one |
| | | * @param {ExportInfoName[] | null=} exportName the exported name |
| | |
| | | setTarget(key, connection, exportName, priority = 0) { |
| | | if (exportName) exportName = [...exportName]; |
| | | if (!this._target) { |
| | | this._target = new Map(); |
| | | this._target = /** @type {Target} */ (new Map()); |
| | | this._target.set(key, { |
| | | connection, |
| | | export: /** @type {ExportInfoName[]} */ (exportName), |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns usage state. |
| | | * @param {RuntimeSpec} runtime for this runtime |
| | | * @returns {UsageStateType} usage state |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * get used name |
| | | * Returns used name. |
| | | * @param {string | undefined} fallbackName fallback name for used exports with no name |
| | | * @param {RuntimeSpec} runtime check usage for this runtime only |
| | | * @returns {string | false} used name |
| | |
| | | } |
| | | |
| | | /** |
| | | * Checks whether this export info has used name. |
| | | * @returns {boolean} true, when a mangled name of this export is set |
| | | */ |
| | | hasUsedName() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Sets the mangled name of this export |
| | | * Updates used name using the provided name. |
| | | * @param {string} name the new name |
| | | * @returns {void} |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets terminal binding. |
| | | * @param {ModuleGraph} moduleGraph the module graph |
| | | * @param {ResolveTargetFilter} resolveTargetFilter filter function to further resolve target |
| | | * @returns {ExportInfo | ExportsInfo | undefined} the terminal binding export(s) info if known |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the target, undefined when there is no target, false when no target is valid. |
| | | * @param {ModuleGraph} moduleGraph the module graph |
| | | * @param {ValidTargetModuleFilter} validTargetModuleFilter a valid target module |
| | | * @returns {TargetItemWithoutConnection | null | undefined | false} the target, undefined when there is no target, false when no target is valid |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the target, undefined when there is no target, false when no target is valid. |
| | | * @param {ModuleGraph} moduleGraph the module graph |
| | | * @param {ValidTargetModuleFilter} validTargetModuleFilter a valid target module |
| | | * @param {AlreadyVisitedExportInfo} alreadyVisited set of already visited export info to avoid circular references |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the target. |
| | | * @param {ModuleGraph} moduleGraph the module graph |
| | | * @param {ResolveTargetFilter} resolveTargetFilter filter function to further resolve target |
| | | * @returns {TargetItemWithConnection | undefined} the target |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the target. |
| | | * @param {ModuleGraph} moduleGraph the module graph |
| | | * @param {ResolveTargetFilter} resolveTargetFilter filter function to further resolve target |
| | | * @param {AlreadyVisitedExportInfo | undefined} alreadyVisited set of already visited export info to avoid circular references |
| | |
| | | */ |
| | | _getTarget(moduleGraph, resolveTargetFilter, alreadyVisited) { |
| | | /** |
| | | * Returns resolved target. |
| | | * @param {TargetItem | undefined | null} inputTarget unresolved target |
| | | * @param {AlreadyVisitedExportInfo} alreadyVisited set of already visited export info to avoid circular references |
| | | * @returns {TargetItemWithConnection | CIRCULAR | null} resolved target |
| | |
| | | } |
| | | |
| | | /** |
| | | * Creates a nested exports info. |
| | | * @returns {ExportsInfo} an exports info |
| | | */ |
| | | createNestedExportsInfo() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Checks whether this export info contains the base info. |
| | | * @param {ExportInfo} baseInfo base info |
| | | * @param {RuntimeSpec} runtime runtime |
| | | * @returns {boolean} true when has info, otherwise false |
| | |
| | | } |
| | | |
| | | /** |
| | | * Updates the hash with the data contributed by this instance. |
| | | * @param {Hash} hash the hash |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Updates hash using the provided hash. |
| | | * @param {Hash} hash the hash |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @param {Set<ExportsInfo>} alreadyVisitedExportsInfo for circular references |