@module-federation/enhanced 2.9.1 → 2.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/CHANGELOG.md +63 -0
  2. package/dist/src/lib/container/ContainerEntryDependency.js +2 -2
  3. package/dist/src/lib/container/ContainerEntryDependency.js.map +1 -1
  4. package/dist/src/lib/container/ContainerEntryModule.js +14 -8
  5. package/dist/src/lib/container/ContainerEntryModule.js.map +1 -1
  6. package/dist/src/lib/container/ContainerExposedDependency.js +2 -2
  7. package/dist/src/lib/container/ContainerExposedDependency.js.map +1 -1
  8. package/dist/src/lib/container/FallbackDependency.js +2 -2
  9. package/dist/src/lib/container/FallbackDependency.js.map +1 -1
  10. package/dist/src/lib/container/FallbackItemDependency.js +2 -2
  11. package/dist/src/lib/container/FallbackItemDependency.js.map +1 -1
  12. package/dist/src/lib/container/FallbackModule.js +2 -2
  13. package/dist/src/lib/container/FallbackModule.js.map +1 -1
  14. package/dist/src/lib/container/HoistContainerReferencesPlugin.js +1 -0
  15. package/dist/src/lib/container/HoistContainerReferencesPlugin.js.map +1 -1
  16. package/dist/src/lib/container/RemoteModule.js +2 -2
  17. package/dist/src/lib/container/RemoteModule.js.map +1 -1
  18. package/dist/src/lib/container/RemoteRuntimeModule.js +2 -1
  19. package/dist/src/lib/container/RemoteRuntimeModule.js.map +1 -1
  20. package/dist/src/lib/container/RemoteToExternalDependency.js +2 -2
  21. package/dist/src/lib/container/RemoteToExternalDependency.js.map +1 -1
  22. package/dist/src/lib/container/runtime/FederationRuntimePlugin.js +29 -5
  23. package/dist/src/lib/container/runtime/FederationRuntimePlugin.js.map +1 -1
  24. package/dist/src/lib/makeSerializable.d.ts +15 -0
  25. package/dist/src/lib/makeSerializable.js +20 -0
  26. package/dist/src/lib/makeSerializable.js.map +1 -0
  27. package/dist/src/lib/sharing/ConsumeSharedFallbackDependency.js +2 -2
  28. package/dist/src/lib/sharing/ConsumeSharedFallbackDependency.js.map +1 -1
  29. package/dist/src/lib/sharing/ConsumeSharedModule.js +6 -6
  30. package/dist/src/lib/sharing/ConsumeSharedModule.js.map +1 -1
  31. package/dist/src/lib/sharing/ConsumeSharedPlugin.d.ts +1 -1
  32. package/dist/src/lib/sharing/ConsumeSharedPlugin.js +27 -38
  33. package/dist/src/lib/sharing/ConsumeSharedPlugin.js.map +1 -1
  34. package/dist/src/lib/sharing/ProvideForSharedDependency.js +2 -2
  35. package/dist/src/lib/sharing/ProvideForSharedDependency.js.map +1 -1
  36. package/dist/src/lib/sharing/ProvideSharedDependency.js +2 -2
  37. package/dist/src/lib/sharing/ProvideSharedDependency.js.map +1 -1
  38. package/dist/src/lib/sharing/ProvideSharedModule.js +2 -2
  39. package/dist/src/lib/sharing/ProvideSharedModule.js.map +1 -1
  40. package/dist/src/lib/sharing/ProvideSharedPlugin.js +14 -65
  41. package/dist/src/lib/sharing/ProvideSharedPlugin.js.map +1 -1
  42. package/dist/src/lib/sharing/tree-shaking/IndependentSharedPlugin.js +46 -36
  43. package/dist/src/lib/sharing/tree-shaking/IndependentSharedPlugin.js.map +1 -1
  44. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedContainerPlugin.js +2 -5
  45. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedContainerPlugin.js.map +1 -1
  46. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedDependency.js +2 -2
  47. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedDependency.js.map +1 -1
  48. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryDependency.js +2 -2
  49. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryDependency.js.map +1 -1
  50. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModule.js +2 -2
  51. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModule.js.map +1 -1
  52. package/package.json +13 -13
package/dist/CHANGELOG.md CHANGED
@@ -1,5 +1,68 @@
1
1
  # @module-federation/enhanced
2
2
 
3
+ ## 2.9.3
4
+
5
+ ### Patch Changes
6
+
7
+ - ee32a0d: Keep one consume-shared module per `requiredVersion` range. Two packages that
8
+ require different ranges of the same shared dependency no longer collapse into
9
+ one module, so each gets its own version check.
10
+ - caafd8d: Read the version for `include.version` and `exclude.version` on consumed
11
+ shared modules from the `package.json` whose `name` matches the consumed
12
+ package. Prefix consumes such as `'lib/'` matched against `lib/sub`, scoped
13
+ packages, and `node_modules` suffix matches previously skipped the filter
14
+ and were always consumed. Relative, absolute, and aliased consume configs
15
+ are unchanged unless `packageName` is set.
16
+ - edf1219: HoistContainerReferencesPlugin no longer hoists modules that webpack already pruned. The module graph walk now skips connections whose active state is false, such as an unused import of a `sideEffects: false` package, so the runtime chunk keeps only modules that are reachable through an active connection.
17
+ - b4b5477: Give each shared tree-shaking child compiler its own filesystem cache pack and close it after its run. Before, the children overwrote the parent's cache pack, so the next build rebuilt every parent module.
18
+ - 543eba3: Test `include.request` and `exclude.request` on provided shared modules only against the import request, or against the path after `node_modules/` (for example `lodash/get.js`) when `allowNodeModulesSuffixMatch` matches, never against the resolved file path. A prefix such as `'lodash/'` with `include: { request: 'get' }` and a direct entry such as `react` with `include: { request: 'react' }` now provide their modules, and an `exclude.request` pattern no longer drops modules whose absolute path happens to match it.
19
+ - fdaeb75: Make the generated federation runtime entry stable and valid. When
20
+ `output.uniqueName` is empty, the fallback container name no longer contains
21
+ the build time. It is now derived from the compiler name and context, so it is
22
+ the same on every build of the same checkout but differs between machines.
23
+ Relative `runtimePlugins` paths now resolve against the compiler `context`. A
24
+ path that only exists relative to the working directory still loads, with a
25
+ warning that asks you to update it. Paths that contain a quote no longer break
26
+ the generated entry.
27
+ - 020fa27: Fix remote runtime output ordering for stable build hashes.
28
+ - 06cb964: Let two installed copies of `@module-federation/enhanced` load in one webpack
29
+ process. Each copy now registers its cache serializers under its own install
30
+ directory, so the second copy no longer throws "serializer ... is already
31
+ registered" and both copies restore their modules from the filesystem cache.
32
+ - Updated dependencies [9135b23]
33
+ - @module-federation/runtime-tools@2.9.3
34
+ - @module-federation/webpack-bundler-runtime@2.9.3
35
+ - @module-federation/sdk@2.9.3
36
+ - @module-federation/error-codes@2.9.3
37
+ - @module-federation/inject-external-runtime-core-plugin@2.9.3
38
+ - @module-federation/dts-plugin@2.9.3
39
+ - @module-federation/rspack@2.9.3
40
+ - @module-federation/bridge-react-webpack-plugin@2.9.3
41
+ - @module-federation/cli@2.9.3
42
+ - @module-federation/managers@2.9.3
43
+ - @module-federation/manifest@2.9.3
44
+
45
+ ## 2.9.2
46
+
47
+ ### Patch Changes
48
+
49
+ - 412f62e: Restore BUILD-001 logging and diagnostic context when an expose cannot resolve. Webpack still reports the build error, and `container.get()` rejects the missing expose.
50
+ - c130946: An exposed module that fails to resolve no longer exits the Node process during code generation. The build finishes with webpack's "Module not found" error in `compilation.errors`, and the container's `get()` for that expose throws `MODULE_NOT_FOUND`, as in upstream webpack. Watch mode and dev servers keep running.
51
+ - 923b55d: Fix the tree-shaking shared entry build finishing its `make` phase before the shared entry module tree was built. Large shared packages with a filesystem cache could crash in `createModuleAssets` or emit a fallback bundle with missing modules, and an entry error was thrown instead of reported.
52
+ - Updated dependencies [000f3fa]
53
+ - Updated dependencies [7f0ac8b]
54
+ - @module-federation/dts-plugin@2.9.2
55
+ - @module-federation/cli@2.9.2
56
+ - @module-federation/manifest@2.9.2
57
+ - @module-federation/rspack@2.9.2
58
+ - @module-federation/runtime-tools@2.9.2
59
+ - @module-federation/webpack-bundler-runtime@2.9.2
60
+ - @module-federation/inject-external-runtime-core-plugin@2.9.2
61
+ - @module-federation/sdk@2.9.2
62
+ - @module-federation/managers@2.9.2
63
+ - @module-federation/bridge-react-webpack-plugin@2.9.2
64
+ - @module-federation/error-codes@2.9.2
65
+
3
66
  ## 2.9.1
4
67
 
5
68
  ### Patch Changes
@@ -1,9 +1,9 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
2
  const require_runtime = require('../../_virtual/_rolldown/runtime.js');
3
+ const require_lib_makeSerializable = require('../makeSerializable.js');
3
4
  let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
4
5
 
5
6
  //#region src/lib/container/ContainerEntryDependency.ts
6
- const makeSerializable = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/makeSerializable"));
7
7
  const { Dependency } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack"));
