@module-federation/enhanced 0.0.0-fix-filter-function-20260327073336 → 0.0.0-fix-valid-same-id-20260429034727

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 (32) hide show
  1. package/dist/CHANGELOG.md +75 -16
  2. package/dist/src/lib/container/ContainerEntryDependency.d.ts +1 -4
  3. package/dist/src/lib/container/ContainerEntryDependency.js +1 -3
  4. package/dist/src/lib/container/ContainerEntryDependency.js.map +1 -1
  5. package/dist/src/lib/container/ContainerEntryModule.d.ts +1 -4
  6. package/dist/src/lib/container/ContainerEntryModule.js +3 -9
  7. package/dist/src/lib/container/ContainerEntryModule.js.map +1 -1
  8. package/dist/src/lib/container/ContainerEntryModuleFactory.js +1 -1
  9. package/dist/src/lib/container/ContainerEntryModuleFactory.js.map +1 -1
  10. package/dist/src/lib/container/ContainerPlugin.js +3 -5
  11. package/dist/src/lib/container/ContainerPlugin.js.map +1 -1
  12. package/dist/src/lib/container/ContainerReferencePlugin.js +0 -1
  13. package/dist/src/lib/container/ContainerReferencePlugin.js.map +1 -1
  14. package/dist/src/lib/container/ModuleFederationPlugin.js +0 -2
  15. package/dist/src/lib/container/ModuleFederationPlugin.js.map +1 -1
  16. package/dist/src/lib/container/runtime/FederationRuntimePlugin.js +1 -5
  17. package/dist/src/lib/container/runtime/FederationRuntimePlugin.js.map +1 -1
  18. package/dist/src/runtime.mjs +3 -0
  19. package/dist/src/schemas/container/ContainerPlugin.check.d.ts +7 -7
  20. package/dist/src/schemas/container/ContainerPlugin.check.js +541 -734
  21. package/dist/src/schemas/container/ContainerPlugin.check.js.map +1 -1
  22. package/dist/src/schemas/container/ContainerPlugin.d.ts +0 -4
  23. package/dist/src/schemas/container/ContainerPlugin.js +0 -4
  24. package/dist/src/schemas/container/ContainerPlugin.js.map +1 -1
  25. package/dist/src/schemas/container/ModuleFederationPlugin.check.js +5 -13
  26. package/dist/src/schemas/container/ModuleFederationPlugin.check.js.map +1 -1
  27. package/dist/src/schemas/container/ModuleFederationPlugin.d.ts +0 -4
  28. package/dist/src/schemas/container/ModuleFederationPlugin.js +0 -4
  29. package/dist/src/schemas/container/ModuleFederationPlugin.js.map +1 -1
  30. package/package.json +14 -25
  31. package/dist/src/prefetch.d.ts +0 -3
  32. package/dist/src/prefetch.js +0 -17
package/dist/CHANGELOG.md CHANGED
@@ -1,21 +1,80 @@
1
1
  # @module-federation/enhanced
2
2
 
3
- ## 0.0.0-fix-filter-function-20260327073336
4
-
5
- ### Patch Changes
6
-
7
- - @module-federation/rspack@0.0.0-fix-filter-function-20260327073336
8
- - @module-federation/webpack-bundler-runtime@0.0.0-fix-filter-function-20260327073336
9
- - @module-federation/sdk@0.0.0-fix-filter-function-20260327073336
10
- - @module-federation/runtime-tools@0.0.0-fix-filter-function-20260327073336
11
- - @module-federation/managers@0.0.0-fix-filter-function-20260327073336
12
- - @module-federation/manifest@0.0.0-fix-filter-function-20260327073336
13
- - @module-federation/dts-plugin@0.0.0-fix-filter-function-20260327073336
14
- - @module-federation/bridge-react-webpack-plugin@0.0.0-fix-filter-function-20260327073336
15
- - @module-federation/data-prefetch@0.0.0-fix-filter-function-20260327073336
16
- - @module-federation/error-codes@0.0.0-fix-filter-function-20260327073336
17
- - @module-federation/inject-external-runtime-core-plugin@0.0.0-fix-filter-function-20260327073336
18
- - @module-federation/cli@0.0.0-fix-filter-function-20260327073336
3
+ ## 0.0.0-fix-valid-same-id-20260429034727
4
+
5
+ ### Minor Changes
6
+
7
+ - 13b1e84: chore: remove the legacy Data Prefetch package and its related configuration, manifest fields, and runtime hooks.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [5eba770]
12
+ - Updated dependencies [13b1e84]
13
+ - @module-federation/sdk@0.0.0-fix-valid-same-id-20260429034727
14
+ - @module-federation/manifest@0.0.0-fix-valid-same-id-20260429034727
15
+ - @module-federation/webpack-bundler-runtime@0.0.0-fix-valid-same-id-20260429034727
16
+ - @module-federation/bridge-react-webpack-plugin@0.0.0-fix-valid-same-id-20260429034727
17
+ - @module-federation/cli@0.0.0-fix-valid-same-id-20260429034727
18
+ - @module-federation/dts-plugin@0.0.0-fix-valid-same-id-20260429034727
19
+ - @module-federation/managers@0.0.0-fix-valid-same-id-20260429034727
20
+ - @module-federation/rspack@0.0.0-fix-valid-same-id-20260429034727
21
+ - @module-federation/runtime-tools@0.0.0-fix-valid-same-id-20260429034727
22
+ - @module-federation/inject-external-runtime-core-plugin@0.0.0-fix-valid-same-id-20260429034727
23
+ - @module-federation/error-codes@0.0.0-fix-valid-same-id-20260429034727
24
+
25
+ ## 2.3.3
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies [6d33275]
30
+ - @module-federation/dts-plugin@2.3.3
31
+ - @module-federation/cli@2.3.3
32
+ - @module-federation/manifest@2.3.3
33
+ - @module-federation/rspack@2.3.3
34
+ - @module-federation/webpack-bundler-runtime@2.3.3
35
+ - @module-federation/sdk@2.3.3
36
+ - @module-federation/runtime-tools@2.3.3
37
+ - @module-federation/managers@2.3.3
38
+ - @module-federation/bridge-react-webpack-plugin@2.3.3
39
+ - @module-federation/data-prefetch@2.3.3
40
+ - @module-federation/error-codes@2.3.3
41
+ - @module-federation/inject-external-runtime-core-plugin@2.3.3
42
+
43
+ ## 2.3.2
44
+
45
+ ### Patch Changes
46
+
47
+ - 1c02710: chore: lock deps
48
+ - Updated dependencies [1c02710]
49
+ - @module-federation/data-prefetch@2.3.2
50
+ - @module-federation/dts-plugin@2.3.2
51
+ - @module-federation/cli@2.3.2
52
+ - @module-federation/manifest@2.3.2
53
+ - @module-federation/rspack@2.3.2
54
+ - @module-federation/webpack-bundler-runtime@2.3.2
55
+ - @module-federation/sdk@2.3.2
56
+ - @module-federation/runtime-tools@2.3.2
57
+ - @module-federation/managers@2.3.2
58
+ - @module-federation/bridge-react-webpack-plugin@2.3.2
59
+ - @module-federation/error-codes@2.3.2
60
+ - @module-federation/inject-external-runtime-core-plugin@2.3.2
61
+
62
+ ## 2.3.1
63
+
64
+ ### Patch Changes
65
+
66
+ - @module-federation/rspack@2.3.1
67
+ - @module-federation/webpack-bundler-runtime@2.3.1
68
+ - @module-federation/sdk@2.3.1
69
+ - @module-federation/runtime-tools@2.3.1
70
+ - @module-federation/managers@2.3.1
71
+ - @module-federation/manifest@2.3.1
72
+ - @module-federation/dts-plugin@2.3.1
73
+ - @module-federation/bridge-react-webpack-plugin@2.3.1
74
+ - @module-federation/data-prefetch@2.3.1
75
+ - @module-federation/error-codes@2.3.1
76
+ - @module-federation/inject-external-runtime-core-plugin@2.3.1
77
+ - @module-federation/cli@2.3.1
19
78
 
20
79
  ## 2.3.0
21
80
 
@@ -1,5 +1,4 @@
1
1
  import { ExposeOptions } from "./ContainerEntryModule.js";
2
- import { containerPlugin } from "@module-federation/sdk";
3
2
  import * as webpack$1 from "webpack";
4
3
 
5
4
  //#region src/lib/container/ContainerEntryDependency.d.ts
