@module-federation/nextjs-mf 8.8.70 → 8.8.72

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 (81) hide show
  1. package/dist/client/UrlNode.d.mts +17 -0
  2. package/dist/client/UrlNode.d.ts +17 -0
  3. package/dist/node.d.mts +1 -0
  4. package/dist/node.d.ts +1 -0
  5. package/dist/src/federation-noop.d.mts +0 -1
  6. package/dist/src/federation-noop.d.ts +0 -1
  7. package/dist/src/index.d.mts +3 -2
  8. package/dist/src/index.d.ts +3 -2
  9. package/dist/src/internal.d.mts +50 -0
  10. package/dist/src/internal.d.ts +50 -0
  11. package/dist/src/loaders/fixImageLoader.d.mts +3 -8
  12. package/dist/src/loaders/fixImageLoader.d.ts +3 -8
  13. package/dist/src/loaders/fixUrlLoader.d.mts +2 -5
  14. package/dist/src/loaders/fixUrlLoader.d.ts +2 -5
  15. package/dist/src/loaders/helpers.d.mts +17 -0
  16. package/dist/src/loaders/helpers.d.ts +17 -0
  17. package/dist/src/loaders/nextPageMapLoader.d.mts +5 -10
  18. package/dist/src/loaders/nextPageMapLoader.d.ts +5 -10
  19. package/dist/src/logger.d.mts +2 -0
  20. package/dist/src/logger.d.ts +2 -0
  21. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.d.mts +5 -0
  22. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.d.ts +5 -0
  23. package/dist/src/plugins/CopyFederationPlugin.d.mts +20 -0
  24. package/dist/src/plugins/CopyFederationPlugin.d.ts +20 -0
  25. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.d.mts +22 -0
  26. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.d.ts +22 -0
  27. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.js +43 -0
  28. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.js.map +1 -0
  29. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.mjs +42 -0
  30. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.mjs.map +1 -0
  31. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.d.mts +23 -0
  32. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.d.ts +23 -0
  33. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js +7 -1
  34. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js.map +1 -1
  35. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.mjs +7 -1
  36. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.mjs.map +1 -1
  37. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.d.mts +36 -0
  38. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.d.ts +36 -0
  39. package/dist/src/plugins/NextFederationPlugin/index.d.mts +23 -27
  40. package/dist/src/plugins/NextFederationPlugin/index.d.ts +23 -27
  41. package/dist/src/plugins/NextFederationPlugin/index.js +2 -4
  42. package/dist/src/plugins/NextFederationPlugin/index.js.map +1 -1
  43. package/dist/src/plugins/NextFederationPlugin/index.mjs +2 -4
  44. package/dist/src/plugins/NextFederationPlugin/index.mjs.map +1 -1
  45. package/dist/src/plugins/NextFederationPlugin/manifest-options.d.mts +4 -0
  46. package/dist/src/plugins/NextFederationPlugin/manifest-options.d.ts +4 -0
  47. package/dist/src/plugins/NextFederationPlugin/manifest-options.js +13 -0
  48. package/dist/src/plugins/NextFederationPlugin/manifest-options.js.map +1 -0
  49. package/dist/src/plugins/NextFederationPlugin/manifest-options.mjs +12 -0
  50. package/dist/src/plugins/NextFederationPlugin/manifest-options.mjs.map +1 -0
  51. package/dist/src/plugins/NextFederationPlugin/next-fragments.d.mts +18 -16
  52. package/dist/src/plugins/NextFederationPlugin/next-fragments.d.ts +18 -16
  53. package/dist/src/plugins/NextFederationPlugin/regex-equal.d.mts +14 -0
  54. package/dist/src/plugins/NextFederationPlugin/regex-equal.d.ts +14 -0
  55. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.d.mts +8 -0
  56. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.d.ts +8 -0
  57. package/dist/src/plugins/NextFederationPlugin/set-options.d.mts +6 -0
  58. package/dist/src/plugins/NextFederationPlugin/set-options.d.ts +6 -0
  59. package/dist/src/plugins/NextFederationPlugin/set-options.js.map +1 -1
  60. package/dist/src/plugins/NextFederationPlugin/set-options.mjs.map +1 -1
  61. package/dist/src/plugins/NextFederationPlugin/validate-options.d.mts +25 -0
  62. package/dist/src/plugins/NextFederationPlugin/validate-options.d.ts +25 -0
  63. package/dist/src/plugins/container/InvertedContainerPlugin.d.mts +5 -0
  64. package/dist/src/plugins/container/InvertedContainerPlugin.d.ts +5 -0
  65. package/dist/src/plugins/container/InvertedContainerRuntimeModule.d.mts +11 -0
  66. package/dist/src/plugins/container/InvertedContainerRuntimeModule.d.ts +11 -0
  67. package/dist/src/plugins/container/InvertedContainerRuntimeModule.js.map +1 -1
  68. package/dist/src/plugins/container/InvertedContainerRuntimeModule.mjs.map +1 -1
  69. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.d.mts +39 -0
  70. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.d.ts +39 -0
  71. package/dist/src/plugins/container/runtimePlugin.d.mts +2 -7
  72. package/dist/src/plugins/container/runtimePlugin.d.ts +2 -6
  73. package/dist/src/plugins/container/types.d.mts +2 -0
  74. package/dist/src/plugins/container/types.d.ts +2 -0
  75. package/dist/src/types.d.mts +28 -0
  76. package/dist/src/types.d.ts +28 -0
  77. package/dist/utils/flushedChunks.d.mts +5 -12
  78. package/dist/utils/flushedChunks.d.ts +5 -12
  79. package/dist/utils/index.d.mts +14 -8
  80. package/dist/utils/index.d.ts +14 -8
  81. package/package.json +9 -9