8
8
  var ContainerEntryDependency = class extends Dependency {
9
9
  /**
@@ -32,7 +32,7 @@ var ContainerEntryDependency = class extends Dependency {
32
32
  return "esm";
33
33
  }
34
34
  };
35
- makeSerializable(ContainerEntryDependency, "enhanced/lib/container/ContainerEntryDependency");
35
+ require_lib_makeSerializable.default(ContainerEntryDependency, "enhanced/lib/container/ContainerEntryDependency");
36
36
 
37
37
  //#endregion
38
38
  exports.default = ContainerEntryDependency;
@@ -1 +1 @@
1
- {"version":3,"file":"ContainerEntryDependency.js","names":[],"sources":["../../../../src/lib/container/ContainerEntryDependency.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr\n*/\n\nimport { ExposeOptions } from './ContainerEntryModule';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\n\nconst makeSerializable = require(\n normalizeWebpackPath('webpack/lib/util/makeSerializable'),\n);\nconst { Dependency } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\nclass ContainerEntryDependency extends Dependency {\n public name: string;\n public exposes: [string, ExposeOptions][];\n public shareScope: string | string[];\n public injectRuntimeEntry: string;\n\n /**\n * @param {string} name entry name\n * @param {[string, ExposeOptions][]} exposes list of exposed modules\n * @param {string|string[]} shareScope name of the share scope\n * @param {string[]} injectRuntimeEntry the path of injectRuntime file.\n */\n constructor(\n name: string,\n exposes: [string, ExposeOptions][],\n shareScope: string | string[],\n injectRuntimeEntry: string,\n ) {\n super();\n this.name = name;\n this.exposes = exposes;\n this.shareScope = shareScope;\n this.injectRuntimeEntry = injectRuntimeEntry;\n }\n\n /**\n * @returns {string | null} an identifier to merge equal requests\n */\n override getResourceIdentifier(): string | null {\n return `container-entry-${this.name}`;\n }\n\n override get type(): string {\n return 'container entry';\n }\n\n override get category(): string {\n return 'esm';\n }\n}\n\nmakeSerializable(\n ContainerEntryDependency,\n 'enhanced/lib/container/ContainerEntryDependency',\n);\n\nexport default ContainerEntryDependency;\n"],"mappings":";;;;;AAQA,MAAM,mBAAmB,gFACF,oCAAoC,CAC1D;AACD,MAAM,EAAE,eAAe,gFACA,UAAU,CAChC;AAED,IAAM,2BAAN,cAAuC,WAAW;;;;;;;CAYhD,YACE,MACA,SACA,YACA,oBACA;AACA,SAAO;AACP,OAAK,OAAO;AACZ,OAAK,UAAU;AACf,OAAK,aAAa;AAClB,OAAK,qBAAqB;;;;;CAM5B,AAAS,wBAAuC;AAC9C,SAAO,mBAAmB,KAAK;;CAGjC,IAAa,OAAe;AAC1B,SAAO;;CAGT,IAAa,WAAmB;AAC9B,SAAO;;;AAIX,iBACE,0BACA,kDACD"}
1
+ {"version":3,"file":"ContainerEntryDependency.js","names":["makeSerializable"],"sources":["../../../../src/lib/container/ContainerEntryDependency.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr\n*/\n\nimport { ExposeOptions } from './ContainerEntryModule';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\n\nimport makeSerializable from '../makeSerializable';\nconst { Dependency } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\nclass ContainerEntryDependency extends Dependency {\n public name: string;\n public exposes: [string, ExposeOptions][];\n public shareScope: string | string[];\n public injectRuntimeEntry: string;\n\n /**\n * @param {string} name entry name\n * @param {[string, ExposeOptions][]} exposes list of exposed modules\n * @param {string|string[]} shareScope name of the share scope\n * @param {string[]} injectRuntimeEntry the path of injectRuntime file.\n */\n constructor(\n name: string,\n exposes: [string, ExposeOptions][],\n shareScope: string | string[],\n injectRuntimeEntry: string,\n ) {\n super();\n this.name = name;\n this.exposes = exposes;\n this.shareScope = shareScope;\n this.injectRuntimeEntry = injectRuntimeEntry;\n }\n\n /**\n * @returns {string | null} an identifier to merge equal requests\n */\n override getResourceIdentifier(): string | null {\n return `container-entry-${this.name}`;\n }\n\n override get type(): string {\n return 'container entry';\n }\n\n override get category(): string {\n return 'esm';\n }\n}\n\nmakeSerializable(\n ContainerEntryDependency,\n 'enhanced/lib/container/ContainerEntryDependency',\n);\n\nexport default ContainerEntryDependency;\n"],"mappings":";;;;;;AASA,MAAM,EAAE,eAAe,gFACA,UAAU,CAChC;AAED,IAAM,2BAAN,cAAuC,WAAW;;;;;;;CAYhD,YACE,MACA,SACA,YACA,oBACA;AACA,SAAO;AACP,OAAK,OAAO;AACZ,OAAK,UAAU;AACf,OAAK,aAAa;AAClB,OAAK,qBAAqB;;;;;CAM5B,AAAS,wBAAuC;AAC9C,SAAO,mBAAmB,KAAK;;CAGjC,IAAa,OAAe;AAC1B,SAAO;;CAGT,IAAa,WAAmB;AAC9B,SAAO;;;AAIXA,qCACE,0BACA,kDACD"}
@@ -3,6 +3,7 @@
3
3
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
4
  const require_runtime = require('../../_virtual/_rolldown/runtime.js');
5
5
  const require_lib_Constants = require('../Constants.js');
6
+ const require_lib_makeSerializable = require('../makeSerializable.js');
6
7
  const require_lib_container_ContainerExposedDependency = require('./ContainerExposedDependency.js');
7
8
  const require_lib_container_runtime_utils = require('./runtime/utils.js');
8
9
  let _module_federation_sdk = require("@module-federation/sdk");
@@ -11,7 +12,6 @@ let _module_federation_error_codes = require("@module-federation/error-codes");
11
12
  let _module_federation_error_codes_node = require("@module-federation/error-codes/node");
12
13
 
13
14
  //#region src/lib/container/ContainerEntryModule.ts
14
- const makeSerializable = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/makeSerializable"));
15
15
  const { sources: webpackSources, AsyncDependenciesBlock, Template, Module, RuntimeGlobals } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack"));
16
16
  const StaticExportsDependency = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/dependencies/StaticExportsDependency"));
17
17
  const EntryDependency = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/dependencies/EntryDependency"));
@@ -125,18 +125,24 @@ var ContainerEntryModule = class ContainerEntryModule extends Module {
125
125
  const getters = [];
126
126
  for (const block of this.blocks) {
127
127
  const { dependencies } = block;
128
- const modules = dependencies.map((dependency) => {
128
+ const modules = [];
129
+ let missingModules;
130
+ let requests = "";
131
+ for (const dependency of dependencies) {
129
132
  const dep = dependency;
130
- return {
133
+ const exposedModule = {
131
134
  name: dep.exposedName,
132
135
  module: moduleGraph.getModule(dep),
133
136
  request: dep.userRequest
134
137
  };
135
- });
138
+ modules.push(exposedModule);
139
+ if (!exposedModule.module) (missingModules ??= []).push(exposedModule);
140
+ requests += `${modules.length > 1 ? ", " : ""}${dep.userRequest}`;
141
+ }
136
142
  let str;
137
- if (modules.some((m) => !m.module)) {
143
+ if (missingModules) {
138
144
  (0, _module_federation_error_codes_node.logAndReport)(_module_federation_error_codes.BUILD_001, _module_federation_error_codes.buildDescMap, {
139
- exposeModules: modules.filter((m) => !m.module),
145
+ exposeModules: missingModules,
140
146
  FEDERATION_WEBPACK_PATH: process.env["FEDERATION_WEBPACK_PATH"]
141
147
  }, _module_federation_sdk.infrastructureLogger.error.bind(_module_federation_sdk.infrastructureLogger), void 0, {
142
148
  bundler: { name: "webpack" },
@@ -145,7 +151,7 @@ var ContainerEntryModule = class ContainerEntryModule extends Module {
145
151
  exposes: Object.fromEntries(this._exposes.map(([key, opts]) => [key, opts.import[opts.import.length - 1]]))
146
152
  }
147
153
  });
148
- process.exit(1);
154
+ str = runtimeTemplate.throwMissingModuleErrorBlock({ request: requests });
149
155
  } else str = `return ${runtimeTemplate.blockPromise({
150
156
  block,
151
157
  message: "",
@@ -210,7 +216,7 @@ var ContainerEntryModule = class ContainerEntryModule extends Module {
210
216
  super.serialize(context);
211
217
  }
212
218
  };
213
- makeSerializable(ContainerEntryModule, "enhanced/lib/container/ContainerEntryModule");
219
+ require_lib_makeSerializable.default(ContainerEntryModule, "enhanced/lib/container/ContainerEntryModule");
214
220
 
215
221
  //#endregion
216
222
  exports.default = ContainerEntryModule;
@@ -1 +1 @@
1
- {"version":3,"file":"ContainerEntryModule.js","names":["JAVASCRIPT_MODULE_TYPE_DYNAMIC","ContainerExposedDependency","BUILD_001","buildDescMap","logger","getFederationGlobalScope"],"sources":["../../../../src/lib/container/ContainerEntryModule.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr\n*/\n\n'use strict';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport { infrastructureLogger as logger } from '@module-federation/sdk';\nimport { buildDescMap, BUILD_001 } from '@module-federation/error-codes';\nimport { logAndReport } from '@module-federation/error-codes/node';\nimport type { Compilation, Dependency } from 'webpack';\nimport type {\n InputFileSystem,\n LibIdentOptions,\n NeedBuildContext,\n ObjectDeserializerContext,\n ObjectSerializerContext,\n RequestShortener,\n ResolverWithOptions,\n WebpackOptions,\n} from 'webpack/lib/Module';\nimport type WebpackError from 'webpack/lib/WebpackError';\nimport { JAVASCRIPT_MODULE_TYPE_DYNAMIC } from '../Constants';\nimport ContainerExposedDependency from './ContainerExposedDependency';\nimport { getFederationGlobalScope } from './runtime/utils';\n\nconst makeSerializable = require(\n normalizeWebpackPath('webpack/lib/util/makeSerializable'),\n) as typeof import('webpack/lib/util/makeSerializable');\nconst {\n sources: webpackSources,\n AsyncDependenciesBlock,\n Template,\n Module,\n RuntimeGlobals,\n} = require(normalizeWebpackPath('webpack')) as typeof import('webpack');\nconst StaticExportsDependency = require(\n normalizeWebpackPath('webpack/lib/dependencies/StaticExportsDependency'),\n) as typeof import('webpack/lib/dependencies/StaticExportsDependency');\nconst EntryDependency = require(\n normalizeWebpackPath('webpack/lib/dependencies/EntryDependency'),\n) as typeof import('webpack/lib/dependencies/EntryDependency');\n\nconst SOURCE_TYPES = new Set(['javascript']);\n\nexport type ExposeOptions = {\n /**\n * requests to exposed modules (last one is exported)\n */\n import: string[];\n /**\n * custom chunk name for the exposed module\n */\n name: string;\n};\n\nclass ContainerEntryModule extends Module {\n private _name: string;\n private _exposes: [string, ExposeOptions][];\n private _shareScope: string | string[];\n private _injectRuntimeEntry: string;\n\n /**\n * @param {string} name container entry name\n * @param {[string, ExposeOptions][]} exposes list of exposed modules\n * @param {string|string[]} shareScope name of the share scope\n * @param {string} injectRuntimeEntry the path of injectRuntime file.\n */\n constructor(\n name: string,\n exposes: [string, ExposeOptions][],\n shareScope: string | string[],\n injectRuntimeEntry: string,\n ) {\n super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null);\n this._name = name;\n this._exposes = exposes;\n this._shareScope = shareScope;\n this._injectRuntimeEntry = injectRuntimeEntry;\n }\n\n /**\n * @param {ObjectDeserializerContext} context context\n * @returns {ContainerEntryModule} deserialized container entry module\n */\n static deserialize(context: ObjectDeserializerContext): ContainerEntryModule {\n const { read } = context;\n const obj = new ContainerEntryModule(read(), read(), read(), read());\n obj.deserialize(context);\n return obj;\n }\n\n /**\n * @returns {Set<string>} types available (do not mutate)\n */\n override getSourceTypes(): Set<string> {\n return SOURCE_TYPES;\n }\n /**\n * @returns {string} a unique identifier of the module\n */\n override identifier(): string {\n const scopeStr = Array.isArray(this._shareScope)\n ? this._shareScope.join('|')\n : this._shareScope;\n\n return `container entry (${scopeStr}) ${JSON.stringify(\n this._exposes,\n )} ${this._injectRuntimeEntry}`;\n }\n /**\n * @param {RequestShortener} requestShortener the request shortener\n * @returns {string} a user readable identifier of the module\n */\n override readableIdentifier(requestShortener: RequestShortener): string {\n return 'container entry';\n }\n /**\n * @param {LibIdentOptions} options options\n * @returns {string | null} an identifier for library inclusion\n */\n override libIdent(options: LibIdentOptions): string | null {\n return `${this.layer ? `(${this.layer})/` : ''}webpack/container/entry/${\n this._name\n }`;\n }\n /**\n * @param {NeedBuildContext} context context info\n * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild\n * @returns {void}\n */\n override needBuild(\n context: NeedBuildContext,\n callback: (\n arg0: (WebpackError | null) | undefined,\n arg1: boolean | undefined,\n ) => void,\n ): void {\n callback(null, !this.buildMeta);\n }\n /**\n * @param {WebpackOptions} options webpack options\n * @param {Compilation} compilation the compilation\n * @param {ResolverWithOptions} resolver the resolver\n * @param {InputFileSystem} fs the file system\n * @param {function(WebpackError): void} callback callback function\n * @returns {void}\n */\n override build(\n options: WebpackOptions,\n compilation: Compilation,\n resolver: ResolverWithOptions,\n fs: InputFileSystem,\n callback: (err?: WebpackError) => void,\n ): void {\n this.buildMeta = {};\n this.buildInfo = {\n strict: true,\n topLevelDeclarations: new Set(['moduleMap', 'get', 'init']),\n };\n this.buildMeta.exportsType = 'namespace';\n this.clearDependenciesAndBlocks();\n\n for (const [name, options] of this._exposes) {\n const block = new AsyncDependenciesBlock(\n {\n name: options.name,\n },\n { name },\n options.import[options.import.length - 1],\n );\n let idx = 0;\n for (const request of options.import) {\n const dep = new ContainerExposedDependency(name, request);\n dep.loc = {\n name,\n index: idx++,\n };\n block.addDependency(dep);\n }\n this.addBlock(block);\n }\n this.addDependency(\n new StaticExportsDependency(\n ['get', 'init'],\n false,\n ) as unknown as Dependency,\n );\n\n this.addDependency(new EntryDependency(this._injectRuntimeEntry));\n\n callback();\n }\n\n /**\n * @param {CodeGenerationContext} context context for code generation\n * @returns {CodeGenerationResult} result\n */\n override codeGeneration({ moduleGraph, chunkGraph, runtimeTemplate }: any) {\n const sources = new Map();\n const runtimeRequirements = new Set([\n RuntimeGlobals.definePropertyGetters,\n RuntimeGlobals.hasOwnProperty,\n RuntimeGlobals.exports,\n ]);\n const getters = [];\n for (const block of this.blocks) {\n const { dependencies } = block;\n\n const modules = dependencies.map((dependency: Dependency) => {\n const dep = dependency as unknown as ContainerExposedDependency;\n return {\n name: dep.exposedName,\n module: moduleGraph.getModule(dep),\n request: dep.userRequest,\n };\n });\n\n let str;\n if (modules.some((m) => !m.module)) {\n logAndReport(\n BUILD_001,\n buildDescMap,\n {\n exposeModules: modules.filter((m) => !m.module),\n FEDERATION_WEBPACK_PATH: process.env['FEDERATION_WEBPACK_PATH'],\n },\n logger.error.bind(logger),\n undefined,\n {\n bundler: { name: 'webpack' },\n mfConfig: {\n name: this._name,\n exposes: Object.fromEntries(\n this._exposes.map(([key, opts]) => [\n key,\n opts.import[opts.import.length - 1],\n ]),\n ),\n },\n },\n );\n process.exit(1);\n } else {\n str = `return ${runtimeTemplate.blockPromise({\n block,\n message: '',\n chunkGraph,\n runtimeRequirements,\n })}.then(${runtimeTemplate.returningFunction(\n runtimeTemplate.returningFunction(\n `(${modules\n .map(({ module, request }) =>\n runtimeTemplate.moduleRaw({\n module,\n chunkGraph,\n request,\n weak: false,\n runtimeRequirements,\n }),\n )\n .join(', ')})`,\n ),\n )});`;\n }\n\n getters.push(\n `${JSON.stringify(modules[0].name)}: ${runtimeTemplate.basicFunction(\n '',\n str,\n )}`,\n );\n }\n const federationGlobal = getFederationGlobalScope(\n RuntimeGlobals || ({} as typeof RuntimeGlobals),\n );\n\n const source = Template.asString([\n `var moduleMap = {`,\n Template.indent(getters.join(',\\n')),\n '};',\n `var get = ${runtimeTemplate.basicFunction('module, getScope', [\n `${RuntimeGlobals.currentRemoteGetScope} = getScope;`,\n // reusing the getScope variable to avoid creating a new var (and module is also used later)\n 'getScope = (',\n Template.indent([\n `${RuntimeGlobals.hasOwnProperty}(moduleMap, module)`,\n Template.indent([\n '? moduleMap[module]()',\n `: Promise.resolve().then(${runtimeTemplate.basicFunction(\n '',\n \"throw new Error('Module \\\"' + module + '\\\" does not exist in container.');\",\n )})`,\n ]),\n ]),\n ');',\n `${RuntimeGlobals.currentRemoteGetScope} = undefined;`,\n 'return getScope;',\n ])};`,\n `var init = ${runtimeTemplate.basicFunction(\n 'shareScope, initScope, remoteEntryInitOptions',\n [\n `return ${federationGlobal}.bundlerRuntime.initContainerEntry({${Template.indent(\n [\n `webpackRequire: ${RuntimeGlobals.require},`,\n `shareScope: shareScope,`,\n `initScope: initScope,`,\n `remoteEntryInitOptions: remoteEntryInitOptions,`,\n `shareScopeKey: ${JSON.stringify(this._shareScope)}`,\n ],\n )}`,\n '})',\n ],\n )};`,\n '// This exports getters to disallow modifications',\n `${RuntimeGlobals.definePropertyGetters}(exports, {`,\n Template.indent([\n `get: ${runtimeTemplate.returningFunction('get')},`,\n `init: ${runtimeTemplate.returningFunction('init')}`,\n ]),\n '});',\n ]);\n\n sources.set(\n 'javascript',\n this.useSourceMap || this.useSimpleSourceMap\n ? new webpackSources.OriginalSource(source, 'webpack/container-entry')\n : new webpackSources.RawSource(source),\n );\n\n return {\n sources,\n runtimeRequirements,\n };\n }\n\n /**\n * @param {string=} type the source type for which the size should be estimated\n * @returns {number} the estimated size of the module (must be non-zero)\n */\n override size(type?: string): number {\n return 42;\n }\n /**\n * @param {ObjectSerializerContext} context context\n */\n override serialize(context: ObjectSerializerContext): void {\n const { write } = context;\n write(this._name);\n write(this._exposes);\n write(this._shareScope);\n write(this._injectRuntimeEntry);\n super.serialize(context);\n }\n}\n\nmakeSerializable(\n ContainerEntryModule,\n 'enhanced/lib/container/ContainerEntryModule',\n);\n\nexport default ContainerEntryModule;\n"],"mappings":";;;;;;;;;;;;;AA0BA,MAAM,mBAAmB,gFACF,oCAAoC,CAC1D;AAC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,CACzC;AAED,SAAO;GACL;GACA;GACD;;;;;;CAOH,AAAS,KAAK,MAAuB;AACnC,SAAO;;;;;CAKT,AAAS,UAAU,SAAwC;EACzD,MAAM,EAAE,UAAU;AAClB,QAAM,KAAK,MAAM;AACjB,QAAM,KAAK,SAAS;AACpB,QAAM,KAAK,YAAY;AACvB,QAAM,KAAK,oBAAoB;AAC/B,QAAM,UAAU,QAAQ;;;AAI5B,iBACE,sBACA,8CACD"}
1
+ {"version":3,"file":"ContainerEntryModule.js","names":["JAVASCRIPT_MODULE_TYPE_DYNAMIC","ContainerExposedDependency","BUILD_001","buildDescMap","logger","getFederationGlobalScope","makeSerializable"],"sources":["../../../../src/lib/container/ContainerEntryModule.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr\n*/\n\n'use strict';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport { infrastructureLogger as logger } from '@module-federation/sdk';\nimport { buildDescMap, BUILD_001 } from '@module-federation/error-codes';\nimport { logAndReport } from '@module-federation/error-codes/node';\nimport type { Compilation, Dependency, Module as WebpackModule } from 'webpack';\nimport type {\n InputFileSystem,\n LibIdentOptions,\n NeedBuildContext,\n ObjectDeserializerContext,\n ObjectSerializerContext,\n RequestShortener,\n ResolverWithOptions,\n WebpackOptions,\n} from 'webpack/lib/Module';\nimport type WebpackError from 'webpack/lib/WebpackError';\nimport { JAVASCRIPT_MODULE_TYPE_DYNAMIC } from '../Constants';\nimport ContainerExposedDependency from './ContainerExposedDependency';\nimport { getFederationGlobalScope } from './runtime/utils';\n\nimport makeSerializable from '../makeSerializable';\nconst {\n sources: webpackSources,\n AsyncDependenciesBlock,\n Template,\n Module,\n RuntimeGlobals,\n} = require(normalizeWebpackPath('webpack')) as typeof import('webpack');\nconst StaticExportsDependency = require(\n normalizeWebpackPath('webpack/lib/dependencies/StaticExportsDependency'),\n) as typeof import('webpack/lib/dependencies/StaticExportsDependency');\nconst EntryDependency = require(\n normalizeWebpackPath('webpack/lib/dependencies/EntryDependency'),\n) as typeof import('webpack/lib/dependencies/EntryDependency');\n\nconst SOURCE_TYPES = new Set(['javascript']);\n\nexport type ExposeOptions = {\n /**\n * requests to exposed modules (last one is exported)\n */\n import: string[];\n /**\n * custom chunk name for the exposed module\n */\n name: string;\n};\n\nclass ContainerEntryModule extends Module {\n private _name: string;\n private _exposes: [string, ExposeOptions][];\n private _shareScope: string | string[];\n private _injectRuntimeEntry: string;\n\n /**\n * @param {string} name container entry name\n * @param {[string, ExposeOptions][]} exposes list of exposed modules\n * @param {string|string[]} shareScope name of the share scope\n * @param {string} injectRuntimeEntry the path of injectRuntime file.\n */\n constructor(\n name: string,\n exposes: [string, ExposeOptions][],\n shareScope: string | string[],\n injectRuntimeEntry: string,\n ) {\n super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, null);\n this._name = name;\n this._exposes = exposes;\n this._shareScope = shareScope;\n this._injectRuntimeEntry = injectRuntimeEntry;\n }\n\n /**\n * @param {ObjectDeserializerContext} context context\n * @returns {ContainerEntryModule} deserialized container entry module\n */\n static deserialize(context: ObjectDeserializerContext): ContainerEntryModule {\n const { read } = context;\n const obj = new ContainerEntryModule(read(), read(), read(), read());\n obj.deserialize(context);\n return obj;\n }\n\n /**\n * @returns {Set<string>} types available (do not mutate)\n */\n override getSourceTypes(): Set<string> {\n return SOURCE_TYPES;\n }\n /**\n * @returns {string} a unique identifier of the module\n */\n override identifier(): string {\n const scopeStr = Array.isArray(this._shareScope)\n ? this._shareScope.join('|')\n : this._shareScope;\n\n return `container entry (${scopeStr}) ${JSON.stringify(\n this._exposes,\n )} ${this._injectRuntimeEntry}`;\n }\n /**\n * @param {RequestShortener} requestShortener the request shortener\n * @returns {string} a user readable identifier of the module\n */\n override readableIdentifier(requestShortener: RequestShortener): string {\n return 'container entry';\n }\n /**\n * @param {LibIdentOptions} options options\n * @returns {string | null} an identifier for library inclusion\n */\n override libIdent(options: LibIdentOptions): string | null {\n return `${this.layer ? `(${this.layer})/` : ''}webpack/container/entry/${\n this._name\n }`;\n }\n /**\n * @param {NeedBuildContext} context context info\n * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild\n * @returns {void}\n */\n override needBuild(\n context: NeedBuildContext,\n callback: (\n arg0: (WebpackError | null) | undefined,\n arg1: boolean | undefined,\n ) => void,\n ): void {\n callback(null, !this.buildMeta);\n }\n /**\n * @param {WebpackOptions} options webpack options\n * @param {Compilation} compilation the compilation\n * @param {ResolverWithOptions} resolver the resolver\n * @param {InputFileSystem} fs the file system\n * @param {function(WebpackError): void} callback callback function\n * @returns {void}\n */\n override build(\n options: WebpackOptions,\n compilation: Compilation,\n resolver: ResolverWithOptions,\n fs: InputFileSystem,\n callback: (err?: WebpackError) => void,\n ): void {\n this.buildMeta = {};\n this.buildInfo = {\n strict: true,\n topLevelDeclarations: new Set(['moduleMap', 'get', 'init']),\n };\n this.buildMeta.exportsType = 'namespace';\n this.clearDependenciesAndBlocks();\n\n for (const [name, options] of this._exposes) {\n const block = new AsyncDependenciesBlock(\n {\n name: options.name,\n },\n { name },\n options.import[options.import.length - 1],\n );\n let idx = 0;\n for (const request of options.import) {\n const dep = new ContainerExposedDependency(name, request);\n dep.loc = {\n name,\n index: idx++,\n };\n block.addDependency(dep);\n }\n this.addBlock(block);\n }\n this.addDependency(\n new StaticExportsDependency(\n ['get', 'init'],\n false,\n ) as unknown as Dependency,\n );\n\n this.addDependency(new EntryDependency(this._injectRuntimeEntry));\n\n callback();\n }\n\n /**\n * @param {CodeGenerationContext} context context for code generation\n * @returns {CodeGenerationResult} result\n */\n override codeGeneration({ moduleGraph, chunkGraph, runtimeTemplate }: any) {\n const sources = new Map();\n const runtimeRequirements = new Set([\n RuntimeGlobals.definePropertyGetters,\n RuntimeGlobals.hasOwnProperty,\n RuntimeGlobals.exports,\n ]);\n const getters = [];\n for (const block of this.blocks) {\n const { dependencies } = block;\n\n const modules: {\n name: string;\n module: WebpackModule | null;\n request: string;\n }[] = [];\n let missingModules: typeof modules | undefined;\n let requests = '';\n for (const dependency of dependencies) {\n const dep = dependency as unknown as ContainerExposedDependency;\n const exposedModule = {\n name: dep.exposedName,\n module: moduleGraph.getModule(dep),\n request: dep.userRequest,\n };\n modules.push(exposedModule);\n if (!exposedModule.module) {\n (missingModules ??= []).push(exposedModule);\n }\n requests += `${modules.length > 1 ? ', ' : ''}${dep.userRequest}`;\n }\n\n let str;\n if (missingModules) {\n logAndReport(\n BUILD_001,\n buildDescMap,\n {\n exposeModules: missingModules,\n FEDERATION_WEBPACK_PATH: process.env['FEDERATION_WEBPACK_PATH'],\n },\n logger.error.bind(logger),\n undefined,\n {\n bundler: { name: 'webpack' },\n mfConfig: {\n name: this._name,\n exposes: Object.fromEntries(\n this._exposes.map(([key, opts]) => [\n key,\n opts.import[opts.import.length - 1],\n ]),\n ),\n },\n },\n );\n str = runtimeTemplate.throwMissingModuleErrorBlock({\n request: requests,\n });\n } else {\n str = `return ${runtimeTemplate.blockPromise({\n block,\n message: '',\n chunkGraph,\n runtimeRequirements,\n })}.then(${runtimeTemplate.returningFunction(\n runtimeTemplate.returningFunction(\n `(${modules\n .map(({ module, request }) =>\n runtimeTemplate.moduleRaw({\n module,\n chunkGraph,\n request,\n weak: false,\n runtimeRequirements,\n }),\n )\n .join(', ')})`,\n ),\n )});`;\n }\n\n getters.push(\n `${JSON.stringify(modules[0].name)}: ${runtimeTemplate.basicFunction(\n '',\n str,\n )}`,\n );\n }\n const federationGlobal = getFederationGlobalScope(\n RuntimeGlobals || ({} as typeof RuntimeGlobals),\n );\n\n const source = Template.asString([\n `var moduleMap = {`,\n Template.indent(getters.join(',\\n')),\n '};',\n `var get = ${runtimeTemplate.basicFunction('module, getScope', [\n `${RuntimeGlobals.currentRemoteGetScope} = getScope;`,\n // reusing the getScope variable to avoid creating a new var (and module is also used later)\n 'getScope = (',\n Template.indent([\n `${RuntimeGlobals.hasOwnProperty}(moduleMap, module)`,\n Template.indent([\n '? moduleMap[module]()',\n `: Promise.resolve().then(${runtimeTemplate.basicFunction(\n '',\n \"throw new Error('Module \\\"' + module + '\\\" does not exist in container.');\",\n )})`,\n ]),\n ]),\n ');',\n `${RuntimeGlobals.currentRemoteGetScope} = undefined;`,\n 'return getScope;',\n ])};`,\n `var init = ${runtimeTemplate.basicFunction(\n 'shareScope, initScope, remoteEntryInitOptions',\n [\n `return ${federationGlobal}.bundlerRuntime.initContainerEntry({${Template.indent(\n [\n `webpackRequire: ${RuntimeGlobals.require},`,\n `shareScope: shareScope,`,\n `initScope: initScope,`,\n `remoteEntryInitOptions: remoteEntryInitOptions,`,\n `shareScopeKey: ${JSON.stringify(this._shareScope)}`,\n ],\n )}`,\n '})',\n ],\n )};`,\n '// This exports getters to disallow modifications',\n `${RuntimeGlobals.definePropertyGetters}(exports, {`,\n Template.indent([\n `get: ${runtimeTemplate.returningFunction('get')},`,\n `init: ${runtimeTemplate.returningFunction('init')}`,\n ]),\n '});',\n ]);\n\n sources.set(\n 'javascript',\n this.useSourceMap || this.useSimpleSourceMap\n ? new webpackSources.OriginalSource(source, 'webpack/container-entry')\n : new webpackSources.RawSource(source),\n );\n\n return {\n sources,\n runtimeRequirements,\n };\n }\n\n /**\n * @param {string=} type the source type for which the size should be estimated\n * @returns {number} the estimated size of the module (must be non-zero)\n */\n override size(type?: string): number {\n return 42;\n }\n /**\n * @param {ObjectSerializerContext} context context\n */\n override serialize(context: ObjectSerializerContext): void {\n const { write } = context;\n write(this._name);\n write(this._exposes);\n write(this._shareScope);\n write(this._injectRuntimeEntry);\n super.serialize(context);\n }\n}\n\nmakeSerializable(\n ContainerEntryModule,\n 'enhanced/lib/container/ContainerEntryModule',\n);\n\nexport default ContainerEntryModule;\n"],"mappings":";;;;;;;;;;;;;;AA2BA,MAAM,EACJ,SAAS,gBACT,wBACA,UACA,QACA,mBACE,gFAA6B,UAAU,CAAC;AAC5C,MAAM,0BAA0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B,IAAI,eAAe,eAAe,QAAQ,0BAA0B,GACpE,IAAI,eAAe,UAAU,OAAO,CACzC;AAED,SAAO;GACL;GACA;GACD;;;;;;CAOH,AAAS,KAAK,MAAuB;AACnC,SAAO;;;;;CAKT,AAAS,UAAU,SAAwC;EACzD,MAAM,EAAE,UAAU;AAClB,QAAM,KAAK,MAAM;AACjB,QAAM,KAAK,SAAS;AACpB,QAAM,KAAK,YAAY;AACvB,QAAM,KAAK,oBAAoB;AAC/B,QAAM,UAAU,QAAQ;;;AAI5BC,qCACE,sBACA,8CACD"}
@@ -1,9 +1,9 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
2
  const require_runtime = require('../../_virtual/_rolldown/runtime.js');
3
+ const require_lib_makeSerializable = require('../makeSerializable.js');
3
4
  let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
4
5
 
5
6
  //#region src/lib/container/ContainerExposedDependency.ts
6
- const makeSerializable = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/makeSerializable"));
7
7
  const { dependencies } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack"));
8
8
  var ContainerExposedDependency = class extends dependencies.ModuleDependency {
9
9
  /**
@@ -42,7 +42,7 @@ var ContainerExposedDependency = class extends dependencies.ModuleDependency {
42
42
  super.deserialize(context);
43
43
  }
44
44
  };
45
- makeSerializable(ContainerExposedDependency, "enhanced/lib/container/ContainerExposedDependency");
45
+ require_lib_makeSerializable.default(ContainerExposedDependency, "enhanced/lib/container/ContainerExposedDependency");
46
46
 
47
47
  //#endregion
48
48
  exports.default = ContainerExposedDependency;
@@ -1 +1 @@
1
- {"version":3,"file":"ContainerExposedDependency.js","names":[],"sources":["../../../../src/lib/container/ContainerExposedDependency.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr\n*/\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\n\nconst makeSerializable = require(\n normalizeWebpackPath('webpack/lib/util/makeSerializable'),\n) as typeof import('webpack/lib/util/makeSerializable');\nconst { dependencies } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\nimport type {\n ObjectDeserializerContext,\n ObjectSerializerContext,\n} from 'webpack/lib/dependencies/ModuleDependency';\n\nclass ContainerExposedDependency extends dependencies.ModuleDependency {\n exposedName: string;\n override request: string;\n\n /**\n * @param {string} exposedName public name\n * @param {string} request request to module\n */\n constructor(exposedName: string, request: string) {\n super(request);\n this.exposedName = exposedName;\n this.request = request;\n }\n\n override get type(): string {\n return 'container exposed';\n }\n\n override get category(): string {\n return 'esm';\n }\n\n /**\n * @returns {string | null} an identifier to merge equal requests\n */\n override getResourceIdentifier(): string | null {\n return `exposed dependency ${this.exposedName}=${this.request}`;\n }\n\n /**\n * @param {ObjectSerializerContext} context context\n */\n override serialize(context: ObjectSerializerContext): void {\n context.write(this.exposedName);\n super.serialize(context);\n }\n\n /**\n * @param {ObjectDeserializerContext} context context\n */\n override deserialize(context: ObjectDeserializerContext): void {\n this.exposedName = context.read();\n super.deserialize(context);\n }\n}\n\nmakeSerializable(\n ContainerExposedDependency,\n 'enhanced/lib/container/ContainerExposedDependency',\n);\n\nexport default ContainerExposedDependency;\n"],"mappings":";;;;;AAMA,MAAM,mBAAmB,gFACF,oCAAoC,CAC1D;AACD,MAAM,EAAE,iBAAiB,gFACF,UAAU,CAChC;AAOD,IAAM,6BAAN,cAAyC,aAAa,iBAAiB;;;;;CAQrE,YAAY,aAAqB,SAAiB;AAChD,QAAM,QAAQ;AACd,OAAK,cAAc;AACnB,OAAK,UAAU;;CAGjB,IAAa,OAAe;AAC1B,SAAO;;CAGT,IAAa,WAAmB;AAC9B,SAAO;;;;;CAMT,AAAS,wBAAuC;AAC9C,SAAO,sBAAsB,KAAK,YAAY,GAAG,KAAK;;;;;CAMxD,AAAS,UAAU,SAAwC;AACzD,UAAQ,MAAM,KAAK,YAAY;AAC/B,QAAM,UAAU,QAAQ;;;;;CAM1B,AAAS,YAAY,SAA0C;AAC7D,OAAK,cAAc,QAAQ,MAAM;AACjC,QAAM,YAAY,QAAQ;;;AAI9B,iBACE,4BACA,oDACD"}
1
+ {"version":3,"file":"ContainerExposedDependency.js","names":["makeSerializable"],"sources":["../../../../src/lib/container/ContainerExposedDependency.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr\n*/\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\n\nimport makeSerializable from '../makeSerializable';\nconst { dependencies } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\nimport type {\n ObjectDeserializerContext,\n ObjectSerializerContext,\n} from 'webpack/lib/dependencies/ModuleDependency';\n\nclass ContainerExposedDependency extends dependencies.ModuleDependency {\n exposedName: string;\n override request: string;\n\n /**\n * @param {string} exposedName public name\n * @param {string} request request to module\n */\n constructor(exposedName: string, request: string) {\n super(request);\n this.exposedName = exposedName;\n this.request = request;\n }\n\n override get type(): string {\n return 'container exposed';\n }\n\n override get category(): string {\n return 'esm';\n }\n\n /**\n * @returns {string | null} an identifier to merge equal requests\n */\n override getResourceIdentifier(): string | null {\n return `exposed dependency ${this.exposedName}=${this.request}`;\n }\n\n /**\n * @param {ObjectSerializerContext} context context\n */\n override serialize(context: ObjectSerializerContext): void {\n context.write(this.exposedName);\n super.serialize(context);\n }\n\n /**\n * @param {ObjectDeserializerContext} context context\n */\n override deserialize(context: ObjectDeserializerContext): void {\n this.exposedName = context.read();\n super.deserialize(context);\n }\n}\n\nmakeSerializable(\n ContainerExposedDependency,\n 'enhanced/lib/container/ContainerExposedDependency',\n);\n\nexport default ContainerExposedDependency;\n"],"mappings":";;;;;;AAOA,MAAM,EAAE,iBAAiB,gFACF,UAAU,CAChC;AAOD,IAAM,6BAAN,cAAyC,aAAa,iBAAiB;;;;;CAQrE,YAAY,aAAqB,SAAiB;AAChD,QAAM,QAAQ;AACd,OAAK,cAAc;AACnB,OAAK,UAAU;;CAGjB,IAAa,OAAe;AAC1B,SAAO;;CAGT,IAAa,WAAmB;AAC9B,SAAO;;;;;CAMT,AAAS,wBAAuC;AAC9C,SAAO,sBAAsB,KAAK,YAAY,GAAG,KAAK;;;;;CAMxD,AAAS,UAAU,SAAwC;AACzD,UAAQ,MAAM,KAAK,YAAY;AAC/B,QAAM,UAAU,QAAQ;;;;;CAM1B,AAAS,YAAY,SAA0C;AAC7D,OAAK,cAAc,QAAQ,MAAM;AACjC,QAAM,YAAY,QAAQ;;;AAI9BA,qCACE,4BACA,oDACD"}
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
4
  const require_runtime = require('../../_virtual/_rolldown/runtime.js');
5
+ const require_lib_makeSerializable = require('../makeSerializable.js');
5
6
  let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
6
7
 
7
8
  //#region src/lib/container/FallbackDependency.ts
8
- const makeSerializable = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/makeSerializable"));
9
9
  const { Dependency } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack"));
10
10
  var FallbackDependency = class FallbackDependency extends Dependency {
11
11
  /**
@@ -42,7 +42,7 @@ var FallbackDependency = class FallbackDependency extends Dependency {
42
42
  return obj;
43
43
  }
44
44
  };
45
- makeSerializable(FallbackDependency, "enhanced/lib/container/FallbackDependency");
45
+ require_lib_makeSerializable.default(FallbackDependency, "enhanced/lib/container/FallbackDependency");
46
46
 
47
47
  //#endregion
48
48
  exports.default = FallbackDependency;
@@ -1 +1 @@
1
- {"version":3,"file":"FallbackDependency.js","names":[],"sources":["../../../../src/lib/container/FallbackDependency.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\n\n'use strict';\n\nimport type {\n ObjectDeserializerContext,\n ObjectSerializerContext,\n} from 'webpack/lib/Dependency';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\n\nconst makeSerializable = require(\n normalizeWebpackPath('webpack/lib/util/makeSerializable'),\n);\nconst { Dependency } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\nclass FallbackDependency extends Dependency {\n requests: string[];\n\n /**\n * @param {string[]} requests requests\n */\n constructor(requests: string[]) {\n super();\n this.requests = requests;\n }\n\n /**\n * @returns {string | null} an identifier to merge equal requests\n */\n override getResourceIdentifier(): string | null {\n return `fallback ${this.requests.join(' ')}`;\n }\n\n override get type(): string {\n return 'fallback';\n }\n\n override get category(): string {\n return 'esm';\n }\n\n /**\n * @param {ObjectSerializerContext} context context\n */\n override serialize(context: ObjectSerializerContext): void {\n const { write } = context;\n write(this.requests);\n super.serialize(context);\n }\n\n static deserialize(context: ObjectDeserializerContext): FallbackDependency {\n const { read } = context;\n const obj = new FallbackDependency(read());\n obj.deserialize(context);\n return obj;\n }\n}\n\nmakeSerializable(\n FallbackDependency,\n 'enhanced/lib/container/FallbackDependency',\n);\n\nexport default FallbackDependency;\n"],"mappings":";;;;;;;AAaA,MAAM,mBAAmB,gFACF,oCAAoC,CAC1D;AACD,MAAM,EAAE,eAAe,gFACA,UAAU,CAChC;AAED,IAAM,qBAAN,MAAM,2BAA2B,WAAW;;;;CAM1C,YAAY,UAAoB;AAC9B,SAAO;AACP,OAAK,WAAW;;;;;CAMlB,AAAS,wBAAuC;AAC9C,SAAO,YAAY,KAAK,SAAS,KAAK,IAAI;;CAG5C,IAAa,OAAe;AAC1B,SAAO;;CAGT,IAAa,WAAmB;AAC9B,SAAO;;;;;CAMT,AAAS,UAAU,SAAwC;EACzD,MAAM,EAAE,UAAU;AAClB,QAAM,KAAK,SAAS;AACpB,QAAM,UAAU,QAAQ;;CAG1B,OAAO,YAAY,SAAwD;EACzE,MAAM,EAAE,SAAS;EACjB,MAAM,MAAM,IAAI,mBAAmB,MAAM,CAAC;AAC1C,MAAI,YAAY,QAAQ;AACxB,SAAO;;;AAIX,iBACE,oBACA,4CACD"}
1
+ {"version":3,"file":"FallbackDependency.js","names":["makeSerializable"],"sources":["../../../../src/lib/container/FallbackDependency.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\n\n'use strict';\n\nimport type {\n ObjectDeserializerContext,\n ObjectSerializerContext,\n} from 'webpack/lib/Dependency';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\n\nimport makeSerializable from '../makeSerializable';\nconst { Dependency } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\nclass FallbackDependency extends Dependency {\n requests: string[];\n\n /**\n * @param {string[]} requests requests\n */\n constructor(requests: string[]) {\n super();\n this.requests = requests;\n }\n\n /**\n * @returns {string | null} an identifier to merge equal requests\n */\n override getResourceIdentifier(): string | null {\n return `fallback ${this.requests.join(' ')}`;\n }\n\n override get type(): string {\n return 'fallback';\n }\n\n override get category(): string {\n return 'esm';\n }\n\n /**\n * @param {ObjectSerializerContext} context context\n */\n override serialize(context: ObjectSerializerContext): void {\n const { write } = context;\n write(this.requests);\n super.serialize(context);\n }\n\n static deserialize(context: ObjectDeserializerContext): FallbackDependency {\n const { read } = context;\n const obj = new FallbackDependency(read());\n obj.deserialize(context);\n return obj;\n }\n}\n\nmakeSerializable(\n FallbackDependency,\n 'enhanced/lib/container/FallbackDependency',\n);\n\nexport default FallbackDependency;\n"],"mappings":";;;;;;;;AAcA,MAAM,EAAE,eAAe,gFACA,UAAU,CAChC;AAED,IAAM,qBAAN,MAAM,2BAA2B,WAAW;;;;CAM1C,YAAY,UAAoB;AAC9B,SAAO;AACP,OAAK,WAAW;;;;;CAMlB,AAAS,wBAAuC;AAC9C,SAAO,YAAY,KAAK,SAAS,KAAK,IAAI;;CAG5C,IAAa,OAAe;AAC1B,SAAO;;CAGT,IAAa,WAAmB;AAC9B,SAAO;;;;;CAMT,AAAS,UAAU,SAAwC;EACzD,MAAM,EAAE,UAAU;AAClB,QAAM,KAAK,SAAS;AACpB,QAAM,UAAU,QAAQ;;CAG1B,OAAO,YAAY,SAAwD;EACzE,MAAM,EAAE,SAAS;EACjB,MAAM,MAAM,IAAI,mBAAmB,MAAM,CAAC;AAC1C,MAAI,YAAY,QAAQ;AACxB,SAAO;;;AAIXA,qCACE,oBACA,4CACD"}
@@ -1,9 +1,9 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
2
  const require_runtime = require('../../_virtual/_rolldown/runtime.js');
3
+ const require_lib_makeSerializable = require('../makeSerializable.js');
3
4
  let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
4
5
 
5
6
  //#region src/lib/container/FallbackItemDependency.ts
6
- const makeSerializable = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/makeSerializable"));
7
7
  const { dependencies } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack"));
8
8
  var FallbackItemDependency = class extends dependencies.ModuleDependency {
9
9
  /**
@@ -19,7 +19,7 @@ var FallbackItemDependency = class extends dependencies.ModuleDependency {
19
19
  return "esm";
20
20
  }
21
21
  };
22
- makeSerializable(FallbackItemDependency, "enhanced/lib/container/FallbackItemDependency");
22
+ require_lib_makeSerializable.default(FallbackItemDependency, "enhanced/lib/container/FallbackItemDependency");
23
23
 
24
24
  //#endregion
25
25
  exports.default = FallbackItemDependency;
@@ -1 +1 @@
1
- {"version":3,"file":"FallbackItemDependency.js","names":[],"sources":["../../../../src/lib/container/FallbackItemDependency.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\n\nconst makeSerializable = require(\n normalizeWebpackPath('webpack/lib/util/makeSerializable'),\n) as typeof import('webpack/lib/util/makeSerializable');\nconst { dependencies } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\nclass FallbackItemDependency extends dependencies.ModuleDependency {\n /**\n * @param {string} request request\n */\n constructor(request: string) {\n super(request);\n }\n\n override get type(): string {\n return 'fallback item';\n }\n\n override get category(): string {\n return 'esm';\n }\n}\n\nmakeSerializable(\n FallbackItemDependency,\n 'enhanced/lib/container/FallbackItemDependency',\n);\n\nexport default FallbackItemDependency;\n"],"mappings":";;;;;AAMA,MAAM,mBAAmB,gFACF,oCAAoC,CAC1D;AACD,MAAM,EAAE,iBAAiB,gFACF,UAAU,CAChC;AAED,IAAM,yBAAN,cAAqC,aAAa,iBAAiB;;;;CAIjE,YAAY,SAAiB;AAC3B,QAAM,QAAQ;;CAGhB,IAAa,OAAe;AAC1B,SAAO;;CAGT,IAAa,WAAmB;AAC9B,SAAO;;;AAIX,iBACE,wBACA,gDACD"}
1
+ {"version":3,"file":"FallbackItemDependency.js","names":["makeSerializable"],"sources":["../../../../src/lib/container/FallbackItemDependency.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\n\nimport makeSerializable from '../makeSerializable';\nconst { dependencies } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\nclass FallbackItemDependency extends dependencies.ModuleDependency {\n /**\n * @param {string} request request\n */\n constructor(request: string) {\n super(request);\n }\n\n override get type(): string {\n return 'fallback item';\n }\n\n override get category(): string {\n return 'esm';\n }\n}\n\nmakeSerializable(\n FallbackItemDependency,\n 'enhanced/lib/container/FallbackItemDependency',\n);\n\nexport default FallbackItemDependency;\n"],"mappings":";;;;;;AAOA,MAAM,EAAE,iBAAiB,gFACF,UAAU,CAChC;AAED,IAAM,yBAAN,cAAqC,aAAa,iBAAiB;;;;CAIjE,YAAY,SAAiB;AAC3B,QAAM,QAAQ;;CAGhB,IAAa,OAAe;AAC1B,SAAO;;CAGT,IAAa,WAAmB;AAC9B,SAAO;;;AAIXA,qCACE,wBACA,gDACD"}
@@ -3,13 +3,13 @@
3
3
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
4
4
  const require_runtime = require('../../_virtual/_rolldown/runtime.js');
5
5
  const require_lib_Constants = require('../Constants.js');
6
+ const require_lib_makeSerializable = require('../makeSerializable.js');
6
7
  const require_lib_container_FallbackItemDependency = require('./FallbackItemDependency.js');
7
8
  let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
8
9
 
9
10
  //#region src/lib/container/FallbackModule.ts
10
11
  const { sources: webpackSources } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack"));
11
12
  const { Template, Module, RuntimeGlobals } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack"));
12
- const makeSerializable = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/makeSerializable"));
13
13
  const TYPES = new Set(["javascript"]);
14
14
  const RUNTIME_REQUIREMENTS = new Set([RuntimeGlobals.module]);
15
15
  var FallbackModule = class FallbackModule extends Module {
@@ -130,7 +130,7 @@ var FallbackModule = class FallbackModule extends Module {
130
130
  return obj;
131
131
  }
132
132
  };
133
- makeSerializable(FallbackModule, "enhanced/lib/container/FallbackModule");
133
+ require_lib_makeSerializable.default(FallbackModule, "enhanced/lib/container/FallbackModule");
134
134
 
135
135
  //#endregion
136
136
  exports.default = FallbackModule;
@@ -1 +1 @@
1
- {"version":3,"file":"FallbackModule.js","names":["WEBPACK_MODULE_TYPE_FALLBACK","FallbackItemDependency"],"sources":["../../../../src/lib/container/FallbackModule.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra and Zackary Jackson @ScriptedAlchemy\n*/\n\n'use strict';\n\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport type { Chunk, ChunkGraph } from 'webpack';\nimport type {\n CodeGenerationContext,\n CodeGenerationResult,\n Compilation,\n InputFileSystem,\n LibIdentOptions,\n NeedBuildContext,\n ObjectDeserializerContext,\n ObjectSerializerContext,\n RequestShortener,\n ResolverWithOptions,\n WebpackError,\n WebpackOptions,\n} from 'webpack/lib/Module';\nimport { WEBPACK_MODULE_TYPE_FALLBACK } from '../Constants';\nimport FallbackItemDependency from './FallbackItemDependency';\n\nconst { sources: webpackSources } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nconst { Template, Module, RuntimeGlobals } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nconst makeSerializable = require(\n normalizeWebpackPath('webpack/lib/util/makeSerializable'),\n) as typeof import('webpack/lib/util/makeSerializable');\n\nconst TYPES = new Set(['javascript']);\nconst RUNTIME_REQUIREMENTS = new Set([RuntimeGlobals.module]);\n\nclass FallbackModule extends Module {\n public requests: string[];\n private _identifier: string;\n\n /**\n * @param {string[]} requests list of requests to choose one\n */\n constructor(requests: string[]) {\n super(WEBPACK_MODULE_TYPE_FALLBACK);\n this.requests = requests;\n this._identifier = `fallback ${this.requests.join(' ')}`;\n }\n\n /**\n * @returns {string} a unique identifier of the module\n */\n override identifier(): string {\n return this._identifier;\n }\n\n /**\n * @param {RequestShortener} requestShortener the request shortener\n * @returns {string} a user readable identifier of the module\n */\n override readableIdentifier(requestShortener: RequestShortener): string {\n return this._identifier;\n }\n\n /**\n * @param {LibIdentOptions} options options\n * @returns {string | null} an identifier for library inclusion\n */\n override libIdent(options: LibIdentOptions): string | null {\n return `${this.layer ? `(${this.layer})/` : ''}webpack/container/fallback/${\n this.requests[0]\n }/and ${this.requests.length - 1} more`;\n }\n\n /**\n * @param {Chunk} chunk the chunk which condition should be checked\n * @param {Compilation} compilation the compilation\n * @returns {boolean} true, if the chunk is ok for the module\n */\n override chunkCondition(\n chunk: Chunk,\n { chunkGraph }: { chunkGraph: ChunkGraph },\n ): boolean {\n return chunkGraph.getNumberOfEntryModules(chunk) > 0;\n }\n\n /**\n * @param {NeedBuildContext} context context info\n * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild\n * @returns {void}\n */\n override needBuild(\n context: NeedBuildContext,\n callback: (error: WebpackError | null, result?: boolean) => void,\n ): void {\n callback(null, !this.buildInfo);\n }\n\n /**\n * @param {WebpackOptions} options webpack options\n * @param {Compilation} compilation the compilation\n * @param {ResolverWithOptions} resolver the resolver\n * @param {InputFileSystem} fs the file system\n * @param {function(WebpackError=): void} callback callback function\n * @returns {void}\n */\n override build(\n options: WebpackOptions,\n compilation: Compilation,\n resolver: ResolverWithOptions,\n fs: InputFileSystem,\n callback: (error?: WebpackError) => void,\n ): void {\n this.buildMeta = {};\n this.buildInfo = {\n strict: true,\n };\n\n this.clearDependenciesAndBlocks();\n for (const request of this.requests)\n this.addDependency(new FallbackItemDependency(request));\n\n callback();\n }\n\n /**\n * @param {string=} type the source type for which the size should be estimated\n * @returns {number} the estimated size of the module (must be non-zero)\n */\n override size(type?: string): number {\n return this.requests.length * 5 + 42;\n }\n\n /**\n * @returns {Set<string>} types available (do not mutate)\n */\n override getSourceTypes(): Set<string> {\n return TYPES;\n }\n\n /**\n * @param {CodeGenerationContext} context context for code generation\n * @returns {CodeGenerationResult} result\n */\n override codeGeneration({\n runtimeTemplate,\n moduleGraph,\n chunkGraph,\n }: CodeGenerationContext): CodeGenerationResult {\n const ids = this.dependencies.map((dep) =>\n // @ts-expect-error incompatible dependency type\n chunkGraph.getModuleId(moduleGraph.getModule(dep)),\n );\n const code = Template.asString([\n `var ids = ${JSON.stringify(ids)};`,\n 'var error, result, i = 0;',\n `var loop = ${runtimeTemplate.basicFunction('next', [\n 'while(i < ids.length) {',\n Template.indent([\n `try { next = ${RuntimeGlobals.require}(ids[i++]); } catch(e) { return handleError(e); }`,\n 'if(next) return next.then ? next.then(handleResult, handleError) : handleResult(next);',\n ]),\n '}',\n 'if(error) throw error;',\n ])}`,\n `var handleResult = ${runtimeTemplate.basicFunction('result', [\n 'if(result) return result;',\n 'return loop();',\n ])};`,\n `var handleError = ${runtimeTemplate.basicFunction('e', [\n 'error = e;',\n 'return loop();',\n ])};`,\n 'module.exports = loop();',\n ]);\n const sources = new Map();\n sources.set('javascript', new webpackSources.RawSource(code));\n return { sources, runtimeRequirements: RUNTIME_REQUIREMENTS };\n }\n\n /**\n * @param {ObjectSerializerContext} context context\n */\n override serialize(context: ObjectSerializerContext): void {\n const { write } = context;\n write(this.requests);\n super.serialize(context);\n }\n\n /**\n * @param {ObjectDeserializerContext} context context\n * @returns {FallbackModule} deserialized fallback module\n */\n static deserialize(context: ObjectDeserializerContext): FallbackModule {\n const { read } = context;\n const obj = new FallbackModule(read());\n obj.deserialize(context);\n return obj;\n }\n}\n\nmakeSerializable(FallbackModule, 'enhanced/lib/container/FallbackModule');\n\nexport default FallbackModule;\n"],"mappings":";;;;;;;;;AA0BA,MAAM,EAAE,SAAS,mBAAmB,gFACb,UAAU,CAChC;AACD,MAAM,EAAE,UAAU,QAAQ,mBAAmB,gFACtB,UAAU,CAChC;AACD,MAAM,mBAAmB,gFACF,oCAAoC,CAC1D;AAED,MAAM,QAAQ,IAAI,IAAI,CAAC,aAAa,CAAC;AACrC,MAAM,uBAAuB,IAAI,IAAI,CAAC,eAAe,OAAO,CAAC;AAE7D,IAAM,iBAAN,MAAM,uBAAuB,OAAO;;;;CAOlC,YAAY,UAAoB;AAC9B,QAAMA,mDAA6B;AACnC,OAAK,WAAW;AAChB,OAAK,cAAc,YAAY,KAAK,SA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KAAK;AACzB,UAAQ,IAAI,cAAc,IAAI,eAAe,UAAU,KAAK,CAAC;AAC7D,SAAO;GAAE;GAAS,qBAAqB;GAAsB;;;;;CAM/D,AAAS,UAAU,SAAwC;EACzD,MAAM,EAAE,UAAU;AAClB,QAAM,KAAK,SAAS;AACpB,QAAM,UAAU,QAAQ;;;;;;CAO1B,OAAO,YAAY,SAAoD;EACrE,MAAM,EAAE,SAAS;EACjB,MAAM,MAAM,IAAI,eAAe,MAAM,CAAC;AACtC,MAAI,YAAY,QAAQ;AACxB,SAAO;;;AAIX,iBAAiB,gBAAgB,wCAAwC"}
1
+ {"version":3,"file":"FallbackModule.js","names":["WEBPACK_MODULE_TYPE_FALLBACK","FallbackItemDependency","makeSerializable"],"sources":["../../../../src/lib/container/FallbackModule.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra and Zackary Jackson @ScriptedAlchemy\n*/\n\n'use strict';\n\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport type { Chunk, ChunkGraph } from 'webpack';\nimport type {\n CodeGenerationContext,\n CodeGenerationResult,\n Compilation,\n InputFileSystem,\n LibIdentOptions,\n NeedBuildContext,\n ObjectDeserializerContext,\n ObjectSerializerContext,\n RequestShortener,\n ResolverWithOptions,\n WebpackError,\n WebpackOptions,\n} from 'webpack/lib/Module';\nimport { WEBPACK_MODULE_TYPE_FALLBACK } from '../Constants';\nimport FallbackItemDependency from './FallbackItemDependency';\n\nconst { sources: webpackSources } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nconst { Template, Module, RuntimeGlobals } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nimport makeSerializable from '../makeSerializable';\n\nconst TYPES = new Set(['javascript']);\nconst RUNTIME_REQUIREMENTS = new Set([RuntimeGlobals.module]);\n\nclass FallbackModule extends Module {\n public requests: string[];\n private _identifier: string;\n\n /**\n * @param {string[]} requests list of requests to choose one\n */\n constructor(requests: string[]) {\n super(WEBPACK_MODULE_TYPE_FALLBACK);\n this.requests = requests;\n this._identifier = `fallback ${this.requests.join(' ')}`;\n }\n\n /**\n * @returns {string} a unique identifier of the module\n */\n override identifier(): string {\n return this._identifier;\n }\n\n /**\n * @param {RequestShortener} requestShortener the request shortener\n * @returns {string} a user readable identifier of the module\n */\n override readableIdentifier(requestShortener: RequestShortener): string {\n return this._identifier;\n }\n\n /**\n * @param {LibIdentOptions} options options\n * @returns {string | null} an identifier for library inclusion\n */\n override libIdent(options: LibIdentOptions): string | null {\n return `${this.layer ? `(${this.layer})/` : ''}webpack/container/fallback/${\n this.requests[0]\n }/and ${this.requests.length - 1} more`;\n }\n\n /**\n * @param {Chunk} chunk the chunk which condition should be checked\n * @param {Compilation} compilation the compilation\n * @returns {boolean} true, if the chunk is ok for the module\n */\n override chunkCondition(\n chunk: Chunk,\n { chunkGraph }: { chunkGraph: ChunkGraph },\n ): boolean {\n return chunkGraph.getNumberOfEntryModules(chunk) > 0;\n }\n\n /**\n * @param {NeedBuildContext} context context info\n * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild\n * @returns {void}\n */\n override needBuild(\n context: NeedBuildContext,\n callback: (error: WebpackError | null, result?: boolean) => void,\n ): void {\n callback(null, !this.buildInfo);\n }\n\n /**\n * @param {WebpackOptions} options webpack options\n * @param {Compilation} compilation the compilation\n * @param {ResolverWithOptions} resolver the resolver\n * @param {InputFileSystem} fs the file system\n * @param {function(WebpackError=): void} callback callback function\n * @returns {void}\n */\n override build(\n options: WebpackOptions,\n compilation: Compilation,\n resolver: ResolverWithOptions,\n fs: InputFileSystem,\n callback: (error?: WebpackError) => void,\n ): void {\n this.buildMeta = {};\n this.buildInfo = {\n strict: true,\n };\n\n this.clearDependenciesAndBlocks();\n for (const request of this.requests)\n this.addDependency(new FallbackItemDependency(request));\n\n callback();\n }\n\n /**\n * @param {string=} type the source type for which the size should be estimated\n * @returns {number} the estimated size of the module (must be non-zero)\n */\n override size(type?: string): number {\n return this.requests.length * 5 + 42;\n }\n\n /**\n * @returns {Set<string>} types available (do not mutate)\n */\n override getSourceTypes(): Set<string> {\n return TYPES;\n }\n\n /**\n * @param {CodeGenerationContext} context context for code generation\n * @returns {CodeGenerationResult} result\n */\n override codeGeneration({\n runtimeTemplate,\n moduleGraph,\n chunkGraph,\n }: CodeGenerationContext): CodeGenerationResult {\n const ids = this.dependencies.map((dep) =>\n // @ts-expect-error incompatible dependency type\n chunkGraph.getModuleId(moduleGraph.getModule(dep)),\n );\n const code = Template.asString([\n `var ids = ${JSON.stringify(ids)};`,\n 'var error, result, i = 0;',\n `var loop = ${runtimeTemplate.basicFunction('next', [\n 'while(i < ids.length) {',\n Template.indent([\n `try { next = ${RuntimeGlobals.require}(ids[i++]); } catch(e) { return handleError(e); }`,\n 'if(next) return next.then ? next.then(handleResult, handleError) : handleResult(next);',\n ]),\n '}',\n 'if(error) throw error;',\n ])}`,\n `var handleResult = ${runtimeTemplate.basicFunction('result', [\n 'if(result) return result;',\n 'return loop();',\n ])};`,\n `var handleError = ${runtimeTemplate.basicFunction('e', [\n 'error = e;',\n 'return loop();',\n ])};`,\n 'module.exports = loop();',\n ]);\n const sources = new Map();\n sources.set('javascript', new webpackSources.RawSource(code));\n return { sources, runtimeRequirements: RUNTIME_REQUIREMENTS };\n }\n\n /**\n * @param {ObjectSerializerContext} context context\n */\n override serialize(context: ObjectSerializerContext): void {\n const { write } = context;\n write(this.requests);\n super.serialize(context);\n }\n\n /**\n * @param {ObjectDeserializerContext} context context\n * @returns {FallbackModule} deserialized fallback module\n */\n static deserialize(context: ObjectDeserializerContext): FallbackModule {\n const { read } = context;\n const obj = new FallbackModule(read());\n obj.deserialize(context);\n return obj;\n }\n}\n\nmakeSerializable(FallbackModule, 'enhanced/lib/container/FallbackModule');\n\nexport default FallbackModule;\n"],"mappings":";;;;;;;;;;AA0BA,MAAM,EAAE,SAAS,mBAAmB,gFACb,UAAU,CAChC;AACD,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C;GACjC;GACA,cAAc,gBAAgB,cAAc,QAAQ;IAClD;IACA,SAAS,OAAO,CACd,gBAAgB,eAAe,QAAQ,oDACvC,yFACD,CAAC;IACF;IACA;IACD,CAAC;GACF,sBAAsB,gBAAgB,cAAc,UAAU,CAC5D,6BACA,iBACD,CAAC,CAAC;GACH,qBAAqB,gBAAgB,cAAc,KAAK,CACtD,cACA,iBACD,CAAC,CAAC;GACH;GACD,CAAC;EACF,MAAM,0BAAU,IAAI,KAAK;AACzB,UAAQ,IAAI,cAAc,IAAI,eAAe,UAAU,KAAK,CAAC;AAC7D,SAAO;GAAE;GAAS,qBAAqB;GAAsB;;;;;CAM/D,AAAS,UAAU,SAAwC;EACzD,MAAM,EAAE,UAAU;AAClB,QAAM,KAAK,SAAS;AACpB,QAAM,UAAU,QAAQ;;;;;;CAO1B,OAAO,YAAY,SAAoD;EACrE,MAAM,EAAE,SAAS;EACjB,MAAM,MAAM,IAAI,eAAe,MAAM,CAAC;AACtC,MAAI,YAAY,QAAQ;AACxB,SAAO;;;AAIXC,qCAAiB,gBAAgB,wCAAwC"}
@@ -110,6 +110,7 @@ function getAllReferencedModules(compilation, module, type) {
110
110
  for (const connection of mgm.outgoingConnections) {
111
111
  const connectedModule = connection.module;
112
112
  if (!connectedModule || visitedModules.has(connectedModule)) continue;
113
+ if (connection.getActiveState(void 0) === false) continue;
113
114
  if (type === "initial") {
114
115
  if (compilation.moduleGraph.getParentBlock(connection.dependency) instanceof AsyncDependenciesBlock) continue;
115
116
  }
@@ -1 +1 @@
1
- {"version":3,"file":"HoistContainerReferencesPlugin.js","names":["FederationModulesPlugin"],"sources":["../../../../src/lib/container/HoistContainerReferencesPlugin.ts"],"sourcesContent":["import type {\n Chunk,\n Compiler,\n Compilation,\n WebpackPluginInstance,\n Module,\n Dependency,\n} from 'webpack';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport FederationModulesPlugin from './runtime/FederationModulesPlugin';\nimport ContainerEntryDependency from './ContainerEntryDependency';\nimport FederationRuntimeDependency from './runtime/FederationRuntimeDependency';\nimport RemoteToExternalDependency from './RemoteToExternalDependency';\nimport FallbackDependency from './FallbackDependency';\n\nconst { AsyncDependenciesBlock, ExternalModule } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\nconst PLUGIN_NAME = 'HoistContainerReferences';\n\n/**\n * This plugin hoists container-related modules into runtime chunks when using runtimeChunk: single configuration.\n */\nclass HoistContainerReferences implements WebpackPluginInstance {\n apply(compiler: Compiler): void {\n compiler.hooks.thisCompilation.tap(\n PLUGIN_NAME,\n (compilation: Compilation) => {\n const logger = compilation.getLogger(PLUGIN_NAME);\n const hooks = FederationModulesPlugin.getCompilationHooks(compilation);\n const containerEntryDependencies = new Set<Dependency>();\n const federationRuntimeDependencies = new Set<Dependency>();\n const remoteDependencies = new Set<Dependency>();\n\n hooks.addContainerEntryDependency.tap(\n 'HoistContainerReferences',\n (dep: ContainerEntryDependency) => {\n containerEntryDependencies.add(dep);\n },\n );\n hooks.addFederationRuntimeDependency.tap(\n 'HoistContainerReferences',\n (dep: FederationRuntimeDependency) => {\n federationRuntimeDependencies.add(dep);\n },\n );\n hooks.addRemoteDependency.tap(\n 'HoistContainerReferences',\n (dep: RemoteToExternalDependency | FallbackDependency) => {\n remoteDependencies.add(dep);\n },\n );\n\n // Hook into the optimizeChunks phase\n compilation.hooks.optimizeChunks.tap(\n {\n name: PLUGIN_NAME,\n // advanced stage is where SplitChunksPlugin runs.\n stage: 11, // advanced + 1\n },\n (chunks: Iterable<Chunk>) => {\n const runtimeChunks = this.getRuntimeChunks(compilation);\n this.hoistModulesInChunks(\n compilation,\n runtimeChunks,\n logger,\n containerEntryDependencies,\n federationRuntimeDependencies,\n remoteDependencies,\n );\n },\n );\n },\n );\n }\n\n // Method to hoist modules in chunks\n private hoistModulesInChunks(\n compilation: Compilation,\n runtimeChunks: Set<Chunk>,\n logger: ReturnType<Compilation['getLogger']>,\n containerEntryDependencies: Set<Dependency>,\n federationRuntimeDependencies: Set<Dependency>,\n remoteDependencies: Set<Dependency>,\n ): void {\n const { chunkGraph, moduleGraph } = compilation;\n const allModulesToHoist = new Set<Module>();\n\n // Process container entry dependencies (needed for nextjs-mf exposed modules)\n for (const dep of containerEntryDependencies) {\n const containerEntryModule = moduleGraph.getModule(dep);\n if (!containerEntryModule) continue;\n const referencedModules = getAllReferencedModules(\n compilation,\n containerEntryModule,\n 'initial',\n );\n referencedModules.forEach((m: Module) => allModulesToHoist.add(m));\n const moduleRuntimes = chunkGraph.getModuleRuntimes(containerEntryModule);\n const runtimes = new Set<string>();\n for (const runtimeSpec of moduleRuntimes) {\n compilation.compiler.webpack.util.runtime.forEachRuntime(\n runtimeSpec,\n (runtimeKey) => {\n if (runtimeKey) {\n runtimes.add(runtimeKey);\n }\n },\n );\n }\n for (const runtime of runtimes) {\n const runtimeChunk = compilation.namedChunks.get(runtime);\n if (!runtimeChunk) continue;\n for (const module of referencedModules) {\n if (!chunkGraph.isModuleInChunk(module, runtimeChunk)) {\n chunkGraph.connectChunkAndModule(runtimeChunk, module);\n }\n }\n }\n }\n\n // Federation Runtime Dependencies: use 'initial' (not 'all')\n for (const dep of federationRuntimeDependencies) {\n const runtimeModule = moduleGraph.getModule(dep);\n if (!runtimeModule) continue;\n const referencedModules = getAllReferencedModules(\n compilation,\n runtimeModule,\n 'initial',\n );\n referencedModules.forEach((m: Module) => allModulesToHoist.add(m));\n const moduleRuntimes = chunkGraph.getModuleRuntimes(runtimeModule);\n const runtimes = new Set<string>();\n for (const runtimeSpec of moduleRuntimes) {\n compilation.compiler.webpack.util.runtime.forEachRuntime(\n runtimeSpec,\n (runtimeKey) => {\n if (runtimeKey) {\n runtimes.add(runtimeKey);\n }\n },\n );\n }\n for (const runtime of runtimes) {\n const runtimeChunk = compilation.namedChunks.get(runtime);\n if (!runtimeChunk) continue;\n for (const module of referencedModules) {\n if (!chunkGraph.isModuleInChunk(module, runtimeChunk)) {\n chunkGraph.connectChunkAndModule(runtimeChunk, module);\n }\n }\n }\n }\n\n // Process remote dependencies\n for (const remoteDep of remoteDependencies) {\n const remoteModule = moduleGraph.getModule(remoteDep);\n if (!remoteModule) continue;\n const referencedRemoteModules = getAllReferencedModules(\n compilation,\n remoteModule,\n 'initial',\n );\n referencedRemoteModules.forEach((m: Module) => allModulesToHoist.add(m));\n const remoteModuleRuntimes = chunkGraph.getModuleRuntimes(remoteModule);\n const remoteRuntimes = new Set<string>();\n for (const runtimeSpec of remoteModuleRuntimes) {\n compilation.compiler.webpack.util.runtime.forEachRuntime(\n runtimeSpec,\n (runtimeKey) => {\n if (runtimeKey) remoteRuntimes.add(runtimeKey);\n },\n );\n }\n for (const runtime of remoteRuntimes) {\n const runtimeChunk = compilation.namedChunks.get(runtime);\n if (!runtimeChunk) continue;\n for (const module of referencedRemoteModules) {\n if (!chunkGraph.isModuleInChunk(module, runtimeChunk)) {\n chunkGraph.connectChunkAndModule(runtimeChunk, module);\n }\n }\n }\n }\n\n this.cleanUpChunks(compilation, allModulesToHoist);\n }\n\n // Method to clean up chunks by disconnecting unused modules\n private cleanUpChunks(compilation: Compilation, modules: Set<Module>): void {\n const { chunkGraph } = compilation;\n for (const module of modules) {\n for (const chunk of chunkGraph.getModuleChunks(module)) {\n if (!chunk.hasRuntime()) {\n chunkGraph.disconnectChunkAndModule(chunk, module);\n }\n }\n }\n }\n\n // Method to get runtime chunks\n private getRuntimeChunks(compilation: Compilation): Set<Chunk> {\n const runtimeChunks = new Set<Chunk>();\n for (const chunk of compilation.chunks) {\n if (chunk.hasRuntime()) {\n runtimeChunks.add(chunk);\n }\n }\n return runtimeChunks;\n }\n}\n\n// Helper method to collect all referenced modules recursively\nexport function getAllReferencedModules(\n compilation: Compilation,\n module: Module,\n type?: 'all' | 'initial' | 'external',\n): Set<Module> {\n const collectedModules = new Set<Module>([module]);\n const visitedModules = new WeakSet<Module>([module]);\n const stack = [module];\n\n while (stack.length > 0) {\n const currentModule = stack.pop();\n if (!currentModule) continue;\n\n const mgm = compilation.moduleGraph._getModuleGraphModule(currentModule);\n if (!mgm?.outgoingConnections) continue;\n for (const connection of mgm.outgoingConnections) {\n const connectedModule = connection.module;\n\n // Skip if module has already been visited\n if (!connectedModule || visitedModules.has(connectedModule)) {\n continue;\n }\n\n // Handle 'initial' type (skipping async blocks)\n if (type === 'initial') {\n const parentBlock = compilation.moduleGraph.getParentBlock(\n connection.dependency,\n );\n if (parentBlock instanceof AsyncDependenciesBlock) {\n continue;\n }\n }\n\n // Handle 'external' type (collecting only external modules)\n if (type === 'external') {\n if (connection.module instanceof ExternalModule) {\n collectedModules.add(connectedModule);\n }\n } else {\n // Handle 'all' or unspecified types\n collectedModules.add(connectedModule);\n }\n\n // Add connected module to the stack and mark it as visited\n visitedModules.add(connectedModule);\n stack.push(connectedModule);\n }\n }\n\n return collectedModules;\n}\n\nexport default HoistContainerReferences;\n"],"mappings":";;;;;;AAeA,MAAM,EAAE,wBAAwB,mBAAmB,gFAC5B,UAAU,CAChC;AAED,MAAM,cAAc;;;;AAKpB,IAAM,2BAAN,MAAgE;CAC9D,MAAM,UAA0B;AAC9B,WAAS,MAAM,gBAAgB,IAC7B,cACC,gBAA6B;GAC5B,MAAM,SAAS,YAAY,UAAU,YAAY;GACjD,MAAM,QAAQA,8DAAwB,oBAAoB,YAAY;GACtE,MAAM,6CAA6B,IAAI,KAAiB;GACxD,MAAM,gDAAgC,IAAI,KAAiB;GAC3D,MAAM,qCAAqB,IAAI,KAAiB;AAEhD,SAAM,4BAA4B,IAChC,6BACC,QAAkC;AACjC,+BAA2B,IAAI,IAAI;KAEtC;AACD,SAAM,+BAA+B,IACnC,6BACC,QAAqC;AACpC,kCAA8B,IAAI,IAAI;KAEzC;AACD,SAAM,oBAAoB,IACxB,6BACC,QAAyD;AACxD,uBAAmB,IAAI,IAAI;KAE9B;AAGD,eAAY,MAAM,eAAe,IAC/B;IACE,MAAM;IAEN,OAAO;IACR,GACA,WAA4B;IAC3B,MAAM,gBAAgB,KAAK,iBAA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QAAgB,CAAC,OAAO,CAAC;CACpD,MAAM,QAAQ,CAAC,OAAO;AAEtB,QAAO,MAAM,SAAS,GAAG;EACvB,MAAM,gBAAgB,MAAM,KAAK;AACjC,MAAI,CAAC,cAAe;EAEpB,MAAM,MAAM,YAAY,YAAY,sBAAsB,cAAc;AACxE,MAAI,CAAC,KAAK,oBAAqB;AAC/B,OAAK,MAAM,cAAc,IAAI,qBAAqB;GAChD,MAAM,kBAAkB,WAAW;AAGnC,OAAI,CAAC,mBAAmB,eAAe,IAAI,gBAAgB,CACzD;AAIF,OAAI,SAAS,WAIX;QAHoB,YAAY,YAAY,eAC1C,WAAW,WACZ,YAC0B,uBACzB;;AAKJ,OAAI,SAAS,YACX;QAAI,WAAW,kBAAkB,eAC/B,kBAAiB,IAAI,gBAAgB;SAIvC,kBAAiB,IAAI,gBAAgB;AAIvC,kBAAe,IAAI,gBAAgB;AACnC,SAAM,KAAK,gBAAgB;;;AAI/B,QAAO"}
1
+ {"version":3,"file":"HoistContainerReferencesPlugin.js","names":["FederationModulesPlugin"],"sources":["../../../../src/lib/container/HoistContainerReferencesPlugin.ts"],"sourcesContent":["import type {\n Chunk,\n Compiler,\n Compilation,\n WebpackPluginInstance,\n Module,\n Dependency,\n} from 'webpack';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport FederationModulesPlugin from './runtime/FederationModulesPlugin';\nimport ContainerEntryDependency from './ContainerEntryDependency';\nimport FederationRuntimeDependency from './runtime/FederationRuntimeDependency';\nimport RemoteToExternalDependency from './RemoteToExternalDependency';\nimport FallbackDependency from './FallbackDependency';\n\nconst { AsyncDependenciesBlock, ExternalModule } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\nconst PLUGIN_NAME = 'HoistContainerReferences';\n\n/**\n * This plugin hoists container-related modules into runtime chunks when using runtimeChunk: single configuration.\n */\nclass HoistContainerReferences implements WebpackPluginInstance {\n apply(compiler: Compiler): void {\n compiler.hooks.thisCompilation.tap(\n PLUGIN_NAME,\n (compilation: Compilation) => {\n const logger = compilation.getLogger(PLUGIN_NAME);\n const hooks = FederationModulesPlugin.getCompilationHooks(compilation);\n const containerEntryDependencies = new Set<Dependency>();\n const federationRuntimeDependencies = new Set<Dependency>();\n const remoteDependencies = new Set<Dependency>();\n\n hooks.addContainerEntryDependency.tap(\n 'HoistContainerReferences',\n (dep: ContainerEntryDependency) => {\n containerEntryDependencies.add(dep);\n },\n );\n hooks.addFederationRuntimeDependency.tap(\n 'HoistContainerReferences',\n (dep: FederationRuntimeDependency) => {\n federationRuntimeDependencies.add(dep);\n },\n );\n hooks.addRemoteDependency.tap(\n 'HoistContainerReferences',\n (dep: RemoteToExternalDependency | FallbackDependency) => {\n remoteDependencies.add(dep);\n },\n );\n\n // Hook into the optimizeChunks phase\n compilation.hooks.optimizeChunks.tap(\n {\n name: PLUGIN_NAME,\n // advanced stage is where SplitChunksPlugin runs.\n stage: 11, // advanced + 1\n },\n (chunks: Iterable<Chunk>) => {\n const runtimeChunks = this.getRuntimeChunks(compilation);\n this.hoistModulesInChunks(\n compilation,\n runtimeChunks,\n logger,\n containerEntryDependencies,\n federationRuntimeDependencies,\n remoteDependencies,\n );\n },\n );\n },\n );\n }\n\n // Method to hoist modules in chunks\n private hoistModulesInChunks(\n compilation: Compilation,\n runtimeChunks: Set<Chunk>,\n logger: ReturnType<Compilation['getLogger']>,\n containerEntryDependencies: Set<Dependency>,\n federationRuntimeDependencies: Set<Dependency>,\n remoteDependencies: Set<Dependency>,\n ): void {\n const { chunkGraph, moduleGraph } = compilation;\n const allModulesToHoist = new Set<Module>();\n\n // Process container entry dependencies (needed for nextjs-mf exposed modules)\n for (const dep of containerEntryDependencies) {\n const containerEntryModule = moduleGraph.getModule(dep);\n if (!containerEntryModule) continue;\n const referencedModules = getAllReferencedModules(\n compilation,\n containerEntryModule,\n 'initial',\n );\n referencedModules.forEach((m: Module) => allModulesToHoist.add(m));\n const moduleRuntimes = chunkGraph.getModuleRuntimes(containerEntryModule);\n const runtimes = new Set<string>();\n for (const runtimeSpec of moduleRuntimes) {\n compilation.compiler.webpack.util.runtime.forEachRuntime(\n runtimeSpec,\n (runtimeKey) => {\n if (runtimeKey) {\n runtimes.add(runtimeKey);\n }\n },\n );\n }\n for (const runtime of runtimes) {\n const runtimeChunk = compilation.namedChunks.get(runtime);\n if (!runtimeChunk) continue;\n for (const module of referencedModules) {\n if (!chunkGraph.isModuleInChunk(module, runtimeChunk)) {\n chunkGraph.connectChunkAndModule(runtimeChunk, module);\n }\n }\n }\n }\n\n // Federation Runtime Dependencies: use 'initial' (not 'all')\n for (const dep of federationRuntimeDependencies) {\n const runtimeModule = moduleGraph.getModule(dep);\n if (!runtimeModule) continue;\n const referencedModules = getAllReferencedModules(\n compilation,\n runtimeModule,\n 'initial',\n );\n referencedModules.forEach((m: Module) => allModulesToHoist.add(m));\n const moduleRuntimes = chunkGraph.getModuleRuntimes(runtimeModule);\n const runtimes = new Set<string>();\n for (const runtimeSpec of moduleRuntimes) {\n compilation.compiler.webpack.util.runtime.forEachRuntime(\n runtimeSpec,\n (runtimeKey) => {\n if (runtimeKey) {\n runtimes.add(runtimeKey);\n }\n },\n );\n }\n for (const runtime of runtimes) {\n const runtimeChunk = compilation.namedChunks.get(runtime);\n if (!runtimeChunk) continue;\n for (const module of referencedModules) {\n if (!chunkGraph.isModuleInChunk(module, runtimeChunk)) {\n chunkGraph.connectChunkAndModule(runtimeChunk, module);\n }\n }\n }\n }\n\n // Process remote dependencies\n for (const remoteDep of remoteDependencies) {\n const remoteModule = moduleGraph.getModule(remoteDep);\n if (!remoteModule) continue;\n const referencedRemoteModules = getAllReferencedModules(\n compilation,\n remoteModule,\n 'initial',\n );\n referencedRemoteModules.forEach((m: Module) => allModulesToHoist.add(m));\n const remoteModuleRuntimes = chunkGraph.getModuleRuntimes(remoteModule);\n const remoteRuntimes = new Set<string>();\n for (const runtimeSpec of remoteModuleRuntimes) {\n compilation.compiler.webpack.util.runtime.forEachRuntime(\n runtimeSpec,\n (runtimeKey) => {\n if (runtimeKey) remoteRuntimes.add(runtimeKey);\n },\n );\n }\n for (const runtime of remoteRuntimes) {\n const runtimeChunk = compilation.namedChunks.get(runtime);\n if (!runtimeChunk) continue;\n for (const module of referencedRemoteModules) {\n if (!chunkGraph.isModuleInChunk(module, runtimeChunk)) {\n chunkGraph.connectChunkAndModule(runtimeChunk, module);\n }\n }\n }\n }\n\n this.cleanUpChunks(compilation, allModulesToHoist);\n }\n\n // Method to clean up chunks by disconnecting unused modules\n private cleanUpChunks(compilation: Compilation, modules: Set<Module>): void {\n const { chunkGraph } = compilation;\n for (const module of modules) {\n for (const chunk of chunkGraph.getModuleChunks(module)) {\n if (!chunk.hasRuntime()) {\n chunkGraph.disconnectChunkAndModule(chunk, module);\n }\n }\n }\n }\n\n // Method to get runtime chunks\n private getRuntimeChunks(compilation: Compilation): Set<Chunk> {\n const runtimeChunks = new Set<Chunk>();\n for (const chunk of compilation.chunks) {\n if (chunk.hasRuntime()) {\n runtimeChunks.add(chunk);\n }\n }\n return runtimeChunks;\n }\n}\n\n// Helper method to collect all referenced modules recursively\nexport function getAllReferencedModules(\n compilation: Compilation,\n module: Module,\n type?: 'all' | 'initial' | 'external',\n): Set<Module> {\n const collectedModules = new Set<Module>([module]);\n const visitedModules = new WeakSet<Module>([module]);\n const stack = [module];\n\n while (stack.length > 0) {\n const currentModule = stack.pop();\n if (!currentModule) continue;\n\n const mgm = compilation.moduleGraph._getModuleGraphModule(currentModule);\n if (!mgm?.outgoingConnections) continue;\n for (const connection of mgm.outgoingConnections) {\n const connectedModule = connection.module;\n\n // Skip if module has already been visited\n if (!connectedModule || visitedModules.has(connectedModule)) {\n continue;\n }\n\n // Connections webpack pruned (an unused import of a sideEffects:false\n // package) stay out of the runtime chunk. undefined means any runtime.\n if (connection.getActiveState(undefined) === false) {\n continue;\n }\n\n // Handle 'initial' type (skipping async blocks)\n if (type === 'initial') {\n const parentBlock = compilation.moduleGraph.getParentBlock(\n connection.dependency,\n );\n if (parentBlock instanceof AsyncDependenciesBlock) {\n continue;\n }\n }\n\n // Handle 'external' type (collecting only external modules)\n if (type === 'external') {\n if (connection.module instanceof ExternalModule) {\n collectedModules.add(connectedModule);\n }\n } else {\n // Handle 'all' or unspecified types\n collectedModules.add(connectedModule);\n }\n\n // Add connected module to the stack and mark it as visited\n visitedModules.add(connectedModule);\n stack.push(connectedModule);\n }\n }\n\n return collectedModules;\n}\n\nexport default HoistContainerReferences;\n"],"mappings":";;;;;;AAeA,MAAM,EAAE,wBAAwB,mBAAmB,gFAC5B,UAAU,CAChC;AAED,MAAM,cAAc;;;;AAKpB,IAAM,2BAAN,MAAgE;CAC9D,MAAM,UAA0B;AAC9B,WAAS,MAAM,gBAAgB,IAC7B,cACC,gBAA6B;GAC5B,MAAM,SAAS,YAAY,UAAU,YAAY;GACjD,MAAM,QAAQA,8DAAwB,oBAAoB,YAAY;GACtE,MAAM,6CAA6B,IAAI,KAAiB;GACxD,MAAM,gDAAgC,IAAI,KAAiB;GAC3D,MAAM,qCAAqB,IAAI,KAAiB;AAEhD,SAAM,4BAA4B,IAChC,6BACC,QAAkC;AACjC,+BAA2B,IAAI,IAAI;KAEtC;AACD,SAAM,+BAA+B,IACnC,6BACC,QAAqC;AACpC,kCAA8B,IAAI,IAAI;KAEzC;AACD,SAAM,oBAAoB,IACxB,6BACC,QAAyD;AACxD,uBAAmB,IAAI,IAAI;KAE9B;AAGD,eAAY,MAAM,eAAe,IAC/B;IACE,MAAM;IAEN,OAAO;IACR,GACA,WAA4B;IAC3B,MAAM,gBAAgB,KAAK,iBAAiB,YAAY;AACxD,SAAK,qBACH,aACA,eACA,QACA,4BACA,+BACA,mBACD;KAEJ;IAEJ;;CAIH,AAAQ,qBACN,aACA,eACA,QACA,4BACA,+BACA,oBACM;EACN,MAAM,EAAE,YAAY,gBAAgB;EACpC,MAAM,oCAAoB,IAAI,KAAa;AAG3C,OAAK,MAAM,OAAO,4BAA4B;GAC5C,MAAM,uBAAuB,YA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AAI,qBAAqB;GAChD,MAAM,kBAAkB,WAAW;AAGnC,OAAI,CAAC,mBAAmB,eAAe,IAAI,gBAAgB,CACzD;AAKF,OAAI,WAAW,eAAe,OAAU,KAAK,MAC3C;AAIF,OAAI,SAAS,WAIX;QAHoB,YAAY,YAAY,eAC1C,WAAW,WACZ,YAC0B,uBACzB;;AAKJ,OAAI,SAAS,YACX;QAAI,WAAW,kBAAkB,eAC/B,kBAAiB,IAAI,gBAAgB;SAIvC,kBAAiB,IAAI,gBAAgB;AAIvC,kBAAe,IAAI,gBAAgB;AACnC,SAAM,KAAK,gBAAgB;;;AAI/B,QAAO"}
@@ -1,6 +1,7 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
2
  const require_runtime = require('../../_virtual/_rolldown/runtime.js');
3
3
  const require_lib_Constants = require('../Constants.js');
4
+ const require_lib_makeSerializable = require('../makeSerializable.js');
4
5
  const require_lib_container_runtime_FederationModulesPlugin = require('./runtime/FederationModulesPlugin.js');
5
6
  const require_lib_container_FallbackDependency = require('./FallbackDependency.js');
6
7
  const require_lib_container_RemoteToExternalDependency = require('./RemoteToExternalDependency.js');
@@ -9,7 +10,6 @@ let _module_federation_sdk_normalize_webpack_path = require("@module-federation/
9
10
  //#region src/lib/container/RemoteModule.ts
10
11
  const { sources: webpackSources } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack"));
11
12
  const { Module, RuntimeGlobals } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack"));
12
- const makeSerializable = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/makeSerializable"));
13
13
  const TYPES = new Set(["remote", "share-init"]);
14
14
  const JAVASCRIPT_TYPES = new Set(["javascript"]);
15
15
  const RUNTIME_REQUIREMENTS = new Set([RuntimeGlobals.module]);
@@ -145,7 +145,7 @@ var RemoteModule = class RemoteModule extends Module {
145
145
  return obj;
146
146
  }
147
147
  };
148
- makeSerializable(RemoteModule, "enhanced/lib/container/RemoteModule");
148
+ require_lib_makeSerializable.default(RemoteModule, "enhanced/lib/container/RemoteModule");
149
149
 
150
150
  //#endregion
151
151
  exports.default = RemoteModule;
@@ -1 +1 @@
1
- {"version":3,"file":"RemoteModule.js","names":["WEBPACK_MODULE_TYPE_REMOTE","RemoteToExternalDependency","FederationModulesPlugin","FallbackDependency"],"sources":["../../../../src/lib/container/RemoteModule.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport type { Compilation, WebpackOptionsNormalized } from 'webpack';\nimport type {\n CodeGenerationContext,\n CodeGenerationResult,\n LibIdentOptions,\n NeedBuildContext,\n WebpackError,\n} from 'webpack/lib/Module';\nimport FallbackDependency from './FallbackDependency';\nimport RemoteToExternalDependency from './RemoteToExternalDependency';\nimport { WEBPACK_MODULE_TYPE_REMOTE } from '../Constants';\nimport type { ResolverWithOptions } from 'webpack/lib/ResolverFactory';\nimport type { InputFileSystem } from 'webpack/lib/FileSystemInfo';\nimport type { RequestShortener } from 'webpack/lib/RuntimeModule';\nimport type { ObjectDeserializerContext } from 'webpack/lib/serialization/ObjectMiddleware';\nimport FederationModulesPlugin from './runtime/FederationModulesPlugin';\n\nconst { sources: webpackSources } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nconst { Module, RuntimeGlobals } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nconst makeSerializable = require(\n normalizeWebpackPath('webpack/lib/util/makeSerializable'),\n) as typeof import('webpack/lib/util/makeSerializable');\n\nconst TYPES: Set<string> = new Set(['remote', 'share-init']);\nconst JAVASCRIPT_TYPES = new Set(['javascript']);\nconst RUNTIME_REQUIREMENTS: Set<string> = new Set([RuntimeGlobals.module]);\n\nclass RemoteModule extends Module {\n private _identifier: string;\n public request: string;\n public externalRequests: string[];\n public internalRequest: string;\n public shareScope: string | string[];\n\n /**\n * @param {string} request request string\n * @param {string[]} externalRequests list of external requests to containers\n * @param {string} internalRequest name of exposed module in container\n * @param {string|string[]} shareScope scope in which modules are shared\n */\n constructor(\n request: string,\n externalRequests: string[],\n internalRequest: string,\n shareScope: string | string[],\n ) {\n super(WEBPACK_MODULE_TYPE_REMOTE);\n this.request = request;\n this.externalRequests = externalRequests;\n this.internalRequest = internalRequest;\n this.shareScope = shareScope;\n const scopeStr = Array.isArray(shareScope)\n ? shareScope.join('|')\n : shareScope;\n this._identifier = `remote (${scopeStr}) ${this.externalRequests.join(\n ' ',\n )} ${this.internalRequest}`;\n }\n\n /**\n * @returns {string} a unique identifier of the module\n */\n override identifier(): string {\n return this._identifier;\n }\n\n /**\n * @param {RequestShortener} requestShortener the request shortener\n * @returns {string} a user readable identifier of the module\n */\n override readableIdentifier(requestShortener: RequestShortener): string {\n return `remote ${this.request}`;\n }\n\n /**\n * @param {LibIdentOptions} options options\n * @returns {string | null} an identifier for library inclusion\n */\n override libIdent(options: LibIdentOptions): string | null {\n return `${this.layer ? `(${this.layer})/` : ''}webpack/container/remote/${\n this.request\n }`;\n }\n\n /**\n * @param {NeedBuildContext} context context info\n * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild\n * @returns {void}\n */\n override needBuild(\n context: NeedBuildContext,\n callback: (err: WebpackError | null, needsRebuild?: boolean) => void,\n ): void {\n callback(null, !this.buildInfo);\n }\n\n /**\n * @param {WebpackOptions} options webpack options\n * @param {Compilation} compilation the compilation\n * @param {ResolverWithOptions} resolver the resolver\n * @param {InputFileSystem} fs the file system\n * @param {function(WebpackError=): void} callback callback function\n * @returns {void}\n */\n // @ts-ignore\n override build(\n options: WebpackOptionsNormalized,\n compilation: Compilation,\n resolver: ResolverWithOptions,\n fs: InputFileSystem,\n callback: (err?: WebpackError | undefined) => void,\n ): void {\n this.buildMeta = {};\n this.buildInfo = {\n strict: true,\n };\n\n this.clearDependenciesAndBlocks();\n if (this.externalRequests.length === 1) {\n const dep = new RemoteToExternalDependency(this.externalRequests[0]);\n this.addDependency(dep);\n const hooks = FederationModulesPlugin.getCompilationHooks(compilation);\n hooks.addRemoteDependency.call(dep);\n } else {\n const dep = new FallbackDependency(this.externalRequests);\n this.addDependency(dep);\n const hooks = FederationModulesPlugin.getCompilationHooks(compilation);\n hooks.addRemoteDependency.call(dep);\n }\n\n callback();\n }\n\n /**\n * @param {string=} type the source type for which the size should be estimated\n * @returns {number} the estimated size of the module (must be non-zero)\n */\n override size(type?: string): number {\n return 6;\n }\n\n /**\n * @returns {Set<string>} types available (do not mutate)\n */\n override getSourceTypes(): Set<string> {\n return TYPES;\n }\n\n /**\n * @returns {Set<string>} types available (do not mutate)\n */\n override getSourceBasicTypes(): Set<string> {\n return JAVASCRIPT_TYPES;\n }\n\n /**\n * @returns {string | null} absolute path which should be used for condition matching (usually the resource path)\n */\n override nameForCondition(): string | null {\n return this.request;\n }\n\n /**\n * @param {CodeGenerationContext} context context for code generation\n * @returns {CodeGenerationResult} result\n */\n // @ts-ignore\n override codeGeneration(\n context: CodeGenerationContext,\n ): CodeGenerationResult {\n const { moduleGraph, chunkGraph } = context;\n const module = moduleGraph.getModule(this.dependencies[0]);\n const id = module && chunkGraph.getModuleId(module);\n const sources = new Map();\n sources.set('remote', new webpackSources.RawSource(''));\n const data = new Map();\n data.set('share-init', [\n {\n shareScope: this.shareScope,\n initStage: 20,\n init: id === undefined ? '' : `initExternal(${JSON.stringify(id)});`,\n },\n ]);\n return { sources, data, runtimeRequirements: RUNTIME_REQUIREMENTS };\n }\n override serialize(context: any) {\n const { write } = context;\n write(this.request);\n write(this.externalRequests);\n write(this.internalRequest);\n write(this.shareScope);\n super.serialize(context);\n }\n\n /**\n * @param {ObjectDeserializerContext} context context\n * @returns {RemoteModule} deserialized module\n */\n static deserialize(context: ObjectDeserializerContext): RemoteModule {\n const { read } = context;\n const obj = new RemoteModule(read(), read(), read(), read());\n obj.deserialize(context);\n return obj;\n }\n}\n\nmakeSerializable(RemoteModule, 'enhanced/lib/container/RemoteModule');\n\nexport default RemoteModule;\n"],"mappings":";;;;;;;;;AAsBA,MAAM,EAAE,SAAS,mBAAmB,gFACb,UAAU,CAChC;AACD,MAAM,EAAE,QAAQ,mBAAmB,gFACZ,UAAU,CAChC;AACD,MAAM,mBAAmB,gFACF,oCAAoC,CAC1D;AAED,MAAM,QAAqB,IAAI,IAAI,CAAC,UAAU,aAAa,CAAC;AAC5D,MAAM,mBAAmB,IAAI,IAAI,CAAC,aAAa,CAAC;AAChD,MAAM,uBAAoC,IAAI,IAAI,CAAC,eAAe,OAAO,CAAC;AAE1E,IAAM,eAAN,MAAM,qBAAqB,OAAO;;;;;;;CAahC,YACE,SACA,kBACA,iBACA,YACA;AACA,QAAMA,iDAA2B;AACjC,OAAK,UAAU;AACf,OAAK,mBAAmB;AACxB,OAAK,kBAAkB;AACvB,OAAK,aAAa;AAIlB,OAAK,cAAc,WAHF,MAAM,QAAQ,WAAW,GACtC,WAAW,KAAK,IAAI,GACpB,WACmC,IAAI,KAAK,iBAAiB,KAC/D,IACD,CAAC,GAAG,KAAK;;;;;CAMZ,AAAS,aAAqB;AAC5B,SAAO,KAAK;;;;;;CAOd,AAAS,mBAAmB,kBAA4C;AACtE,SAAO,UAAU,KAAK;;;;;;CAOxB,AAAS,SAAS,SAAyC;AACzD,SAAO,GAAG,KAAK,QAAQ,IAAI,KAAK,MAAM,MAAM,GAAG,2BAC7C,KAAK;;;;;;;CAST,AAAS,UACP,SACA,UACM;AACN,WAAS,MAAM,CAAC,KAAK,UAAU;;;;;;;;;;CAYjC,AAAS,MACP,SACA,aACA,UACA,IACA,UACM;AACN,OAAK,YAAY,EAAE;AACnB,OAAK,YAAY,EACf,QAAQ,MACT;AAED,OAAK,4BAA4B;AACjC,MAAI,KAAK,iBAAiB,WAAW,GAAG;GACtC,MAAM,MAAM,IAAIC,yDAA2B,KAAK,i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BAAiB,cAAc,sCAAsC"}
1
+ {"version":3,"file":"RemoteModule.js","names":["WEBPACK_MODULE_TYPE_REMOTE","RemoteToExternalDependency","FederationModulesPlugin","FallbackDependency","makeSerializable"],"sources":["../../../../src/lib/container/RemoteModule.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy\n*/\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport type { Compilation, WebpackOptionsNormalized } from 'webpack';\nimport type {\n CodeGenerationContext,\n CodeGenerationResult,\n LibIdentOptions,\n NeedBuildContext,\n WebpackError,\n} from 'webpack/lib/Module';\nimport FallbackDependency from './FallbackDependency';\nimport RemoteToExternalDependency from './RemoteToExternalDependency';\nimport { WEBPACK_MODULE_TYPE_REMOTE } from '../Constants';\nimport type { ResolverWithOptions } from 'webpack/lib/ResolverFactory';\nimport type { InputFileSystem } from 'webpack/lib/FileSystemInfo';\nimport type { RequestShortener } from 'webpack/lib/RuntimeModule';\nimport type { ObjectDeserializerContext } from 'webpack/lib/serialization/ObjectMiddleware';\nimport FederationModulesPlugin from './runtime/FederationModulesPlugin';\n\nconst { sources: webpackSources } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nconst { Module, RuntimeGlobals } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nimport makeSerializable from '../makeSerializable';\n\nconst TYPES: Set<string> = new Set(['remote', 'share-init']);\nconst JAVASCRIPT_TYPES = new Set(['javascript']);\nconst RUNTIME_REQUIREMENTS: Set<string> = new Set([RuntimeGlobals.module]);\n\nclass RemoteModule extends Module {\n private _identifier: string;\n public request: string;\n public externalRequests: string[];\n public internalRequest: string;\n public shareScope: string | string[];\n\n /**\n * @param {string} request request string\n * @param {string[]} externalRequests list of external requests to containers\n * @param {string} internalRequest name of exposed module in container\n * @param {string|string[]} shareScope scope in which modules are shared\n */\n constructor(\n request: string,\n externalRequests: string[],\n internalRequest: string,\n shareScope: string | string[],\n ) {\n super(WEBPACK_MODULE_TYPE_REMOTE);\n this.request = request;\n this.externalRequests = externalRequests;\n this.internalRequest = internalRequest;\n this.shareScope = shareScope;\n const scopeStr = Array.isArray(shareScope)\n ? shareScope.join('|')\n : shareScope;\n this._identifier = `remote (${scopeStr}) ${this.externalRequests.join(\n ' ',\n )} ${this.internalRequest}`;\n }\n\n /**\n * @returns {string} a unique identifier of the module\n */\n override identifier(): string {\n return this._identifier;\n }\n\n /**\n * @param {RequestShortener} requestShortener the request shortener\n * @returns {string} a user readable identifier of the module\n */\n override readableIdentifier(requestShortener: RequestShortener): string {\n return `remote ${this.request}`;\n }\n\n /**\n * @param {LibIdentOptions} options options\n * @returns {string | null} an identifier for library inclusion\n */\n override libIdent(options: LibIdentOptions): string | null {\n return `${this.layer ? `(${this.layer})/` : ''}webpack/container/remote/${\n this.request\n }`;\n }\n\n /**\n * @param {NeedBuildContext} context context info\n * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild\n * @returns {void}\n */\n override needBuild(\n context: NeedBuildContext,\n callback: (err: WebpackError | null, needsRebuild?: boolean) => void,\n ): void {\n callback(null, !this.buildInfo);\n }\n\n /**\n * @param {WebpackOptions} options webpack options\n * @param {Compilation} compilation the compilation\n * @param {ResolverWithOptions} resolver the resolver\n * @param {InputFileSystem} fs the file system\n * @param {function(WebpackError=): void} callback callback function\n * @returns {void}\n */\n // @ts-ignore\n override build(\n options: WebpackOptionsNormalized,\n compilation: Compilation,\n resolver: ResolverWithOptions,\n fs: InputFileSystem,\n callback: (err?: WebpackError | undefined) => void,\n ): void {\n this.buildMeta = {};\n this.buildInfo = {\n strict: true,\n };\n\n this.clearDependenciesAndBlocks();\n if (this.externalRequests.length === 1) {\n const dep = new RemoteToExternalDependency(this.externalRequests[0]);\n this.addDependency(dep);\n const hooks = FederationModulesPlugin.getCompilationHooks(compilation);\n hooks.addRemoteDependency.call(dep);\n } else {\n const dep = new FallbackDependency(this.externalRequests);\n this.addDependency(dep);\n const hooks = FederationModulesPlugin.getCompilationHooks(compilation);\n hooks.addRemoteDependency.call(dep);\n }\n\n callback();\n }\n\n /**\n * @param {string=} type the source type for which the size should be estimated\n * @returns {number} the estimated size of the module (must be non-zero)\n */\n override size(type?: string): number {\n return 6;\n }\n\n /**\n * @returns {Set<string>} types available (do not mutate)\n */\n override getSourceTypes(): Set<string> {\n return TYPES;\n }\n\n /**\n * @returns {Set<string>} types available (do not mutate)\n */\n override getSourceBasicTypes(): Set<string> {\n return JAVASCRIPT_TYPES;\n }\n\n /**\n * @returns {string | null} absolute path which should be used for condition matching (usually the resource path)\n */\n override nameForCondition(): string | null {\n return this.request;\n }\n\n /**\n * @param {CodeGenerationContext} context context for code generation\n * @returns {CodeGenerationResult} result\n */\n // @ts-ignore\n override codeGeneration(\n context: CodeGenerationContext,\n ): CodeGenerationResult {\n const { moduleGraph, chunkGraph } = context;\n const module = moduleGraph.getModule(this.dependencies[0]);\n const id = module && chunkGraph.getModuleId(module);\n const sources = new Map();\n sources.set('remote', new webpackSources.RawSource(''));\n const data = new Map();\n data.set('share-init', [\n {\n shareScope: this.shareScope,\n initStage: 20,\n init: id === undefined ? '' : `initExternal(${JSON.stringify(id)});`,\n },\n ]);\n return { sources, data, runtimeRequirements: RUNTIME_REQUIREMENTS };\n }\n override serialize(context: any) {\n const { write } = context;\n write(this.request);\n write(this.externalRequests);\n write(this.internalRequest);\n write(this.shareScope);\n super.serialize(context);\n }\n\n /**\n * @param {ObjectDeserializerContext} context context\n * @returns {RemoteModule} deserialized module\n */\n static deserialize(context: ObjectDeserializerContext): RemoteModule {\n const { read } = context;\n const obj = new RemoteModule(read(), read(), read(), read());\n obj.deserialize(context);\n return obj;\n }\n}\n\nmakeSerializable(RemoteModule, 'enhanced/lib/container/RemoteModule');\n\nexport default RemoteModule;\n"],"mappings":";;;;;;;;;;AAsBA,MAAM,EAAE,SAAS,mBAAmB,gFACb,UAAU,CAChC;AACD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oB,KAAK,IAAI;;AAGrC,YAAU;;;;;;CAOZ,AAAS,KAAK,MAAuB;AACnC,SAAO;;;;;CAMT,AAAS,iBAA8B;AACrC,SAAO;;;;;CAMT,AAAS,sBAAmC;AAC1C,SAAO;;;;;CAMT,AAAS,mBAAkC;AACzC,SAAO,KAAK;;;;;;CAQd,AAAS,eACP,SACsB;EACtB,MAAM,EAAE,aAAa,eAAe;EACpC,MAAM,SAAS,YAAY,UAAU,KAAK,aAAa,GAAG;EAC1D,MAAM,KAAK,UAAU,WAAW,YAAY,OAAO;EACnD,MAAM,0BAAU,IAAI,KAAK;AACzB,UAAQ,IAAI,UAAU,IAAI,eAAe,UAAU,GAAG,CAAC;EACvD,MAAM,uBAAO,IAAI,KAAK;AACtB,OAAK,IAAI,cAAc,CACrB;GACE,YAAY,KAAK;GACjB,WAAW;GACX,MAAM,OAAO,SAAY,KAAK,gBAAgB,KAAK,UAAU,GAAG,CAAC;GAClE,CACF,CAAC;AACF,SAAO;GAAE;GAAS;GAAM,qBAAqB;GAAsB;;CAErE,AAAS,UAAU,SAAc;EAC/B,MAAM,EAAE,UAAU;AAClB,QAAM,KAAK,QAAQ;AACnB,QAAM,KAAK,iBAAiB;AAC5B,QAAM,KAAK,gBAAgB;AAC3B,QAAM,KAAK,WAAW;AACtB,QAAM,UAAU,QAAQ;;;;;;CAO1B,OAAO,YAAY,SAAkD;EACnE,MAAM,EAAE,SAAS;EACjB,MAAM,MAAM,IAAI,aAAa,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;AAC5D,MAAI,YAAY,QAAQ;AACxB,SAAO;;;AAIXE,qCAAiB,cAAc,sCAAsC"}
@@ -6,6 +6,7 @@ let _module_federation_sdk_normalize_webpack_path = require("@module-federation/
6
6
  //#region src/lib/container/RemoteRuntimeModule.ts
7
7
  const extractUrlAndGlobal = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/extractUrlAndGlobal"));
8
8
  const { Template, RuntimeModule, RuntimeGlobals } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack"));
9
+ const { compareModulesByIdentifier } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/comparators"));
9
10
  var RemoteRuntimeModule = class extends RuntimeModule {
10
11
  constructor() {
11
12
  super("remotes loading");
@@ -23,7 +24,7 @@ var RemoteRuntimeModule = class extends RuntimeModule {
23
24
  const allChunks = [...Array.from(this.chunk?.getAllReferencedChunks() || [])];
24
25
  for (const chunk of allChunks) {
25
26
  if (chunk.id === null || chunk.id === void 0) continue;
26
- const modules = chunkGraph?.getChunkModulesIterableBySourceType(chunk, "remote");
27
+ const modules = chunkGraph?.getOrderedChunkModulesIterableBySourceType(chunk, "remote", compareModulesByIdentifier);
27
28
  if (!modules) continue;
28
29
  const remotes = chunkToRemotesMapping[chunk.id] = [];
29
30
  for (const m of modules) {