@@ -9,15 +8,13 @@ declare class ContainerEntryDependency extends Dependency {
9
8
  exposes: [string, ExposeOptions][];
10
9
  shareScope: string | string[];
11
10
  injectRuntimeEntry: string;
12
- dataPrefetch: containerPlugin.ContainerPluginOptions['dataPrefetch'];
13
11
  /**
14
12
  * @param {string} name entry name
15
13
  * @param {[string, ExposeOptions][]} exposes list of exposed modules
16
14
  * @param {string|string[]} shareScope name of the share scope
17
15
  * @param {string[]} injectRuntimeEntry the path of injectRuntime file.
18
- * @param {containerPlugin.ContainerPluginOptions['dataPrefetch']} dataPrefetch whether enable dataPrefetch
19
16
  */
20
- constructor(name: string, exposes: [string, ExposeOptions][], shareScope: string | string[], injectRuntimeEntry: string, dataPrefetch: containerPlugin.ContainerPluginOptions['dataPrefetch']);
17
+ constructor(name: string, exposes: [string, ExposeOptions][], shareScope: string | string[], injectRuntimeEntry: string);
21
18
  /**
22
19
  * @returns {string | null} an identifier to merge equal requests
23
20
  */
@@ -11,15 +11,13 @@ var ContainerEntryDependency = class extends Dependency {
11
11
  * @param {[string, ExposeOptions][]} exposes list of exposed modules
12
12
  * @param {string|string[]} shareScope name of the share scope
13
13
  * @param {string[]} injectRuntimeEntry the path of injectRuntime file.
14
- * @param {containerPlugin.ContainerPluginOptions['dataPrefetch']} dataPrefetch whether enable dataPrefetch
15
14
  */
16
- constructor(name, exposes, shareScope, injectRuntimeEntry, dataPrefetch) {
15
+ constructor(name, exposes, shareScope, injectRuntimeEntry) {
17
16
  super();
18
17
  this.name = name;
19
18
  this.exposes = exposes;
20
19
  this.shareScope = shareScope;
21
20
  this.injectRuntimeEntry = injectRuntimeEntry;
22
- this.dataPrefetch = dataPrefetch;
23
21
  }
24
22
  /**
25
23
  * @returns {string | null} an identifier to merge equal requests
@@ -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\nimport type { containerPlugin } from '@module-federation/sdk';\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 public dataPrefetch: containerPlugin.ContainerPluginOptions['dataPrefetch'];\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 * @param {containerPlugin.ContainerPluginOptions['dataPrefetch']} dataPrefetch whether enable dataPrefetch\n */\n constructor(\n name: string,\n exposes: [string, ExposeOptions][],\n shareScope: string | string[],\n injectRuntimeEntry: string,\n dataPrefetch: containerPlugin.ContainerPluginOptions['dataPrefetch'],\n ) {\n super();\n this.name = name;\n this.exposes = exposes;\n this.shareScope = shareScope;\n this.injectRuntimeEntry = injectRuntimeEntry;\n this.dataPrefetch = dataPrefetch;\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":";;;;;AAUA,MAAM,mBAAmB,gFACF,oCAAoC,CAC1D;AACD,MAAM,EAAE,eAAe,gFACA,UAAU,CAChC;AAED,IAAM,2BAAN,cAAuC,WAAW;;;;;;;;CAchD,YACE,MACA,SACA,YACA,oBACA,cACA;AACA,SAAO;AACP,OAAK,OAAO;AACZ,OAAK,UAAU;AACf,OAAK,aAAa;AAClB,OAAK,qBAAqB;AAC1B,OAAK,eAAe;;;;;CAMtB,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":[],"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,4 +1,3 @@
1
- import { containerPlugin } from "@module-federation/sdk";
2
1
  import * as webpack$1 from "webpack";
3
2
  import { Compilation } from "webpack";
4
3
  import { InputFileSystem, LibIdentOptions, NeedBuildContext, ObjectDeserializerContext, ObjectSerializerContext, RequestShortener, ResolverWithOptions, WebpackOptions } from "webpack/lib/Module";
@@ -21,15 +20,13 @@ declare class ContainerEntryModule extends Module$1 {
21
20
  private _exposes;
22
21
  private _shareScope;
23
22
  private _injectRuntimeEntry;
24
- private _dataPrefetch;
25
23
  /**
26
24
  * @param {string} name container entry name
27
25
  * @param {[string, ExposeOptions][]} exposes list of exposed modules
28
26
  * @param {string|string[]} shareScope name of the share scope
29
27
  * @param {string} injectRuntimeEntry the path of injectRuntime file.
30
- * @param {containerPlugin.ContainerPluginOptions['dataPrefetch']} dataPrefetch whether enable dataPrefetch
31
28
  */
32
- constructor(name: string, exposes: [string, ExposeOptions][], shareScope: string | string[], injectRuntimeEntry: string, dataPrefetch: containerPlugin.ContainerPluginOptions['dataPrefetch']);
29
+ constructor(name: string, exposes: [string, ExposeOptions][], shareScope: string | string[], injectRuntimeEntry: string);
33
30
  /**
34
31
  * @param {ObjectDeserializerContext} context context
35
32
  * @returns {ContainerEntryModule} deserialized container entry module
@@ -9,7 +9,6 @@ let _module_federation_sdk = require("@module-federation/sdk");
9
9
  let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
10
10
  let _module_federation_error_codes = require("@module-federation/error-codes");
11
11
  let _module_federation_error_codes_node = require("@module-federation/error-codes/node");
12
- let _module_federation_data_prefetch_cli = require("@module-federation/data-prefetch/cli");
13
12
 
14
13
  //#region src/lib/container/ContainerEntryModule.ts
15
14
  const makeSerializable = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/makeSerializable"));
@@ -23,15 +22,13 @@ var ContainerEntryModule = class ContainerEntryModule extends Module {
23
22
  * @param {[string, ExposeOptions][]} exposes list of exposed modules
24
23
  * @param {string|string[]} shareScope name of the share scope
25
24
  * @param {string} injectRuntimeEntry the path of injectRuntime file.
26
- * @param {containerPlugin.ContainerPluginOptions['dataPrefetch']} dataPrefetch whether enable dataPrefetch
27
25
  */
28
- constructor(name, exposes, shareScope, injectRuntimeEntry, dataPrefetch) {
26
+ constructor(name, exposes, shareScope, injectRuntimeEntry) {
29
27
  super(require_lib_Constants.JAVASCRIPT_MODULE_TYPE_DYNAMIC, null);
30
28
  this._name = name;
31
29
  this._exposes = exposes;
32
30
  this._shareScope = shareScope;
33
31
  this._injectRuntimeEntry = injectRuntimeEntry;
34
- this._dataPrefetch = dataPrefetch;
35
32
  }
36
33
  /**
37
34
  * @param {ObjectDeserializerContext} context context
@@ -39,7 +36,7 @@ var ContainerEntryModule = class ContainerEntryModule extends Module {
39
36
  */
40
37
  static deserialize(context) {
41
38
  const { read } = context;
42
- const obj = new ContainerEntryModule(read(), read(), read(), read(), read());
39
+ const obj = new ContainerEntryModule(read(), read(), read(), read());
43
40
  obj.deserialize(context);
44
41
  return obj;
45
42
  }
@@ -53,7 +50,7 @@ var ContainerEntryModule = class ContainerEntryModule extends Module {
53
50
  * @returns {string} a unique identifier of the module
54
51
  */
55
52
  identifier() {
56
- return `container entry (${Array.isArray(this._shareScope) ? this._shareScope.join("|") : this._shareScope}) ${JSON.stringify(this._exposes)} ${this._injectRuntimeEntry} ${JSON.stringify(this._dataPrefetch)}`;
53
+ return `container entry (${Array.isArray(this._shareScope) ? this._shareScope.join("|") : this._shareScope}) ${JSON.stringify(this._exposes)} ${this._injectRuntimeEntry}`;
57
54
  }
58
55
  /**
59
56
  * @param {RequestShortener} requestShortener the request shortener
@@ -183,8 +180,6 @@ var ContainerEntryModule = class ContainerEntryModule extends Module {
183
180
  `remoteEntryInitOptions: remoteEntryInitOptions,`,
184
181
  `shareScopeKey: ${JSON.stringify(this._shareScope)}`
185
182
  ])}`, "})"])};`,
186
- this._dataPrefetch ? _module_federation_data_prefetch_cli.PrefetchPlugin.setRemoteIdentifier() : "",
187
- this._dataPrefetch ? _module_federation_data_prefetch_cli.PrefetchPlugin.removeRemoteIdentifier() : "",
188
183
  "// This exports getters to disallow modifications",
189
184
  `${RuntimeGlobals.definePropertyGetters}(exports, {`,
190
185
  Template.indent([`get: ${runtimeTemplate.returningFunction("get")},`, `init: ${runtimeTemplate.returningFunction("init")}`]),
@@ -212,7 +207,6 @@ var ContainerEntryModule = class ContainerEntryModule extends Module {
212
207
  write(this._exposes);
213
208
  write(this._shareScope);
214
209
  write(this._injectRuntimeEntry);
215
- write(this._dataPrefetch);
216
210
  super.serialize(context);
217
211
  }
218
212
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ContainerEntryModule.js","names":["JAVASCRIPT_MODULE_TYPE_DYNAMIC","ContainerExposedDependency","BUILD_001","buildDescMap","logger","getFederationGlobalScope","PrefetchPlugin"],"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 { containerPlugin } from '@module-federation/sdk';\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 { PrefetchPlugin } from '@module-federation/data-prefetch/cli';\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 private _dataPrefetch: containerPlugin.ContainerPluginOptions['dataPrefetch'];\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 * @param {containerPlugin.ContainerPluginOptions['dataPrefetch']} dataPrefetch whether enable dataPrefetch\n */\n constructor(\n name: string,\n exposes: [string, ExposeOptions][],\n shareScope: string | string[],\n injectRuntimeEntry: string,\n dataPrefetch: containerPlugin.ContainerPluginOptions['dataPrefetch'],\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 this._dataPrefetch = dataPrefetch;\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(\n read(),\n read(),\n read(),\n read(),\n read(),\n );\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} ${JSON.stringify(this._dataPrefetch)}`;\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._dataPrefetch ? PrefetchPlugin.setRemoteIdentifier() : '',\n this._dataPrefetch ? PrefetchPlugin.removeRemoteIdentifier() : '',\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 write(this._dataPrefetch);\n super.serialize(context);\n }\n}\n\nmakeSerializable(\n ContainerEntryModule,\n 'enhanced/lib/container/ContainerEntryModule',\n);\n\nexport default ContainerEntryModule;\n"],"mappings":";;;;;;;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QAAQ,gBAAgB,kBAAkB,MAAM,CAAC,IACjD,SAAS,gBAAgB,kBAAkB,OAAO,GACnD,CAAC;GACF;GACD,CAAC;AAEF,UAAQ,IACN,cACA,KAAK,gBAAgB,KAAK,qBACtB,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,KAAK,cAAc;AACzB,QAAM,UAAU,QAAQ;;;AAI5B,iBACE,sBACA,8CACD"}
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,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0B,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;;;AAI5B,iBACE,sBACA,8CACD"}
@@ -16,7 +16,7 @@ var ContainerEntryModuleFactory = class extends ModuleFactory {
16
16
  create(data, callback) {
17
17
  const { dependencies } = data;
18
18
  const dep = dependencies[0];
19
- callback(null, { module: new require_lib_container_ContainerEntryModule.default(dep.name, dep.exposes, dep.shareScope, dep.injectRuntimeEntry, dep.dataPrefetch) });
19
+ callback(null, { module: new require_lib_container_ContainerEntryModule.default(dep.name, dep.exposes, dep.shareScope, dep.injectRuntimeEntry) });
20
20
  }
21
21
  };
22
22
 
@@ -1 +1 @@
1
- {"version":3,"file":"ContainerEntryModuleFactory.js","names":["ContainerEntryModule"],"sources":["../../../../src/lib/container/ContainerEntryModuleFactory.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';\n\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport ContainerEntryModule from './ContainerEntryModule';\nimport ContainerEntryDependency from './ContainerEntryDependency';\n\nconst ModuleFactory = require(\n normalizeWebpackPath('webpack/lib/ModuleFactory'),\n) as typeof import('webpack/lib/ModuleFactory');\nimport type {\n ModuleFactoryCreateData,\n ModuleFactoryResult,\n} from 'webpack/lib/ModuleFactory';\n\nexport default class ContainerEntryModuleFactory extends ModuleFactory {\n /**\n * @param {ModuleFactoryCreateData} data data object\n * @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback\n * @returns {void}\n */\n override create(\n data: ModuleFactoryCreateData,\n callback: (error: Error | null, result: ModuleFactoryResult) => void,\n ): void {\n const { dependencies } = data;\n const containerDependencies =\n dependencies as unknown as ContainerEntryDependency[];\n const dep = containerDependencies[0];\n\n callback(null, {\n module: new ContainerEntryModule(\n dep.name,\n dep.exposes,\n dep.shareScope,\n dep.injectRuntimeEntry,\n dep.dataPrefetch,\n ),\n });\n }\n}\n"],"mappings":";;;;;;;;AAWA,MAAM,gBAAgB,gFACC,4BAA4B,CAClD;AAMD,IAAqB,8BAArB,cAAyD,cAAc;;;;;;CAMrE,AAAS,OACP,MACA,UACM;EACN,MAAM,EAAE,iBAAiB;EAGzB,MAAM,MADJ,aACgC;AAElC,WAAS,MAAM,EACb,QAAQ,IAAIA,mDACV,IAAI,MACJ,IAAI,SACJ,IAAI,YACJ,IAAI,oBACJ,IAAI,aACL,EACF,CAAC"}
1
+ {"version":3,"file":"ContainerEntryModuleFactory.js","names":["ContainerEntryModule"],"sources":["../../../../src/lib/container/ContainerEntryModuleFactory.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';\n\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport ContainerEntryModule from './ContainerEntryModule';\nimport ContainerEntryDependency from './ContainerEntryDependency';\n\nconst ModuleFactory = require(\n normalizeWebpackPath('webpack/lib/ModuleFactory'),\n) as typeof import('webpack/lib/ModuleFactory');\nimport type {\n ModuleFactoryCreateData,\n ModuleFactoryResult,\n} from 'webpack/lib/ModuleFactory';\n\nexport default class ContainerEntryModuleFactory extends ModuleFactory {\n /**\n * @param {ModuleFactoryCreateData} data data object\n * @param {function((Error | null)=, ModuleFactoryResult=): void} callback callback\n * @returns {void}\n */\n override create(\n data: ModuleFactoryCreateData,\n callback: (error: Error | null, result: ModuleFactoryResult) => void,\n ): void {\n const { dependencies } = data;\n const containerDependencies =\n dependencies as unknown as ContainerEntryDependency[];\n const dep = containerDependencies[0];\n\n callback(null, {\n module: new ContainerEntryModule(\n dep.name,\n dep.exposes,\n dep.shareScope,\n dep.injectRuntimeEntry,\n ),\n });\n }\n}\n"],"mappings":";;;;;;;;AAWA,MAAM,gBAAgB,gFACC,4BAA4B,CAClD;AAMD,IAAqB,8BAArB,cAAyD,cAAc;;;;;;CAMrE,AAAS,OACP,MACA,UACM;EACN,MAAM,EAAE,iBAAiB;EAGzB,MAAM,MADJ,aACgC;AAElC,WAAS,MAAM,EACb,QAAQ,IAAIA,mDACV,IAAI,MACJ,IAAI,SACJ,IAAI,YACJ,IAAI,mBACL,EACF,CAAC"}
@@ -12,7 +12,6 @@ let _module_federation_sdk_normalize_webpack_path = require("@module-federation/
12
12
  //#region src/lib/container/ContainerPlugin.ts
13
13
  const ModuleDependency = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/dependencies/ModuleDependency"));
14
14
  const EntryDependency = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/dependencies/EntryDependency"));
15
- require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/create-schema-validation"));
16
15
  const PLUGIN_NAME = "ContainerPlugin";
17
16
  var ContainerPlugin = class ContainerPlugin {
18
17
  constructor(options) {
@@ -33,8 +32,7 @@ var ContainerPlugin = class ContainerPlugin {
33
32
  import: Array.isArray(item.import) ? item.import : [item.import],
34
33
  name: item.name || void 0
35
34
  })),
36
- runtimePlugins: options.runtimePlugins,
37
- dataPrefetch: options.dataPrefetch
35
+ runtimePlugins: options.runtimePlugins
38
36
  };
39
37
  }
40
38
  static patchChunkSplit(compiler, name) {
@@ -92,7 +90,7 @@ var ContainerPlugin = class ContainerPlugin {
92
90
  compiler.hooks.make.tapAsync(PLUGIN_NAME, async (compilation, callback) => {
93
91
  const hooks = require_lib_container_runtime_FederationModulesPlugin.default.getCompilationHooks(compilation);
94
92
  const federationRuntimeDependency = federationRuntimePluginInstance.getDependency(compiler);
95
- const dep = new require_lib_container_ContainerEntryDependency.default(name, exposes, shareScope, federationRuntimePluginInstance.entryFilePath, this._options.dataPrefetch);
93
+ const dep = new require_lib_container_ContainerEntryDependency.default(name, exposes, shareScope, federationRuntimePluginInstance.entryFilePath);
96
94
  dep.loc = { name };
97
95
  await new Promise((resolve, reject) => {
98
96
  compilation.addEntry(compilation.options.context || "", dep, {
@@ -124,7 +122,7 @@ var ContainerPlugin = class ContainerPlugin {
124
122
  if (runtime) createdRuntimes.add(runtime);
125
123
  }
126
124
  if (createdRuntimes.size === 0 && !compilation.options?.optimization?.runtimeChunk) return callback();
127
- const dep = new require_lib_container_ContainerEntryDependency.default(name, exposes, shareScope, federationRuntimePluginInstance.entryFilePath, this._options.dataPrefetch);
125
+ const dep = new require_lib_container_ContainerEntryDependency.default(name, exposes, shareScope, federationRuntimePluginInstance.entryFilePath);
128
126
  dep.loc = { name };
129
127
  compilation.addInclude(compilation.options.context || "", dep, { name: void 0 }, (error) => {
130
128
  if (error) return callback(error);
@@ -1 +1 @@
1
- {"version":3,"file":"ContainerPlugin.js","names":["parseOptions","FederationRuntimePlugin","FederationModulesPlugin","ContainerEntryDependency","ContainerEntryModuleFactory","ContainerExposedDependency","FederationRuntimeDependency"],"sources":["../../../../src/lib/container/ContainerPlugin.ts"],"sourcesContent":["/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n Author Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr\n*/\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport ContainerEntryDependency from './ContainerEntryDependency';\nimport ContainerEntryModuleFactory from './ContainerEntryModuleFactory';\nimport ContainerExposedDependency from './ContainerExposedDependency';\nimport { parseOptions } from './options';\nimport type {\n Compiler,\n Compilation,\n WebpackError,\n WebpackPluginInstance,\n WebpackPluginFunction,\n} from 'webpack';\nimport type { containerPlugin } from '@module-federation/sdk';\nimport FederationRuntimePlugin from './runtime/FederationRuntimePlugin';\nimport FederationModulesPlugin from './runtime/FederationModulesPlugin';\nimport checkOptions from '../../schemas/container/ContainerPlugin.check';\nimport schema from '../../schemas/container/ContainerPlugin';\nimport FederationRuntimeDependency from './runtime/FederationRuntimeDependency';\nimport type { OptimizationSplitChunksCacheGroup } from 'webpack/lib/optimize/SplitChunksPlugin';\nimport type { Falsy } from 'webpack/declarations/WebpackOptions';\n\nconst ModuleDependency = require(\n normalizeWebpackPath('webpack/lib/dependencies/ModuleDependency'),\n) as typeof import('webpack/lib/dependencies/ModuleDependency');\n\nconst EntryDependency = require(\n normalizeWebpackPath('webpack/lib/dependencies/EntryDependency'),\n) as typeof import('webpack/lib/dependencies/EntryDependency');\n\nconst createSchemaValidation = require(\n normalizeWebpackPath('webpack/lib/util/create-schema-validation'),\n) as typeof import('webpack/lib/util/create-schema-validation');\n\n// const validate = createSchemaValidation(checkOptions, () => schema, {\n// name: 'Container Plugin',\n// baseDataPath: 'options',\n// });\n\nconst PLUGIN_NAME = 'ContainerPlugin';\n\nclass ContainerPlugin {\n _options: containerPlugin.ContainerPluginOptions;\n name: string;\n\n constructor(options: containerPlugin.ContainerPluginOptions) {\n // validate(options);\n this.name = PLUGIN_NAME;\n\n this._options = {\n name: options.name,\n shareScope: options.shareScope || 'default',\n library: options.library || {\n type: 'global',\n name: options.name,\n },\n runtime: options.runtime,\n filename: options.filename || undefined,\n //@ts-ignore\n exposes: parseOptions(\n options.exposes,\n (item) => ({\n import: Array.isArray(item) ? item : [item],\n name: undefined,\n }),\n (item) => ({\n import: Array.isArray(item.import) ? item.import : [item.import],\n name: item.name || undefined,\n }),\n ),\n runtimePlugins: options.runtimePlugins,\n dataPrefetch: options.dataPrefetch,\n };\n }\n\n // container should not be affected by splitChunks\n static patchChunkSplit(compiler: Compiler, name: string): void {\n const { splitChunks } = compiler.options.optimization;\n const patchChunkSplit = (\n cacheGroup:\n | string\n | false\n | ((...args: any[]) => any)\n | RegExp\n | OptimizationSplitChunksCacheGroup,\n ) => {\n switch (typeof cacheGroup) {\n case 'boolean':\n case 'string':\n case 'function':\n break;\n // cacheGroup.chunks will inherit splitChunks.chunks, so you only need to modify the chunks that are set separately\n case 'object':\n {\n if (cacheGroup instanceof RegExp) {\n break;\n }\n if (!cacheGroup.chunks) {\n break;\n }\n if (typeof cacheGroup.chunks === 'function') {\n const prevChunks = cacheGroup.chunks;\n cacheGroup.chunks = (chunk) => {\n if (\n chunk.name &&\n (chunk.name === name || chunk.name === name + '_partial')\n ) {\n return false;\n }\n return prevChunks(chunk);\n };\n break;\n }\n\n if (cacheGroup.chunks === 'all') {\n cacheGroup.chunks = (chunk) => {\n if (\n chunk.name &&\n (chunk.name === name || chunk.name === name + '_partial')\n ) {\n return false;\n }\n return true;\n };\n break;\n }\n if (cacheGroup.chunks === 'initial') {\n cacheGroup.chunks = (chunk) => {\n if (\n chunk.name &&\n (chunk.name === name || chunk.name === name + '_partial')\n ) {\n return false;\n }\n return chunk.isOnlyInitial();\n };\n break;\n }\n }\n break;\n }\n };\n\n if (!splitChunks) {\n return;\n }\n // patch splitChunk.chunks\n patchChunkSplit(splitChunks);\n\n const cacheGroups = splitChunks.cacheGroups;\n if (!cacheGroups) {\n return;\n }\n\n // patch splitChunk.cacheGroups[key].chunks\n Object.keys(cacheGroups).forEach((cacheGroupKey) => {\n patchChunkSplit(cacheGroups[cacheGroupKey]);\n });\n }\n\n apply(compiler: Compiler): void {\n const useModuleFederationPlugin = compiler.options.plugins.find(\n (p: Falsy | WebpackPluginInstance | WebpackPluginFunction) => {\n if (typeof p !== 'object' || !p) {\n return false;\n }\n\n return p['name'] === 'ModuleFederationPlugin';\n },\n );\n\n if (!useModuleFederationPlugin) {\n ContainerPlugin.patchChunkSplit(compiler, this._options.name);\n }\n\n const federationRuntimePluginInstance = new FederationRuntimePlugin();\n federationRuntimePluginInstance.apply(compiler);\n\n const { name, exposes, shareScope, filename, library, runtime } =\n this._options;\n\n if (\n library &&\n compiler.options.output &&\n compiler.options.output.enabledLibraryTypes &&\n !compiler.options.output.enabledLibraryTypes.includes(library.type)\n ) {\n compiler.options.output.enabledLibraryTypes.push(library.type);\n }\n\n compiler.hooks.make.tapAsync(\n PLUGIN_NAME,\n async (\n compilation: Compilation,\n callback: (error?: WebpackError | null | undefined) => void,\n ) => {\n const hooks = FederationModulesPlugin.getCompilationHooks(compilation);\n const federationRuntimeDependency =\n federationRuntimePluginInstance.getDependency(compiler);\n const dep = new ContainerEntryDependency(\n name,\n //@ts-ignore\n exposes,\n shareScope,\n federationRuntimePluginInstance.entryFilePath,\n this._options.dataPrefetch,\n );\n dep.loc = { name };\n\n await new Promise((resolve, reject) => {\n compilation.addEntry(\n compilation.options.context || '',\n dep,\n {\n name,\n filename,\n runtime,\n library,\n },\n (error: WebpackError | null | undefined) => {\n if (error) return reject(error);\n hooks.addContainerEntryDependency.call(dep);\n resolve(undefined);\n },\n );\n }).catch(callback);\n\n await new Promise((resolve, reject) => {\n compilation.addInclude(\n compiler.context,\n federationRuntimeDependency,\n { name: undefined },\n (err, module) => {\n if (err) {\n return reject(err);\n }\n hooks.addFederationRuntimeDependency.call(\n federationRuntimeDependency,\n );\n resolve(undefined);\n },\n );\n }).catch(callback);\n\n callback();\n },\n );\n\n // this will still be copied into child compiler, so it needs a check to avoid running hook on child\n // we have to use finishMake in order to check the entries created and see if there are multiple runtime chunks\n compiler.hooks.finishMake.tapAsync(\n PLUGIN_NAME,\n (compilation: Compilation, callback) => {\n if (\n compilation.compiler.parentCompilation &&\n compilation.compiler.parentCompilation !== compilation\n ) {\n return callback();\n }\n\n const hooks = FederationModulesPlugin.getCompilationHooks(compilation);\n const createdRuntimes = new Set<string>();\n\n for (const entry of compilation.entries.values()) {\n const runtime = entry.options.runtime;\n if (runtime) {\n createdRuntimes.add(runtime);\n }\n }\n\n if (\n createdRuntimes.size === 0 &&\n !compilation.options?.optimization?.runtimeChunk\n ) {\n return callback();\n }\n\n const dep = new ContainerEntryDependency(\n name,\n //@ts-ignore\n exposes,\n shareScope,\n federationRuntimePluginInstance.entryFilePath,\n this._options.dataPrefetch,\n );\n\n dep.loc = { name };\n\n compilation.addInclude(\n compilation.options.context || '',\n dep,\n { name: undefined },\n (error: WebpackError | null | undefined) => {\n if (error) return callback(error);\n hooks.addContainerEntryDependency.call(dep);\n callback();\n },\n );\n },\n );\n\n // add the container entry module\n compiler.hooks.thisCompilation.tap(\n PLUGIN_NAME,\n (compilation: Compilation, { normalModuleFactory }) => {\n compilation.dependencyFactories.set(\n ContainerEntryDependency,\n new ContainerEntryModuleFactory(),\n );\n\n compilation.dependencyFactories.set(\n ContainerExposedDependency,\n normalModuleFactory,\n );\n\n if (!compilation.dependencyFactories.has(EntryDependency)) {\n compilation.dependencyFactories.set(\n EntryDependency,\n normalModuleFactory,\n );\n }\n },\n );\n\n // add include of federation runtime\n compiler.hooks.thisCompilation.tap(\n PLUGIN_NAME,\n (compilation: Compilation, { normalModuleFactory }) => {\n compilation.dependencyFactories.set(\n FederationRuntimeDependency,\n normalModuleFactory,\n );\n compilation.dependencyTemplates.set(\n FederationRuntimeDependency,\n new ModuleDependency.Template(),\n );\n },\n );\n }\n}\n\nexport default ContainerPlugin;\n"],"mappings":";;;;;;;;;;;;AAyBA,MAAM,mBAAmB,gFACF,4CAA4C,CAClE;AAED,MAAM,kBAAkB,gFACD,2CAA2C,CACjE;AAE8B,gFACR,4CAA4C,CAClE;AAOD,MAAM,cAAc;AAEpB,IAAM,kBAAN,MAAM,gBAAgB;CAIpB,YAAY,SAAiD;AAE3D,OAAK,OAAO;AAEZ,OAAK,WAAW;GACd,MAAM,QAAQ;GACd,YAAY,QAAQ,cAAc;GAClC,SAAS,QAAQ,WAAW;IAC1B,MAAM;IACN,MAAM,QAAQ;IACf;GACD,SAAS,QAAQ;GACjB,UAAU,QAAQ,YAAY;GAE9B,SAASA,2CACP,QAAQ,UACP,UAAU;IACT,QAAQ,MAAM,QAAQ,KAAK,GAAG,O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D,8DAAwB,oBAAoB,YAAY;GACtE,MAAM,kCAAkB,IAAI,KAAa;AAEzC,QAAK,MAAM,SAAS,YAAY,QAAQ,QAAQ,EAAE;IAChD,MAAM,UAAU,MAAM,QAAQ;AAC9B,QAAI,QACF,iBAAgB,IAAI,QAAQ;;AAIhC,OACE,gBAAgB,SAAS,KACzB,CAAC,YAAY,SAAS,cAAc,aAEpC,QAAO,UAAU;GAGnB,MAAM,MAAM,IAAIC,uDACd,MAEA,SACA,YACA,gCAAgC,eAChC,KAAK,SAAS,aACf;AAED,OAAI,MAAM,EAAE,MAAM;AAElB,eAAY,WACV,YAAY,QAAQ,WAAW,IAC/B,KACA,EAAE,MAAM,QAAW,GAClB,UAA2C;AAC1C,QAAI,MAAO,QAAO,SAAS,MAAM;AACjC,UAAM,4BAA4B,KAAK,IAAI;AAC3C,cAAU;KAEb;IAEJ;AAGD,WAAS,MAAM,gBAAgB,IAC7B,cACC,aAA0B,EAAE,0BAA0B;AACrD,eAAY,oBAAoB,IAC9BA,wDACA,IAAIC,2DAA6B,CAClC;AAED,eAAY,oBAAoB,IAC9BC,0DACA,oBACD;AAED,OAAI,CAAC,YAAY,oBAAoB,IAAI,gBAAgB,CACvD,aAAY,oBAAoB,IAC9B,iBACA,oBACD;IAGN;AAGD,WAAS,MAAM,gBAAgB,IAC7B,cACC,aAA0B,EAAE,0BAA0B;AACrD,eAAY,oBAAoB,IAC9BC,mEACA,oBACD;AACD,eAAY,oBAAoB,IAC9BA,mEACA,IAAI,iBAAiB,UAAU,CAChC;IAEJ"}
1
+ {"version":3,"file":"ContainerPlugin.js","names":["parseOptions","FederationRuntimePlugin","FederationModulesPlugin","ContainerEntryDependency","ContainerEntryModuleFactory","ContainerExposedDependency","FederationRuntimeDependency"],"sources":["../../../../src/lib/container/ContainerPlugin.ts"],"sourcesContent":["/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n Author Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr\n*/\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport ContainerEntryDependency from './ContainerEntryDependency';\nimport ContainerEntryModuleFactory from './ContainerEntryModuleFactory';\nimport ContainerExposedDependency from './ContainerExposedDependency';\nimport { parseOptions } from './options';\nimport type {\n Compiler,\n Compilation,\n WebpackError,\n WebpackPluginInstance,\n WebpackPluginFunction,\n} from 'webpack';\nimport type { containerPlugin } from '@module-federation/sdk';\nimport FederationRuntimePlugin from './runtime/FederationRuntimePlugin';\nimport FederationModulesPlugin from './runtime/FederationModulesPlugin';\nimport FederationRuntimeDependency from './runtime/FederationRuntimeDependency';\nimport type { OptimizationSplitChunksCacheGroup } from 'webpack/lib/optimize/SplitChunksPlugin';\nimport type { Falsy } from 'webpack/declarations/WebpackOptions';\n\nconst ModuleDependency = require(\n normalizeWebpackPath('webpack/lib/dependencies/ModuleDependency'),\n) as typeof import('webpack/lib/dependencies/ModuleDependency');\n\nconst EntryDependency = require(\n normalizeWebpackPath('webpack/lib/dependencies/EntryDependency'),\n) as typeof import('webpack/lib/dependencies/EntryDependency');\n\nconst PLUGIN_NAME = 'ContainerPlugin';\n\nclass ContainerPlugin {\n _options: containerPlugin.ContainerPluginOptions;\n name: string;\n\n constructor(options: containerPlugin.ContainerPluginOptions) {\n // validate(options);\n this.name = PLUGIN_NAME;\n\n this._options = {\n name: options.name,\n shareScope: options.shareScope || 'default',\n library: options.library || {\n type: 'global',\n name: options.name,\n },\n runtime: options.runtime,\n filename: options.filename || undefined,\n //@ts-ignore\n exposes: parseOptions(\n options.exposes,\n (item) => ({\n import: Array.isArray(item) ? item : [item],\n name: undefined,\n }),\n (item) => ({\n import: Array.isArray(item.import) ? item.import : [item.import],\n name: item.name || undefined,\n }),\n ),\n runtimePlugins: options.runtimePlugins,\n };\n }\n\n // container should not be affected by splitChunks\n static patchChunkSplit(compiler: Compiler, name: string): void {\n const { splitChunks } = compiler.options.optimization;\n const patchChunkSplit = (\n cacheGroup:\n | string\n | false\n | ((...args: any[]) => any)\n | RegExp\n | OptimizationSplitChunksCacheGroup,\n ) => {\n switch (typeof cacheGroup) {\n case 'boolean':\n case 'string':\n case 'function':\n break;\n // cacheGroup.chunks will inherit splitChunks.chunks, so you only need to modify the chunks that are set separately\n case 'object':\n {\n if (cacheGroup instanceof RegExp) {\n break;\n }\n if (!cacheGroup.chunks) {\n break;\n }\n if (typeof cacheGroup.chunks === 'function') {\n const prevChunks = cacheGroup.chunks;\n cacheGroup.chunks = (chunk) => {\n if (\n chunk.name &&\n (chunk.name === name || chunk.name === name + '_partial')\n ) {\n return false;\n }\n return prevChunks(chunk);\n };\n break;\n }\n\n if (cacheGroup.chunks === 'all') {\n cacheGroup.chunks = (chunk) => {\n if (\n chunk.name &&\n (chunk.name === name || chunk.name === name + '_partial')\n ) {\n return false;\n }\n return true;\n };\n break;\n }\n if (cacheGroup.chunks === 'initial') {\n cacheGroup.chunks = (chunk) => {\n if (\n chunk.name &&\n (chunk.name === name || chunk.name === name + '_partial')\n ) {\n return false;\n }\n return chunk.isOnlyInitial();\n };\n break;\n }\n }\n break;\n }\n };\n\n if (!splitChunks) {\n return;\n }\n // patch splitChunk.chunks\n patchChunkSplit(splitChunks);\n\n const cacheGroups = splitChunks.cacheGroups;\n if (!cacheGroups) {\n return;\n }\n\n // patch splitChunk.cacheGroups[key].chunks\n Object.keys(cacheGroups).forEach((cacheGroupKey) => {\n patchChunkSplit(cacheGroups[cacheGroupKey]);\n });\n }\n\n apply(compiler: Compiler): void {\n const useModuleFederationPlugin = compiler.options.plugins.find(\n (p: Falsy | WebpackPluginInstance | WebpackPluginFunction) => {\n if (typeof p !== 'object' || !p) {\n return false;\n }\n\n return p['name'] === 'ModuleFederationPlugin';\n },\n );\n\n if (!useModuleFederationPlugin) {\n ContainerPlugin.patchChunkSplit(compiler, this._options.name);\n }\n\n const federationRuntimePluginInstance = new FederationRuntimePlugin();\n federationRuntimePluginInstance.apply(compiler);\n\n const { name, exposes, shareScope, filename, library, runtime } =\n this._options;\n\n if (\n library &&\n compiler.options.output &&\n compiler.options.output.enabledLibraryTypes &&\n !compiler.options.output.enabledLibraryTypes.includes(library.type)\n ) {\n compiler.options.output.enabledLibraryTypes.push(library.type);\n }\n\n compiler.hooks.make.tapAsync(\n PLUGIN_NAME,\n async (\n compilation: Compilation,\n callback: (error?: WebpackError | null | undefined) => void,\n ) => {\n const hooks = FederationModulesPlugin.getCompilationHooks(compilation);\n const federationRuntimeDependency =\n federationRuntimePluginInstance.getDependency(compiler);\n const dep = new ContainerEntryDependency(\n name,\n //@ts-ignore\n exposes,\n shareScope,\n federationRuntimePluginInstance.entryFilePath,\n );\n dep.loc = { name };\n\n await new Promise((resolve, reject) => {\n compilation.addEntry(\n compilation.options.context || '',\n dep,\n {\n name,\n filename,\n runtime,\n library,\n },\n (error: WebpackError | null | undefined) => {\n if (error) return reject(error);\n hooks.addContainerEntryDependency.call(dep);\n resolve(undefined);\n },\n );\n }).catch(callback);\n\n await new Promise((resolve, reject) => {\n compilation.addInclude(\n compiler.context,\n federationRuntimeDependency,\n { name: undefined },\n (err, module) => {\n if (err) {\n return reject(err);\n }\n hooks.addFederationRuntimeDependency.call(\n federationRuntimeDependency,\n );\n resolve(undefined);\n },\n );\n }).catch(callback);\n\n callback();\n },\n );\n\n // this will still be copied into child compiler, so it needs a check to avoid running hook on child\n // we have to use finishMake in order to check the entries created and see if there are multiple runtime chunks\n compiler.hooks.finishMake.tapAsync(\n PLUGIN_NAME,\n (compilation: Compilation, callback) => {\n if (\n compilation.compiler.parentCompilation &&\n compilation.compiler.parentCompilation !== compilation\n ) {\n return callback();\n }\n\n const hooks = FederationModulesPlugin.getCompilationHooks(compilation);\n const createdRuntimes = new Set<string>();\n\n for (const entry of compilation.entries.values()) {\n const runtime = entry.options.runtime;\n if (runtime) {\n createdRuntimes.add(runtime);\n }\n }\n\n if (\n createdRuntimes.size === 0 &&\n !compilation.options?.optimization?.runtimeChunk\n ) {\n return callback();\n }\n\n const dep = new ContainerEntryDependency(\n name,\n //@ts-ignore\n exposes,\n shareScope,\n federationRuntimePluginInstance.entryFilePath,\n );\n\n dep.loc = { name };\n\n compilation.addInclude(\n compilation.options.context || '',\n dep,\n { name: undefined },\n (error: WebpackError | null | undefined) => {\n if (error) return callback(error);\n hooks.addContainerEntryDependency.call(dep);\n callback();\n },\n );\n },\n );\n\n // add the container entry module\n compiler.hooks.thisCompilation.tap(\n PLUGIN_NAME,\n (compilation: Compilation, { normalModuleFactory }) => {\n compilation.dependencyFactories.set(\n ContainerEntryDependency,\n new ContainerEntryModuleFactory(),\n );\n\n compilation.dependencyFactories.set(\n ContainerExposedDependency,\n normalModuleFactory,\n );\n\n if (!compilation.dependencyFactories.has(EntryDependency)) {\n compilation.dependencyFactories.set(\n EntryDependency,\n normalModuleFactory,\n );\n }\n },\n );\n\n // add include of federation runtime\n compiler.hooks.thisCompilation.tap(\n PLUGIN_NAME,\n (compilation: Compilation, { normalModuleFactory }) => {\n compilation.dependencyFactories.set(\n FederationRuntimeDependency,\n normalModuleFactory,\n );\n compilation.dependencyTemplates.set(\n FederationRuntimeDependency,\n new ModuleDependency.Template(),\n );\n },\n );\n }\n}\n\nexport default ContainerPlugin;\n"],"mappings":";;;;;;;;;;;;AAuBA,MAAM,mBAAmB,gFACF,4CAA4C,CAClE;AAED,MAAM,kBAAkB,gFACD,2CAA2C,CACjE;AAED,MAAM,cAAc;AAEpB,IAAM,kBAAN,MAAM,gBAAgB;CAIpB,YAAY,SAAiD;AAE3D,OAAK,OAAO;AAEZ,OAAK,WAAW;GACd,MAAM,QAAQ;GACd,YAAY,QAAQ,cAAc;GAClC,SAAS,QAAQ,WAAW;IAC1B,MAAM;IACN,MAAM,QAAQ;IACf;GACD,SAAS,QAAQ;GACjB,UAAU,QAAQ,YAAY;GAE9B,SAASA,2CACP,QAAQ,UACP,UAAU;IACT,QAAQ,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC,KAAK;IAC3C,MAAM;IACP,IACA,UAAU;IACT,QAAQ,MA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QAAQ,EAAE;IAChD,MAAM,UAAU,MAAM,QAAQ;AAC9B,QAAI,QACF,iBAAgB,IAAI,QAAQ;;AAIhC,OACE,gBAAgB,SAAS,KACzB,CAAC,YAAY,SAAS,cAAc,aAEpC,QAAO,UAAU;GAGnB,MAAM,MAAM,IAAIC,uDACd,MAEA,SACA,YACA,gCAAgC,cACjC;AAED,OAAI,MAAM,EAAE,MAAM;AAElB,eAAY,WACV,YAAY,QAAQ,WAAW,IAC/B,KACA,EAAE,MAAM,QAAW,GAClB,UAA2C;AAC1C,QAAI,MAAO,QAAO,SAAS,MAAM;AACjC,UAAM,4BAA4B,KAAK,IAAI;AAC3C,cAAU;KAEb;IAEJ;AAGD,WAAS,MAAM,gBAAgB,IAC7B,cACC,aAA0B,EAAE,0BAA0B;AACrD,eAAY,oBAAoB,IAC9BA,wDACA,IAAIC,2DAA6B,CAClC;AAED,eAAY,oBAAoB,IAC9BC,0DACA,oBACD;AAED,OAAI,CAAC,YAAY,oBAAoB,IAAI,gBAAgB,CACvD,aAAY,oBAAoB,IAC9B,iBACA,oBACD;IAGN;AAGD,WAAS,MAAM,gBAAgB,IAC7B,cACC,aAA0B,EAAE,0BAA0B;AACrD,eAAY,oBAAoB,IAC9BC,mEACA,oBACD;AACD,eAAY,oBAAoB,IAC9BA,mEACA,IAAI,iBAAiB,UAAU,CAChC;IAEJ"}
@@ -13,7 +13,6 @@ let _module_federation_sdk_normalize_webpack_path = require("@module-federation/
13
13
 
14
14
  //#region src/lib/container/ContainerReferencePlugin.ts
15
15
  const { ExternalsPlugin } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack"));
16
- require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack/lib/util/create-schema-validation"));
17
16
  const slashCode = "/".charCodeAt(0);
18
17
  var ContainerReferencePlugin = class {
19
18
  constructor(options) {
@@ -1 +1 @@
1
- {"version":3,"file":"ContainerReferencePlugin.js","names":["parseOptions","FederationRuntimePlugin","RemoteToExternalDependency","FallbackItemDependency","FallbackDependency","FallbackModuleFactory","FederationModulesPlugin","RemoteModule","RemoteRuntimeModule"],"sources":["../../../../src/lib/container/ContainerReferencePlugin.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra and Zackary Jackson @ScriptedAlchemy\n*/\nimport type { Compiler } from 'webpack';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\n\n// import * as RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport FallbackDependency from './FallbackDependency';\nimport FallbackItemDependency from './FallbackItemDependency';\nimport FallbackModuleFactory from './FallbackModuleFactory';\nimport RemoteModule from './RemoteModule';\nimport RemoteRuntimeModule from './RemoteRuntimeModule';\nimport RemoteToExternalDependency from './RemoteToExternalDependency';\nimport { parseOptions } from './options';\nimport type {\n containerReferencePlugin,\n moduleFederationPlugin,\n} from '@module-federation/sdk';\nimport FederationRuntimePlugin from './runtime/FederationRuntimePlugin';\nimport FederationModulesPlugin from './runtime/FederationModulesPlugin';\nimport schema from '../../schemas/container/ContainerReferencePlugin';\nimport checkOptions from '../../schemas/container/ContainerReferencePlugin.check';\n\nconst { ExternalsPlugin } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\nconst createSchemaValidation = require(\n normalizeWebpackPath('webpack/lib/util/create-schema-validation'),\n) as typeof import('webpack/lib/util/create-schema-validation');\n\n// const validate = createSchemaValidation(\n// //eslint-disable-next-line\n// checkOptions,\n// () => schema,\n// {\n// name: 'Container Reference Plugin',\n// baseDataPath: 'options',\n// },\n// );\n\nconst slashCode = '/'.charCodeAt(0);\n\nclass ContainerReferencePlugin {\n private _remoteType: moduleFederationPlugin.ExternalsType;\n private _remotes: [string, moduleFederationPlugin.RemotesConfig][];\n\n constructor(\n options: containerReferencePlugin.ContainerReferencePluginOptions,\n ) {\n // validate(options);\n\n this._remoteType = options.remoteType;\n this._remotes = parseOptions(\n options.remotes,\n (item) => ({\n external: Array.isArray(item) ? item : [item],\n shareScope: options.shareScope || 'default',\n }),\n (item) => ({\n external: Array.isArray(item.external)\n ? item.external\n : [item.external],\n shareScope: item.shareScope || options.shareScope || 'default',\n }),\n );\n }\n\n /**\n * Apply the plugin\n * @param {Compiler} compiler the compiler instance\n * @returns {void}\n */\n apply(compiler: Compiler): void {\n const { _remotes: remotes, _remoteType: remoteType } = this;\n new FederationRuntimePlugin().apply(compiler);\n /** @type {Record<string, string>} */\n const remoteExternals: Record<string, string> = {};\n\n for (const [key, config] of remotes) {\n let i = 0;\n for (const external of config.external) {\n if (typeof external === 'string' && external.startsWith('internal ')) {\n continue;\n }\n remoteExternals[\n `webpack/container/reference/${key}${i ? `/fallback-${i}` : ''}`\n ] = external;\n i++;\n }\n }\n const Externals = compiler.webpack.ExternalsPlugin || ExternalsPlugin;\n new Externals(remoteType, remoteExternals).apply(compiler);\n\n compiler.hooks.compilation.tap(\n 'ContainerReferencePlugin',\n (compilation, { normalModuleFactory }) => {\n compilation.dependencyFactories.set(\n RemoteToExternalDependency,\n normalModuleFactory,\n );\n\n compilation.dependencyFactories.set(\n FallbackItemDependency,\n normalModuleFactory,\n );\n\n compilation.dependencyFactories.set(\n FallbackDependency,\n new FallbackModuleFactory(),\n );\n\n const hooks = FederationModulesPlugin.getCompilationHooks(compilation);\n\n normalModuleFactory.hooks.factorize.tap(\n 'ContainerReferencePlugin',\n //@ts-ignore\n (data) => {\n if (!data.request.includes('!')) {\n for (const [key, config] of remotes) {\n if (\n data.request.startsWith(`${key}`) &&\n (data.request.length === key.length ||\n data.request.charCodeAt(key.length) === slashCode)\n ) {\n const remoteModule = new RemoteModule(\n data.request,\n //@ts-ignore\n config.external.map((external: any, i: any) =>\n external.startsWith('internal ')\n ? external.slice(9)\n : `webpack/container/reference/${key}${\n i ? `/fallback-${i}` : ''\n }`,\n ),\n `.${data.request.slice(key.length)}`,\n //@ts-ignore\n config.shareScope,\n );\n hooks.addRemoteDependency.call(remoteModule);\n return remoteModule;\n }\n }\n }\n },\n );\n\n compilation.hooks.runtimeRequirementInTree\n .for(compiler.webpack.RuntimeGlobals.ensureChunkHandlers)\n .tap('ContainerReferencePlugin', (chunk, set) => {\n set.add(compiler.webpack.RuntimeGlobals.module);\n set.add(compiler.webpack.RuntimeGlobals.moduleFactoriesAddOnly);\n set.add(compiler.webpack.RuntimeGlobals.hasOwnProperty);\n set.add(compiler.webpack.RuntimeGlobals.initializeSharing);\n set.add(compiler.webpack.RuntimeGlobals.shareScopeMap);\n compilation.addRuntimeModule(chunk, new RemoteRuntimeModule());\n });\n },\n );\n }\n}\n\nexport default ContainerReferencePlugin;\n"],"mappings":";;;;;;;;;;;;;;AAwBA,MAAM,EAAE,oBAAoB,gFACL,UAAU,CAChC;AAE8B,gFACR,4CAA4C,CAClE;AAYD,MAAM,YAAY,IAAI,WAAW,EAAE;AAEnC,IAAM,2BAAN,MAA+B;CAI7B,YACE,SACA;AAGA,OAAK,cAAc,QAAQ;AAC3B,OAAK,WAAWA,2CACd,QAAQ,UACP,UAAU;GACT,UAAU,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC,KAAK;GAC7C,YAAY,QAAQ,cAAc;GACnC,IACA,UAAU;GACT,UAAU,MAAM,QAAQ,KAAK,SAAS,GAClC,KAAK,WACL,CAAC,KAAK,SAAS;GACnB,YAAY,KAAK,cAAc,QAAQ,cAAc;GACtD,EACF;;;;;;;CAQH,MAAM,UAA0B;EAC9B,MAAM,EAAE,UAAU,SAAS,aAAa,eAAe;AACvD,MAAIC,+DAAyB,CAAC,MAAM,SAAS;;EAE7C,MAAM,kBAA0C,EAAE;AAElD,OAAK,MAAM,CAAC,KAAK,WAAW,SAAS;GACnC,IAAI,IAAI;AACR,QAAK,MAAM,YAAY,OAAO,UAAU;AACtC,QAAI,OAAO,aAAa,YAAY,SAAS,WAAW,YAAY,CAClE;AAEF,oBACE,+BAA+B,MAAM,IAAI,aAAa,MAAM,QAC1D;AACJ;;;AAIJ,OADkB,SAA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ugin.js","names":["parseOptions","FederationRuntimePlugin","RemoteToExternalDependency","FallbackItemDependency","FallbackDependency","FallbackModuleFactory","FederationModulesPlugin","RemoteModule","RemoteRuntimeModule"],"sources":["../../../../src/lib/container/ContainerReferencePlugin.ts"],"sourcesContent":["/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra and Zackary Jackson @ScriptedAlchemy\n*/\nimport type { Compiler } from 'webpack';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\n\n// import * as RuntimeGlobals from 'webpack/lib/RuntimeGlobals';\nimport FallbackDependency from './FallbackDependency';\nimport FallbackItemDependency from './FallbackItemDependency';\nimport FallbackModuleFactory from './FallbackModuleFactory';\nimport RemoteModule from './RemoteModule';\nimport RemoteRuntimeModule from './RemoteRuntimeModule';\nimport RemoteToExternalDependency from './RemoteToExternalDependency';\nimport { parseOptions } from './options';\nimport type {\n containerReferencePlugin,\n moduleFederationPlugin,\n} from '@module-federation/sdk';\nimport FederationRuntimePlugin from './runtime/FederationRuntimePlugin';\nimport FederationModulesPlugin from './runtime/FederationModulesPlugin';\n\nconst { ExternalsPlugin } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\nconst slashCode = '/'.charCodeAt(0);\n\nclass ContainerReferencePlugin {\n private _remoteType: moduleFederationPlugin.ExternalsType;\n private _remotes: [string, moduleFederationPlugin.RemotesConfig][];\n\n constructor(\n options: containerReferencePlugin.ContainerReferencePluginOptions,\n ) {\n // validate(options);\n\n this._remoteType = options.remoteType;\n this._remotes = parseOptions(\n options.remotes,\n (item) => ({\n external: Array.isArray(item) ? item : [item],\n shareScope: options.shareScope || 'default',\n }),\n (item) => ({\n external: Array.isArray(item.external)\n ? item.external\n : [item.external],\n shareScope: item.shareScope || options.shareScope || 'default',\n }),\n );\n }\n\n /**\n * Apply the plugin\n * @param {Compiler} compiler the compiler instance\n * @returns {void}\n */\n apply(compiler: Compiler): void {\n const { _remotes: remotes, _remoteType: remoteType } = this;\n new FederationRuntimePlugin().apply(compiler);\n /** @type {Record<string, string>} */\n const remoteExternals: Record<string, string> = {};\n\n for (const [key, config] of remotes) {\n let i = 0;\n for (const external of config.external) {\n if (typeof external === 'string' && external.startsWith('internal ')) {\n continue;\n }\n remoteExternals[\n `webpack/container/reference/${key}${i ? `/fallback-${i}` : ''}`\n ] = external;\n i++;\n }\n }\n const Externals = compiler.webpack.ExternalsPlugin || ExternalsPlugin;\n new Externals(remoteType, remoteExternals).apply(compiler);\n\n compiler.hooks.compilation.tap(\n 'ContainerReferencePlugin',\n (compilation, { normalModuleFactory }) => {\n compilation.dependencyFactories.set(\n RemoteToExternalDependency,\n normalModuleFactory,\n );\n\n compilation.dependencyFactories.set(\n FallbackItemDependency,\n normalModuleFactory,\n );\n\n compilation.dependencyFactories.set(\n FallbackDependency,\n new FallbackModuleFactory(),\n );\n\n const hooks = FederationModulesPlugin.getCompilationHooks(compilation);\n\n normalModuleFactory.hooks.factorize.tap(\n 'ContainerReferencePlugin',\n //@ts-ignore\n (data) => {\n if (!data.request.includes('!')) {\n for (const [key, config] of remotes) {\n if (\n data.request.startsWith(`${key}`) &&\n (data.request.length === key.length ||\n data.request.charCodeAt(key.length) === slashCode)\n ) {\n const remoteModule = new RemoteModule(\n data.request,\n //@ts-ignore\n config.external.map((external: any, i: any) =>\n external.startsWith('internal ')\n ? external.slice(9)\n : `webpack/container/reference/${key}${\n i ? `/fallback-${i}` : ''\n }`,\n ),\n `.${data.request.slice(key.length)}`,\n //@ts-ignore\n config.shareScope,\n );\n hooks.addRemoteDependency.call(remoteModule);\n return remoteModule;\n }\n }\n }\n },\n );\n\n compilation.hooks.runtimeRequirementInTree\n .for(compiler.webpack.RuntimeGlobals.ensureChunkHandlers)\n .tap('ContainerReferencePlugin', (chunk, set) => {\n set.add(compiler.webpack.RuntimeGlobals.module);\n set.add(compiler.webpack.RuntimeGlobals.moduleFactoriesAddOnly);\n set.add(compiler.webpack.RuntimeGlobals.hasOwnProperty);\n set.add(compiler.webpack.RuntimeGlobals.initializeSharing);\n set.add(compiler.webpack.RuntimeGlobals.shareScopeMap);\n compilation.addRuntimeModule(chunk, new RemoteRuntimeModule());\n });\n },\n );\n }\n}\n\nexport default ContainerReferencePlugin;\n"],"mappings":";;;;;;;;;;;;;;AAsBA,MAAM,EAAE,oBAAoB,gFACL,UAAU,CAChC;AAED,MAAM,YAAY,IAAI,WAAW,EAAE;AAEnC,IAAM,2BAAN,MAA+B;CAI7B,YACE,SACA;AAGA,OAAK,cAAc,QAAQ;AAC3B,OAAK,WAAWA,2CACd,QAAQ,UACP,UAAU;GACT,UAAU,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC,KAAK;GAC7C,YAAY,QAAQ,cAAc;GACnC,IACA,UAAU;GACT,UAAU,MAAM,QAAQ,KAAK,SAAS,GAClC,KAAK,WACL,CAAC,KAAK,SAAS;GACnB,YAAY,KAAK,cAAc,QAAQ,cAAc;GACtD,EACF;;;;;;;CAQH,MAAM,UAA0B;EAC9B,MAAM,EAAE,UAAU,SAAS,aAAa,eAAe;AACvD,MAAIC,+DAAyB,CAAC,MAAM,SAAS;;EAE7C,MAAM,kBAA0C,EAAE;AAElD,OAAK,MAAM,CAAC,KAAK,WAAW,SAAS;GACnC,IAAI,IAAI;AACR,QAAK,MAAM,YAAY,OAAO,UAAU;AACtC,QAAI,OAAO,aAAa,YAAY,SAAS,WAAW,YAAY,CAClE;AAEF,oBACE,+BAA+B,MAAM,IAAI,aAAa,MAAM,QAC1D;AACJ;;;AAIJ,OADkB,SAAS,QAAQ,mBAAmB,iBACxC,YAAY,gBAAgB,CAAC,MAAM,SAAS;AAE1D,WAAS,MAAM,YAAY,IACzB,6BACC,aAAa,EAAE,0BAA0B;AACxC,eAAY,oBAAoB,IAC9BC,0DACA,oBACD;AAED,eAAY,oBAAoB,IAC9BC,sDACA,oBACD;AAED,eAAY,oBAAoB,IAC9BC,kDACA,IAAIC,qDAAuB,CAC5B;GAED,MAAM,QAAQC,8DAAwB,oBAAoB,YAAY;AAEtE,uBAAoB,MAAM,UAAU,IAClC,6BAEC,SAAS;AACR,QAAI,CAAC,KAAK,QAAQ,SAAS,IAAI,EAC7B;UAAK,MAAM,CAAC,KAAK,WAAW,QAC1B,KACE,KAAK,QAAQ,WAAW,GAAG,MAAM,KAChC,KAAK,QAAQ,WAAW,IAAI,UAC3B,KAAK,QAAQ,WAAW,IAAI,OAAO,KAAK,YAC1C;MACA,MAAM,eAAe,IAAIC,2CACvB,KAAK,SAEL,OAAO,SAAS,KAAK,UAAe,MAClC,SAAS,WAAW,YAAY,GAC5B,SAAS,MAAM,EAAE,GACjB,+BAA+B,MAC7B,IAAI,aAAa,MAAM,KAE9B,EACD,IAAI,KAAK,QAAQ,MAAM,IAAI,OAAO,IAElC,OAAO,WACR;AACD,YAAM,oBAAoB,KAAK,aAAa;AAC5C,aAAO;;;KAKhB;AAED,eAAY,MAAM,yBACf,IAAI,SAAS,QAAQ,eAAe,oBAAoB,CACxD,IAAI,6BAA6B,OAAO,QAAQ;AAC/C,QAAI,IAAI,SAAS,QAAQ,eAAe,OAAO;AAC/C,QAAI,IAAI,SAAS,QAAQ,eAAe,uBAAuB;AAC/D,QAAI,IAAI,SAAS,QAAQ,eAAe,eAAe;AACvD,QAAI,IAAI,SAAS,QAAQ,eAAe,kBAAkB;AAC1D,QAAI,IAAI,SAAS,QAAQ,eAAe,cAAc;AACtD,gBAAY,iBAAiB,OAAO,IAAIC,mDAAqB,CAAC;KAC9D;IAEP"}
@@ -18,7 +18,6 @@ node_path = require_runtime.__toESM(node_path);
18
18
  let node_fs = require("node:fs");
19
19
  node_fs = require_runtime.__toESM(node_fs);
20
20
  let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
21
- let _module_federation_data_prefetch_cli = require("@module-federation/data-prefetch/cli");
22
21
  let _module_federation_dts_plugin = require("@module-federation/dts-plugin");
23
22
  let _module_federation_managers = require("@module-federation/managers");
24
23
  let _module_federation_manifest = require("@module-federation/manifest");
@@ -89,7 +88,6 @@ var ModuleFederationPlugin = class {
89
88
  dtsPlugin.apply(compiler);
90
89
  dtsPlugin.addRuntimePlugins();
91
90
  }
92
- if (options.dataPrefetch) new _module_federation_data_prefetch_cli.PrefetchPlugin(options).apply(compiler);
93
91
  new require_lib_container_runtime_FederationRuntimePlugin.default(options).apply(compiler);
94
92
  const library = options.library || {
95
93
  type: "var",
@@ -1 +1 @@
1
- {"version":3,"file":"ModuleFederationPlugin.js","names":["createSchemaValidation","path","fs","utils","infrastructureLogger","RemoteEntryPlugin","FederationModulesPlugin","StartupChunkDependenciesPlugin","DtsPlugin","PrefetchPlugin","FederationRuntimePlugin","ContainerManager","ContainerPlugin","ContainerReferencePlugin","TreeShakingSharedPlugin","SharePlugin","StatsPlugin"],"sources":["../../../../src/lib/container/ModuleFederationPlugin.ts"],"sourcesContent":["/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n Author Tobias Koppers @sokra and Zackary Jackson @ScriptedAlchemy\n*/\n\n'use strict';\nimport { DtsPlugin } from '@module-federation/dts-plugin';\nimport { ContainerManager, utils } from '@module-federation/managers';\nimport { StatsPlugin } from '@module-federation/manifest';\nimport {\n bindLoggerToCompiler,\n composeKeyWithSeparator,\n type moduleFederationPlugin,\n infrastructureLogger,\n} from '@module-federation/sdk';\nimport { PrefetchPlugin } from '@module-federation/data-prefetch/cli';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport type { Compiler, WebpackPluginInstance } from 'webpack';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport SharePlugin from '../sharing/SharePlugin';\nimport ContainerPlugin from './ContainerPlugin';\nimport ContainerReferencePlugin from './ContainerReferencePlugin';\nimport FederationRuntimePlugin from './runtime/FederationRuntimePlugin';\nimport { RemoteEntryPlugin } from '@module-federation/rspack/remote-entry-plugin';\nimport StartupChunkDependenciesPlugin from '../startup/MfStartupChunkDependenciesPlugin';\nimport FederationModulesPlugin from './runtime/FederationModulesPlugin';\nimport { createSchemaValidation } from '../../utils';\nimport TreeShakingSharedPlugin from '../sharing/tree-shaking/TreeShakingSharedPlugin';\n\nconst isValidExternalsType = require(\n normalizeWebpackPath(\n 'webpack/schemas/plugins/container/ExternalsType.check.js',\n ),\n) as typeof import('webpack/schemas/plugins/container/ExternalsType.check.js');\n\nconst { ExternalsPlugin } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\nconst validate = createSchemaValidation(\n //eslint-disable-next-line\n require('../../schemas/container/ModuleFederationPlugin.check.js').validate,\n () => require('../../schemas/container/ModuleFederationPlugin').default,\n {\n name: 'Module Federation Plugin',\n baseDataPath: 'options',\n },\n);\n\nfunction getEnhancedPackageVersion(): string {\n let currentDir = __dirname;\n\n while (true) {\n const packageJsonPath = path.join(currentDir, 'package.json');\n\n if (fs.existsSync(packageJsonPath)) {\n const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')) as {\n name?: string;\n version?: string;\n };\n\n if (pkg.name === '@module-federation/enhanced' && pkg.version) {\n return pkg.version;\n }\n }\n\n const parentDir = path.dirname(currentDir);\n if (parentDir === currentDir) {\n break;\n }\n currentDir = parentDir;\n }\n\n throw new Error('Unable to resolve @module-federation/enhanced package.json');\n}\n\nclass ModuleFederationPlugin implements WebpackPluginInstance {\n private _options: moduleFederationPlugin.ModuleFederationPluginOptions;\n private _statsPlugin?: StatsPlugin;\n /**\n * @param {moduleFederationPlugin.ModuleFederationPluginOptions} options options\n */\n constructor(options: moduleFederationPlugin.ModuleFederationPluginOptions) {\n validate(options);\n this._options = options;\n }\n\n private _patchBundlerConfig(compiler: Compiler): void {\n const { name, experiments } = this._options;\n const definePluginOptions: Record<string, string | boolean> = {};\n\n const MFPluginNum = compiler.options.plugins.filter(\n (p): p is WebpackPluginInstance =>\n !!p && (p as any).name === 'ModuleFederationPlugin',\n ).length;\n\n if (name && MFPluginNum < 2) {\n definePluginOptions['FEDERATION_BUILD_IDENTIFIER'] = JSON.stringify(\n composeKeyWithSeparator(name, utils.getBuildVersion()),\n );\n }\n\n const disableSnapshot = experiments?.optimization?.disableSnapshot ?? false;\n definePluginOptions['FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN'] =\n disableSnapshot;\n\n // Determine ENV_TARGET: only if manually specified in experiments.optimization.target\n if (\n experiments?.optimization &&\n typeof experiments.optimization === 'object' &&\n experiments.optimization !== null &&\n 'target' in experiments.optimization\n ) {\n const manualTarget = experiments.optimization.target as\n | 'web'\n | 'node'\n | undefined;\n // Ensure the target is one of the expected values before setting\n if (manualTarget === 'web' || manualTarget === 'node') {\n definePluginOptions['ENV_TARGET'] = JSON.stringify(manualTarget);\n }\n }\n // No inference for ENV_TARGET. If not manually set and valid, it's not defined.\n\n new compiler.webpack.DefinePlugin(definePluginOptions).apply(compiler);\n }\n\n /**\n * Apply the plugin\n * @param {Compiler} compiler the compiler instance\n * @returns {void}\n */\n apply(compiler: Compiler): void {\n bindLoggerToCompiler(\n infrastructureLogger,\n compiler,\n 'EnhancedModuleFederationPlugin',\n );\n const { _options: options } = this;\n const { name, experiments, dts, remotes, shared, shareScope } = options;\n if (!name) {\n // TODO: remove the comment\n throw new Error('ModuleFederationPlugin name is required');\n }\n // must before ModuleFederationPlugin\n (new RemoteEntryPlugin(options) as unknown as WebpackPluginInstance).apply(\n compiler,\n );\n const useContainerPlugin =\n options.exposes &&\n (Array.isArray(options.exposes)\n ? options.exposes.length > 0\n : Object.keys(options.exposes).length > 0);\n\n if (experiments?.provideExternalRuntime) {\n if (useContainerPlugin) {\n throw new Error(\n 'You can only set provideExternalRuntime: true in pure consumer which not expose modules.',\n );\n }\n const runtimePlugins = options.runtimePlugins || [];\n options.runtimePlugins = runtimePlugins.concat(\n require.resolve('@module-federation/inject-external-runtime-core-plugin'),\n );\n }\n\n if (experiments?.externalRuntime === true) {\n const Externals = compiler.webpack.ExternalsPlugin || ExternalsPlugin;\n new Externals(compiler.options.externalsType || 'global', {\n '@module-federation/runtime-core': '_FEDERATION_RUNTIME_CORE',\n }).apply(compiler);\n }\n\n // federation hooks\n new FederationModulesPlugin().apply(compiler);\n\n if (experiments?.asyncStartup) {\n new StartupChunkDependenciesPlugin({\n asyncChunkLoading: true,\n }).apply(compiler);\n }\n\n if (dts !== false) {\n const dtsPlugin = new DtsPlugin(options);\n dtsPlugin.apply(compiler);\n dtsPlugin.addRuntimePlugins();\n }\n // TODO: REMOVE in next major version\n if (options.dataPrefetch) {\n new PrefetchPlugin(options).apply(compiler);\n }\n\n new FederationRuntimePlugin(options).apply(compiler);\n\n const library = options.library || { type: 'var', name: name };\n const remoteType =\n options.remoteType ||\n (options.library && isValidExternalsType(options.library.type)\n ? (options.library.type as moduleFederationPlugin.ExternalsType)\n : ('script' as moduleFederationPlugin.ExternalsType));\n const containerRemoteType =\n remoteType as moduleFederationPlugin.ExternalsType;\n\n let disableManifest = options.manifest === false;\n if (useContainerPlugin) {\n ContainerPlugin.patchChunkSplit(compiler, name);\n }\n this._patchBundlerConfig(compiler);\n if (!disableManifest && useContainerPlugin) {\n try {\n const containerManager = new ContainerManager();\n containerManager.init(options);\n options.exposes = containerManager.containerPluginExposesOptions;\n } catch (err) {\n if (err instanceof Error) {\n err.message = `[ ModuleFederationPlugin ]: Manifest will not generate, because: ${err.message}`;\n }\n infrastructureLogger.warn(err);\n disableManifest = true;\n }\n }\n\n if (\n library &&\n !compiler.options.output.enabledLibraryTypes?.includes(library.type)\n ) {\n compiler.options.output.enabledLibraryTypes?.push(library.type);\n }\n\n compiler.hooks.afterPlugins.tap('ModuleFederationPlugin', () => {\n if (useContainerPlugin) {\n new ContainerPlugin({\n name,\n library,\n filename: options.filename,\n runtime: options.runtime,\n shareScope: options.shareScope,\n exposes: options.exposes!,\n runtimePlugins: options.runtimePlugins,\n }).apply(compiler);\n }\n if (\n remotes &&\n (Array.isArray(remotes)\n ? remotes.length > 0\n : Object.keys(remotes).length > 0)\n ) {\n new ContainerReferencePlugin({\n remoteType: containerRemoteType,\n shareScope,\n remotes,\n }).apply(compiler);\n }\n if (shared) {\n new TreeShakingSharedPlugin({\n mfConfig: options,\n }).apply(compiler);\n new SharePlugin({\n shared,\n shareScope,\n }).apply(compiler);\n }\n });\n\n if (!disableManifest) {\n this._statsPlugin = new StatsPlugin(options, {\n pluginVersion: getEnhancedPackageVersion(),\n bundler: 'webpack',\n });\n this._statsPlugin.apply(compiler);\n }\n }\n}\n\nexport default ModuleFederationPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAM,uBAAuB,gFAEzB,2DACD,CACF;AAED,MAAM,EAAE,oBAAoB,gFACL,UAAU,CAChC;AAED,MAAM,WAAWA,6PAEoD,gNACH,SAChE;CACE,MAAM;CACN,cAAc;CACf,CACF;AAED,SAAS,4BAAoC;CAC3C,IAAI,aAAa;AAEjB,QAAO,MAAM;EACX,MAAM,kBAAkBC,kBAAK,KAAK,YAAY,eAAe;AAE7D,MAAIC,gBAAG,WAAW,gBAAgB,EAAE;GAClC,MAAM,MAAM,KAAK,MAAMA,gBAAG,aAAa,iBAAiB,QAAQ,CAAC;AAKjE,OAAI,IAAI,SAAS,iCAAiC,IAAI,QACpD,QAAO,IAAI;;EAIf,MAAM,YAAYD,kBAAK,QAAQ,WAAW;AAC1C,MAAI,cAAc,WAChB;AAEF,eAAa;;AAGf,OAAM,IAAI,MAAM,6DAA6D;;AAG/E,IAAM,yBAAN,MAA8D;;;;CAM5D,YAAY,SAA+D;AACzE,WAAS,QAAQ;AACjB,OAAK,WAAW;;CAGlB,AAAQ,oBAAoB,UAA0B;EACpD,MAAM,EAAE,MAAM,gBAAgB,KAAK;EACnC,MAAM,sBAAwD,EAAE;EAEhE,MAAM,cAAc,SAAS,QAAQ,QAAQ,QAC1C,MACC,CAAC,CAAC,KAAM,EAAU,SAAS,yBAC9B,CAAC;AAEF,MAAI,QAAQ,cAAc,EACxB,qBAAoB,iCAAiC,KAAK,8DAChC,MAAME,kCAAM,iBAAiB,CAAC,CACvD;AAIH,sBAAoB,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EpB;AAEF,MAAI,CAAC,iBAAiB;AACpB,QAAK,eAAe,IAAIC,wCAAY,SAAS;IAC3C,eAAe,2BAA2B;IAC1C,SAAS;IACV,CAAC;AACF,QAAK,aAAa,MAAM,SAAS"}
1
+ {"version":3,"file":"ModuleFederationPlugin.js","names":["createSchemaValidation","path","fs","utils","infrastructureLogger","RemoteEntryPlugin","FederationModulesPlugin","StartupChunkDependenciesPlugin","DtsPlugin","FederationRuntimePlugin","ContainerManager","ContainerPlugin","ContainerReferencePlugin","TreeShakingSharedPlugin","SharePlugin","StatsPlugin"],"sources":["../../../../src/lib/container/ModuleFederationPlugin.ts"],"sourcesContent":["/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n Author Tobias Koppers @sokra and Zackary Jackson @ScriptedAlchemy\n*/\n\n'use strict';\nimport { DtsPlugin } from '@module-federation/dts-plugin';\nimport { ContainerManager, utils } from '@module-federation/managers';\nimport { StatsPlugin } from '@module-federation/manifest';\nimport {\n bindLoggerToCompiler,\n composeKeyWithSeparator,\n type moduleFederationPlugin,\n infrastructureLogger,\n} from '@module-federation/sdk';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport type { Compiler, WebpackPluginInstance } from 'webpack';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport SharePlugin from '../sharing/SharePlugin';\nimport ContainerPlugin from './ContainerPlugin';\nimport ContainerReferencePlugin from './ContainerReferencePlugin';\nimport FederationRuntimePlugin from './runtime/FederationRuntimePlugin';\nimport { RemoteEntryPlugin } from '@module-federation/rspack/remote-entry-plugin';\nimport StartupChunkDependenciesPlugin from '../startup/MfStartupChunkDependenciesPlugin';\nimport FederationModulesPlugin from './runtime/FederationModulesPlugin';\nimport { createSchemaValidation } from '../../utils';\nimport TreeShakingSharedPlugin from '../sharing/tree-shaking/TreeShakingSharedPlugin';\n\nconst isValidExternalsType = require(\n normalizeWebpackPath(\n 'webpack/schemas/plugins/container/ExternalsType.check.js',\n ),\n) as typeof import('webpack/schemas/plugins/container/ExternalsType.check.js');\n\nconst { ExternalsPlugin } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\nconst validate = createSchemaValidation(\n //eslint-disable-next-line\n require('../../schemas/container/ModuleFederationPlugin.check.js').validate,\n () => require('../../schemas/container/ModuleFederationPlugin').default,\n {\n name: 'Module Federation Plugin',\n baseDataPath: 'options',\n },\n);\n\nfunction getEnhancedPackageVersion(): string {\n let currentDir = __dirname;\n\n while (true) {\n const packageJsonPath = path.join(currentDir, 'package.json');\n\n if (fs.existsSync(packageJsonPath)) {\n const pkg = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')) as {\n name?: string;\n version?: string;\n };\n\n if (pkg.name === '@module-federation/enhanced' && pkg.version) {\n return pkg.version;\n }\n }\n\n const parentDir = path.dirname(currentDir);\n if (parentDir === currentDir) {\n break;\n }\n currentDir = parentDir;\n }\n\n throw new Error('Unable to resolve @module-federation/enhanced package.json');\n}\n\nclass ModuleFederationPlugin implements WebpackPluginInstance {\n private _options: moduleFederationPlugin.ModuleFederationPluginOptions;\n private _statsPlugin?: StatsPlugin;\n /**\n * @param {moduleFederationPlugin.ModuleFederationPluginOptions} options options\n */\n constructor(options: moduleFederationPlugin.ModuleFederationPluginOptions) {\n validate(options);\n this._options = options;\n }\n\n private _patchBundlerConfig(compiler: Compiler): void {\n const { name, experiments } = this._options;\n const definePluginOptions: Record<string, string | boolean> = {};\n\n const MFPluginNum = compiler.options.plugins.filter(\n (p): p is WebpackPluginInstance =>\n !!p && (p as any).name === 'ModuleFederationPlugin',\n ).length;\n\n if (name && MFPluginNum < 2) {\n definePluginOptions['FEDERATION_BUILD_IDENTIFIER'] = JSON.stringify(\n composeKeyWithSeparator(name, utils.getBuildVersion()),\n );\n }\n\n const disableSnapshot = experiments?.optimization?.disableSnapshot ?? false;\n definePluginOptions['FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN'] =\n disableSnapshot;\n\n // Determine ENV_TARGET: only if manually specified in experiments.optimization.target\n if (\n experiments?.optimization &&\n typeof experiments.optimization === 'object' &&\n experiments.optimization !== null &&\n 'target' in experiments.optimization\n ) {\n const manualTarget = experiments.optimization.target as\n | 'web'\n | 'node'\n | undefined;\n // Ensure the target is one of the expected values before setting\n if (manualTarget === 'web' || manualTarget === 'node') {\n definePluginOptions['ENV_TARGET'] = JSON.stringify(manualTarget);\n }\n }\n // No inference for ENV_TARGET. If not manually set and valid, it's not defined.\n\n new compiler.webpack.DefinePlugin(definePluginOptions).apply(compiler);\n }\n\n /**\n * Apply the plugin\n * @param {Compiler} compiler the compiler instance\n * @returns {void}\n */\n apply(compiler: Compiler): void {\n bindLoggerToCompiler(\n infrastructureLogger,\n compiler,\n 'EnhancedModuleFederationPlugin',\n );\n const { _options: options } = this;\n const { name, experiments, dts, remotes, shared, shareScope } = options;\n if (!name) {\n // TODO: remove the comment\n throw new Error('ModuleFederationPlugin name is required');\n }\n // must before ModuleFederationPlugin\n (new RemoteEntryPlugin(options) as unknown as WebpackPluginInstance).apply(\n compiler,\n );\n const useContainerPlugin =\n options.exposes &&\n (Array.isArray(options.exposes)\n ? options.exposes.length > 0\n : Object.keys(options.exposes).length > 0);\n\n if (experiments?.provideExternalRuntime) {\n if (useContainerPlugin) {\n throw new Error(\n 'You can only set provideExternalRuntime: true in pure consumer which not expose modules.',\n );\n }\n const runtimePlugins = options.runtimePlugins || [];\n options.runtimePlugins = runtimePlugins.concat(\n require.resolve('@module-federation/inject-external-runtime-core-plugin'),\n );\n }\n\n if (experiments?.externalRuntime === true) {\n const Externals = compiler.webpack.ExternalsPlugin || ExternalsPlugin;\n new Externals(compiler.options.externalsType || 'global', {\n '@module-federation/runtime-core': '_FEDERATION_RUNTIME_CORE',\n }).apply(compiler);\n }\n\n // federation hooks\n new FederationModulesPlugin().apply(compiler);\n\n if (experiments?.asyncStartup) {\n new StartupChunkDependenciesPlugin({\n asyncChunkLoading: true,\n }).apply(compiler);\n }\n\n if (dts !== false) {\n const dtsPlugin = new DtsPlugin(options);\n dtsPlugin.apply(compiler);\n dtsPlugin.addRuntimePlugins();\n }\n new FederationRuntimePlugin(options).apply(compiler);\n\n const library = options.library || { type: 'var', name: name };\n const remoteType =\n options.remoteType ||\n (options.library && isValidExternalsType(options.library.type)\n ? (options.library.type as moduleFederationPlugin.ExternalsType)\n : ('script' as moduleFederationPlugin.ExternalsType));\n const containerRemoteType =\n remoteType as moduleFederationPlugin.ExternalsType;\n\n let disableManifest = options.manifest === false;\n if (useContainerPlugin) {\n ContainerPlugin.patchChunkSplit(compiler, name);\n }\n this._patchBundlerConfig(compiler);\n if (!disableManifest && useContainerPlugin) {\n try {\n const containerManager = new ContainerManager();\n containerManager.init(options);\n options.exposes = containerManager.containerPluginExposesOptions;\n } catch (err) {\n if (err instanceof Error) {\n err.message = `[ ModuleFederationPlugin ]: Manifest will not generate, because: ${err.message}`;\n }\n infrastructureLogger.warn(err);\n disableManifest = true;\n }\n }\n\n if (\n library &&\n !compiler.options.output.enabledLibraryTypes?.includes(library.type)\n ) {\n compiler.options.output.enabledLibraryTypes?.push(library.type);\n }\n\n compiler.hooks.afterPlugins.tap('ModuleFederationPlugin', () => {\n if (useContainerPlugin) {\n new ContainerPlugin({\n name,\n library,\n filename: options.filename,\n runtime: options.runtime,\n shareScope: options.shareScope,\n exposes: options.exposes!,\n runtimePlugins: options.runtimePlugins,\n }).apply(compiler);\n }\n if (\n remotes &&\n (Array.isArray(remotes)\n ? remotes.length > 0\n : Object.keys(remotes).length > 0)\n ) {\n new ContainerReferencePlugin({\n remoteType: containerRemoteType,\n shareScope,\n remotes,\n }).apply(compiler);\n }\n if (shared) {\n new TreeShakingSharedPlugin({\n mfConfig: options,\n }).apply(compiler);\n new SharePlugin({\n shared,\n shareScope,\n }).apply(compiler);\n }\n });\n\n if (!disableManifest) {\n this._statsPlugin = new StatsPlugin(options, {\n pluginVersion: getEnhancedPackageVersion(),\n bundler: 'webpack',\n });\n this._statsPlugin.apply(compiler);\n }\n }\n}\n\nexport default Mod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