@module-federation/enhanced 2.3.3 → 2.4.0
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.
- package/dist/CHANGELOG.md +22 -0
- package/dist/src/lib/container/ContainerEntryDependency.d.ts +1 -4
- package/dist/src/lib/container/ContainerEntryDependency.js +1 -3
- package/dist/src/lib/container/ContainerEntryDependency.js.map +1 -1
- package/dist/src/lib/container/ContainerEntryModule.d.ts +1 -4
- package/dist/src/lib/container/ContainerEntryModule.js +3 -9
- package/dist/src/lib/container/ContainerEntryModule.js.map +1 -1
- package/dist/src/lib/container/ContainerEntryModuleFactory.js +1 -1
- package/dist/src/lib/container/ContainerEntryModuleFactory.js.map +1 -1
- package/dist/src/lib/container/ContainerPlugin.js +3 -4
- package/dist/src/lib/container/ContainerPlugin.js.map +1 -1
- package/dist/src/lib/container/ModuleFederationPlugin.js +0 -2
- package/dist/src/lib/container/ModuleFederationPlugin.js.map +1 -1
- package/dist/src/lib/container/runtime/FederationRuntimePlugin.js +0 -2
- package/dist/src/lib/container/runtime/FederationRuntimePlugin.js.map +1 -1
- package/dist/src/runtime.mjs +3 -0
- package/dist/src/schemas/container/ContainerPlugin.check.d.ts +7 -7
- package/dist/src/schemas/container/ContainerPlugin.check.js +541 -734
- package/dist/src/schemas/container/ContainerPlugin.check.js.map +1 -1
- package/dist/src/schemas/container/ContainerPlugin.d.ts +0 -4
- package/dist/src/schemas/container/ContainerPlugin.js +0 -4
- package/dist/src/schemas/container/ContainerPlugin.js.map +1 -1
- package/dist/src/schemas/container/ModuleFederationPlugin.check.js +5 -13
- package/dist/src/schemas/container/ModuleFederationPlugin.check.js.map +1 -1
- package/dist/src/schemas/container/ModuleFederationPlugin.d.ts +0 -4
- package/dist/src/schemas/container/ModuleFederationPlugin.js +0 -4
- package/dist/src/schemas/container/ModuleFederationPlugin.js.map +1 -1
- package/package.json +13 -22
- package/dist/src/prefetch.d.ts +0 -3
- package/dist/src/prefetch.js +0 -17
package/dist/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @module-federation/enhanced
|
|
2
2
|
|
|
3
|
+
## 2.4.0
|
|
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@2.4.0
|
|
14
|
+
- @module-federation/manifest@2.4.0
|
|
15
|
+
- @module-federation/webpack-bundler-runtime@2.4.0
|
|
16
|
+
- @module-federation/bridge-react-webpack-plugin@2.4.0
|
|
17
|
+
- @module-federation/cli@2.4.0
|
|
18
|
+
- @module-federation/dts-plugin@2.4.0
|
|
19
|
+
- @module-federation/managers@2.4.0
|
|
20
|
+
- @module-federation/rspack@2.4.0
|
|
21
|
+
- @module-federation/runtime-tools@2.4.0
|
|
22
|
+
- @module-federation/inject-external-runtime-core-plugin@2.4.0
|
|
23
|
+
- @module-federation/error-codes@2.4.0
|
|
24
|
+
|
|
3
25
|
## 2.3.3
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -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
|
|
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
|
|
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\
|
|
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
|
|
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
|
|
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()
|
|
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}
|
|
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":";;;;;;;;;;;;;;AA4BA,MAAM,mBAAmB,gFACF,oCAAoC,CAC1D;AACD,MAAM,EACJ,SAAS,gBACT,wBACA,UACA,QACA,mBACE,gFAA6B,UAAU,CAAC;AAC5C,MAAM,0BAA0B,gFACT,mDAAmD,CACzE;AACD,MAAM,kBAAkB,gFACD,2CAA2C,CACjE;AAED,MAAM,eAAe,IAAI,IAAI,CAAC,aAAa,CA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;;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,mBAAmB,gFACF,oCAAoC,CAC1D;AACD,MAAM,EACJ,SAAS,gBACT,wBACA,UACA,QACA,mBACE,gFAA6B,UAAU,CAAC;AAC5C,MAAM,0BAA0B,gFACT,mDAAmD,CACzE;AACD,MAAM,kBAAkB,gFACD,2CAA2C,CACjE;AAED,MAAM,eAAe,IAAI,IAAI,CAAC,aAAa,CAAC;AAa5C,IAA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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
|
|
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
|
|
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"}
|
|
@@ -32,8 +32,7 @@ var ContainerPlugin = class ContainerPlugin {
|
|
|
32
32
|
import: Array.isArray(item.import) ? item.import : [item.import],
|
|
33
33
|
name: item.name || void 0
|
|
34
34
|
})),
|
|
35
|
-
runtimePlugins: options.runtimePlugins
|
|
36
|
-
dataPrefetch: options.dataPrefetch
|
|
35
|
+
runtimePlugins: options.runtimePlugins
|
|
37
36
|
};
|
|
38
37
|
}
|
|
39
38
|
static patchChunkSplit(compiler, name) {
|
|
@@ -91,7 +90,7 @@ var ContainerPlugin = class ContainerPlugin {
|
|
|
91
90
|
compiler.hooks.make.tapAsync(PLUGIN_NAME, async (compilation, callback) => {
|
|
92
91
|
const hooks = require_lib_container_runtime_FederationModulesPlugin.default.getCompilationHooks(compilation);
|
|
93
92
|
const federationRuntimeDependency = federationRuntimePluginInstance.getDependency(compiler);
|
|
94
|
-
const dep = new require_lib_container_ContainerEntryDependency.default(name, exposes, shareScope, federationRuntimePluginInstance.entryFilePath
|
|
93
|
+
const dep = new require_lib_container_ContainerEntryDependency.default(name, exposes, shareScope, federationRuntimePluginInstance.entryFilePath);
|
|
95
94
|
dep.loc = { name };
|
|
96
95
|
await new Promise((resolve, reject) => {
|
|
97
96
|
compilation.addEntry(compilation.options.context || "", dep, {
|
|
@@ -123,7 +122,7 @@ var ContainerPlugin = class ContainerPlugin {
|
|
|
123
122
|
if (runtime) createdRuntimes.add(runtime);
|
|
124
123
|
}
|
|
125
124
|
if (createdRuntimes.size === 0 && !compilation.options?.optimization?.runtimeChunk) return callback();
|
|
126
|
-
const dep = new require_lib_container_ContainerEntryDependency.default(name, exposes, shareScope, federationRuntimePluginInstance.entryFilePath
|
|
125
|
+
const dep = new require_lib_container_ContainerEntryDependency.default(name, exposes, shareScope, federationRuntimePluginInstance.entryFilePath);
|
|
127
126
|
dep.loc = { name };
|
|
128
127
|
compilation.addInclude(compilation.options.context || "", dep, { name: void 0 }, (error) => {
|
|
129
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 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 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":";;;;;;;;;;;;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,O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":["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;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AU;IAEb;AAID,WAAS,MAAM,WAAW,SACxB,cACC,aAA0B,aAAa;AACtC,OACE,YAAY,SAAS,qBACrB,YAAY,SAAS,sBAAsB,YAE3C,QAAO,UAAU;GAGnB,MAAM,QAAQD,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,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"}
|
|
@@ -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;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QAAQ,SAAS,IACjB,OAAO,KAAK,QAAQ,CAAC,SAAS,GAElC,KAAIC,uDAAyB;IAC3B,YAAY;IACZ;IACA;IACD,CAAC,CAAC,MAAM,SAAS;AAEpB,OAAI,QAAQ;AACV,QAAIC,iEAAwB,EAC1B,UAAU,SACX,CAAC,CAAC,MAAM,SAAS;AAClB,QAAIC,wCAAY;KACd;KACA;KACD,CAAC,CAAC,MAAM,SAAS;;IAEpB;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 ModuleFederationPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,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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QAAK,eAAe,IAAIC,wCAAY,SAAS;IAC3C,eAAe,2BAA2B;IAC1C,SAAS;IACV,CAAC;AACF,QAAK,aAAa,MAAM,SAAS"}
|
|
@@ -8,7 +8,6 @@ const require_lib_container_runtime_EmbedFederationRuntimePlugin = require('./Em
|
|
|
8
8
|
const require_lib_container_HoistContainerReferencesPlugin = require('../HoistContainerReferencesPlugin.js');
|
|
9
9
|
const require_lib_container_runtime_FederationRuntimeDependency = require('./FederationRuntimeDependency.js');
|
|
10
10
|
let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
|
|
11
|
-
let _module_federation_data_prefetch_cli = require("@module-federation/data-prefetch/cli");
|
|
12
11
|
let path = require("path");
|
|
13
12
|
path = require_runtime.__toESM(path);
|
|
14
13
|
let fs = require("fs");
|
|
@@ -122,7 +121,6 @@ var FederationRuntimePlugin = class FederationRuntimePlugin {
|
|
|
122
121
|
Template.indent([`${federationGlobal}.installInitialConsumes()`]),
|
|
123
122
|
"}"
|
|
124
123
|
]),
|
|
125
|
-
_module_federation_data_prefetch_cli.PrefetchPlugin.addRuntime(compiler, { name: options.name }),
|
|
126
124
|
"}"
|
|
127
125
|
]);
|
|
128
126
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FederationRuntimePlugin.js","names":["getFederationGlobalScope","normalizeToPosixPath","PrefetchPlugin","createHash","TEMP_DIR","FederationRuntimeDependency","FederationModulesPlugin","normalizeRuntimeInitOptionsWithOutShared","FederationRuntimeModule","EmbedFederationRuntimePlugin","HoistContainerReferences"],"sources":["../../../../../src/lib/container/runtime/FederationRuntimePlugin.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport type {\n Compiler,\n WebpackPluginInstance,\n Compilation,\n Chunk,\n} from 'webpack';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport { PrefetchPlugin } from '@module-federation/data-prefetch/cli';\nimport { moduleFederationPlugin } from '@module-federation/sdk';\nimport FederationRuntimeModule from './FederationRuntimeModule';\nimport {\n getFederationGlobalScope,\n normalizeRuntimeInitOptionsWithOutShared,\n createHash,\n normalizeToPosixPath,\n} from './utils';\nimport { TEMP_DIR } from '../constant';\nimport EmbedFederationRuntimePlugin from './EmbedFederationRuntimePlugin';\nimport FederationModulesPlugin from './FederationModulesPlugin';\nimport HoistContainerReferences from '../HoistContainerReferencesPlugin';\nimport FederationRuntimeDependency from './FederationRuntimeDependency';\n\nconst ModuleDependency = require(\n normalizeWebpackPath('webpack/lib/dependencies/ModuleDependency'),\n) as typeof import('webpack/lib/dependencies/ModuleDependency');\n\nconst { RuntimeGlobals, Template } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nconst { mkdirpSync } = require(\n normalizeWebpackPath('webpack/lib/util/fs'),\n) as typeof import('webpack/lib/util/fs');\n\ntype ResolveFn = typeof require.resolve;\ntype RuntimeEntrySpec = {\n bundler: string;\n esm: string;\n cjs: string;\n};\n\nfunction resolveRuntimeEntry(\n spec: RuntimeEntrySpec,\n implementation: string | undefined,\n resolve: ResolveFn = require.resolve,\n) {\n const candidates = [spec.bundler, spec.esm, spec.cjs];\n const modulePaths = implementation ? [implementation] : undefined;\n let lastError: unknown;\n\n for (const candidate of candidates) {\n try {\n return modulePaths\n ? resolve(candidate, { paths: modulePaths })\n : resolve(candidate);\n } catch (error) {\n lastError = error;\n }\n }\n\n throw lastError;\n}\n\nfunction resolveRuntimeEntryWithFallback(\n spec: RuntimeEntrySpec,\n implementation: string | undefined,\n resolve: ResolveFn = require.resolve,\n) {\n if (implementation) {\n try {\n return resolveRuntimeEntry(spec, implementation, resolve);\n } catch {\n // Fall back to the workspace runtime packages when a custom\n // implementation hasn't published the newer subpath yet.\n }\n }\n\n return resolveRuntimeEntry(spec, undefined, resolve);\n}\nexport function resolveRuntimePaths(\n implementation?: string,\n resolve: ResolveFn = require.resolve,\n) {\n // Prefer the dedicated bundler subpath so webpack can tree-shake across the\n // runtime package boundary. Fall back to the legacy dist contract for older\n // custom implementations that have not published /bundler yet.\n const runtimeToolsPath = resolveRuntimeEntryWithFallback(\n {\n bundler: '@module-federation/runtime-tools/bundler',\n esm: '@module-federation/runtime-tools/dist/index.js',\n cjs: '@module-federation/runtime-tools/dist/index.cjs',\n },\n implementation,\n resolve,\n );\n const moduleBase = implementation || runtimeToolsPath;\n\n return {\n runtimeToolsPath,\n bundlerRuntimePath: resolveRuntimeEntry(\n {\n bundler: '@module-federation/webpack-bundler-runtime/bundler',\n esm: '@module-federation/webpack-bundler-runtime/dist/index.js',\n cjs: '@module-federation/webpack-bundler-runtime/dist/index.cjs',\n },\n moduleBase,\n resolve,\n ),\n runtimePath: resolveRuntimeEntry(\n {\n bundler: '@module-federation/runtime/bundler',\n esm: '@module-federation/runtime/dist/index.js',\n cjs: '@module-federation/runtime/dist/index.cjs',\n },\n moduleBase,\n resolve,\n ),\n };\n}\n\nconst {\n runtimeToolsPath: RuntimeToolsPath,\n bundlerRuntimePath: BundlerRuntimePath,\n runtimePath: RuntimePath,\n} = resolveRuntimePaths();\nconst federationGlobal = getFederationGlobalScope(RuntimeGlobals);\n\nconst onceForCompiler = new WeakSet<Compiler>();\nconst onceForCompilerEntryMap = new WeakMap<Compiler, string>();\n\nclass FederationRuntimePlugin {\n options?: moduleFederationPlugin.ModuleFederationPluginOptions;\n entryFilePath: string;\n bundlerRuntimePath: string;\n runtimePath: string;\n runtimeToolsPath: string;\n federationRuntimeDependency?: FederationRuntimeDependency; // Add this line\n\n constructor(options?: moduleFederationPlugin.ModuleFederationPluginOptions) {\n this.options = options ? { ...options } : undefined;\n this.entryFilePath = '';\n this.bundlerRuntimePath = BundlerRuntimePath;\n this.runtimePath = RuntimePath;\n this.runtimeToolsPath = RuntimeToolsPath;\n this.federationRuntimeDependency = undefined; // Initialize as undefined\n }\n\n static getTemplate(\n compiler: Compiler,\n options: moduleFederationPlugin.ModuleFederationPluginOptions,\n bundlerRuntimePath?: string,\n ) {\n // internal runtime plugin\n const runtimePlugins = options.runtimePlugins;\n const normalizedBundlerRuntimePath = normalizeToPosixPath(\n bundlerRuntimePath || BundlerRuntimePath,\n );\n\n let runtimePluginTemplates = '';\n const runtimePluginCalls: string[] = [];\n\n if (Array.isArray(runtimePlugins)) {\n runtimePlugins.forEach((runtimePlugin, index) => {\n if (!runtimePlugin) {\n return;\n }\n const runtimePluginName = `plugin_${index}`;\n const runtimePluginEntry = Array.isArray(runtimePlugin)\n ? runtimePlugin[0]\n : runtimePlugin;\n const runtimePluginPath = normalizeToPosixPath(\n path.isAbsolute(runtimePluginEntry)\n ? runtimePluginEntry\n : path.join(process.cwd(), runtimePluginEntry),\n );\n const paramsStr =\n Array.isArray(runtimePlugin) && runtimePlugin.length > 1\n ? JSON.stringify(runtimePlugin[1])\n : 'undefined';\n runtimePluginTemplates += `import ${runtimePluginName} from '${runtimePluginPath}';\\n`;\n runtimePluginCalls.push(\n `${runtimePluginName} ? (${runtimePluginName}.default || ${runtimePluginName})(${paramsStr}) : false`,\n );\n });\n }\n const embedRuntimeLines = Template.asString([\n `if(!${federationGlobal}.runtime || !${federationGlobal}.bundlerRuntime){`,\n Template.indent([\n `var prevFederation = ${federationGlobal};`,\n `${federationGlobal} = {}`,\n `for(var key in federation){`,\n Template.indent([`${federationGlobal}[key] = federation[key];`]),\n '}',\n `for(var key in prevFederation){`,\n Template.indent([`${federationGlobal}[key] = prevFederation[key];`]),\n '}',\n ]),\n '}',\n ]);\n\n return Template.asString([\n `import federation from '${normalizedBundlerRuntimePath}';`,\n runtimePluginTemplates,\n embedRuntimeLines,\n `if(!${federationGlobal}.instance){`,\n Template.indent([\n runtimePluginCalls.length\n ? Template.asString([\n `var pluginsToAdd = [`,\n Template.indent(\n Template.indent(runtimePluginCalls.map((call) => `${call},`)),\n ),\n `].filter(Boolean);`,\n `${federationGlobal}.initOptions.plugins = ${federationGlobal}.initOptions.plugins ? `,\n `${federationGlobal}.initOptions.plugins.concat(pluginsToAdd) : pluginsToAdd;`,\n ])\n : '',\n // `${federationGlobal}.instance = ${federationGlobal}.runtime.init(${federationGlobal}.initOptions);`,\n `${federationGlobal}.instance = ${federationGlobal}.bundlerRuntime.init({webpackRequire:${RuntimeGlobals.require}});`,\n `if(${federationGlobal}.attachShareScopeMap){`,\n Template.indent([\n `${federationGlobal}.attachShareScopeMap(${RuntimeGlobals.require})`,\n ]),\n '}',\n `if(${federationGlobal}.installInitialConsumes){`,\n Template.indent([`${federationGlobal}.installInitialConsumes()`]),\n '}',\n ]),\n PrefetchPlugin.addRuntime(compiler, {\n name: options.name!,\n }),\n '}',\n ]);\n }\n\n getFilePath(compiler: Compiler) {\n if (!this.options) {\n return '';\n }\n\n const existedFilePath = onceForCompilerEntryMap.get(compiler);\n\n if (existedFilePath) {\n return existedFilePath;\n }\n\n let entryFilePath = '';\n if (!this.options?.virtualRuntimeEntry) {\n const containerName = this.options.name;\n const hash = createHash(\n `${containerName} ${FederationRuntimePlugin.getTemplate(\n compiler,\n this.options,\n this.bundlerRuntimePath,\n )}`,\n );\n entryFilePath = path.join(TEMP_DIR, `entry.${hash}.js`);\n } else {\n entryFilePath = `data:text/javascript;charset=utf-8;base64,${Buffer.from(\n FederationRuntimePlugin.getTemplate(\n compiler,\n this.options,\n this.bundlerRuntimePath,\n ),\n 'utf8',\n ).toString('base64')}`;\n }\n\n onceForCompilerEntryMap.set(compiler, entryFilePath);\n\n return entryFilePath;\n }\n\n ensureFile(compiler: Compiler) {\n if (!this.options) {\n return;\n }\n // skip virtual entry\n if (this.options?.virtualRuntimeEntry) {\n return;\n }\n const filePath = this.entryFilePath;\n const outputFs = (compiler as unknown as { outputFileSystem?: unknown })\n .outputFileSystem;\n const fsLike =\n outputFs &&\n typeof (outputFs as typeof fs).readFileSync === 'function' &&\n typeof (outputFs as typeof fs).writeFileSync === 'function'\n ? (outputFs as typeof fs)\n : fs;\n try {\n fsLike.readFileSync(filePath);\n } catch {\n mkdirpSync(fsLike as any, TEMP_DIR);\n fsLike.writeFileSync(\n filePath,\n FederationRuntimePlugin.getTemplate(\n compiler,\n this.options,\n this.bundlerRuntimePath,\n ),\n );\n }\n }\n\n getDependency(compiler: Compiler) {\n if (this.federationRuntimeDependency)\n return this.federationRuntimeDependency;\n\n this.ensureFile(compiler);\n\n this.federationRuntimeDependency = new FederationRuntimeDependency(\n this.entryFilePath,\n );\n return this.federationRuntimeDependency;\n }\n\n prependEntry(compiler: Compiler) {\n if (!this.options?.virtualRuntimeEntry) {\n this.ensureFile(compiler);\n }\n\n compiler.hooks.thisCompilation.tap(\n this.constructor.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 compiler.hooks.make.tapAsync(\n this.constructor.name,\n (compilation: Compilation, callback) => {\n const federationRuntimeDependency = this.getDependency(compiler);\n const hooks = FederationModulesPlugin.getCompilationHooks(compilation);\n compilation.addInclude(\n compiler.context,\n federationRuntimeDependency,\n { name: undefined },\n (err) => {\n if (err) {\n return callback(err);\n }\n hooks.addFederationRuntimeDependency.call(\n federationRuntimeDependency,\n );\n callback();\n },\n );\n },\n );\n }\n\n injectRuntime(compiler: Compiler) {\n if (!this.options || !this.options.name) {\n return;\n }\n const name = this.options.name;\n const initOptionsWithoutShared = normalizeRuntimeInitOptionsWithOutShared(\n this.options,\n );\n const federationGlobal = getFederationGlobalScope(\n RuntimeGlobals || ({} as typeof RuntimeGlobals),\n );\n\n compiler.hooks.thisCompilation.tap(\n this.constructor.name,\n (compilation: Compilation) => {\n const handler = (chunk: Chunk, runtimeRequirements: Set<string>) => {\n if (runtimeRequirements.has(federationGlobal)) return;\n runtimeRequirements.add(federationGlobal);\n runtimeRequirements.add(RuntimeGlobals.interceptModuleExecution);\n runtimeRequirements.add(RuntimeGlobals.moduleCache);\n runtimeRequirements.add(RuntimeGlobals.compatGetDefaultExport);\n\n compilation.addRuntimeModule(\n chunk,\n new FederationRuntimeModule(\n runtimeRequirements,\n name,\n initOptionsWithoutShared,\n ),\n );\n };\n\n compilation.hooks.additionalTreeRuntimeRequirements.tap(\n this.constructor.name,\n (chunk: Chunk, runtimeRequirements: Set<string>) => {\n if (!chunk.hasRuntime()) return;\n if (runtimeRequirements.has(RuntimeGlobals.initializeSharing))\n return;\n if (runtimeRequirements.has(RuntimeGlobals.currentRemoteGetScope))\n return;\n if (runtimeRequirements.has(RuntimeGlobals.shareScopeMap)) return;\n if (runtimeRequirements.has(federationGlobal)) return;\n handler(chunk, runtimeRequirements);\n },\n );\n\n // if federation runtime requirements exist\n // attach runtime module to the chunk\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.initializeSharing)\n .tap(this.constructor.name, handler);\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.currentRemoteGetScope)\n .tap(this.constructor.name, handler);\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.shareScopeMap)\n .tap(this.constructor.name, handler);\n compilation.hooks.runtimeRequirementInTree\n .for(federationGlobal)\n .tap(this.constructor.name, handler);\n },\n );\n }\n\n getRuntimeAlias(compiler: Compiler) {\n const { implementation } = this.options || {};\n const alias: any = compiler.options.resolve.alias || {};\n\n const resolvedPaths = resolveRuntimePaths(implementation);\n\n this.runtimeToolsPath = resolvedPaths.runtimeToolsPath;\n this.bundlerRuntimePath = resolvedPaths.bundlerRuntimePath;\n\n if (alias['@module-federation/runtime$']) {\n this.runtimePath = alias['@module-federation/runtime$'];\n return this.runtimePath;\n }\n\n this.runtimePath = resolvedPaths.runtimePath;\n\n return this.runtimePath;\n }\n\n setRuntimeAlias(compiler: Compiler) {\n const { implementation } = this.options || {};\n const alias: any = compiler.options.resolve.alias || {};\n const runtimePath = this.getRuntimeAlias(compiler);\n alias['@module-federation/runtime$'] =\n alias['@module-federation/runtime$'] || runtimePath;\n alias['@module-federation/runtime-tools$'] =\n alias['@module-federation/runtime-tools$'] ||\n implementation ||\n this.runtimeToolsPath;\n\n // Set up aliases for the federation runtime and tools\n // This ensures that the correct versions are used throughout the project\n compiler.options.resolve.alias = alias;\n }\n\n apply(compiler: Compiler) {\n const useSharedContainerPlugin = compiler.options.plugins.find(\n (p): p is WebpackPluginInstance & { _options?: any } => {\n if (typeof p !== 'object' || !p) {\n return false;\n }\n return p['name'] === 'SharedContainerPlugin';\n },\n );\n // share container plugin should not inject mf runtime\n if (useSharedContainerPlugin) {\n return;\n }\n const useModuleFederationPlugin = compiler.options.plugins.find(\n (p): p is WebpackPluginInstance & { _options?: any } => {\n if (typeof p !== 'object' || !p) {\n return false;\n }\n return p['name'] === 'ModuleFederationPlugin';\n },\n );\n\n if (useModuleFederationPlugin && !this.options) {\n this.options = useModuleFederationPlugin._options;\n }\n\n const useContainerPlugin = compiler.options.plugins.find(\n (p): p is WebpackPluginInstance & { _options?: any } => {\n if (typeof p !== 'object' || !p) {\n return false;\n }\n\n return p['name'] === 'ContainerPlugin';\n },\n );\n\n if (useContainerPlugin && !this.options) {\n this.options = useContainerPlugin._options;\n }\n\n if (!useContainerPlugin && !useModuleFederationPlugin) {\n this.options = {\n remotes: {},\n ...this.options,\n };\n }\n if (this.options && !this.options?.name) {\n //! the instance may get the same one if the name is the same https://github.com/module-federation/core/blob/main/packages/runtime/src/index.ts#L18\n this.options.name =\n compiler.options.output.uniqueName || `container_${Date.now()}`;\n }\n\n const resolvedPaths = resolveRuntimePaths(this.options?.implementation);\n this.bundlerRuntimePath = resolvedPaths.bundlerRuntimePath;\n this.runtimePath = resolvedPaths.runtimePath;\n this.runtimeToolsPath = resolvedPaths.runtimeToolsPath;\n\n this.entryFilePath = this.getFilePath(compiler);\n\n new EmbedFederationRuntimePlugin().apply(compiler);\n\n new HoistContainerReferences().apply(compiler);\n\n // dont run multiple times on every apply()\n if (!onceForCompiler.has(compiler)) {\n this.prependEntry(compiler);\n this.injectRuntime(compiler);\n this.setRuntimeAlias(compiler);\n onceForCompiler.add(compiler);\n }\n }\n}\n\nexport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ntimePlugin.js","names":["getFederationGlobalScope","normalizeToPosixPath","createHash","TEMP_DIR","FederationRuntimeDependency","FederationModulesPlugin","normalizeRuntimeInitOptionsWithOutShared","FederationRuntimeModule","EmbedFederationRuntimePlugin","HoistContainerReferences"],"sources":["../../../../../src/lib/container/runtime/FederationRuntimePlugin.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport type {\n Compiler,\n WebpackPluginInstance,\n Compilation,\n Chunk,\n} from 'webpack';\nimport { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport { moduleFederationPlugin } from '@module-federation/sdk';\nimport FederationRuntimeModule from './FederationRuntimeModule';\nimport {\n getFederationGlobalScope,\n normalizeRuntimeInitOptionsWithOutShared,\n createHash,\n normalizeToPosixPath,\n} from './utils';\nimport { TEMP_DIR } from '../constant';\nimport EmbedFederationRuntimePlugin from './EmbedFederationRuntimePlugin';\nimport FederationModulesPlugin from './FederationModulesPlugin';\nimport HoistContainerReferences from '../HoistContainerReferencesPlugin';\nimport FederationRuntimeDependency from './FederationRuntimeDependency';\n\nconst ModuleDependency = require(\n normalizeWebpackPath('webpack/lib/dependencies/ModuleDependency'),\n) as typeof import('webpack/lib/dependencies/ModuleDependency');\n\nconst { RuntimeGlobals, Template } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\nconst { mkdirpSync } = require(\n normalizeWebpackPath('webpack/lib/util/fs'),\n) as typeof import('webpack/lib/util/fs');\n\ntype ResolveFn = typeof require.resolve;\ntype RuntimeEntrySpec = {\n bundler: string;\n esm: string;\n cjs: string;\n};\n\nfunction resolveRuntimeEntry(\n spec: RuntimeEntrySpec,\n implementation: string | undefined,\n resolve: ResolveFn = require.resolve,\n) {\n const candidates = [spec.bundler, spec.esm, spec.cjs];\n const modulePaths = implementation ? [implementation] : undefined;\n let lastError: unknown;\n\n for (const candidate of candidates) {\n try {\n return modulePaths\n ? resolve(candidate, { paths: modulePaths })\n : resolve(candidate);\n } catch (error) {\n lastError = error;\n }\n }\n\n throw lastError;\n}\n\nfunction resolveRuntimeEntryWithFallback(\n spec: RuntimeEntrySpec,\n implementation: string | undefined,\n resolve: ResolveFn = require.resolve,\n) {\n if (implementation) {\n try {\n return resolveRuntimeEntry(spec, implementation, resolve);\n } catch {\n // Fall back to the workspace runtime packages when a custom\n // implementation hasn't published the newer subpath yet.\n }\n }\n\n return resolveRuntimeEntry(spec, undefined, resolve);\n}\nexport function resolveRuntimePaths(\n implementation?: string,\n resolve: ResolveFn = require.resolve,\n) {\n // Prefer the dedicated bundler subpath so webpack can tree-shake across the\n // runtime package boundary. Fall back to the legacy dist contract for older\n // custom implementations that have not published /bundler yet.\n const runtimeToolsPath = resolveRuntimeEntryWithFallback(\n {\n bundler: '@module-federation/runtime-tools/bundler',\n esm: '@module-federation/runtime-tools/dist/index.js',\n cjs: '@module-federation/runtime-tools/dist/index.cjs',\n },\n implementation,\n resolve,\n );\n const moduleBase = implementation || runtimeToolsPath;\n\n return {\n runtimeToolsPath,\n bundlerRuntimePath: resolveRuntimeEntry(\n {\n bundler: '@module-federation/webpack-bundler-runtime/bundler',\n esm: '@module-federation/webpack-bundler-runtime/dist/index.js',\n cjs: '@module-federation/webpack-bundler-runtime/dist/index.cjs',\n },\n moduleBase,\n resolve,\n ),\n runtimePath: resolveRuntimeEntry(\n {\n bundler: '@module-federation/runtime/bundler',\n esm: '@module-federation/runtime/dist/index.js',\n cjs: '@module-federation/runtime/dist/index.cjs',\n },\n moduleBase,\n resolve,\n ),\n };\n}\n\nconst {\n runtimeToolsPath: RuntimeToolsPath,\n bundlerRuntimePath: BundlerRuntimePath,\n runtimePath: RuntimePath,\n} = resolveRuntimePaths();\nconst federationGlobal = getFederationGlobalScope(RuntimeGlobals);\n\nconst onceForCompiler = new WeakSet<Compiler>();\nconst onceForCompilerEntryMap = new WeakMap<Compiler, string>();\n\nclass FederationRuntimePlugin {\n options?: moduleFederationPlugin.ModuleFederationPluginOptions;\n entryFilePath: string;\n bundlerRuntimePath: string;\n runtimePath: string;\n runtimeToolsPath: string;\n federationRuntimeDependency?: FederationRuntimeDependency; // Add this line\n\n constructor(options?: moduleFederationPlugin.ModuleFederationPluginOptions) {\n this.options = options ? { ...options } : undefined;\n this.entryFilePath = '';\n this.bundlerRuntimePath = BundlerRuntimePath;\n this.runtimePath = RuntimePath;\n this.runtimeToolsPath = RuntimeToolsPath;\n this.federationRuntimeDependency = undefined; // Initialize as undefined\n }\n\n static getTemplate(\n compiler: Compiler,\n options: moduleFederationPlugin.ModuleFederationPluginOptions,\n bundlerRuntimePath?: string,\n ) {\n // internal runtime plugin\n const runtimePlugins = options.runtimePlugins;\n const normalizedBundlerRuntimePath = normalizeToPosixPath(\n bundlerRuntimePath || BundlerRuntimePath,\n );\n\n let runtimePluginTemplates = '';\n const runtimePluginCalls: string[] = [];\n\n if (Array.isArray(runtimePlugins)) {\n runtimePlugins.forEach((runtimePlugin, index) => {\n if (!runtimePlugin) {\n return;\n }\n const runtimePluginName = `plugin_${index}`;\n const runtimePluginEntry = Array.isArray(runtimePlugin)\n ? runtimePlugin[0]\n : runtimePlugin;\n const runtimePluginPath = normalizeToPosixPath(\n path.isAbsolute(runtimePluginEntry)\n ? runtimePluginEntry\n : path.join(process.cwd(), runtimePluginEntry),\n );\n const paramsStr =\n Array.isArray(runtimePlugin) && runtimePlugin.length > 1\n ? JSON.stringify(runtimePlugin[1])\n : 'undefined';\n runtimePluginTemplates += `import ${runtimePluginName} from '${runtimePluginPath}';\\n`;\n runtimePluginCalls.push(\n `${runtimePluginName} ? (${runtimePluginName}.default || ${runtimePluginName})(${paramsStr}) : false`,\n );\n });\n }\n const embedRuntimeLines = Template.asString([\n `if(!${federationGlobal}.runtime || !${federationGlobal}.bundlerRuntime){`,\n Template.indent([\n `var prevFederation = ${federationGlobal};`,\n `${federationGlobal} = {}`,\n `for(var key in federation){`,\n Template.indent([`${federationGlobal}[key] = federation[key];`]),\n '}',\n `for(var key in prevFederation){`,\n Template.indent([`${federationGlobal}[key] = prevFederation[key];`]),\n '}',\n ]),\n '}',\n ]);\n\n return Template.asString([\n `import federation from '${normalizedBundlerRuntimePath}';`,\n runtimePluginTemplates,\n embedRuntimeLines,\n `if(!${federationGlobal}.instance){`,\n Template.indent([\n runtimePluginCalls.length\n ? Template.asString([\n `var pluginsToAdd = [`,\n Template.indent(\n Template.indent(runtimePluginCalls.map((call) => `${call},`)),\n ),\n `].filter(Boolean);`,\n `${federationGlobal}.initOptions.plugins = ${federationGlobal}.initOptions.plugins ? `,\n `${federationGlobal}.initOptions.plugins.concat(pluginsToAdd) : pluginsToAdd;`,\n ])\n : '',\n // `${federationGlobal}.instance = ${federationGlobal}.runtime.init(${federationGlobal}.initOptions);`,\n `${federationGlobal}.instance = ${federationGlobal}.bundlerRuntime.init({webpackRequire:${RuntimeGlobals.require}});`,\n `if(${federationGlobal}.attachShareScopeMap){`,\n Template.indent([\n `${federationGlobal}.attachShareScopeMap(${RuntimeGlobals.require})`,\n ]),\n '}',\n `if(${federationGlobal}.installInitialConsumes){`,\n Template.indent([`${federationGlobal}.installInitialConsumes()`]),\n '}',\n ]),\n '}',\n ]);\n }\n\n getFilePath(compiler: Compiler) {\n if (!this.options) {\n return '';\n }\n\n const existedFilePath = onceForCompilerEntryMap.get(compiler);\n\n if (existedFilePath) {\n return existedFilePath;\n }\n\n let entryFilePath = '';\n if (!this.options?.virtualRuntimeEntry) {\n const containerName = this.options.name;\n const hash = createHash(\n `${containerName} ${FederationRuntimePlugin.getTemplate(\n compiler,\n this.options,\n this.bundlerRuntimePath,\n )}`,\n );\n entryFilePath = path.join(TEMP_DIR, `entry.${hash}.js`);\n } else {\n entryFilePath = `data:text/javascript;charset=utf-8;base64,${Buffer.from(\n FederationRuntimePlugin.getTemplate(\n compiler,\n this.options,\n this.bundlerRuntimePath,\n ),\n 'utf8',\n ).toString('base64')}`;\n }\n\n onceForCompilerEntryMap.set(compiler, entryFilePath);\n\n return entryFilePath;\n }\n\n ensureFile(compiler: Compiler) {\n if (!this.options) {\n return;\n }\n // skip virtual entry\n if (this.options?.virtualRuntimeEntry) {\n return;\n }\n const filePath = this.entryFilePath;\n const outputFs = (compiler as unknown as { outputFileSystem?: unknown })\n .outputFileSystem;\n const fsLike =\n outputFs &&\n typeof (outputFs as typeof fs).readFileSync === 'function' &&\n typeof (outputFs as typeof fs).writeFileSync === 'function'\n ? (outputFs as typeof fs)\n : fs;\n try {\n fsLike.readFileSync(filePath);\n } catch {\n mkdirpSync(fsLike as any, TEMP_DIR);\n fsLike.writeFileSync(\n filePath,\n FederationRuntimePlugin.getTemplate(\n compiler,\n this.options,\n this.bundlerRuntimePath,\n ),\n );\n }\n }\n\n getDependency(compiler: Compiler) {\n if (this.federationRuntimeDependency)\n return this.federationRuntimeDependency;\n\n this.ensureFile(compiler);\n\n this.federationRuntimeDependency = new FederationRuntimeDependency(\n this.entryFilePath,\n );\n return this.federationRuntimeDependency;\n }\n\n prependEntry(compiler: Compiler) {\n if (!this.options?.virtualRuntimeEntry) {\n this.ensureFile(compiler);\n }\n\n compiler.hooks.thisCompilation.tap(\n this.constructor.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 compiler.hooks.make.tapAsync(\n this.constructor.name,\n (compilation: Compilation, callback) => {\n const federationRuntimeDependency = this.getDependency(compiler);\n const hooks = FederationModulesPlugin.getCompilationHooks(compilation);\n compilation.addInclude(\n compiler.context,\n federationRuntimeDependency,\n { name: undefined },\n (err) => {\n if (err) {\n return callback(err);\n }\n hooks.addFederationRuntimeDependency.call(\n federationRuntimeDependency,\n );\n callback();\n },\n );\n },\n );\n }\n\n injectRuntime(compiler: Compiler) {\n if (!this.options || !this.options.name) {\n return;\n }\n const name = this.options.name;\n const initOptionsWithoutShared = normalizeRuntimeInitOptionsWithOutShared(\n this.options,\n );\n const federationGlobal = getFederationGlobalScope(\n RuntimeGlobals || ({} as typeof RuntimeGlobals),\n );\n\n compiler.hooks.thisCompilation.tap(\n this.constructor.name,\n (compilation: Compilation) => {\n const handler = (chunk: Chunk, runtimeRequirements: Set<string>) => {\n if (runtimeRequirements.has(federationGlobal)) return;\n runtimeRequirements.add(federationGlobal);\n runtimeRequirements.add(RuntimeGlobals.interceptModuleExecution);\n runtimeRequirements.add(RuntimeGlobals.moduleCache);\n runtimeRequirements.add(RuntimeGlobals.compatGetDefaultExport);\n\n compilation.addRuntimeModule(\n chunk,\n new FederationRuntimeModule(\n runtimeRequirements,\n name,\n initOptionsWithoutShared,\n ),\n );\n };\n\n compilation.hooks.additionalTreeRuntimeRequirements.tap(\n this.constructor.name,\n (chunk: Chunk, runtimeRequirements: Set<string>) => {\n if (!chunk.hasRuntime()) return;\n if (runtimeRequirements.has(RuntimeGlobals.initializeSharing))\n return;\n if (runtimeRequirements.has(RuntimeGlobals.currentRemoteGetScope))\n return;\n if (runtimeRequirements.has(RuntimeGlobals.shareScopeMap)) return;\n if (runtimeRequirements.has(federationGlobal)) return;\n handler(chunk, runtimeRequirements);\n },\n );\n\n // if federation runtime requirements exist\n // attach runtime module to the chunk\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.initializeSharing)\n .tap(this.constructor.name, handler);\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.currentRemoteGetScope)\n .tap(this.constructor.name, handler);\n compilation.hooks.runtimeRequirementInTree\n .for(RuntimeGlobals.shareScopeMap)\n .tap(this.constructor.name, handler);\n compilation.hooks.runtimeRequirementInTree\n .for(federationGlobal)\n .tap(this.constructor.name, handler);\n },\n );\n }\n\n getRuntimeAlias(compiler: Compiler) {\n const { implementation } = this.options || {};\n const alias: any = compiler.options.resolve.alias || {};\n\n const resolvedPaths = resolveRuntimePaths(implementation);\n\n this.runtimeToolsPath = resolvedPaths.runtimeToolsPath;\n this.bundlerRuntimePath = resolvedPaths.bundlerRuntimePath;\n\n if (alias['@module-federation/runtime$']) {\n this.runtimePath = alias['@module-federation/runtime$'];\n return this.runtimePath;\n }\n\n this.runtimePath = resolvedPaths.runtimePath;\n\n return this.runtimePath;\n }\n\n setRuntimeAlias(compiler: Compiler) {\n const { implementation } = this.options || {};\n const alias: any = compiler.options.resolve.alias || {};\n const runtimePath = this.getRuntimeAlias(compiler);\n alias['@module-federation/runtime$'] =\n alias['@module-federation/runtime$'] || runtimePath;\n alias['@module-federation/runtime-tools$'] =\n alias['@module-federation/runtime-tools$'] ||\n implementation ||\n this.runtimeToolsPath;\n\n // Set up aliases for the federation runtime and tools\n // This ensures that the correct versions are used throughout the project\n compiler.options.resolve.alias = alias;\n }\n\n apply(compiler: Compiler) {\n const useSharedContainerPlugin = compiler.options.plugins.find(\n (p): p is WebpackPluginInstance & { _options?: any } => {\n if (typeof p !== 'object' || !p) {\n return false;\n }\n return p['name'] === 'SharedContainerPlugin';\n },\n );\n // share container plugin should not inject mf runtime\n if (useSharedContainerPlugin) {\n return;\n }\n const useModuleFederationPlugin = compiler.options.plugins.find(\n (p): p is WebpackPluginInstance & { _options?: any } => {\n if (typeof p !== 'object' || !p) {\n return false;\n }\n return p['name'] === 'ModuleFederationPlugin';\n },\n );\n\n if (useModuleFederationPlugin && !this.options) {\n this.options = useModuleFederationPlugin._options;\n }\n\n const useContainerPlugin = compiler.options.plugins.find(\n (p): p is WebpackPluginInstance & { _options?: any } => {\n if (typeof p !== 'object' || !p) {\n return false;\n }\n\n return p['name'] === 'ContainerPlugin';\n },\n );\n\n if (useContainerPlugin && !this.options) {\n this.options = useContainerPlugin._options;\n }\n\n if (!useContainerPlugin && !useModuleFederationPlugin) {\n this.options = {\n remotes: {},\n ...this.options,\n };\n }\n if (this.options && !this.options?.name) {\n //! the instance may get the same one if the name is the same https://github.com/module-federation/core/blob/main/packages/runtime/src/index.ts#L18\n this.options.name =\n compiler.options.output.uniqueName || `container_${Date.now()}`;\n }\n\n const resolvedPaths = resolveRuntimePaths(this.options?.implementation);\n this.bundlerRuntimePath = resolvedPaths.bundlerRuntimePath;\n this.runtimePath = resolvedPaths.runtimePath;\n this.runtimeToolsPath = resolvedPaths.runtimeToolsPath;\n\n this.entryFilePath = this.getFilePath(compiler);\n\n new EmbedFederationRuntimePlugin().apply(compiler);\n\n new HoistContainerReferences().apply(compiler);\n\n // dont run multiple times on every apply()\n if (!onceForCompiler.has(compiler)) {\n this.prependEntry(compiler);\n this.injectRuntime(compiler);\n this.setRuntimeAlias(compiler);\n onceForCompiler.add(compiler);\n }\n }\n}\n\nexport default FederationRuntimePlugin;\n"],"mappings":";;;;;;;;;;;;;;;;AAuBA,MAAM,mBAAmB,gFACF,4CAA4C,CAClE;AAED,MAAM,EAAE,gBAAgB,aAAa,gFACd,UAAU,CAChC;AACD,MAAM,EAAE,eAAe,gFACA,sBAAsB,CAC5C;AASD,SAAS,oBACP,MACA,gBACA,UAAqB,QAAQ,SAC7B;CACA,MAAM,aAAa;EAAC,KAAK;EAAS,KAAK;EAAK,KAAK;EAAI;CACrD,MAAM,cAAc,iBAAiB,CAAC,eAAe,GAAG;CACxD,IAAI;AAEJ,MAAK,MAAM,aAAa,WACtB,KAAI;AACF,SAAO,cACH,QAAQ,WAAW,EAAE,OAAO,aAAa,CAAC,GAC1C,QAAQ,UAAU;UACf,OAAO;AACd,cAAY;;AAIhB,OAAM;;AAGR,SAAS,gCACP,MACA,gBACA,UAAqB,QAAQ,SAC7B;AACA,KAAI,eACF,KAAI;AACF,SAAO,oBAAoB,MAAM,gBAAgB,QAAQ;SACnD;AAMV,QAAO,oBAAoB,MAAM,QAAW,QAAQ;;AAEtD,SAAgB,oBACd,gBACA,UAAqB,QAAQ,SAC7B;CAIA,MAAM,mBAAmB,gCACvB;EACE,SAAS;EACT,KAAK;EACL,KAAK;EACN,EACD,gBACA,QACD;CACD,MAAM,aAAa,kBAAkB;AAErC,QAAO;EACL;EACA,oBAAoB,oBAClB;GACE,SAAS;GACT,KAAK;GACL,KAAK;GACN,EACD,YACA,QACD;EAC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