@module-federation/enhanced 2.6.0 → 2.8.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.
Files changed (45) hide show
  1. package/dist/CHANGELOG.md +44 -0
  2. package/dist/rstestmigrate.md +2 -2
  3. package/dist/src/lib/Constants.d.ts +29 -25
  4. package/dist/src/lib/container/ContainerEntryDependency.d.ts +2 -2
  5. package/dist/src/lib/container/ContainerEntryModule.d.ts +40 -21
  6. package/dist/src/lib/container/ContainerExposedDependency.d.ts +6 -8
  7. package/dist/src/lib/container/FallbackDependency.d.ts +2 -2
  8. package/dist/src/lib/container/FallbackItemDependency.d.ts +2 -2
  9. package/dist/src/lib/container/FallbackModule.d.ts +2 -2
  10. package/dist/src/lib/container/ModuleFederationPlugin.js +13 -2
  11. package/dist/src/lib/container/ModuleFederationPlugin.js.map +1 -1
  12. package/dist/src/lib/container/RemoteModule.d.ts +2 -2
  13. package/dist/src/lib/container/RemoteRuntimeModule.d.ts +2 -2
  14. package/dist/src/lib/container/RemoteToExternalDependency.d.ts +2 -2
  15. package/dist/src/lib/container/options.d.ts +12 -7
  16. package/dist/src/lib/container/runtime/EmbedFederationRuntimeModule.d.ts +2 -2
  17. package/dist/src/lib/container/runtime/FederationRuntimeModule.d.ts +2 -2
  18. package/dist/src/lib/container/runtime/FederationRuntimePlugin.js +3 -2
  19. package/dist/src/lib/container/runtime/FederationRuntimePlugin.js.map +1 -1
  20. package/dist/src/lib/container/runtime/getFederationGlobal.d.ts +2 -2
  21. package/dist/src/lib/container/runtime/normalizeToPosixPath.d.ts +5 -0
  22. package/dist/src/lib/container/runtime/normalizeToPosixPath.js +20 -0
  23. package/dist/src/lib/container/runtime/normalizeToPosixPath.js.map +1 -0
  24. package/dist/src/lib/container/runtime/utils.d.ts +23 -19
  25. package/dist/src/lib/container/runtime/utils.js +2 -6
  26. package/dist/src/lib/container/runtime/utils.js.map +1 -1
  27. package/dist/src/lib/sharing/ConsumeSharedFallbackDependency.d.ts +2 -2
  28. package/dist/src/lib/sharing/ConsumeSharedModule.d.ts +5 -5
  29. package/dist/src/lib/sharing/ConsumeSharedRuntimeModule.d.ts +2 -2
  30. package/dist/src/lib/sharing/ProvideForSharedDependency.d.ts +2 -2
  31. package/dist/src/lib/sharing/ProvideSharedDependency.d.ts +2 -2
  32. package/dist/src/lib/sharing/ProvideSharedModule.d.ts +2 -2
  33. package/dist/src/lib/sharing/ShareRuntimeModule.d.ts +2 -2
  34. package/dist/src/lib/sharing/tree-shaking/IndependentSharedRuntimeModule.d.ts +2 -2
  35. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedDependency.d.ts +2 -2
  36. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryDependency.d.ts +2 -2
  37. package/dist/src/lib/sharing/tree-shaking/SharedContainerPlugin/SharedEntryModule.d.ts +2 -2
  38. package/dist/src/lib/sharing/tree-shaking/SharedUsedExportsOptimizerRuntimeModule.d.ts +2 -2
  39. package/dist/src/schemas/container/ModuleFederationPlugin.check.js +25 -13
  40. package/dist/src/schemas/container/ModuleFederationPlugin.check.js.map +1 -1
  41. package/dist/src/schemas/container/ModuleFederationPlugin.d.ts +9 -1
  42. package/dist/src/schemas/container/ModuleFederationPlugin.js +9 -5
  43. package/dist/src/schemas/container/ModuleFederationPlugin.js.map +1 -1
  44. package/dist/src/wrapper/FederationModulesPlugin.d.ts +4 -4
  45. package/package.json +17 -17
package/dist/CHANGELOG.md CHANGED
@@ -1,5 +1,49 @@
1
1
  # @module-federation/enhanced
2
2
 
