| | |
| | | const { countIterable } = require("../util/IterableHelpers"); |
| | | const { combine, first } = require("../util/SetHelpers"); |
| | | const makeSerializable = require("../util/makeSerializable"); |
| | | const propertyAccess = require("../util/propertyAccess"); |
| | | const { propertyName } = require("../util/propertyName"); |
| | | const { propertyAccess, propertyName } = require("../util/property"); |
| | | const { |
| | | filterRuntime, |
| | | getRuntimeKey, |
| | |
| | | /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */ |
| | | /** @typedef {import("./HarmonyImportDependency").Ids} Ids */ |
| | | /** @typedef {import("./HarmonyImportDependency").ExportPresenceMode} ExportPresenceMode */ |
| | | /** @typedef {import("./HarmonyExportInitFragment").ExportMap} ExportMap */ |
| | | /** @typedef {import("../dependencies/ImportPhase").ImportPhaseType} ImportPhaseType */ |
| | | |
| | | /** @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 */ |
| | | /** @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 */ |
| | | |
| | | const { ExportPresenceModes } = HarmonyImportDependency; |
| | | |
| | | const idsSymbol = Symbol("HarmonyExportImportedSpecifierDependency.ids"); |
| | | const idsSymbol = /** @type {symbol} */ ( |
| | | Symbol("HarmonyExportImportedSpecifierDependency.ids") |
| | | ); |
| | | |
| | | class NormalReexportItem { |
| | | /** |
| | | * Creates an instance of NormalReexportItem. |
| | | * @param {string} name export name |
| | | * @param {Ids} ids reexported ids from other module |
| | | * @param {ExportInfo} exportInfo export info from other module |
| | |
| | | |
| | | class ExportMode { |
| | | /** |
| | | * Creates an instance of ExportMode. |
| | | * @param {ExportModeType} type type of the mode |
| | | */ |
| | | constructor(type) { |
| | |
| | | /** @typedef {number[]} DependencyIndices */ |
| | | |
| | | /** |
| | | * Determine export assignments. |
| | | * @param {ModuleGraph} moduleGraph module graph |
| | | * @param {HarmonyExportImportedSpecifierDependency[]} dependencies dependencies |
| | | * @param {HarmonyExportImportedSpecifierDependency=} additionalDependency additional dependency |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Finds dependency for name. |
| | | * @param {object} options options |
| | | * @param {ExportInfoName[]} options.names names |
| | | * @param {DependencyIndices} options.dependencyIndices dependency indices |
| | |
| | | }; |
| | | |
| | | /** |
| | | * Returns the export mode. |
| | | * @param {ModuleGraph} moduleGraph the module graph |
| | | * @param {HarmonyExportImportedSpecifierDependency} dep the dependency |
| | | * @param {string} runtimeKey the runtime key |
| | |
| | | |
| | | // reexporting with a fixed name |
| | | if (name) { |
| | | /** @type {ExportMode} */ |
| | | let mode; |
| | | const exportInfo = exportsInfo.getReadOnlyExportInfo(name); |
| | | |
| | |
| | | |
| | | class HarmonyExportImportedSpecifierDependency extends HarmonyImportDependency { |
| | | /** |
| | | * Creates an instance of HarmonyExportImportedSpecifierDependency. |
| | | * @param {string} request the request string |
| | | * @param {number} sourceOrder the order in the original source file |
| | | * @param {Ids} ids the requested export name of the imported module |
| | |
| | | } |
| | | |
| | | /** |
| | | * Could affect referencing module. |
| | | * @returns {boolean | TRANSITIVE} true, when changes to the referenced module could affect the referencing module; TRANSITIVE, when changes to the referenced module could affect referencing modules of the referencing module |
| | | */ |
| | | couldAffectReferencingModule() { |
| | |
| | | } |
| | | |
| | | // TODO webpack 6 remove |
| | | /** |
| | | * Returns id. |
| | | * @deprecated |
| | | */ |
| | | get id() { |
| | | throw new Error("id was renamed to ids and type changed to string[]"); |
| | | } |
| | | |
| | | // TODO webpack 6 remove |
| | | /** |
| | | * Returns id. |
| | | * @deprecated |
| | | */ |
| | | getId() { |
| | | throw new Error("id was renamed to ids and type changed to string[]"); |
| | | } |
| | | |
| | | // TODO webpack 6 remove |
| | | /** |
| | | * Updates id. |
| | | * @deprecated |
| | | */ |
| | | setId() { |
| | | throw new Error("id was renamed to ids and type changed to string[]"); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the imported id. |
| | | * @param {ModuleGraph} moduleGraph the module graph |
| | | * @returns {Ids} the imported id |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Updates ids using the provided module graph. |
| | | * @param {ModuleGraph} moduleGraph the module graph |
| | | * @param {Ids} ids the imported ids |
| | | * @returns {void} |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns the export mode. |
| | | * @param {ModuleGraph} moduleGraph the module graph |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @returns {ExportMode} the export mode |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets star reexports. |
| | | * @param {ModuleGraph} moduleGraph the module graph |
| | | * @param {RuntimeSpec} runtime the runtime |
| | | * @param {ExportsInfo} exportsInfo exports info about the current module (optional) |
| | | * @param {Module} importedModule the imported module (optional) |
| | | * @returns {{exports?: Exports, checked?: Checked, ignoredExports: IgnoredExports, hidden?: Hidden}} information |
| | | * @returns {{ exports?: Exports, checked?: Checked, ignoredExports: IgnoredExports, hidden?: Hidden }} information |
| | | */ |
| | | getStarReexports( |
| | | moduleGraph, |
| | |
| | | const noExtraImports = |
| | | exportsInfo.otherExportsInfo.getUsed(runtime) === UsageState.Unused; |
| | | |
| | | /** @type {IgnoredExports} */ |
| | | const ignoredExports = new Set(["default", ...this.activeExports]); |
| | | |
| | | /** @type {Hidden | undefined} */ |
| | | let hiddenExports; |
| | | const otherStarExports = |
| | | this._discoverActiveExportsFromOtherStarExports(moduleGraph); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns function to determine if the connection is active. |
| | | * @param {ModuleGraph} moduleGraph module graph |
| | | * @returns {null | false | GetConditionFn} function to determine if the connection is active |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets module evaluation side effects state. |
| | | * @param {ModuleGraph} moduleGraph the module graph |
| | | * @returns {ConnectionState} how this dependency connects the module to referencing modules |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Discover active exports from other star exports. |
| | | * @param {ModuleGraph} moduleGraph the module graph |
| | | * @returns {{ names: ExportInfoName[], namesSlice: number, dependencyIndices: DependencyIndices, dependencyIndex: number } | undefined} exported names and their origin dependency |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Get effective export presence level. |
| | | * @param {ModuleGraph} moduleGraph module graph |
| | | * @returns {ExportPresenceMode} effective mode |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns warnings |
| | | * Returns warnings. |
| | | * @param {ModuleGraph} moduleGraph module graph |
| | | * @returns {WebpackError[] | null | undefined} warnings |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns errors |
| | | * Returns errors. |
| | | * @param {ModuleGraph} moduleGraph module graph |
| | | * @returns {WebpackError[] | null | undefined} errors |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns errors. |
| | | * @param {ModuleGraph} moduleGraph module graph |
| | | * @returns {WebpackError[] | undefined} errors |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Serializes this instance into the provided serializer context. |
| | | * @param {ObjectSerializerContext} context context |
| | | */ |
| | | serialize(context) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Restores this instance from the provided deserializer context. |
| | | * @param {ObjectDeserializerContext} context context |
| | | */ |
| | | deserialize(context) { |
| | |
| | | HarmonyImportDependency.Template |
| | | ) { |
| | | /** |
| | | * Applies the plugin by registering its hooks on the compiler. |
| | | * @param {Dependency} dependency the dependency for which the template should be applied |
| | | * @param {ReplaceSource} source the current replace source which can be modified |
| | | * @param {DependencyTemplateContext} templateContext the context object |
| | |
| | | } |
| | | |
| | | /** |
| | | * Add export fragments. |
| | | * @param {InitFragment<GenerateContext>[]} initFragments target array for init fragments |
| | | * @param {HarmonyExportImportedSpecifierDependency} dep dependency |
| | | * @param {ExportMode} mode the export mode |
| | |
| | | } |
| | | |
| | | content += "__WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = "; |
| | | content += runtimeTemplate.supportsArrowFunction() |
| | | ? `() => ${importVar}[__WEBPACK_IMPORT_KEY__]` |
| | | : `function(key) { return ${importVar}[key]; }.bind(0, __WEBPACK_IMPORT_KEY__)`; |
| | | content += |
| | | runtimeTemplate.supportsArrowFunction() && |
| | | runtimeTemplate.supportsConst() |
| | | ? `() => ${importVar}[__WEBPACK_IMPORT_KEY__]` |
| | | : `function(key) { return ${importVar}[key]; }.bind(0, __WEBPACK_IMPORT_KEY__)`; |
| | | |
| | | runtimeRequirements.add(RuntimeGlobals.exports); |
| | | runtimeRequirements.add(RuntimeGlobals.definePropertyGetters); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets reexport fragment. |
| | | * @param {Module} module the current module |
| | | * @param {string} comment comment |
| | | * @param {UsedName} key key |
| | |
| | | runtimeRequirements.add(RuntimeGlobals.exports); |
| | | runtimeRequirements.add(RuntimeGlobals.definePropertyGetters); |
| | | |
| | | /** @type {ExportMap} */ |
| | | const map = new Map(); |
| | | map.set(key, `/* ${comment} */ ${returnValue}`); |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets reexport fake namespace object fragments. |
| | | * @param {Module} module module |
| | | * @param {UsedName} key key |
| | | * @param {string} name name |
| | |
| | | runtimeRequirements.add(RuntimeGlobals.definePropertyGetters); |
| | | runtimeRequirements.add(RuntimeGlobals.createFakeNamespaceObject); |
| | | |
| | | /** @type {ExportMap} */ |
| | | const map = new Map(); |
| | | map.set( |
| | | key, |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets reexport deferred namespace object fragments. |
| | | * @param {Module} module module |
| | | * @param {ChunkGraph} chunkGraph chunkGraph |
| | | * @param {UsedName} key key |
| | |
| | | runtimeRequirements.add(RuntimeGlobals.definePropertyGetters); |
| | | runtimeRequirements.add(RuntimeGlobals.makeDeferredNamespaceObject); |
| | | |
| | | /** @type {ExportMap} */ |
| | | const map = new Map(); |
| | | const moduleId = JSON.stringify(chunkGraph.getModuleId(module)); |
| | | const mode = getMakeDeferredNamespaceModeFromExportsType(exportsType); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Gets conditional reexport statement. |
| | | * @param {Module} module module |
| | | * @param {string} key key |
| | | * @param {string} name name |
| | |
| | | } |
| | | |
| | | /** |
| | | * Returns value. |
| | | * @param {string} name name |
| | | * @param {null | false | string | string[]} valueKey value key |
| | | * @returns {string | undefined} value |
| | |
| | | } |
| | | |
| | | /** |
| | | * Processes the provided dep. |
| | | * @param {HarmonyExportImportedSpecifierDependency} dep dependency |
| | | * @returns {void} |
| | | */ |
| | |
| | | } |
| | | |
| | | /** |
| | | * Serializes this instance into the provided serializer context. |
| | | * @param {ObjectSerializerContext} context context |
| | | */ |
| | | serialize({ write, setCircularReference }) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Restores this instance from the provided deserializer context. |
| | | * @param {ObjectDeserializerContext} context context |
| | | */ |
| | | deserialize({ read, setCircularReference }) { |