@@ -0,0 +1,17 @@
1
+ /**
2
+ * This class provides a logic of sorting dynamic routes in NextJS.
3
+ *
4
+ * It was copied from
5
+ * @see https://github.com/vercel/next.js/blob/canary/packages/next/shared/lib/router/utils/sorted-routes.ts
6
+ */
7
+ export declare class UrlNode {
8
+ placeholder: boolean;
9
+ children: Map<string, UrlNode>;
10
+ slugName: string | null;
11
+ restSlugName: string | null;
12
+ optionalRestSlugName: string | null;
13
+ insert(urlPath: string): void;
14
+ smoosh(): string[];
15
+ private _smoosh;
16
+ private _insert;
17
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * This class provides a logic of sorting dynamic routes in NextJS.
3
+ *
4
+ * It was copied from
5
+ * @see https://github.com/vercel/next.js/blob/canary/packages/next/shared/lib/router/utils/sorted-routes.ts
6
+ */
7
+ export declare class UrlNode {
8
+ placeholder: boolean;
9
+ children: Map<string, UrlNode>;
10
+ slugName: string | null;
11
+ restSlugName: string | null;
12
+ optionalRestSlugName: string | null;
13
+ insert(urlPath: string): void;
14
+ smoosh(): string[];
15
+ private _smoosh;
16
+ private _insert;
17
+ }
@@ -0,0 +1 @@
1
+ export * from '@module-federation/node';
package/dist/node.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '@module-federation/node';
@@ -1 +0,0 @@
1
- export { };
@@ -1 +0,0 @@
1
- export { };
@@ -1,2 +1,3 @@
1
- import { NextFederationPlugin } from "./plugins/NextFederationPlugin/index.mjs";
2
- export { NextFederationPlugin, NextFederationPlugin as default };
1
+ import NextFederationPlugin from './plugins/NextFederationPlugin';
2
+ export { NextFederationPlugin };
3
+ export default NextFederationPlugin;
@@ -1,2 +1,3 @@
1
- import { NextFederationPlugin } from "./plugins/NextFederationPlugin/index.js";
2
- export { NextFederationPlugin, NextFederationPlugin as default };
1
+ import NextFederationPlugin from './plugins/NextFederationPlugin';
2
+ export { NextFederationPlugin };
3
+ export default NextFederationPlugin;
@@ -0,0 +1,50 @@
1
+ import type { moduleFederationPlugin } from '@module-federation/sdk';
2
+ /**
3
+ * @typedef SharedObject
4
+ * @type {object}
5
+ * @property {object} [key] - The key representing the shared object's package name.
6
+ * @property {boolean} key.singleton - Whether the shared object should be a singleton.
7
+ * @property {boolean} key.requiredVersion - Whether a specific version of the shared object is required.
8
+ * @property {boolean} key.eager - Whether the shared object should be eagerly loaded.
9
+ * @property {boolean} key.import - Whether the shared object should be imported or not.
10
+ * @property {string} key.layer - The webpack layer this shared module belongs to.
11
+ * @property {string|string[]} key.issuerLayer - The webpack layer that can import this shared module.
12
+ */
13
+ export declare const DEFAULT_SHARE_SCOPE: moduleFederationPlugin.SharedObject;
14
+ /**
15
+ * Defines a default share scope for the browser environment.
16
+ * This function takes the DEFAULT_SHARE_SCOPE and sets eager to undefined and import to undefined for all entries.
17
+ * For 'react', 'react-dom', 'next/router', and 'next/link', it sets eager to true.
18
+ * The module hoisting system relocates these modules into the right runtime and out of the remote.
19
+ *
20
+ * @type {SharedObject}
21
+ * @returns {SharedObject} - The modified share scope for the browser environment.
22
+ */
23
+ export declare const DEFAULT_SHARE_SCOPE_BROWSER: moduleFederationPlugin.SharedObject;
24
+ /**
25
+ * Parses the remotes object and checks if they are using a custom promise template or not.
26
+ * If it's a custom promise template, the remote syntax is parsed to get the module name and version number.
27
+ * If the remote value is using the standard remote syntax, a delegated module is created.
28
+ *
29
+ * @param {Record<string, any>} remotes - The remotes object to be parsed.
30
+ * @returns {Record<string, string>} - The parsed remotes object with either the original value,
31
+ * the value for internal or promise delegate module reference, or the created delegated module.
32
+ */
33
+ export declare const parseRemotes: (remotes: Record<string, any>) => Record<string, string>;
34
+ /**
35
+ * Extracts the delegate modules from the provided remotes object.
36
+ * This function iterates over the remotes object and checks if each remote value is an internal delegate module reference.
37
+ * If it is, the function adds it to the returned object.
38
+ *
39
+ * @param {Record<string, any>} remotes - The remotes object containing delegate module references.
40
+ * @returns {Record<string, string>} - An object containing only the delegate modules from the remotes object.
41
+ */
42
+ export declare const getDelegates: (remotes: Record<string, any>) => Record<string, string>;
43
+ /**
44
+ * Transforms an array of Error objects into a single string. Each error message is formatted using the 'formatError' function.
45
+ * The resulting error messages are then joined together, separated by newline characters.
46
+ *
47
+ * @param {Error[]} err - An array of Error objects that need to be formatted and combined.
48
+ * @returns {string} - A single string containing all the formatted error messages, separated by newline characters.
49
+ */
50
+ export declare const toDisplayErrors: (err: Error[]) => string;
@@ -0,0 +1,50 @@
1
+ import type { moduleFederationPlugin } from '@module-federation/sdk';
2
+ /**
3
+ * @typedef SharedObject
4
+ * @type {object}
5
+ * @property {object} [key] - The key representing the shared object's package name.
6
+ * @property {boolean} key.singleton - Whether the shared object should be a singleton.
7
+ * @property {boolean} key.requiredVersion - Whether a specific version of the shared object is required.
8
+ * @property {boolean} key.eager - Whether the shared object should be eagerly loaded.
9
+ * @property {boolean} key.import - Whether the shared object should be imported or not.
10
+ * @property {string} key.layer - The webpack layer this shared module belongs to.
11
+ * @property {string|string[]} key.issuerLayer - The webpack layer that can import this shared module.
12
+ */
13
+ export declare const DEFAULT_SHARE_SCOPE: moduleFederationPlugin.SharedObject;
14
+ /**
15
+ * Defines a default share scope for the browser environment.
16
+ * This function takes the DEFAULT_SHARE_SCOPE and sets eager to undefined and import to undefined for all entries.
17
+ * For 'react', 'react-dom', 'next/router', and 'next/link', it sets eager to true.
18
+ * The module hoisting system relocates these modules into the right runtime and out of the remote.
19
+ *
20
+ * @type {SharedObject}
21
+ * @returns {SharedObject} - The modified share scope for the browser environment.
22
+ */
23
+ export declare const DEFAULT_SHARE_SCOPE_BROWSER: moduleFederationPlugin.SharedObject;
24
+ /**
25
+ * Parses the remotes object and checks if they are using a custom promise template or not.
26
+ * If it's a custom promise template, the remote syntax is parsed to get the module name and version number.
27
+ * If the remote value is using the standard remote syntax, a delegated module is created.
28
+ *
29
+ * @param {Record<string, any>} remotes - The remotes object to be parsed.
30
+ * @returns {Record<string, string>} - The parsed remotes object with either the original value,
31
+ * the value for internal or promise delegate module reference, or the created delegated module.
32
+ */
33
+ export declare const parseRemotes: (remotes: Record<string, any>) => Record<string, string>;
34
+ /**
35
+ * Extracts the delegate modules from the provided remotes object.
36
+ * This function iterates over the remotes object and checks if each remote value is an internal delegate module reference.
37
+ * If it is, the function adds it to the returned object.
38
+ *
39
+ * @param {Record<string, any>} remotes - The remotes object containing delegate module references.
40
+ * @returns {Record<string, string>} - An object containing only the delegate modules from the remotes object.
41
+ */
42
+ export declare const getDelegates: (remotes: Record<string, any>) => Record<string, string>;
43
+ /**
44
+ * Transforms an array of Error objects into a single string. Each error message is formatted using the 'formatError' function.
45
+ * The resulting error messages are then joined together, separated by newline characters.
46
+ *
47
+ * @param {Error[]} err - An array of Error objects that need to be formatted and combined.
48
+ * @returns {string} - A single string containing all the formatted error messages, separated by newline characters.
49
+ */
50
+ export declare const toDisplayErrors: (err: Error[]) => string;
@@ -1,6 +1,4 @@
1
- import { LoaderContext } from "webpack";
2
-
3
- //#region src/loaders/fixImageLoader.d.ts
1
+ import type { LoaderContext } from 'webpack';
4
2
  /**
5
3
  * This loader is specifically created for tuning the next-image-loader result.
6
4
  * It modifies the regular string output of the next-image-loader.
@@ -17,11 +15,8 @@ import { LoaderContext } from "webpack";
17
15
  * @param {string} remaining - The remaining part of the resource path.
18
16
  * @returns {string} The modified source code with the injected code.
19
17
  */
20
- declare function fixImageLoader(this: LoaderContext<Record<string, unknown>>, remaining: string): Promise<string>;
18
+ export declare function fixImageLoader(this: LoaderContext<Record<string, unknown>>, remaining: string): Promise<string>;
21
19
  /**
22
20
  * The pitch function of the loader, which is the same as the fixImageLoader function.
23
21
  */
24
- declare const pitch: typeof fixImageLoader;
25
- //#endregion
26
- export { fixImageLoader, pitch };
27
- //# sourceMappingURL=fixImageLoader.d.mts.map
22
+ export declare const pitch: typeof fixImageLoader;
@@ -1,6 +1,4 @@
1
- import { LoaderContext } from "webpack";
2
-
3
- //#region src/loaders/fixImageLoader.d.ts
1
+ import type { LoaderContext } from 'webpack';
4
2
  /**
5
3
  * This loader is specifically created for tuning the next-image-loader result.
6
4
  * It modifies the regular string output of the next-image-loader.
@@ -17,11 +15,8 @@ import { LoaderContext } from "webpack";
17
15
  * @param {string} remaining - The remaining part of the resource path.
18
16
  * @returns {string} The modified source code with the injected code.
19
17
  */
20
- declare function fixImageLoader(this: LoaderContext<Record<string, unknown>>, remaining: string): Promise<string>;
18
+ export declare function fixImageLoader(this: LoaderContext<Record<string, unknown>>, remaining: string): Promise<string>;
21
19
  /**
22
20
  * The pitch function of the loader, which is the same as the fixImageLoader function.
23
21
  */
24
- declare const pitch: typeof fixImageLoader;
25
- //#endregion
26
- export { fixImageLoader, pitch };
27
- //# sourceMappingURL=fixImageLoader.d.ts.map
22
+ export declare const pitch: typeof fixImageLoader;
@@ -1,4 +1,3 @@
1
- //#region src/loaders/fixUrlLoader.d.ts
2
1
  /**
3
2
  * `fixUrlLoader` is a custom loader designed to modify the output of the url-loader.
4
3
  * It injects the PUBLIC_PATH from the webpack runtime into the output.
@@ -10,7 +9,5 @@
10
9
  * @param {string} content - The original output from the url-loader.
11
10
  * @returns {string} The modified output with the injected PUBLIC_PATH.
12
11
  */
13
- declare function fixUrlLoader(content: string): string;
14
- //#endregion
15
- export { fixUrlLoader as default, fixUrlLoader };
16
- //# sourceMappingURL=fixUrlLoader.d.mts.map
12
+ export declare function fixUrlLoader(content: string): string;
13
+ export default fixUrlLoader;
@@ -1,4 +1,3 @@
1
- //#region src/loaders/fixUrlLoader.d.ts
2
1
  /**
3
2
  * `fixUrlLoader` is a custom loader designed to modify the output of the url-loader.
4
3
  * It injects the PUBLIC_PATH from the webpack runtime into the output.
@@ -10,7 +9,5 @@
10
9
  * @param {string} content - The original output from the url-loader.
11
10
  * @returns {string} The modified output with the injected PUBLIC_PATH.
12
11
  */
13
- declare function fixUrlLoader(content: string): string;
14
- //#endregion
15
- export { fixUrlLoader as default, fixUrlLoader };
16
- //# sourceMappingURL=fixUrlLoader.d.ts.map
12
+ export declare function fixUrlLoader(content: string): string;
13
+ export default fixUrlLoader;
@@ -0,0 +1,17 @@
1
+ import type { RuleSetRule, RuleSetUseItem } from 'webpack';
2
+ export declare function injectRuleLoader(rule: any, loader?: RuleSetUseItem): void;
3
+ /**
4
+ * This function checks if the current module rule has a loader with the provided name.
5
+ *
6
+ * @param {RuleSetRule} rule - The current module rule.
7
+ * @param {string} loaderName - The name of the loader to check.
8
+ * @returns {boolean} Returns true if the current module rule has a loader with the provided name, otherwise false.
9
+ */
10
+ export declare function hasLoader(rule: RuleSetRule, loaderName: string): boolean;
11
+ interface Resource {
12
+ path: string;
13
+ layer?: string;
14
+ issuerLayer?: string;
15
+ }
16
+ export declare function findLoaderForResource(rules: RuleSetRule[], resource: Resource, path?: string[]): RuleSetRule | null;
17
+ export {};
@@ -0,0 +1,17 @@
1
+ import type { RuleSetRule, RuleSetUseItem } from 'webpack';
2
+ export declare function injectRuleLoader(rule: any, loader?: RuleSetUseItem): void;
3
+ /**
4
+ * This function checks if the current module rule has a loader with the provided name.
5
+ *
6
+ * @param {RuleSetRule} rule - The current module rule.
7
+ * @param {string} loaderName - The name of the loader to check.
8
+ * @returns {boolean} Returns true if the current module rule has a loader with the provided name, otherwise false.
9
+ */
10
+ export declare function hasLoader(rule: RuleSetRule, loaderName: string): boolean;
11
+ interface Resource {
12
+ path: string;
13
+ layer?: string;
14
+ issuerLayer?: string;
15
+ }
16
+ export declare function findLoaderForResource(rules: RuleSetRule[], resource: Resource, path?: string[]): RuleSetRule | null;
17
+ export {};
@@ -1,6 +1,4 @@
1
- import { LoaderContext } from "webpack";
2
-
3
- //#region src/loaders/nextPageMapLoader.d.ts
1
+ import type { LoaderContext } from 'webpack';
4
2
  /**
5
3
  * Webpack loader which prepares MF map for NextJS pages.
6
4
  * This function is the main entry point for the loader.
@@ -11,7 +9,7 @@ import { LoaderContext } from "webpack";
11
9
  *
12
10
  * @param {LoaderContext<Record<string, unknown>>} this - The loader context.
13
11
  */
14
- declare function nextPageMapLoader(this: LoaderContext<Record<string, unknown>>): void;
12
+ export default function nextPageMapLoader(this: LoaderContext<Record<string, unknown>>): void;
15
13
  /**
16
14
  * Webpack config generator for `exposes` option.
17
15
  * This function generates the webpack config for the 'exposes' option.
@@ -20,10 +18,7 @@ declare function nextPageMapLoader(this: LoaderContext<Record<string, unknown>>)
20
18
  * @param {string} cwd - The current working directory.
21
19
  * @returns {Record<string, string>} The webpack config for the 'exposes' option.
22
20
  */
23
- declare function exposeNextjsPages(cwd: string): {
24
- './pages-map': string;
25
- './pages-map-v2': string;
21
+ export declare function exposeNextjsPages(cwd: string): {
22
+ './pages-map': string;
23
+ './pages-map-v2': string;
26
24
  };
27
- //#endregion
28
- export { nextPageMapLoader as default, exposeNextjsPages };
29
- //# sourceMappingURL=nextPageMapLoader.d.mts.map
@@ -1,6 +1,4 @@
1
- import { LoaderContext } from "webpack";
2
-
3
- //#region src/loaders/nextPageMapLoader.d.ts
1
+ import type { LoaderContext } from 'webpack';
4
2
  /**
5
3
  * Webpack loader which prepares MF map for NextJS pages.
6
4
  * This function is the main entry point for the loader.
@@ -11,7 +9,7 @@ import { LoaderContext } from "webpack";
11
9
  *
12
10
  * @param {LoaderContext<Record<string, unknown>>} this - The loader context.
13
11
  */
14
- declare function nextPageMapLoader(this: LoaderContext<Record<string, unknown>>): void;
12
+ export default function nextPageMapLoader(this: LoaderContext<Record<string, unknown>>): void;
15
13
  /**
16
14
  * Webpack config generator for `exposes` option.
17
15
  * This function generates the webpack config for the 'exposes' option.
@@ -20,10 +18,7 @@ declare function nextPageMapLoader(this: LoaderContext<Record<string, unknown>>)
20
18
  * @param {string} cwd - The current working directory.
21
19
  * @returns {Record<string, string>} The webpack config for the 'exposes' option.
22
20
  */
23
- declare function exposeNextjsPages(cwd: string): {
24
- './pages-map': string;
25
- './pages-map-v2': string;
21
+ export declare function exposeNextjsPages(cwd: string): {
22
+ './pages-map': string;
23
+ './pages-map-v2': string;
26
24
  };
27
- //#endregion
28
- export { nextPageMapLoader as default, exposeNextjsPages };
29
- //# sourceMappingURL=nextPageMapLoader.d.ts.map
@@ -0,0 +1,2 @@
1
+ declare const logger: import("@module-federation/sdk").Logger;
2
+ export default logger;
@@ -0,0 +1,2 @@
1
+ declare const logger: import("@module-federation/sdk").Logger;
2
+ export default logger;
@@ -0,0 +1,5 @@
1
+ import type { Compiler, WebpackPluginInstance } from 'webpack';
2
+ export declare class AddRuntimeRequirementToPromiseExternal implements WebpackPluginInstance {
3
+ apply(compiler: Compiler): void;
4
+ }
5
+ export default AddRuntimeRequirementToPromiseExternal;
@@ -0,0 +1,5 @@
1
+ import type { Compiler, WebpackPluginInstance } from 'webpack';
2
+ export declare class AddRuntimeRequirementToPromiseExternal implements WebpackPluginInstance {
3
+ apply(compiler: Compiler): void;
4
+ }
5
+ export default AddRuntimeRequirementToPromiseExternal;
@@ -0,0 +1,20 @@
1
+ import type { Compiler, WebpackPluginInstance } from 'webpack';
2
+ /**
3
+ * Plugin to copy build output files.
4
+ * @class
5
+ */
6
+ declare class CopyBuildOutputPlugin implements WebpackPluginInstance {
7
+ private isServer;
8
+ /**
9
+ * @param {boolean} isServer - Indicates if the current environment is server.
10
+ * @constructor
11
+ */
12
+ constructor(isServer: boolean);
13
+ /**
14
+ * Applies the plugin to the compiler.
15
+ * @param {Compiler} compiler - The webpack compiler object.
16
+ * @method
17
+ */
18
+ apply(compiler: Compiler): void;
19
+ }
20
+ export default CopyBuildOutputPlugin;
@@ -0,0 +1,20 @@
1
+ import type { Compiler, WebpackPluginInstance } from 'webpack';
2
+ /**
3
+ * Plugin to copy build output files.
4
+ * @class
5
+ */
6
+ declare class CopyBuildOutputPlugin implements WebpackPluginInstance {
7
+ private isServer;
8
+ /**
9
+ * @param {boolean} isServer - Indicates if the current environment is server.
10
+ * @constructor
11
+ */
12
+ constructor(isServer: boolean);
13
+ /**
14
+ * Applies the plugin to the compiler.
15
+ * @param {Compiler} compiler - The webpack compiler object.
16
+ * @method
17
+ */
18
+ apply(compiler: Compiler): void;
19
+ }
20
+ export default CopyBuildOutputPlugin;
@@ -0,0 +1,22 @@
1
+ import type { Compiler, WebpackPluginInstance } from 'webpack';
2
+ import { type Manifest, type moduleFederationPlugin } from '@module-federation/sdk';
3
+ type FederatedStatsCompatibilityPluginOptions = {
4
+ filenames: string[];
5
+ manifest: moduleFederationPlugin.ModuleFederationPluginOptions['manifest'];
6
+ };
7
+ export declare const createFederatedStats: (manifest: Manifest) => {
8
+ sharedModules: any[];
9
+ federatedModules: {
10
+ remote: string;
11
+ entry: string;
12
+ sharedModules: any[];
13
+ exposes: Record<string, string[]>;
14
+ remoteModules: {};
15
+ }[];
16
+ };
17
+ export declare class FederatedStatsCompatibilityPlugin implements WebpackPluginInstance {
18
+ private readonly options;
19
+ constructor(options: FederatedStatsCompatibilityPluginOptions);
20
+ apply(compiler: Compiler): void;
21
+ }
22
+ export {};
@@ -0,0 +1,22 @@
1
+ import type { Compiler, WebpackPluginInstance } from 'webpack';
2
+ import { type Manifest, type moduleFederationPlugin } from '@module-federation/sdk';
3
+ type FederatedStatsCompatibilityPluginOptions = {
4
+ filenames: string[];
5
+ manifest: moduleFederationPlugin.ModuleFederationPluginOptions['manifest'];
6
+ };
7
+ export declare const createFederatedStats: (manifest: Manifest) => {
8
+ sharedModules: any[];
9
+ federatedModules: {
10
+ remote: string;
11
+ entry: string;
12
+ sharedModules: any[];
13
+ exposes: Record<string, string[]>;
14
+ remoteModules: {};
15
+ }[];
16
+ };
17
+ export declare class FederatedStatsCompatibilityPlugin implements WebpackPluginInstance {
18
+ private readonly options;
19
+ constructor(options: FederatedStatsCompatibilityPluginOptions);
20
+ apply(compiler: Compiler): void;
21
+ }
22
+ export {};
@@ -0,0 +1,43 @@
1
+ const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
2
+ let _module_federation_sdk = require("@module-federation/sdk");
3
+
4
+ //#region src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.ts
5
+ const createFederatedStats = (manifest) => {
6
+ const exposes = {};
7
+ for (const expose of manifest.exposes) exposes[expose.path || `./${expose.name}`] = [...expose.assets.js.sync, ...expose.assets.css.sync];
8
+ return {
9
+ sharedModules: [],
10
+ federatedModules: [{
11
+ remote: manifest.name,
12
+ entry: (0, _module_federation_sdk.simpleJoinRemoteEntry)(manifest.metaData.remoteEntry.path, manifest.metaData.remoteEntry.name),
13
+ sharedModules: [],
14
+ exposes,
15
+ remoteModules: {}
16
+ }]
17
+ };
18
+ };
19
+ var FederatedStatsCompatibilityPlugin = class {
20
+ constructor(options) {
21
+ this.options = options;
22
+ }
23
+ apply(compiler) {
24
+ compiler.hooks.thisCompilation.tap("FederatedStatsCompatibilityPlugin", (compilation) => {
25
+ compilation.hooks.processAssets.tap({
26
+ name: "FederatedStatsCompatibilityPlugin",
27
+ stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT
28
+ }, () => {
29
+ const manifestFilename = (0, _module_federation_sdk.getManifestFileName)(this.options.manifest).manifestFileName;
30
+ const manifestAsset = compilation.getAsset(manifestFilename);
31
+ if (!manifestAsset) throw new Error(`Cannot emit federated-stats.json because ${manifestFilename} was not generated`);
32
+ const manifest = JSON.parse(manifestAsset.source.source().toString());
33
+ const source = new compiler.webpack.sources.RawSource(JSON.stringify(createFederatedStats(manifest)));
34
+ for (const filename of this.options.filenames) if (compilation.getAsset(filename)) compilation.updateAsset(filename, source);
35
+ else compilation.emitAsset(filename, source);
36
+ });
37
+ });
38
+ }
39
+ };
40
+
41
+ //#endregion
42
+ exports.FederatedStatsCompatibilityPlugin = FederatedStatsCompatibilityPlugin;
43
+ //# sourceMappingURL=FederatedStatsCompatibilityPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FederatedStatsCompatibilityPlugin.js","names":[],"sources":["../../../../src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.ts"],"sourcesContent":["import type { Compiler, WebpackPluginInstance } from 'webpack';\nimport {\n getManifestFileName,\n simpleJoinRemoteEntry,\n type Manifest,\n type moduleFederationPlugin,\n} from '@module-federation/sdk';\n\ntype FederatedStatsCompatibilityPluginOptions = {\n filenames: string[];\n manifest: moduleFederationPlugin.ModuleFederationPluginOptions['manifest'];\n};\n\nexport const createFederatedStats = (manifest: Manifest) => {\n const exposes: Record<string, string[]> = {};\n\n for (const expose of manifest.exposes) {\n exposes[expose.path || `./${expose.name}`] = [\n ...expose.assets.js.sync,\n ...expose.assets.css.sync,\n ];\n }\n\n return {\n sharedModules: [],\n federatedModules: [\n {\n remote: manifest.name,\n entry: simpleJoinRemoteEntry(\n manifest.metaData.remoteEntry.path,\n manifest.metaData.remoteEntry.name,\n ),\n sharedModules: [],\n exposes,\n remoteModules: {},\n },\n ],\n };\n};\n\nexport class FederatedStatsCompatibilityPlugin implements WebpackPluginInstance {\n private readonly options: FederatedStatsCompatibilityPluginOptions;\n\n constructor(options: FederatedStatsCompatibilityPluginOptions) {\n this.options = options;\n }\n\n apply(compiler: Compiler): void {\n compiler.hooks.thisCompilation.tap(\n 'FederatedStatsCompatibilityPlugin',\n (compilation) => {\n compilation.hooks.processAssets.tap(\n {\n name: 'FederatedStatsCompatibilityPlugin',\n stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT,\n },\n () => {\n const manifestFilename = getManifestFileName(\n this.options.manifest,\n ).manifestFileName;\n const manifestAsset = compilation.getAsset(manifestFilename);\n if (!manifestAsset) {\n throw new Error(\n `Cannot emit federated-stats.json because ${manifestFilename} was not generated`,\n );\n }\n\n const manifest = JSON.parse(\n manifestAsset.source.source().toString(),\n ) as Manifest;\n const source = new compiler.webpack.sources.RawSource(\n JSON.stringify(createFederatedStats(manifest)),\n );\n\n for (const filename of this.options.filenames) {\n if (compilation.getAsset(filename)) {\n compilation.updateAsset(filename, source);\n } else {\n compilation.emitAsset(filename, source);\n }\n }\n },\n );\n },\n );\n }\n}\n"],"mappings":";;;;AAaA,MAAa,wBAAwB,aAAuB;CAC1D,MAAM,UAAoC,EAAE;AAE5C,MAAK,MAAM,UAAU,SAAS,QAC5B,SAAQ,OAAO,QAAQ,KAAK,OAAO,UAAU,CAC3C,GAAG,OAAO,OAAO,GAAG,MACpB,GAAG,OAAO,OAAO,IAAI,KACtB;AAGH,QAAO;EACL,eAAe,EAAE;EACjB,kBAAkB,CAChB;GACE,QAAQ,SAAS;GACjB,yDACE,SAAS,SAAS,YAAY,MAC9B,SAAS,SAAS,YAAY,KAC/B;GACD,eAAe,EAAE;GACjB;GACA,eAAe,EAAE;GAClB,CACF;EACF;;AAGH,IAAa,oCAAb,MAAgF;CAG9E,YAAY,SAAmD;AAC7D,OAAK,UAAU;;CAGjB,MAAM,UAA0B;AAC9B,WAAS,MAAM,gBAAgB,IAC7B,sCACC,gBAAgB;AACf,eAAY,MAAM,cAAc,IAC9B;IACE,MAAM;IACN,OAAO,SAAS,QAAQ,YAAY;IACrC,QACK;IACJ,MAAM,mEACJ,KAAK,QAAQ,SACd,CAAC;IACF,MAAM,gBAAgB,YAAY,SAAS,iBAAiB;AAC5D,QAAI,CAAC,cACH,OAAM,IAAI,MACR,4CAA4C,iBAAiB,oBAC9D;IAGH,MAAM,WAAW,KAAK,MACpB,cAAc,OAAO,QAAQ,CAAC,UAAU,CACzC;IACD,MAAM,SAAS,IAAI,SAAS,QAAQ,QAAQ,UAC1C,KAAK,UAAU,qBAAqB,SAAS,CAAC,CAC/C;AAED,SAAK,MAAM,YAAY,KAAK,QAAQ,UAClC,KAAI,YAAY,SAAS,SAAS,CAChC,aAAY,YAAY,UAAU,OAAO;QAEzC,aAAY,UAAU,UAAU,OAAO;KAI9C;IAEJ"}
@@ -0,0 +1,42 @@
1
+ import { getManifestFileName, simpleJoinRemoteEntry } from "@module-federation/sdk";
2
+
3
+ //#region src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.ts
4
+ const createFederatedStats = (manifest) => {
5
+ const exposes = {};
6
+ for (const expose of manifest.exposes) exposes[expose.path || `./${expose.name}`] = [...expose.assets.js.sync, ...expose.assets.css.sync];
7
+ return {
8
+ sharedModules: [],
9
+ federatedModules: [{
10
+ remote: manifest.name,
11
+ entry: simpleJoinRemoteEntry(manifest.metaData.remoteEntry.path, manifest.metaData.remoteEntry.name),
12
+ sharedModules: [],
13
+ exposes,
14
+ remoteModules: {}
15
+ }]
16
+ };
17
+ };
18
+ var FederatedStatsCompatibilityPlugin = class {
19
+ constructor(options) {
20
+ this.options = options;
21
+ }
22
+ apply(compiler) {
23
+ compiler.hooks.thisCompilation.tap("FederatedStatsCompatibilityPlugin", (compilation) => {
24
+ compilation.hooks.processAssets.tap({
25
+ name: "FederatedStatsCompatibilityPlugin",
26
+ stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT
27
+ }, () => {
28
+ const manifestFilename = getManifestFileName(this.options.manifest).manifestFileName;
29
+ const manifestAsset = compilation.getAsset(manifestFilename);
30
+ if (!manifestAsset) throw new Error(`Cannot emit federated-stats.json because ${manifestFilename} was not generated`);
31
+ const manifest = JSON.parse(manifestAsset.source.source().toString());
32
+ const source = new compiler.webpack.sources.RawSource(JSON.stringify(createFederatedStats(manifest)));
33
+ for (const filename of this.options.filenames) if (compilation.getAsset(filename)) compilation.updateAsset(filename, source);
34
+ else compilation.emitAsset(filename, source);
35
+ });
36
+ });
37
+ }
38
+ };
39
+
40
+ //#endregion
41
+ export { FederatedStatsCompatibilityPlugin };
42
+ //# sourceMappingURL=FederatedStatsCompatibilityPlugin.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FederatedStatsCompatibilityPlugin.mjs","names":[],"sources":["../../../../src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.ts"],"sourcesContent":["import type { Compiler, WebpackPluginInstance } from 'webpack';\nimport {\n getManifestFileName,\n simpleJoinRemoteEntry,\n type Manifest,\n type moduleFederationPlugin,\n} from '@module-federation/sdk';\n\ntype FederatedStatsCompatibilityPluginOptions = {\n filenames: string[];\n manifest: moduleFederationPlugin.ModuleFederationPluginOptions['manifest'];\n};\n\nexport const createFederatedStats = (manifest: Manifest) => {\n const exposes: Record<string, string[]> = {};\n\n for (const expose of manifest.exposes) {\n exposes[expose.path || `./${expose.name}`] = [\n ...expose.assets.js.sync,\n ...expose.assets.css.sync,\n ];\n }\n\n return {\n sharedModules: [],\n federatedModules: [\n {\n remote: manifest.name,\n entry: simpleJoinRemoteEntry(\n manifest.metaData.remoteEntry.path,\n manifest.metaData.remoteEntry.name,\n ),\n sharedModules: [],\n exposes,\n remoteModules: {},\n },\n ],\n };\n};\n\nexport class FederatedStatsCompatibilityPlugin implements WebpackPluginInstance {\n private readonly options: FederatedStatsCompatibilityPluginOptions;\n\n constructor(options: FederatedStatsCompatibilityPluginOptions) {\n this.options = options;\n }\n\n apply(compiler: Compiler): void {\n compiler.hooks.thisCompilation.tap(\n 'FederatedStatsCompatibilityPlugin',\n (compilation) => {\n compilation.hooks.processAssets.tap(\n {\n name: 'FederatedStatsCompatibilityPlugin',\n stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT,\n },\n () => {\n const manifestFilename = getManifestFileName(\n this.options.manifest,\n ).manifestFileName;\n const manifestAsset = compilation.getAsset(manifestFilename);\n if (!manifestAsset) {\n throw new Error(\n `Cannot emit federated-stats.json because ${manifestFilename} was not generated`,\n );\n }\n\n const manifest = JSON.parse(\n manifestAsset.source.source().toString(),\n ) as Manifest;\n const source = new compiler.webpack.sources.RawSource(\n JSON.stringify(createFederatedStats(manifest)),\n );\n\n for (const filename of this.options.filenames) {\n if (compilation.getAsset(filename)) {\n compilation.updateAsset(filename, source);\n } else {\n compilation.emitAsset(filename, source);\n }\n }\n },\n );\n },\n );\n }\n}\n"],"mappings":";;;AAaA,MAAa,wBAAwB,aAAuB;CAC1D,MAAM,UAAoC,EAAE;AAE5C,MAAK,MAAM,UAAU,SAAS,QAC5B,SAAQ,OAAO,QAAQ,KAAK,OAAO,UAAU,CAC3C,GAAG,OAAO,OAAO,GAAG,MACpB,GAAG,OAAO,OAAO,IAAI,KACtB;AAGH,QAAO;EACL,eAAe,EAAE;EACjB,kBAAkB,CAChB;GACE,QAAQ,SAAS;GACjB,OAAO,sBACL,SAAS,SAAS,YAAY,MAC9B,SAAS,SAAS,YAAY,KAC/B;GACD,eAAe,EAAE;GACjB;GACA,eAAe,EAAE;GAClB,CACF;EACF;;AAGH,IAAa,oCAAb,MAAgF;CAG9E,YAAY,SAAmD;AAC7D,OAAK,UAAU;;CAGjB,MAAM,UAA0B;AAC9B,WAAS,MAAM,gBAAgB,IAC7B,sCACC,gBAAgB;AACf,eAAY,MAAM,cAAc,IAC9B;IACE,MAAM;IACN,OAAO,SAAS,QAAQ,YAAY;IACrC,QACK;IACJ,MAAM,mBAAmB,oBACvB,KAAK,QAAQ,SACd,CAAC;IACF,MAAM,gBAAgB,YAAY,SAAS,iBAAiB;AAC5D,QAAI,CAAC,cACH,OAAM,IAAI,MACR,4CAA4C,iBAAiB,oBAC9D;IAGH,MAAM,WAAW,KAAK,MACpB,cAAc,OAAO,QAAQ,CAAC,UAAU,CACzC;IACD,MAAM,SAAS,IAAI,SAAS,QAAQ,QAAQ,UAC1C,KAAK,UAAU,qBAAqB,SAAS,CAAC,CAC/C;AAED,SAAK,MAAM,YAAY,KAAK,QAAQ,UAClC,KAAI,YAAY,SAAS,SAAS,CAChC,aAAY,YAAY,UAAU,OAAO;QAEzC,aAAY,UAAU,UAAU,OAAO;KAI9C;IAEJ"}
@@ -0,0 +1,23 @@
1
+ import type { Compiler } from 'webpack';
2
+ import type { moduleFederationPlugin } from '@module-federation/sdk';
3
+ import type { NextFederationPluginExtraOptions } from './next-fragments';
4
+ /**
5
+ * Applies client-specific plugins.
6
+ *
7
+ * @param compiler - The Webpack compiler instance.
8
+ * @param options - The ModuleFederationPluginOptions instance.
9
+ * @param extraOptions - The NextFederationPluginExtraOptions instance.
10
+ *
11
+ * @remarks
12
+ * This function applies plugins to the Webpack compiler instance that are specific to the client build of
13
+ * a Next.js application with Module Federation enabled. These plugins include the following:
14
+ *
15
+ * - ChunkCorrelationPlugin: Collects metadata on chunks to enable proper module loading across different runtimes.
16
+ * - InvertedContainerPlugin: Adds custom runtime modules to the container runtime to allow a host to expose its
17
+ * own remote interface at startup.
18
+
19
+ * If automatic page stitching is enabled, a warning is logged indicating that it is disabled in v7.
20
+ * If a custom library is specified in the options, an error is logged. The options.library property is
21
+ * also set to `{ type: 'window', name: options.name }`.
22
+ */
23
+ export declare function applyClientPlugins(compiler: Compiler, options: moduleFederationPlugin.ModuleFederationPluginOptions, extraOptions: NextFederationPluginExtraOptions): void;
@@ -0,0 +1,23 @@
1
+ import type { Compiler } from 'webpack';
2
+ import type { moduleFederationPlugin } from '@module-federation/sdk';
3
+ import type { NextFederationPluginExtraOptions } from './next-fragments';
4
+ /**
5
+ * Applies client-specific plugins.
6
+ *
7
+ * @param compiler - The Webpack compiler instance.
8
+ * @param options - The ModuleFederationPluginOptions instance.
9
+ * @param extraOptions - The NextFederationPluginExtraOptions instance.
10
+ *
11
+ * @remarks
12
+ * This function applies plugins to the Webpack compiler instance that are specific to the client build of
13
+ * a Next.js application with Module Federation enabled. These plugins include the following:
14
+ *
15
+ * - ChunkCorrelationPlugin: Collects metadata on chunks to enable proper module loading across different runtimes.
16
+ * - InvertedContainerPlugin: Adds custom runtime modules to the container runtime to allow a host to expose its
17
+ * own remote interface at startup.
18
+
19
+ * If automatic page stitching is enabled, a warning is logged indicating that it is disabled in v7.
20
+ * If a custom library is specified in the options, an error is logged. The options.library property is
21
+ * also set to `{ type: 'window', name: options.name }`.
22
+ */
23
+ export declare function applyClientPlugins(compiler: Compiler, options: moduleFederationPlugin.ModuleFederationPluginOptions, extraOptions: NextFederationPluginExtraOptions): void;
@@ -1,9 +1,11 @@
1
1
  const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
2
2
  const require_logger = require('../../logger.js');
3
3
  const require_InvertedContainerPlugin = require('../container/InvertedContainerPlugin.js');
4
+ const require_FederatedStatsCompatibilityPlugin = require('./FederatedStatsCompatibilityPlugin.js');
4
5
  let _module_federation_node = require("@module-federation/node");
5
6
 
6
7
  //#region src/plugins/NextFederationPlugin/apply-client-plugins.ts
8
+ const FEDERATED_STATS_FILENAMES = ["static/chunks/federated-stats.json", "server/federated-stats.json"];
7
9
  /**
8
10
  * Applies client-specific plugins.
9
11
  *
@@ -32,7 +34,11 @@ function applyClientPlugins(compiler, options, extraOptions) {
32
34
  type: "window",
33
35
  name
34
36
  };
35
- new _module_federation_node.ChunkCorrelationPlugin({ filename: ["static/chunks/federated-stats.json", "server/federated-stats.json"] }).apply(compiler);
37
+ if (!(options.manifest !== false && (typeof options.manifest !== "object" || !options.manifest.disableAssetsAnalyze))) new _module_federation_node.ChunkCorrelationPlugin({ filename: FEDERATED_STATS_FILENAMES }).apply(compiler);
38
+ else new require_FederatedStatsCompatibilityPlugin.FederatedStatsCompatibilityPlugin({
39
+ filenames: FEDERATED_STATS_FILENAMES,
40
+ manifest: options.manifest
41
+ }).apply(compiler);
36
42
  new require_InvertedContainerPlugin.default().apply(compiler);
37
43
  }
38
44