3
+ ## 2.8.0
4
+
5
+ ### Patch Changes
6
+
7
+ - ea490ae: Allow builds to exclude unused remote consumption and shared capabilities, and automatically omit Webpack container initialization when no exposes are configured.
8
+ - 6ee67dc: Reduce installed and bundled size by replacing general-purpose cache, path, version, package lookup, scheduling, fetch, and error fallback dependencies with focused built-in utilities.
9
+ - 681e5d2: feat(dts-plugin): support ts 7 for federated type generation while keeping existing ts versions supported
10
+ - Updated dependencies [d6a76d8]
11
+ - Updated dependencies [ea490ae]
12
+ - Updated dependencies [6ee67dc]
13
+ - Updated dependencies [681e5d2]
14
+ - Updated dependencies [a5633f8]
15
+ - @module-federation/manifest@2.8.0
16
+ - @module-federation/rspack@2.8.0
17
+ - @module-federation/sdk@2.8.0
18
+ - @module-federation/webpack-bundler-runtime@2.8.0
19
+ - @module-federation/bridge-react-webpack-plugin@2.8.0
20
+ - @module-federation/dts-plugin@2.8.0
21
+ - @module-federation/managers@2.8.0
22
+ - @module-federation/cli@2.8.0
23
+ - @module-federation/runtime-tools@2.8.0
24
+ - @module-federation/inject-external-runtime-core-plugin@2.8.0
25
+ - @module-federation/error-codes@2.8.0
26
+
27
+ ## 2.7.0
28
+
29
+ ### Patch Changes
30
+
31
+ - Updated dependencies [a7351f3]
32
+ - Updated dependencies [dcc640b]
33
+ - Updated dependencies [9958086]
34
+ - Updated dependencies [a5f123a]
35
+ - @module-federation/dts-plugin@2.7.0
36
+ - @module-federation/sdk@2.7.0
37
+ - @module-federation/managers@2.7.0
38
+ - @module-federation/manifest@2.7.0
39
+ - @module-federation/cli@2.7.0
40
+ - @module-federation/rspack@2.7.0
41
+ - @module-federation/bridge-react-webpack-plugin@2.7.0
42
+ - @module-federation/webpack-bundler-runtime@2.7.0
43
+ - @module-federation/runtime-tools@2.7.0
44
+ - @module-federation/inject-external-runtime-core-plugin@2.7.0
45
+ - @module-federation/error-codes@2.7.0
46
+
3
47
  ## 2.6.0
4
48
 
5
49
  ### Patch Changes
@@ -24,11 +24,11 @@ Rstest docs listed in the references section.
24
24
 
25
25
  ### 1) Update scripts and Nx targets
26
26
  - Switch `packages/enhanced/project.json` `test` target to Rstest:
27
- `rstest run -c packages/enhanced/rstest.config.ts` (match CLI usage).
27
+ `rstest -c packages/enhanced/rstest.config.ts` (match CLI usage).
28
28
  - Replace or remove `test:jest` and `test:experiments` targets, or rewrite
29
29
  them as Rstest equivalents (for example, separate includes/projects).
30
30
  - Keep `enhanced:rstest` in the root `package.json` as the user-facing entry
31
- point and ensure it uses `rstest run` (or `rstest`) consistently.
31
+ point and ensure it uses `rstest` consistently.
32
32
 
33
33
  ### 2) Expand `rstest.config.ts` coverage
34
34
  - Include unit and compiler tests (not just ConfigTestCases):
@@ -1,113 +1,117 @@
1
- //#region src/lib/Constants.d.ts
2
1
  /**
3
2
  * @type {Readonly<"javascript/auto">}
4
3
  */
5
- declare const JAVASCRIPT_MODULE_TYPE_AUTO: Readonly<'javascript/auto'>;
4
+ export declare const JAVASCRIPT_MODULE_TYPE_AUTO: Readonly<'javascript/auto'>;
6
5
  /**
7
6
  * @type {Readonly<"javascript/dynamic">}
8
7
  */
9
- declare const JAVASCRIPT_MODULE_TYPE_DYNAMIC: Readonly<'javascript/dynamic'>;
8
+ export declare const JAVASCRIPT_MODULE_TYPE_DYNAMIC: Readonly<'javascript/dynamic'>;
10
9
  /**
11
10
  * @type {Readonly<"javascript/esm">}
12
11
  * This is the module type used for _strict_ ES Module syntax. This means that all legacy formats
13
12
  * that webpack supports (CommonJS, AMD, SystemJS) are not supported.
14
13
  */
15
- declare const JAVASCRIPT_MODULE_TYPE_ESM: Readonly<'javascript/esm'>;
14
+ export declare const JAVASCRIPT_MODULE_TYPE_ESM: Readonly<'javascript/esm'>;
16
15
  /**
17
16
  * @type {Readonly<"json">}
18
17
  * This is the module type used for JSON files. JSON files are always parsed as ES Module.
19
18
  */
20
- declare const JSON_MODULE_TYPE: Readonly<'json'>;
19
+ export declare const JSON_MODULE_TYPE: Readonly<'json'>;
21
20
  /**
22
21
  * @type {Readonly<"webassembly/async">}
23
22
  * This is the module type used for WebAssembly modules. In webpack 5 they are always treated as async modules.
24
23
  *
25
24
  */
26
- declare const WEBASSEMBLY_MODULE_TYPE_ASYNC: Readonly<'webassembly/async'>;
25
+ export declare const WEBASSEMBLY_MODULE_TYPE_ASYNC: Readonly<'webassembly/async'>;
27
26
  /**
28
27
  * @type {Readonly<"webassembly/sync">}
29
28
  * This is the module type used for WebAssembly modules. In webpack 4 they are always treated as sync modules.
30
29
  * There is a legacy option to support this usage in webpack 5 and up.
31
30
  */
32
- declare const WEBASSEMBLY_MODULE_TYPE_SYNC: Readonly<'webassembly/sync'>;
31
+ export declare const WEBASSEMBLY_MODULE_TYPE_SYNC: Readonly<'webassembly/sync'>;
33
32
  /**
34
33
  * @type {Readonly<"css">}
35
34
  * This is the module type used for CSS files.
36
35
  */
37
- declare const CSS_MODULE_TYPE: Readonly<'css'>;
36
+ export declare const CSS_MODULE_TYPE: Readonly<'css'>;
38
37
  /**
39
38
  * @type {Readonly<"css/global">}
40
39
  * This is the module type used for CSS modules files where you need to use `:local` in selector list to hash classes.
41
40
  */
42
- declare const CSS_MODULE_TYPE_GLOBAL: Readonly<'css/global'>;
41
+ export declare const CSS_MODULE_TYPE_GLOBAL: Readonly<'css/global'>;
43
42
  /**
44
43
  * @type {Readonly<"css/module">}
45
44
  * This is the module type used for CSS modules files, by default all classes are hashed.
46
45
  */
47
- declare const CSS_MODULE_TYPE_MODULE: Readonly<'css/module'>;
46
+ export declare const CSS_MODULE_TYPE_MODULE: Readonly<'css/module'>;
48
47
  /**
49
48
  * @type {Readonly<"css/auto">}
50
49
  * This is the module type used for CSS files, the module will be parsed as CSS modules if it's filename contains `.module.` or `.modules.`.
51
50
  */
52
- declare const CSS_MODULE_TYPE_AUTO: Readonly<'css/auto'>;
51
+ export declare const CSS_MODULE_TYPE_AUTO: Readonly<'css/auto'>;
53
52
  /**
54
53
  * @type {Readonly<"asset">}
55
54
  * This is the module type used for automatically choosing between `asset/inline`, `asset/resource` based on asset size limit (8096).
56
55
  */
57
- declare const ASSET_MODULE_TYPE: Readonly<'asset'>;
56
+ export declare const ASSET_MODULE_TYPE: Readonly<'asset'>;
58
57
  /**
59
58
  * @type {Readonly<"asset/inline">}
60
59
  * This is the module type used for assets that are inlined as a data URI. This is the equivalent of `url-loader`.
61
60
  */
62
- declare const ASSET_MODULE_TYPE_INLINE: Readonly<'asset/inline'>;
61
+ export declare const ASSET_MODULE_TYPE_INLINE: Readonly<'asset/inline'>;
63
62
  /**
64
63
  * @type {Readonly<"asset/resource">}
65
64
  * This is the module type used for assets that are copied to the output directory. This is the equivalent of `file-loader`.
66
65
  */
67
- declare const ASSET_MODULE_TYPE_RESOURCE: Readonly<'asset/resource'>;
66
+ export declare const ASSET_MODULE_TYPE_RESOURCE: Readonly<'asset/resource'>;
68
67
  /**
69
68
  * @type {Readonly<"asset/source">}
70
69
  * This is the module type used for assets that are imported as source code. This is the equivalent of `raw-loader`.
71
70
  */
72
- declare const ASSET_MODULE_TYPE_SOURCE: Readonly<'asset/source'>;
71
+ export declare const ASSET_MODULE_TYPE_SOURCE: Readonly<'asset/source'>;
73
72
  /**
74
73
  * @type {Readonly<"asset/raw-data-url">}
75
74
  * TODO: Document what this asset type is for. See css-loader tests for its usage.
76
75
  */
77
- declare const ASSET_MODULE_TYPE_RAW_DATA_URL: Readonly<'asset/raw-data-url'>;
76
+ export declare const ASSET_MODULE_TYPE_RAW_DATA_URL: Readonly<'asset/raw-data-url'>;
78
77
  /**
79
78
  * @type {Readonly<"runtime">}
80
79
  * This is the module type used for the webpack runtime abstractions.
81
80
  */
82
- declare const WEBPACK_MODULE_TYPE_RUNTIME: Readonly<'runtime'>;
81
+ export declare const WEBPACK_MODULE_TYPE_RUNTIME: Readonly<'runtime'>;
83
82
  /**
84
83
  * @type {Readonly<"fallback-module">}
85
84
  * This is the module type used for the ModuleFederation feature's FallbackModule class.
86
85
  * TODO: Document this better.
87
86
  */
88
- declare const WEBPACK_MODULE_TYPE_FALLBACK: Readonly<'fallback-module'>;
87
+ export declare const WEBPACK_MODULE_TYPE_FALLBACK: Readonly<'fallback-module'>;
89
88
  /**
90
89
  * @type {Readonly<"remote-module">}
91
90
  * This is the module type used for the ModuleFederation feature's RemoteModule class.
92
91
  * TODO: Document this better.
93
92
  */
94
- declare const WEBPACK_MODULE_TYPE_REMOTE: Readonly<'remote-module'>;
93
+ export declare const WEBPACK_MODULE_TYPE_REMOTE: Readonly<'remote-module'>;
95
94
  /**
96
95
  * @type {Readonly<"provide-module">}
97
96
  * This is the module type used for the ModuleFederation feature's ProvideModule class.
98
97
  * TODO: Document this better.
99
98
  */
100
- declare const WEBPACK_MODULE_TYPE_PROVIDE: Readonly<'provide-module'>;
99
+ export declare const WEBPACK_MODULE_TYPE_PROVIDE: Readonly<'provide-module'>;
101
100
  /**
102
101
  * @type {Readonly<"consume-shared-module">}
103
102
  * This is the module type used for the ModuleFederation feature's ConsumeSharedModule class.
104
103
  */
105
- declare const WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE: Readonly<'consume-shared-module'>;
104
+ export declare const WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE: Readonly<'consume-shared-module'>;
106
105
  /**
107
106
  * @type {Readonly<"lazy-compilation-proxy">}
108
107
  * Module type used for `experiments.lazyCompilation` feature. See `LazyCompilationPlugin` for more information.
109
108
  */
110
- declare const WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY: Readonly<'lazy-compilation-proxy'>;
111
- //#endregion
112
- export { ASSET_MODULE_TYPE, ASSET_MODULE_TYPE_INLINE, ASSET_MODULE_TYPE_RAW_DATA_URL, ASSET_MODULE_TYPE_RESOURCE, ASSET_MODULE_TYPE_SOURCE, CSS_MODULE_TYPE, CSS_MODULE_TYPE_AUTO, CSS_MODULE_TYPE_GLOBAL, CSS_MODULE_TYPE_MODULE, JAVASCRIPT_MODULE_TYPE_AUTO, JAVASCRIPT_MODULE_TYPE_DYNAMIC, JAVASCRIPT_MODULE_TYPE_ESM, JSON_MODULE_TYPE, WEBASSEMBLY_MODULE_TYPE_ASYNC, WEBASSEMBLY_MODULE_TYPE_SYNC, WEBPACK_MODULE_TYPE_CONSUME_SHARED_MODULE, WEBPACK_MODULE_TYPE_FALLBACK, WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY, WEBPACK_MODULE_TYPE_PROVIDE, WEBPACK_MODULE_TYPE_REMOTE, WEBPACK_MODULE_TYPE_RUNTIME };
113
- //# sourceMappingURL=Constants.d.ts.map
109
+ export declare const WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY: Readonly<'lazy-compilation-proxy'>;
110
+ /** @typedef {"javascript/auto" | "javascript/dynamic" | "javascript/esm"} JavaScriptModuleTypes */
111
+ /** @typedef {"json"} JSONModuleType */
112
+ /** @typedef {"webassembly/async" | "webassembly/sync"} WebAssemblyModuleTypes */
113
+ /** @typedef {"css" | "css/global" | "css/module"} CSSModuleTypes */
114
+ /** @typedef {"asset" | "asset/inline" | "asset/resource" | "asset/source" | "asset/raw-data-url"} AssetModuleTypes */
115
+ /** @typedef {"runtime" | "fallback-module" | "remote-module" | "provide-module" | "consume-shared-module" | "lazy-compilation-proxy"} WebpackModuleTypes */
116
+ /** @typedef {string} UnknownModuleTypes */
117
+ /** @typedef {JavaScriptModuleTypes | JSONModuleType | WebAssemblyModuleTypes | CSSModuleTypes | AssetModuleTypes | WebpackModuleTypes | UnknownModuleTypes} ModuleTypes */
@@ -1,8 +1,8 @@
1
1
  import { ExposeOptions } from "./ContainerEntryModule.js";
2
- import * as webpack$1 from "webpack";
2
+ import * as node_modules_webpack_types0 from "node_modules/webpack/types";
3
3
 
4
4
  //#region src/lib/container/ContainerEntryDependency.d.ts
5
- declare const Dependency: typeof webpack$1.Dependency;
5
+ declare const Dependency: typeof node_modules_webpack_types0.Dependency;
6
6
  declare class ContainerEntryDependency extends Dependency {
7
7
  name: string;
8
8
  exposes: [string, ExposeOptions][];
@@ -1,11 +1,17 @@
1
- import * as webpack$1 from "webpack";
2
- import { Compilation } from "webpack";
3
- import { InputFileSystem, LibIdentOptions, NeedBuildContext, ObjectDeserializerContext, ObjectSerializerContext, RequestShortener, ResolverWithOptions, WebpackOptions } from "webpack/lib/Module";
4
- import WebpackError$1 from "webpack/lib/WebpackError";
5
-
6
- //#region src/lib/container/ContainerEntryModule.d.ts
7
- declare const Module$1: typeof webpack$1.Module;
8
- type ExposeOptions = {
1
+ import type { Compilation } from 'webpack';
2
+ import type {
3
+ InputFileSystem,
4
+ LibIdentOptions,
5
+ NeedBuildContext,
6
+ ObjectDeserializerContext,
7
+ ObjectSerializerContext,
8
+ RequestShortener,
9
+ ResolverWithOptions,
10
+ WebpackOptions,
11
+ } from 'webpack/lib/Module';
12
+ import type WebpackError from 'webpack/lib/WebpackError';
13
+ declare const Module: typeof import('webpack').Module;
14
+ export type ExposeOptions = {
9
15
  /**
10
16
  * requests to exposed modules (last one is exported)
11
17
  */
@@ -15,7 +21,7 @@ type ExposeOptions = {
15
21
  */
16
22
  name: string;
17
23
  };
18
- declare class ContainerEntryModule extends Module$1 {
24
+ declare class ContainerEntryModule extends Module {
19
25
  private _name;
20
26
  private _exposes;
21
27
  private _shareScope;
@@ -26,7 +32,12 @@ declare class ContainerEntryModule extends Module$1 {
26
32
  * @param {string|string[]} shareScope name of the share scope
27
33
  * @param {string} injectRuntimeEntry the path of injectRuntime file.
28
34
  */
29
- constructor(name: string, exposes: [string, ExposeOptions][], shareScope: string | string[], injectRuntimeEntry: string);
35
+ constructor(
36
+ name: string,
37
+ exposes: [string, ExposeOptions][],
38
+ shareScope: string | string[],
39
+ injectRuntimeEntry: string,
40
+ );
30
41
  /**
31
42
  * @param {ObjectDeserializerContext} context context
32
43
  * @returns {ContainerEntryModule} deserialized container entry module
@@ -55,7 +66,13 @@ declare class ContainerEntryModule extends Module$1 {
55
66
  * @param {function((WebpackError | null)=, boolean=): void} callback callback function, returns true, if the module needs a rebuild
56
67
  * @returns {void}
57
68
  */
58
- needBuild(context: NeedBuildContext, callback: (arg0: (WebpackError$1 | null) | undefined, arg1: boolean | undefined) => void): void;
69
+ needBuild(
70
+ context: NeedBuildContext,
71
+ callback: (
72
+ arg0: (WebpackError | null) | undefined,
73
+ arg1: boolean | undefined,
74
+ ) => void,
75
+ ): void;
59
76
  /**
60
77
  * @param {WebpackOptions} options webpack options
61
78
  * @param {Compilation} compilation the compilation
@@ -64,18 +81,22 @@ declare class ContainerEntryModule extends Module$1 {
64
81
  * @param {function(WebpackError): void} callback callback function
65
82
  * @returns {void}
66
83
  */
67
- build(options: WebpackOptions, compilation: Compilation, resolver: ResolverWithOptions, fs: InputFileSystem, callback: (err?: WebpackError$1) => void): void;
84
+ build(
85
+ options: WebpackOptions,
86
+ compilation: Compilation,
87
+ resolver: ResolverWithOptions,
88
+ fs: InputFileSystem,
89
+ callback: (err?: WebpackError) => void,
90
+ ): void;
68
91
  /**
69
92
  * @param {CodeGenerationContext} context context for code generation
70
93
  * @returns {CodeGenerationResult} result
71
94
  */
72
- codeGeneration({
73
- moduleGraph,
74
- chunkGraph,
75
- runtimeTemplate
76
- }: any): {
95
+ codeGeneration({ moduleGraph, chunkGraph, runtimeTemplate }: any): {
77
96
  sources: Map<any, any>;
78
- runtimeRequirements: Set<"__webpack_require__.d" | "__webpack_require__.o" | "__webpack_exports__">;
97
+ runtimeRequirements: Set<
98
+ '__webpack_exports__' | '__webpack_require__.d' | '__webpack_require__.o'
99
+ >;
79
100
  };
80
101
  /**
81
102
  * @param {string=} type the source type for which the size should be estimated
@@ -87,6 +108,4 @@ declare class ContainerEntryModule extends Module$1 {
87
108
  */
88
109
  serialize(context: ObjectSerializerContext): void;
89
110
  }
90
- //#endregion
91
- export { ExposeOptions, ContainerEntryModule as default };
92
- //# sourceMappingURL=ContainerEntryModule.d.ts.map
111
+ export default ContainerEntryModule;
@@ -1,8 +1,8 @@
1
- import * as webpack$1 from "webpack";
2
- import { ObjectDeserializerContext, ObjectSerializerContext } from "webpack/lib/dependencies/ModuleDependency";
3
-
4
- //#region src/lib/container/ContainerExposedDependency.d.ts
5
- declare const dependencies: typeof webpack$1.dependencies;
1
+ declare const dependencies: typeof import('webpack').dependencies;
2
+ import type {
3
+ ObjectDeserializerContext,
4
+ ObjectSerializerContext,
5
+ } from 'webpack/lib/dependencies/ModuleDependency';
6
6
  declare class ContainerExposedDependency extends dependencies.ModuleDependency {
7
7
  exposedName: string;
8
8
  request: string;
@@ -26,6 +26,4 @@ declare class ContainerExposedDependency extends dependencies.ModuleDependency {
26
26
  */
27
27
  deserialize(context: ObjectDeserializerContext): void;
28
28
  }
29
- //#endregion
30
- export { ContainerExposedDependency as default };
31
- //# sourceMappingURL=ContainerExposedDependency.d.ts.map
29
+ export default ContainerExposedDependency;
@@ -1,8 +1,8 @@
1
- import * as webpack$1 from "webpack";
1
+ import * as node_modules_webpack_types0 from "node_modules/webpack/types";
2
2
  import { ObjectDeserializerContext, ObjectSerializerContext } from "webpack/lib/Dependency";
3
3
 
4
4
  //#region src/lib/container/FallbackDependency.d.ts
5
- declare const Dependency: typeof webpack$1.Dependency;
5
+ declare const Dependency: typeof node_modules_webpack_types0.Dependency;
6
6
  declare class FallbackDependency extends Dependency {
7
7
  requests: string[];
8
8
  /**
@@ -1,7 +1,7 @@
1
- import * as webpack$1 from "webpack";
1
+ import * as node_modules_webpack_types0 from "node_modules/webpack/types";
2
2
 
3
3
  //#region src/lib/container/FallbackItemDependency.d.ts
4
- declare const dependencies: typeof webpack$1.dependencies;
4
+ declare const dependencies: typeof node_modules_webpack_types0.dependencies;
5
5
  declare class FallbackItemDependency extends dependencies.ModuleDependency {
6
6
  /**
7
7
  * @param {string} request request
@@ -1,9 +1,9 @@
1
- import * as webpack$1 from "webpack";
2
1
  import { Chunk, ChunkGraph } from "webpack";
2
+ import * as node_modules_webpack_types0 from "node_modules/webpack/types";
3
3
  import { CodeGenerationContext, CodeGenerationResult, Compilation as Compilation$1, InputFileSystem, LibIdentOptions, NeedBuildContext, ObjectDeserializerContext, ObjectSerializerContext, RequestShortener, ResolverWithOptions, WebpackError, WebpackOptions } from "webpack/lib/Module";
4
4
 
5
5
  //#region src/lib/container/FallbackModule.d.ts
6
- declare const Module$1: typeof webpack$1.Module;
6
+ declare const Module$1: typeof node_modules_webpack_types0.Module;
7
7
  declare class FallbackModule extends Module$1 {
8
8
  requests: string[];
9
9
  private _identifier;
@@ -30,6 +30,9 @@ const validate = require_utils.createSchemaValidation((require_schemas_container
30
30
  name: "Module Federation Plugin",
31
31
  baseDataPath: "options"
32
32
  });
33
+ function hasExposes(exposes) {
34
+ return Boolean(exposes && (Array.isArray(exposes) ? exposes.length > 0 : Object.keys(exposes).length > 0));
35
+ }
33
36
  function getEnhancedPackageVersion() {
34
37
  let currentDir = __dirname;
35
38
  while (true) {
@@ -53,11 +56,19 @@ var ModuleFederationPlugin = class {
53
56
  this._options = options;
54
57
  }
55
58
  _patchBundlerConfig(compiler) {
56
- const { name, experiments } = this._options;
59
+ const { name, experiments, exposes } = this._options;
57
60
  const definePluginOptions = {};
58
61
  const MFPluginNum = compiler.options.plugins.filter((p) => !!p && p.name === "ModuleFederationPlugin").length;
59
62
  if (name && MFPluginNum < 2) definePluginOptions["FEDERATION_BUILD_IDENTIFIER"] = JSON.stringify((0, _module_federation_sdk.composeKeyWithSeparator)(name, _module_federation_managers.utils.getBuildVersion()));
60
63
  definePluginOptions["FEDERATION_OPTIMIZE_NO_SNAPSHOT_PLUGIN"] = experiments?.optimization?.disableSnapshot ?? false;
64
+ definePluginOptions["FEDERATION_OPTIMIZE_NO_REMOTE"] = experiments?.optimization?.disableRemote ?? false;
65
+ definePluginOptions["FEDERATION_OPTIMIZE_NO_SHARED"] = experiments?.optimization?.disableShared ?? false;
66
+ definePluginOptions["FEDERATION_HAS_EXPOSES"] = hasExposes(exposes) || compiler.options.plugins.some((plugin) => {
67
+ if (!plugin || typeof plugin !== "object") return false;
68
+ const namedPlugin = plugin;
69
+ if (namedPlugin.name !== "ModuleFederationPlugin") return false;
70
+ return hasExposes(namedPlugin._options?.exposes);
71
+ });
61
72
  if (experiments?.optimization && typeof experiments.optimization === "object" && experiments.optimization !== null && "target" in experiments.optimization) {
62
73
  const manualTarget = experiments.optimization.target;
63
74
  if (manualTarget === "web" || manualTarget === "node") definePluginOptions["ENV_TARGET"] = JSON.stringify(manualTarget);
@@ -75,7 +86,7 @@ var ModuleFederationPlugin = class {
75
86
  const { name, experiments, dts, remotes, shared, shareScope } = options;
76
87
  if (!name) throw new Error("ModuleFederationPlugin name is required");
77
88
  new _module_federation_rspack_remote_entry_plugin.RemoteEntryPlugin(options).apply(compiler);
78
- const useContainerPlugin = options.exposes && (Array.isArray(options.exposes) ? options.exposes.length > 0 : Object.keys(options.exposes).length > 0);
89
+ const useContainerPlugin = hasExposes(options.exposes);
79
90
  if (experiments?.provideExternalRuntime) {
80
91
  if (useContainerPlugin) throw new Error("You can only set provideExternalRuntime: true in pure consumer which not expose modules.");
81
92
  options.runtimePlugins = (options.runtimePlugins || []).concat(require.resolve("@module-federation/inject-external-runtime-core-plugin"));
@@ -1 +1 @@
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,CAAC,CACvD;AAIH,sBAAoB,4CADI,a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C3C,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 hasExposes(\n exposes: moduleFederationPlugin.ModuleFederationPluginOptions['exposes'],\n): boolean {\n return Boolean(\n exposes &&\n (Array.isArray(exposes)\n ? exposes.length > 0\n : Object.keys(exposes).length > 0),\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, exposes } = 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 definePluginOptions['FEDERATION_OPTIMIZE_NO_REMOTE'] =\n experiments?.optimization?.disableRemote ?? false;\n definePluginOptions['FEDERATION_OPTIMIZE_NO_SHARED'] =\n experiments?.optimization?.disableShared ?? false;\n definePluginOptions['FEDERATION_HAS_EXPOSES'] =\n hasExposes(exposes) ||\n compiler.options.plugins.some((plugin) => {\n if (!plugin || typeof plugin !== 'object') {\n return false;\n }\n\n const namedPlugin = plugin as WebpackPluginInstance & {\n name?: string;\n _options?: moduleFederationPlugin.ModuleFederationPluginOptions;\n };\n if (namedPlugin.name !== 'ModuleFederationPlugin') {\n return false;\n }\n\n return hasExposes(namedPlugin._options?.exposes);\n });\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 = hasExposes(options.exposes);\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,WACP,SACS;AACT,QAAO,QACL,YACC,MAAM,QAAQ,QAAQ,GACnB,QAAQ,SAAS,IACjB,OAAO,KAAK,QAAQ,CAAC,SAAS,GACnC;;AAGH,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,OA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ACF,KAAIC,8CAAgB;IAClB;IACA;IACA,UAAU,QAAQ;IAClB,SAAS,QAAQ;IACjB,YAAY,QAAQ;IACpB,SAAS,QAAQ;IACjB,gBAAgB,QAAQ;IACzB,CAAC,CAAC,MAAM,SAAS;AAEpB,OACE,YACC,MAAM,QAAQ,QAAQ,GACnB,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,5 +1,5 @@
1
- import * as webpack$1 from "webpack";
2
1
  import { Compilation, WebpackOptionsNormalized } from "webpack";
2
+ import * as node_modules_webpack_types0 from "node_modules/webpack/types";
3
3
  import { CodeGenerationContext, CodeGenerationResult, LibIdentOptions, NeedBuildContext, WebpackError } from "webpack/lib/Module";
4
4
  import { ResolverWithOptions as ResolverWithOptions$1 } from "webpack/lib/ResolverFactory";
5
5
  import { InputFileSystem as InputFileSystem$1 } from "webpack/lib/FileSystemInfo";
@@ -7,7 +7,7 @@ import { RequestShortener as RequestShortener$1 } from "webpack/lib/RuntimeModul
7
7
  import { ObjectDeserializerContext as ObjectDeserializerContext$1 } from "webpack/lib/serialization/ObjectMiddleware";
8
8
 
9
9
  //#region src/lib/container/RemoteModule.d.ts
10
- declare const Module$1: typeof webpack$1.Module;
10
+ declare const Module$1: typeof node_modules_webpack_types0.Module;
11
11
  declare class RemoteModule extends Module$1 {
12
12
  private _identifier;
13
13
  request: string;
@@ -1,7 +1,7 @@
1
- import * as webpack$1 from "webpack";
1
+ import * as node_modules_webpack_types0 from "node_modules/webpack/types";
2
2
 
3
3
  //#region src/lib/container/RemoteRuntimeModule.d.ts
4
- declare const RuntimeModule: typeof webpack$1.RuntimeModule;
4
+ declare const RuntimeModule: typeof node_modules_webpack_types0.RuntimeModule;
5
5
  declare class RemoteRuntimeModule extends RuntimeModule {
6
6
  constructor();
7
7
  /**
@@ -1,7 +1,7 @@
1
- import * as webpack$1 from "webpack";
1
+ import * as node_modules_webpack_types0 from "node_modules/webpack/types";
2
2
 
3
3
  //#region src/lib/container/RemoteToExternalDependency.d.ts
4
- declare const dependencies: typeof webpack$1.dependencies;
4
+ declare const dependencies: typeof node_modules_webpack_types0.dependencies;
5
5
  declare class RemoteToExternalDependency extends dependencies.ModuleDependency {
6
6
  /**
7
7
  * @param {string} request request
@@ -1,5 +1,6 @@
1
- //#region src/lib/container/options.d.ts
2
- type ContainerOptionsFormat<T> = (string | Record<string, string | string[] | T>)[] | Record<string, string | string[] | T>;
1
+ export type ContainerOptionsFormat<T> =
2
+ | (string | Record<string, string | string[] | T>)[]
3
+ | Record<string, string | string[] | T>;
3
4
  /**
4
5
  * @template T
5
6
  * @template R
@@ -8,14 +9,18 @@ type ContainerOptionsFormat<T> = (string | Record<string, string | string[] | T>
8
9
  * @param {function(T, string) : R} normalizeOptions normalize a complex item
9
10
  * @returns {[string, R][]} parsed options
10
11
  */
11
- declare function parseOptions<T, R>(options: ContainerOptionsFormat<T>, normalizeSimple: (item: string | string[], name: string) => R, normalizeOptions: (item: T, name: string) => R): [string, R][];
12
+ export declare function parseOptions<T, R>(
13
+ options: ContainerOptionsFormat<T>,
14
+ normalizeSimple: (item: string | string[], name: string) => R,
15
+ normalizeOptions: (item: T, name: string) => R,
16
+ ): [string, R][];
12
17
  /**
13
18
  * @template T
14
19
  * @param {string} scope scope name
15
20
  * @param {ContainerOptionsFormat<T>} options options passed by the user
16
21
  * @returns {Record<string, string | string[] | T>} options to spread or pass
17
22
  */
18
- declare function scope<T>(scope: string, options: ContainerOptionsFormat<T>): Record<string, string | string[] | T>;
19
- //#endregion
20
- export { ContainerOptionsFormat, parseOptions, scope };
21
- //# sourceMappingURL=options.d.ts.map
23
+ export declare function scope<T>(
24
+ scope: string,
25
+ options: ContainerOptionsFormat<T>,
26
+ ): Record<string, string | string[] | T>;
@@ -1,9 +1,9 @@
1
1
  import ContainerEntryDependency from "../ContainerEntryDependency.js";
2
2
  import FederationRuntimeDependency from "./FederationRuntimeDependency.js";
3
- import * as webpack$1 from "webpack";
3
+ import * as node_modules_webpack_types0 from "node_modules/webpack/types";
4
4
 
5
5
  //#region src/lib/container/runtime/EmbedFederationRuntimeModule.d.ts
6
- declare const RuntimeModule: typeof webpack$1.RuntimeModule;
6
+ declare const RuntimeModule: typeof node_modules_webpack_types0.RuntimeModule;
7
7
  declare class EmbedFederationRuntimeModule extends RuntimeModule {
8
8
  private containerEntrySet;
9
9
  _cachedGeneratedCode: string | undefined;
@@ -1,8 +1,8 @@
1
1
  import { NormalizedRuntimeInitOptionsWithOutShared } from "./utils.js";
2
- import * as webpack$1 from "webpack";
2
+ import * as node_modules_webpack_types0 from "node_modules/webpack/types";
3
3
 
4
4
  //#region src/lib/container/runtime/FederationRuntimeModule.d.ts
5
- declare const RuntimeModule: typeof webpack$1.RuntimeModule;
5
+ declare const RuntimeModule: typeof node_modules_webpack_types0.RuntimeModule;
6
6
  declare class FederationRuntimeModule extends RuntimeModule {
7
7
  runtimeRequirements: ReadonlySet<string>;
8
8
  containerName: string;
@@ -1,5 +1,6 @@
1
1
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
2
2
  const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
3
+ const require_lib_container_runtime_normalizeToPosixPath = require('./normalizeToPosixPath.js');
3
4
  const require_lib_container_runtime_utils = require('./utils.js');
4
5
  const require_lib_container_runtime_FederationRuntimeModule = require('./FederationRuntimeModule.js');
5
6
  const require_lib_container_constant = require('../constant.js');
@@ -74,14 +75,14 @@ var FederationRuntimePlugin = class FederationRuntimePlugin {
74
75
  }
75
76
  static getTemplate(compiler, options, bundlerRuntimePath) {
76
77
  const runtimePlugins = options.runtimePlugins;
77
- const normalizedBundlerRuntimePath = require_lib_container_runtime_utils.normalizeToPosixPath(bundlerRuntimePath || BundlerRuntimePath);
78
+ const normalizedBundlerRuntimePath = require_lib_container_runtime_normalizeToPosixPath.normalizeToPosixPath(bundlerRuntimePath || BundlerRuntimePath);
78
79
  let runtimePluginTemplates = "";
79
80
  const runtimePluginCalls = [];
80
81
  if (Array.isArray(runtimePlugins)) runtimePlugins.forEach((runtimePlugin, index) => {
81
82
  if (!runtimePlugin) return;
82
83
  const runtimePluginName = `plugin_${index}`;
83
84
  const runtimePluginEntry = Array.isArray(runtimePlugin) ? runtimePlugin[0] : runtimePlugin;
84
- const runtimePluginPath = require_lib_container_runtime_utils.normalizeToPosixPath(path.default.isAbsolute(runtimePluginEntry) ? runtimePluginEntry : path.default.join(process.cwd(), runtimePluginEntry));
85
+ const runtimePluginPath = require_lib_container_runtime_normalizeToPosixPath.normalizeToPosixPath(path.default.isAbsolute(runtimePluginEntry) ? runtimePluginEntry : path.default.join(process.cwd(), runtimePluginEntry));
85
86
  const paramsStr = Array.isArray(runtimePlugin) && runtimePlugin.length > 1 ? JSON.stringify(runtimePlugin[1]) : "undefined";
86
87
  runtimePluginTemplates += `import ${runtimePluginName} from '${runtimePluginPath}';\n`;
87
88
  runtimePluginCalls.push(`${runtimePluginName} ? (${runtimePluginName}.default || ${runtimePluginName})(${paramsStr}) : false`);