@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
@@ -1 +1 @@
1
- {"version":3,"file":"apply-client-plugins.js","names":["ChunkCorrelationPlugin","InvertedContainerPlugin"],"sources":["../../../../src/plugins/NextFederationPlugin/apply-client-plugins.ts"],"sourcesContent":["import type { Compiler } from 'webpack';\nimport { ChunkCorrelationPlugin } from '@module-federation/node';\nimport InvertedContainerPlugin from '../container/InvertedContainerPlugin';\nimport type { moduleFederationPlugin } from '@module-federation/sdk';\nimport type { NextFederationPluginExtraOptions } from './next-fragments';\nimport logger from '../../logger';\n\n/**\n * Applies client-specific plugins.\n *\n * @param compiler - The Webpack compiler instance.\n * @param options - The ModuleFederationPluginOptions instance.\n * @param extraOptions - The NextFederationPluginExtraOptions instance.\n *\n * @remarks\n * This function applies plugins to the Webpack compiler instance that are specific to the client build of\n * a Next.js application with Module Federation enabled. These plugins include the following:\n *\n * - ChunkCorrelationPlugin: Collects metadata on chunks to enable proper module loading across different runtimes.\n * - InvertedContainerPlugin: Adds custom runtime modules to the container runtime to allow a host to expose its\n * own remote interface at startup.\n\n * If automatic page stitching is enabled, a warning is logged indicating that it is disabled in v7.\n * If a custom library is specified in the options, an error is logged. The options.library property is\n * also set to `{ type: 'window', name: options.name }`.\n */\nexport function applyClientPlugins(\n compiler: Compiler,\n options: moduleFederationPlugin.ModuleFederationPluginOptions,\n extraOptions: NextFederationPluginExtraOptions,\n): void {\n const { name } = options;\n\n // Adjust the public path if it is set to the default Next.js path\n if (compiler.options.output.publicPath === '/_next/') {\n compiler.options.output.publicPath = 'auto';\n }\n\n // Log a warning if automatic page stitching is enabled, as it is disabled in v7\n if (extraOptions.automaticPageStitching) {\n logger.warn('automatic page stitching is disabled in v7');\n }\n\n // Log an error if a custom library is set, as it is not allowed\n if (options.library) {\n logger.error('you cannot set custom library');\n }\n\n // Set the library option to be a window object with the name of the module federation plugin\n options.library = {\n type: 'window',\n name,\n };\n\n // Apply the ChunkCorrelationPlugin to collect metadata on chunks\n new ChunkCorrelationPlugin({\n filename: [\n 'static/chunks/federated-stats.json',\n 'server/federated-stats.json',\n ],\n }).apply(compiler);\n\n // Apply the InvertedContainerPlugin to add custom runtime modules to the container runtime\n new InvertedContainerPlugin().apply(compiler);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,mBACd,UACA,SACA,cACM;CACN,MAAM,EAAE,SAAS;AAGjB,KAAI,SAAS,QAAQ,OAAO,eAAe,UACzC,UAAS,QAAQ,OAAO,aAAa;AAIvC,KAAI,aAAa,uBACf,wBAAO,KAAK,6CAA6C;AAI3D,KAAI,QAAQ,QACV,wBAAO,MAAM,gCAAgC;AAI/C,SAAQ,UAAU;EAChB,MAAM;EACN;EACD;AAGD,KAAIA,+CAAuB,EACzB,UAAU,CACR,sCACA,8BACD,EACF,CAAC,CAAC,MAAM,SAAS;AAGlB,KAAIC,yCAAyB,CAAC,MAAM,SAAS"}
1
+ {"version":3,"file":"apply-client-plugins.js","names":["ChunkCorrelationPlugin","FederatedStatsCompatibilityPlugin","InvertedContainerPlugin"],"sources":["../../../../src/plugins/NextFederationPlugin/apply-client-plugins.ts"],"sourcesContent":["import type { Compiler } from 'webpack';\nimport { ChunkCorrelationPlugin } from '@module-federation/node';\nimport InvertedContainerPlugin from '../container/InvertedContainerPlugin';\nimport type { moduleFederationPlugin } from '@module-federation/sdk';\nimport type { NextFederationPluginExtraOptions } from './next-fragments';\nimport logger from '../../logger';\nimport { FederatedStatsCompatibilityPlugin } from './FederatedStatsCompatibilityPlugin';\n\nconst FEDERATED_STATS_FILENAMES = [\n 'static/chunks/federated-stats.json',\n 'server/federated-stats.json',\n];\n\n/**\n * Applies client-specific plugins.\n *\n * @param compiler - The Webpack compiler instance.\n * @param options - The ModuleFederationPluginOptions instance.\n * @param extraOptions - The NextFederationPluginExtraOptions instance.\n *\n * @remarks\n * This function applies plugins to the Webpack compiler instance that are specific to the client build of\n * a Next.js application with Module Federation enabled. These plugins include the following:\n *\n * - ChunkCorrelationPlugin: Collects metadata on chunks to enable proper module loading across different runtimes.\n * - InvertedContainerPlugin: Adds custom runtime modules to the container runtime to allow a host to expose its\n * own remote interface at startup.\n\n * If automatic page stitching is enabled, a warning is logged indicating that it is disabled in v7.\n * If a custom library is specified in the options, an error is logged. The options.library property is\n * also set to `{ type: 'window', name: options.name }`.\n */\nexport function applyClientPlugins(\n compiler: Compiler,\n options: moduleFederationPlugin.ModuleFederationPluginOptions,\n extraOptions: NextFederationPluginExtraOptions,\n): void {\n const { name } = options;\n\n // Adjust the public path if it is set to the default Next.js path\n if (compiler.options.output.publicPath === '/_next/') {\n compiler.options.output.publicPath = 'auto';\n }\n\n // Log a warning if automatic page stitching is enabled, as it is disabled in v7\n if (extraOptions.automaticPageStitching) {\n logger.warn('automatic page stitching is disabled in v7');\n }\n\n // Log an error if a custom library is set, as it is not allowed\n if (options.library) {\n logger.error('you cannot set custom library');\n }\n\n // Set the library option to be a window object with the name of the module federation plugin\n options.library = {\n type: 'window',\n name,\n };\n\n // Preserve the legacy asset for hosts that have not migrated to manifests.\n const manifestHasAssets =\n options.manifest !== false &&\n (typeof options.manifest !== 'object' ||\n !options.manifest.disableAssetsAnalyze);\n\n if (!manifestHasAssets) {\n new ChunkCorrelationPlugin({\n filename: FEDERATED_STATS_FILENAMES,\n }).apply(compiler);\n } else {\n new FederatedStatsCompatibilityPlugin({\n filenames: FEDERATED_STATS_FILENAMES,\n manifest: options.manifest,\n }).apply(compiler);\n }\n\n // Apply the InvertedContainerPlugin to add custom runtime modules to the container runtime\n new InvertedContainerPlugin().apply(compiler);\n}\n"],"mappings":";;;;;;;AAQA,MAAM,4BAA4B,CAChC,sCACA,8BACD;;;;;;;;;;;;;;;;;;;;AAqBD,SAAgB,mBACd,UACA,SACA,cACM;CACN,MAAM,EAAE,SAAS;AAGjB,KAAI,SAAS,QAAQ,OAAO,eAAe,UACzC,UAAS,QAAQ,OAAO,aAAa;AAIvC,KAAI,aAAa,uBACf,wBAAO,KAAK,6CAA6C;AAI3D,KAAI,QAAQ,QACV,wBAAO,MAAM,gCAAgC;AAI/C,SAAQ,UAAU;EAChB,MAAM;EACN;EACD;AAQD,KAAI,EAJF,QAAQ,aAAa,UACpB,OAAO,QAAQ,aAAa,YAC3B,CAAC,QAAQ,SAAS,uBAGpB,KAAIA,+CAAuB,EACzB,UAAU,2BACX,CAAC,CAAC,MAAM,SAAS;KAElB,KAAIC,4EAAkC;EACpC,WAAW;EACX,UAAU,QAAQ;EACnB,CAAC,CAAC,MAAM,SAAS;AAIpB,KAAIC,yCAAyB,CAAC,MAAM,SAAS"}
@@ -1,8 +1,10 @@
1
1
  import logger from "../../logger.mjs";
2
2
  import InvertedContainerPlugin from "../container/InvertedContainerPlugin.mjs";
3
+ import { FederatedStatsCompatibilityPlugin } from "./FederatedStatsCompatibilityPlugin.mjs";
3
4
  import { ChunkCorrelationPlugin } from "@module-federation/node";
4
5
 
5
6
  //#region src/plugins/NextFederationPlugin/apply-client-plugins.ts
7
+ const FEDERATED_STATS_FILENAMES = ["static/chunks/federated-stats.json", "server/federated-stats.json"];
6
8
  /**
7
9
  * Applies client-specific plugins.
8
10
  *
@@ -31,7 +33,11 @@ function applyClientPlugins(compiler, options, extraOptions) {
31
33
  type: "window",
32
34
  name
33
35
  };
34
- new ChunkCorrelationPlugin({ filename: ["static/chunks/federated-stats.json", "server/federated-stats.json"] }).apply(compiler);
36
+ if (!(options.manifest !== false && (typeof options.manifest !== "object" || !options.manifest.disableAssetsAnalyze))) new ChunkCorrelationPlugin({ filename: FEDERATED_STATS_FILENAMES }).apply(compiler);
37
+ else new FederatedStatsCompatibilityPlugin({
38
+ filenames: FEDERATED_STATS_FILENAMES,
39
+ manifest: options.manifest
40
+ }).apply(compiler);
35
41
  new InvertedContainerPlugin().apply(compiler);
36
42
  }
37
43
 
@@ -1 +1 @@
1
- {"version":3,"file":"apply-client-plugins.mjs","names":[],"sources":["../../../../src/plugins/NextFederationPlugin/apply-client-plugins.ts"],"sourcesContent":["import type { Compiler } from 'webpack';\nimport { ChunkCorrelationPlugin } from '@module-federation/node';\nimport InvertedContainerPlugin from '../container/InvertedContainerPlugin';\nimport type { moduleFederationPlugin } from '@module-federation/sdk';\nimport type { NextFederationPluginExtraOptions } from './next-fragments';\nimport logger from '../../logger';\n\n/**\n * Applies client-specific plugins.\n *\n * @param compiler - The Webpack compiler instance.\n * @param options - The ModuleFederationPluginOptions instance.\n * @param extraOptions - The NextFederationPluginExtraOptions instance.\n *\n * @remarks\n * This function applies plugins to the Webpack compiler instance that are specific to the client build of\n * a Next.js application with Module Federation enabled. These plugins include the following:\n *\n * - ChunkCorrelationPlugin: Collects metadata on chunks to enable proper module loading across different runtimes.\n * - InvertedContainerPlugin: Adds custom runtime modules to the container runtime to allow a host to expose its\n * own remote interface at startup.\n\n * If automatic page stitching is enabled, a warning is logged indicating that it is disabled in v7.\n * If a custom library is specified in the options, an error is logged. The options.library property is\n * also set to `{ type: 'window', name: options.name }`.\n */\nexport function applyClientPlugins(\n compiler: Compiler,\n options: moduleFederationPlugin.ModuleFederationPluginOptions,\n extraOptions: NextFederationPluginExtraOptions,\n): void {\n const { name } = options;\n\n // Adjust the public path if it is set to the default Next.js path\n if (compiler.options.output.publicPath === '/_next/') {\n compiler.options.output.publicPath = 'auto';\n }\n\n // Log a warning if automatic page stitching is enabled, as it is disabled in v7\n if (extraOptions.automaticPageStitching) {\n logger.warn('automatic page stitching is disabled in v7');\n }\n\n // Log an error if a custom library is set, as it is not allowed\n if (options.library) {\n logger.error('you cannot set custom library');\n }\n\n // Set the library option to be a window object with the name of the module federation plugin\n options.library = {\n type: 'window',\n name,\n };\n\n // Apply the ChunkCorrelationPlugin to collect metadata on chunks\n new ChunkCorrelationPlugin({\n filename: [\n 'static/chunks/federated-stats.json',\n 'server/federated-stats.json',\n ],\n }).apply(compiler);\n\n // Apply the InvertedContainerPlugin to add custom runtime modules to the container runtime\n new InvertedContainerPlugin().apply(compiler);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,mBACd,UACA,SACA,cACM;CACN,MAAM,EAAE,SAAS;AAGjB,KAAI,SAAS,QAAQ,OAAO,eAAe,UACzC,UAAS,QAAQ,OAAO,aAAa;AAIvC,KAAI,aAAa,uBACf,QAAO,KAAK,6CAA6C;AAI3D,KAAI,QAAQ,QACV,QAAO,MAAM,gCAAgC;AAI/C,SAAQ,UAAU;EAChB,MAAM;EACN;EACD;AAGD,KAAI,uBAAuB,EACzB,UAAU,CACR,sCACA,8BACD,EACF,CAAC,CAAC,MAAM,SAAS;AAGlB,KAAI,yBAAyB,CAAC,MAAM,SAAS"}
1
+ {"version":3,"file":"apply-client-plugins.mjs","names":[],"sources":["../../../../src/plugins/NextFederationPlugin/apply-client-plugins.ts"],"sourcesContent":["import type { Compiler } from 'webpack';\nimport { ChunkCorrelationPlugin } from '@module-federation/node';\nimport InvertedContainerPlugin from '../container/InvertedContainerPlugin';\nimport type { moduleFederationPlugin } from '@module-federation/sdk';\nimport type { NextFederationPluginExtraOptions } from './next-fragments';\nimport logger from '../../logger';\nimport { FederatedStatsCompatibilityPlugin } from './FederatedStatsCompatibilityPlugin';\n\nconst FEDERATED_STATS_FILENAMES = [\n 'static/chunks/federated-stats.json',\n 'server/federated-stats.json',\n];\n\n/**\n * Applies client-specific plugins.\n *\n * @param compiler - The Webpack compiler instance.\n * @param options - The ModuleFederationPluginOptions instance.\n * @param extraOptions - The NextFederationPluginExtraOptions instance.\n *\n * @remarks\n * This function applies plugins to the Webpack compiler instance that are specific to the client build of\n * a Next.js application with Module Federation enabled. These plugins include the following:\n *\n * - ChunkCorrelationPlugin: Collects metadata on chunks to enable proper module loading across different runtimes.\n * - InvertedContainerPlugin: Adds custom runtime modules to the container runtime to allow a host to expose its\n * own remote interface at startup.\n\n * If automatic page stitching is enabled, a warning is logged indicating that it is disabled in v7.\n * If a custom library is specified in the options, an error is logged. The options.library property is\n * also set to `{ type: 'window', name: options.name }`.\n */\nexport function applyClientPlugins(\n compiler: Compiler,\n options: moduleFederationPlugin.ModuleFederationPluginOptions,\n extraOptions: NextFederationPluginExtraOptions,\n): void {\n const { name } = options;\n\n // Adjust the public path if it is set to the default Next.js path\n if (compiler.options.output.publicPath === '/_next/') {\n compiler.options.output.publicPath = 'auto';\n }\n\n // Log a warning if automatic page stitching is enabled, as it is disabled in v7\n if (extraOptions.automaticPageStitching) {\n logger.warn('automatic page stitching is disabled in v7');\n }\n\n // Log an error if a custom library is set, as it is not allowed\n if (options.library) {\n logger.error('you cannot set custom library');\n }\n\n // Set the library option to be a window object with the name of the module federation plugin\n options.library = {\n type: 'window',\n name,\n };\n\n // Preserve the legacy asset for hosts that have not migrated to manifests.\n const manifestHasAssets =\n options.manifest !== false &&\n (typeof options.manifest !== 'object' ||\n !options.manifest.disableAssetsAnalyze);\n\n if (!manifestHasAssets) {\n new ChunkCorrelationPlugin({\n filename: FEDERATED_STATS_FILENAMES,\n }).apply(compiler);\n } else {\n new FederatedStatsCompatibilityPlugin({\n filenames: FEDERATED_STATS_FILENAMES,\n manifest: options.manifest,\n }).apply(compiler);\n }\n\n // Apply the InvertedContainerPlugin to add custom runtime modules to the container runtime\n new InvertedContainerPlugin().apply(compiler);\n}\n"],"mappings":";;;;;;AAQA,MAAM,4BAA4B,CAChC,sCACA,8BACD;;;;;;;;;;;;;;;;;;;;AAqBD,SAAgB,mBACd,UACA,SACA,cACM;CACN,MAAM,EAAE,SAAS;AAGjB,KAAI,SAAS,QAAQ,OAAO,eAAe,UACzC,UAAS,QAAQ,OAAO,aAAa;AAIvC,KAAI,aAAa,uBACf,QAAO,KAAK,6CAA6C;AAI3D,KAAI,QAAQ,QACV,QAAO,MAAM,gCAAgC;AAI/C,SAAQ,UAAU;EAChB,MAAM;EACN;EACD;AAQD,KAAI,EAJF,QAAQ,aAAa,UACpB,OAAO,QAAQ,aAAa,YAC3B,CAAC,QAAQ,SAAS,uBAGpB,KAAI,uBAAuB,EACzB,UAAU,2BACX,CAAC,CAAC,MAAM,SAAS;KAElB,KAAI,kCAAkC;EACpC,WAAW;EACX,UAAU,QAAQ;EACnB,CAAC,CAAC,MAAM,SAAS;AAIpB,KAAI,yBAAyB,CAAC,MAAM,SAAS"}
@@ -0,0 +1,36 @@
1
+ import type { WebpackOptionsNormalized, Compiler } from 'webpack';
2
+ import type { moduleFederationPlugin } from '@module-federation/sdk';
3
+ type EntryStaticNormalized = Awaited<ReturnType<Extract<WebpackOptionsNormalized['entry'], () => any>>>;
4
+ interface ModifyEntryOptions {
5
+ compiler: Compiler;
6
+ prependEntry?: (entry: EntryStaticNormalized) => void;
7
+ staticEntry?: EntryStaticNormalized;
8
+ }
9
+ export declare function modifyEntry(options: ModifyEntryOptions): void;
10
+ /**
11
+ * Applies server-specific plugins to the webpack compiler.
12
+ *
13
+ * @param {Compiler} compiler - The Webpack compiler instance.
14
+ * @param {moduleFederationPlugin.ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
15
+ */
16
+ export declare function applyServerPlugins(compiler: Compiler, options: moduleFederationPlugin.ModuleFederationPluginOptions): void;
17
+ /**
18
+ * Configures server-specific library and filename options.
19
+ *
20
+ * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
21
+ */
22
+ export declare function configureServerLibraryAndFilename(options: moduleFederationPlugin.ModuleFederationPluginOptions): void;
23
+ /**
24
+ * Patches Next.js' default externals function to ensure shared modules are bundled and not treated as external.
25
+ *
26
+ * @param {Compiler} compiler - The Webpack compiler instance.
27
+ * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
28
+ */
29
+ export declare function handleServerExternals(compiler: Compiler, options: moduleFederationPlugin.ModuleFederationPluginOptions): void;
30
+ /**
31
+ * Configures server-specific compiler options.
32
+ *
33
+ * @param {Compiler} compiler - The Webpack compiler instance.
34
+ */
35
+ export declare function configureServerCompilerOptions(compiler: Compiler): void;
36
+ export {};
@@ -0,0 +1,36 @@
1
+ import type { WebpackOptionsNormalized, Compiler } from 'webpack';
2
+ import type { moduleFederationPlugin } from '@module-federation/sdk';
3
+ type EntryStaticNormalized = Awaited<ReturnType<Extract<WebpackOptionsNormalized['entry'], () => any>>>;
4
+ interface ModifyEntryOptions {
5
+ compiler: Compiler;
6
+ prependEntry?: (entry: EntryStaticNormalized) => void;
7
+ staticEntry?: EntryStaticNormalized;
8
+ }
9
+ export declare function modifyEntry(options: ModifyEntryOptions): void;
10
+ /**
11
+ * Applies server-specific plugins to the webpack compiler.
12
+ *
13
+ * @param {Compiler} compiler - The Webpack compiler instance.
14
+ * @param {moduleFederationPlugin.ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
15
+ */
16
+ export declare function applyServerPlugins(compiler: Compiler, options: moduleFederationPlugin.ModuleFederationPluginOptions): void;
17
+ /**
18
+ * Configures server-specific library and filename options.
19
+ *
20
+ * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
21
+ */
22
+ export declare function configureServerLibraryAndFilename(options: moduleFederationPlugin.ModuleFederationPluginOptions): void;
23
+ /**
24
+ * Patches Next.js' default externals function to ensure shared modules are bundled and not treated as external.
25
+ *
26
+ * @param {Compiler} compiler - The Webpack compiler instance.
27
+ * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
28
+ */
29
+ export declare function handleServerExternals(compiler: Compiler, options: moduleFederationPlugin.ModuleFederationPluginOptions): void;
30
+ /**
31
+ * Configures server-specific compiler options.
32
+ *
33
+ * @param {Compiler} compiler - The Webpack compiler instance.
34
+ */
35
+ export declare function configureServerCompilerOptions(compiler: Compiler): void;
36
+ export {};
@@ -1,31 +1,27 @@
1
- import { NextFederationPluginOptions } from "./next-fragments.mjs";
2
- import { Compiler } from "webpack";
3
-
4
- //#region src/plugins/NextFederationPlugin/index.d.ts
1
+ import type { NextFederationPluginOptions } from './next-fragments';
2
+ import type { Compiler } from 'webpack';
5
3
  /**
6
4
  * NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.
7
5
  */
8
- declare class NextFederationPlugin {
9
- private _options;
10
- private _extraOptions;
11
- name: string;
12
- /**
13
- * Constructs the NextFederationPlugin with the provided options.
14
- *
15
- * @param options The options to configure the plugin.
16
- */
17
- constructor(options: NextFederationPluginOptions);
18
- /**
19
- * The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.
20
- * @param compiler The webpack compiler object.
21
- */
22
- apply(compiler: Compiler): void;
23
- private validateOptions;
24
- private isServerCompiler;
25
- private applyConditionalPlugins;
26
- private getNormalFederationPluginOptions;
27
- private getNoopPath;
6
+ export declare class NextFederationPlugin {
7
+ private _options;
8
+ private _extraOptions;
9
+ name: string;
10
+ /**
11
+ * Constructs the NextFederationPlugin with the provided options.
12
+ *
13
+ * @param options The options to configure the plugin.
14
+ */
15
+ constructor(options: NextFederationPluginOptions);
16
+ /**
17
+ * The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.
18
+ * @param compiler The webpack compiler object.
19
+ */
20
+ apply(compiler: Compiler): void;
21
+ private validateOptions;
22
+ private isServerCompiler;
23
+ private applyConditionalPlugins;
24
+ private getNormalFederationPluginOptions;
25
+ private getNoopPath;
28
26
  }
29
- //#endregion
30
- export { NextFederationPlugin };
31
- //# sourceMappingURL=index.d.mts.map
27
+ export default NextFederationPlugin;
@@ -1,31 +1,27 @@
1
- import { NextFederationPluginOptions } from "./next-fragments.js";
2
- import { Compiler } from "webpack";
3
-
4
- //#region src/plugins/NextFederationPlugin/index.d.ts
1
+ import type { NextFederationPluginOptions } from './next-fragments';
2
+ import type { Compiler } from 'webpack';
5
3
  /**
6
4
  * NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.
7
5
  */
8
- declare class NextFederationPlugin {
9
- private _options;
10
- private _extraOptions;
11
- name: string;
12
- /**
13
- * Constructs the NextFederationPlugin with the provided options.
14
- *
15
- * @param options The options to configure the plugin.
16
- */
17
- constructor(options: NextFederationPluginOptions);
18
- /**
19
- * The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.
20
- * @param compiler The webpack compiler object.
21
- */
22
- apply(compiler: Compiler): void;
23
- private validateOptions;
24
- private isServerCompiler;
25
- private applyConditionalPlugins;
26
- private getNormalFederationPluginOptions;
27
- private getNoopPath;
6
+ export declare class NextFederationPlugin {
7
+ private _options;
8
+ private _extraOptions;
9
+ name: string;
10
+ /**
11
+ * Constructs the NextFederationPlugin with the provided options.
12
+ *
13
+ * @param options The options to configure the plugin.
14
+ */
15
+ constructor(options: NextFederationPluginOptions);
16
+ /**
17
+ * The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.
18
+ * @param compiler The webpack compiler object.
19
+ */
20
+ apply(compiler: Compiler): void;
21
+ private validateOptions;
22
+ private isServerCompiler;
23
+ private applyConditionalPlugins;
24
+ private getNormalFederationPluginOptions;
25
+ private getNoopPath;
28
26
  }
29
- //#endregion
30
- export { NextFederationPlugin };
31
- //# sourceMappingURL=index.d.ts.map
27
+ export default NextFederationPlugin;
@@ -9,6 +9,7 @@ const require_set_options = require('./set-options.js');
9
9
  const require_validate_options = require('./validate-options.js');
10
10
  const require_apply_server_plugins = require('./apply-server-plugins.js');
11
11
  const require_apply_client_plugins = require('./apply-client-plugins.js');
12
+ const require_manifest_options = require('./manifest-options.js');
12
13
  let path = require("path");
13
14
  path = require_runtime.__toESM(path);
14
15
  let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
@@ -137,10 +138,7 @@ var NextFederationPlugin = class {
137
138
  ...defaultShared,
138
139
  ...this._options.shared
139
140
  },
140
- manifest: {
141
- ...this._options.manifest ?? {},
142
- filePath: isServer ? "" : "/static/chunks"
143
- },
141
+ manifest: require_manifest_options.normalizeManifestOptions(this._options.manifest, isServer),
144
142
  dts: this._options.dts ?? false,
145
143
  shareStrategy: this._options.shareStrategy ?? "loaded-first",
146
144
  experiments: { asyncStartup: true }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["setOptions","logger","CopyFederationPlugin","ModuleFederationPlugin","validateCompilerOptions","validatePluginOptions","retrieveDefaultShared","exposeNextjsPages"],"sources":["../../../../src/plugins/NextFederationPlugin/index.ts"],"sourcesContent":["/**\n * MIT License http://www.opensource.org/licenses/mit-license.php\n * Author Zackary Jackson @ScriptedAlchemy\n * This module contains the NextFederationPlugin class which is a webpack plugin that handles Next.js application federation using Module Federation.\n */\n'use strict';\n\nimport type {\n NextFederationPluginExtraOptions,\n NextFederationPluginOptions,\n} from './next-fragments';\nimport type { Compiler, WebpackPluginInstance } from 'webpack';\nimport path from 'path';\nimport { getWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport CopyFederationPlugin from '../CopyFederationPlugin';\nimport { exposeNextjsPages } from '../../loaders/nextPageMapLoader';\nimport { retrieveDefaultShared, applyPathFixes } from './next-fragments';\nimport { setOptions } from './set-options';\nimport {\n validateCompilerOptions,\n validatePluginOptions,\n} from './validate-options';\nimport {\n applyServerPlugins,\n configureServerCompilerOptions,\n configureServerLibraryAndFilename,\n handleServerExternals,\n} from './apply-server-plugins';\nimport { applyClientPlugins } from './apply-client-plugins';\nimport { ModuleFederationPlugin } from '@module-federation/enhanced/webpack';\nimport { bindLoggerToCompiler } from '@module-federation/sdk';\nimport type { moduleFederationPlugin } from '@module-federation/sdk';\nimport logger from '../../logger';\n\nconst resolveRuntimePluginPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/plugins/container/runtimePlugin.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/plugins/container/runtimePlugin.js');\n\nconst resolveNoopPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/federation-noop.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/federation-noop.js');\n\nconst resolveNodeRuntimePluginPath = (): string => {\n const nodePackageRoot = path.dirname(\n require.resolve('@module-federation/node/package.json'),\n );\n\n return require.resolve(\n path.join(\n nodePackageRoot,\n process.env.IS_ESM_BUILD === 'true'\n ? 'dist/src/runtimePlugin.mjs'\n : 'dist/src/runtimePlugin.js',\n ),\n );\n};\n/**\n * NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.\n */\nexport class NextFederationPlugin {\n private _options: moduleFederationPlugin.ModuleFederationPluginOptions;\n private _extraOptions: NextFederationPluginExtraOptions;\n public name: string;\n /**\n * Constructs the NextFederationPlugin with the provided options.\n *\n * @param options The options to configure the plugin.\n */\n constructor(options: NextFederationPluginOptions) {\n const { mainOptions, extraOptions } = setOptions(options);\n this._options = mainOptions;\n this._extraOptions = extraOptions;\n this.name = 'ModuleFederationPlugin';\n }\n\n /**\n * The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.\n * @param compiler The webpack compiler object.\n */\n apply(compiler: Compiler) {\n bindLoggerToCompiler(logger, compiler, 'NextFederationPlugin');\n process.env['FEDERATION_WEBPACK_PATH'] =\n process.env['FEDERATION_WEBPACK_PATH'] ||\n getWebpackPath(compiler, { framework: 'nextjs' });\n if (!this.validateOptions(compiler)) return;\n const isServer = this.isServerCompiler(compiler);\n new CopyFederationPlugin(isServer).apply(compiler);\n const normalFederationPluginOptions = this.getNormalFederationPluginOptions(\n compiler,\n isServer,\n );\n this._options = normalFederationPluginOptions;\n this.applyConditionalPlugins(compiler, isServer);\n\n new ModuleFederationPlugin(normalFederationPluginOptions).apply(compiler);\n\n const noop = this.getNoopPath();\n\n if (!this._extraOptions.skipSharingNextInternals) {\n compiler.hooks.make.tapAsync(\n 'NextFederationPlugin',\n (compilation, callback) => {\n const dep = compiler.webpack.EntryPlugin.createDependency(\n noop,\n 'noop',\n );\n compilation.addEntry(\n compiler.context,\n dep,\n { name: 'noop' },\n (err, module) => {\n if (err) {\n return callback(err);\n }\n callback();\n },\n );\n },\n );\n }\n\n if (!compiler.options.ignoreWarnings) {\n compiler.options.ignoreWarnings = [\n //@ts-ignore\n (message) => /your target environment does not appear/.test(message),\n ];\n }\n }\n\n private validateOptions(compiler: Compiler): boolean {\n const manifestPlugin = compiler.options.plugins.find(\n (p): p is WebpackPluginInstance =>\n p?.constructor?.name === 'BuildManifestPlugin',\n );\n\n if (manifestPlugin) {\n //@ts-ignore\n if (manifestPlugin?.appDirEnabled) {\n throw new Error(\n 'App Directory is not supported by nextjs-mf. Use only pages directory, do not open git issues about this',\n );\n }\n }\n\n const compilerValid = validateCompilerOptions(compiler);\n const pluginValid = validatePluginOptions(this._options);\n const envValid = process.env['NEXT_PRIVATE_LOCAL_WEBPACK'];\n if (compilerValid === undefined) logger.error('Compiler validation failed');\n if (pluginValid === undefined) logger.error('Plugin validation failed');\n const validCompilerTarget =\n compiler.options.name === 'server' || compiler.options.name === 'client';\n if (!envValid)\n throw new Error(\n 'process.env.NEXT_PRIVATE_LOCAL_WEBPACK is not set to true, please set it to true, and \"npm install webpack\"',\n );\n return (\n compilerValid !== undefined &&\n pluginValid !== undefined &&\n validCompilerTarget\n );\n }\n\n private isServerCompiler(compiler: Compiler): boolean {\n return compiler.options.name === 'server';\n }\n\n private applyConditionalPlugins(compiler: Compiler, isServer: boolean) {\n compiler.options.output.uniqueName = this._options.name;\n compiler.options.output.environment = {\n ...compiler.options.output.environment,\n asyncFunction: true,\n };\n\n // Add layer rules for resource queries\n if (!compiler.options.module.rules) {\n compiler.options.module.rules = [];\n }\n\n // Add layer rules for RSC, client and SSR\n compiler.options.module.rules.push({\n resourceQuery: /\\?rsc/,\n layer: 'rsc',\n });\n\n compiler.options.module.rules.push({\n resourceQuery: /\\?client/,\n layer: 'client',\n });\n\n compiler.options.module.rules.push({\n resourceQuery: /\\?ssr/,\n layer: 'ssr',\n });\n\n applyPathFixes(compiler, this._options, this._extraOptions);\n if (this._extraOptions.debug) {\n compiler.options.devtool = false;\n }\n\n if (isServer) {\n configureServerCompilerOptions(compiler);\n configureServerLibraryAndFilename(this._options);\n applyServerPlugins(compiler, this._options);\n handleServerExternals(compiler, {\n ...this._options,\n shared: { ...retrieveDefaultShared(isServer), ...this._options.shared },\n });\n } else {\n applyClientPlugins(compiler, this._options, this._extraOptions);\n }\n }\n\n private getNormalFederationPluginOptions(\n compiler: Compiler,\n isServer: boolean,\n ): moduleFederationPlugin.ModuleFederationPluginOptions {\n const defaultShared = this._extraOptions.skipSharingNextInternals\n ? {}\n : retrieveDefaultShared(isServer);\n\n return {\n ...this._options,\n runtime: false,\n remoteType: 'script',\n runtimePlugins: [\n ...(isServer ? [resolveNodeRuntimePluginPath()] : []),\n resolveRuntimePluginPath(),\n ...(this._options.runtimePlugins || []),\n ].map((plugin) => plugin + '?runtimePlugin'),\n //@ts-ignore\n exposes: {\n ...this._options.exposes,\n ...(this._extraOptions.exposePages\n ? exposeNextjsPages(compiler.options.context as string)\n : {}),\n },\n remotes: {\n ...this._options.remotes,\n },\n shared: {\n ...defaultShared,\n ...this._options.shared,\n },\n manifest: {\n ...(this._options.manifest ?? {}),\n filePath: isServer ? '' : '/static/chunks',\n },\n // nextjs project needs to add config.watchOptions = ['**/node_modules/**', '**/@mf-types/**'] to prevent loop types update\n dts: this._options.dts ?? false,\n shareStrategy: this._options.shareStrategy ?? 'loaded-first',\n experiments: {\n asyncStartup: true,\n },\n };\n }\n\n private getNoopPath(): string {\n return resolveNoopPath();\n }\n}\n\nexport default NextFederationPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,iCAGA,QAAQ,QAAQ,2EAA2E;AAEjG,MAAM,wBAGA,QAAQ,QAAQ,2DAA2D;AAEjF,MAAM,qCAA6C;CACjD,MAAM,kBAAkB,aAAK,QAC3B,QAAQ,QAAQ,uCAAuC,CACxD;AAED,QAAO,QAAQ,QACb,aAAK,KACH,iBAGI,4BACL,CACF;;;;;AAKH,IAAa,uBAAb,MAAkC;;;;;;CAShC,YAAY,SAAsC;EAChD,MAAM,EAAE,aAAa,iBAAiBA,+BAAW,QAAQ;AACzD,OAAK,WAAW;AAChB,OAAK,gBAAgB;AACrB,OAAK,OAAO;;;;;;CAOd,MAAM,UAAoB;AACxB,mDAAqBC,wBAAQ,UAAU,uBAAuB;AAC9D,UAAQ,IAAI,6BACV,QAAQ,IAAI,gGACG,UAAU,EAAE,WAAW,UAAU,CAAC;AACnD,MAAI,CAAC,KAAK,gBAAgB,SAAS,CAAE;EACrC,MAAM,WAAW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;GACD,QAAQ;IACN,GAAG;IACH,GAAG,KAAK,SAAS;IAClB;GACD,UAAU;IACR,GAAI,KAAK,SAAS,YAAY,EAAE;IAChC,UAAU,WAAW,KAAK;IAC3B;GAED,KAAK,KAAK,SAAS,OAAO;GAC1B,eAAe,KAAK,SAAS,iBAAiB;GAC9C,aAAa,EACX,cAAc,MACf;GACF;;CAGH,AAAQ,cAAsB;AAC5B,SAAO,iBAAiB"}
1
+ {"version":3,"file":"index.js","names":["setOptions","logger","CopyFederationPlugin","ModuleFederationPlugin","validateCompilerOptions","validatePluginOptions","retrieveDefaultShared","exposeNextjsPages","normalizeManifestOptions"],"sources":["../../../../src/plugins/NextFederationPlugin/index.ts"],"sourcesContent":["/**\n * MIT License http://www.opensource.org/licenses/mit-license.php\n * Author Zackary Jackson @ScriptedAlchemy\n * This module contains the NextFederationPlugin class which is a webpack plugin that handles Next.js application federation using Module Federation.\n */\n'use strict';\n\nimport type {\n NextFederationPluginExtraOptions,\n NextFederationPluginOptions,\n} from './next-fragments';\nimport type { Compiler, WebpackPluginInstance } from 'webpack';\nimport path from 'path';\nimport { getWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport CopyFederationPlugin from '../CopyFederationPlugin';\nimport { exposeNextjsPages } from '../../loaders/nextPageMapLoader';\nimport { retrieveDefaultShared, applyPathFixes } from './next-fragments';\nimport { setOptions } from './set-options';\nimport {\n validateCompilerOptions,\n validatePluginOptions,\n} from './validate-options';\nimport {\n applyServerPlugins,\n configureServerCompilerOptions,\n configureServerLibraryAndFilename,\n handleServerExternals,\n} from './apply-server-plugins';\nimport { applyClientPlugins } from './apply-client-plugins';\nimport { ModuleFederationPlugin } from '@module-federation/enhanced/webpack';\nimport { bindLoggerToCompiler } from '@module-federation/sdk';\nimport type { moduleFederationPlugin } from '@module-federation/sdk';\nimport logger from '../../logger';\nimport { normalizeManifestOptions } from './manifest-options';\n\nconst resolveRuntimePluginPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/plugins/container/runtimePlugin.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/plugins/container/runtimePlugin.js');\n\nconst resolveNoopPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/federation-noop.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/federation-noop.js');\n\nconst resolveNodeRuntimePluginPath = (): string => {\n const nodePackageRoot = path.dirname(\n require.resolve('@module-federation/node/package.json'),\n );\n\n return require.resolve(\n path.join(\n nodePackageRoot,\n process.env.IS_ESM_BUILD === 'true'\n ? 'dist/src/runtimePlugin.mjs'\n : 'dist/src/runtimePlugin.js',\n ),\n );\n};\n/**\n * NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.\n */\nexport class NextFederationPlugin {\n private _options: moduleFederationPlugin.ModuleFederationPluginOptions;\n private _extraOptions: NextFederationPluginExtraOptions;\n public name: string;\n /**\n * Constructs the NextFederationPlugin with the provided options.\n *\n * @param options The options to configure the plugin.\n */\n constructor(options: NextFederationPluginOptions) {\n const { mainOptions, extraOptions } = setOptions(options);\n this._options = mainOptions;\n this._extraOptions = extraOptions;\n this.name = 'ModuleFederationPlugin';\n }\n\n /**\n * The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.\n * @param compiler The webpack compiler object.\n */\n apply(compiler: Compiler) {\n bindLoggerToCompiler(logger, compiler, 'NextFederationPlugin');\n process.env['FEDERATION_WEBPACK_PATH'] =\n process.env['FEDERATION_WEBPACK_PATH'] ||\n getWebpackPath(compiler, { framework: 'nextjs' });\n if (!this.validateOptions(compiler)) return;\n const isServer = this.isServerCompiler(compiler);\n new CopyFederationPlugin(isServer).apply(compiler);\n const normalFederationPluginOptions = this.getNormalFederationPluginOptions(\n compiler,\n isServer,\n );\n this._options = normalFederationPluginOptions;\n this.applyConditionalPlugins(compiler, isServer);\n\n new ModuleFederationPlugin(normalFederationPluginOptions).apply(compiler);\n\n const noop = this.getNoopPath();\n\n if (!this._extraOptions.skipSharingNextInternals) {\n compiler.hooks.make.tapAsync(\n 'NextFederationPlugin',\n (compilation, callback) => {\n const dep = compiler.webpack.EntryPlugin.createDependency(\n noop,\n 'noop',\n );\n compilation.addEntry(\n compiler.context,\n dep,\n { name: 'noop' },\n (err, module) => {\n if (err) {\n return callback(err);\n }\n callback();\n },\n );\n },\n );\n }\n\n if (!compiler.options.ignoreWarnings) {\n compiler.options.ignoreWarnings = [\n //@ts-ignore\n (message) => /your target environment does not appear/.test(message),\n ];\n }\n }\n\n private validateOptions(compiler: Compiler): boolean {\n const manifestPlugin = compiler.options.plugins.find(\n (p): p is WebpackPluginInstance =>\n p?.constructor?.name === 'BuildManifestPlugin',\n );\n\n if (manifestPlugin) {\n //@ts-ignore\n if (manifestPlugin?.appDirEnabled) {\n throw new Error(\n 'App Directory is not supported by nextjs-mf. Use only pages directory, do not open git issues about this',\n );\n }\n }\n\n const compilerValid = validateCompilerOptions(compiler);\n const pluginValid = validatePluginOptions(this._options);\n const envValid = process.env['NEXT_PRIVATE_LOCAL_WEBPACK'];\n if (compilerValid === undefined) logger.error('Compiler validation failed');\n if (pluginValid === undefined) logger.error('Plugin validation failed');\n const validCompilerTarget =\n compiler.options.name === 'server' || compiler.options.name === 'client';\n if (!envValid)\n throw new Error(\n 'process.env.NEXT_PRIVATE_LOCAL_WEBPACK is not set to true, please set it to true, and \"npm install webpack\"',\n );\n return (\n compilerValid !== undefined &&\n pluginValid !== undefined &&\n validCompilerTarget\n );\n }\n\n private isServerCompiler(compiler: Compiler): boolean {\n return compiler.options.name === 'server';\n }\n\n private applyConditionalPlugins(compiler: Compiler, isServer: boolean) {\n compiler.options.output.uniqueName = this._options.name;\n compiler.options.output.environment = {\n ...compiler.options.output.environment,\n asyncFunction: true,\n };\n\n // Add layer rules for resource queries\n if (!compiler.options.module.rules) {\n compiler.options.module.rules = [];\n }\n\n // Add layer rules for RSC, client and SSR\n compiler.options.module.rules.push({\n resourceQuery: /\\?rsc/,\n layer: 'rsc',\n });\n\n compiler.options.module.rules.push({\n resourceQuery: /\\?client/,\n layer: 'client',\n });\n\n compiler.options.module.rules.push({\n resourceQuery: /\\?ssr/,\n layer: 'ssr',\n });\n\n applyPathFixes(compiler, this._options, this._extraOptions);\n if (this._extraOptions.debug) {\n compiler.options.devtool = false;\n }\n\n if (isServer) {\n configureServerCompilerOptions(compiler);\n configureServerLibraryAndFilename(this._options);\n applyServerPlugins(compiler, this._options);\n handleServerExternals(compiler, {\n ...this._options,\n shared: { ...retrieveDefaultShared(isServer), ...this._options.shared },\n });\n } else {\n applyClientPlugins(compiler, this._options, this._extraOptions);\n }\n }\n\n private getNormalFederationPluginOptions(\n compiler: Compiler,\n isServer: boolean,\n ): moduleFederationPlugin.ModuleFederationPluginOptions {\n const defaultShared = this._extraOptions.skipSharingNextInternals\n ? {}\n : retrieveDefaultShared(isServer);\n return {\n ...this._options,\n runtime: false,\n remoteType: 'script',\n runtimePlugins: [\n ...(isServer ? [resolveNodeRuntimePluginPath()] : []),\n resolveRuntimePluginPath(),\n ...(this._options.runtimePlugins || []),\n ].map((plugin) => plugin + '?runtimePlugin'),\n //@ts-ignore\n exposes: {\n ...this._options.exposes,\n ...(this._extraOptions.exposePages\n ? exposeNextjsPages(compiler.options.context as string)\n : {}),\n },\n remotes: {\n ...this._options.remotes,\n },\n shared: {\n ...defaultShared,\n ...(this._options.shared as Record<string, unknown>),\n },\n manifest: normalizeManifestOptions(this._options.manifest, isServer),\n // nextjs project needs to add config.watchOptions = ['**/node_modules/**', '**/@mf-types/**'] to prevent loop types update\n dts: this._options.dts ?? false,\n shareStrategy: this._options.shareStrategy ?? 'loaded-first',\n experiments: {\n asyncStartup: true,\n },\n };\n }\n\n private getNoopPath(): string {\n return resolveNoopPath();\n }\n}\n\nexport default NextFederationPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,iCAGA,QAAQ,QAAQ,2EAA2E;AAEjG,MAAM,wB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AAS;KAAQ;IACxE,CAAC;QAEF,iDAAmB,UAAU,KAAK,UAAU,KAAK,cAAc;;CAInE,AAAQ,iCACN,UACA,UACsD;EACtD,MAAM,gBAAgB,KAAK,cAAc,2BACrC,EAAE,GACFA,6CAAsB,SAAS;AACnC,SAAO;GACL,GAAG,KAAK;GACR,SAAS;GACT,YAAY;GACZ,gBAAgB;IACd,GAAI,WAAW,CAAC,8BAA8B,CAAC,GAAG,EAAE;IACpD,0BAA0B;IAC1B,GAAI,KAAK,SAAS,kBAAkB,EAAE;IACvC,CAAC,KAAK,WAAW,SAAS,iBAAiB;GAE5C,SAAS;IACP,GAAG,KAAK,SAAS;IACjB,GAAI,KAAK,cAAc,cACnBC,wDAAkB,SAAS,QAAQ,QAAkB,GACrD,EAAE;IACP;GACD,SAAS,EACP,GAAG,KAAK,SAAS,SAClB;GACD,QAAQ;IACN,GAAG;IACH,GAAI,KAAK,SAAS;IACnB;GACD,UAAUC,kDAAyB,KAAK,SAAS,UAAU,SAAS;GAEpE,KAAK,KAAK,SAAS,OAAO;GAC1B,eAAe,KAAK,SAAS,iBAAiB;GAC9C,aAAa,EACX,cAAc,MACf;GACF;;CAGH,AAAQ,cAAsB;AAC5B,SAAO,iBAAiB"}
@@ -7,6 +7,7 @@ import { setOptions } from "./set-options.mjs";
7
7
  import { validateCompilerOptions, validatePluginOptions } from "./validate-options.mjs";
8
8
  import { applyServerPlugins, configureServerCompilerOptions, configureServerLibraryAndFilename, handleServerExternals } from "./apply-server-plugins.mjs";
9
9
  import { applyClientPlugins } from "./apply-client-plugins.mjs";
10
+ import { normalizeManifestOptions } from "./manifest-options.mjs";
10
11
  import path from "path";
11
12
  import { getWebpackPath } from "@module-federation/sdk/normalize-webpack-path";
12
13
  import { bindLoggerToCompiler } from "@module-federation/sdk";
@@ -134,10 +135,7 @@ var NextFederationPlugin = class {
134
135
  ...defaultShared,
135
136
  ...this._options.shared
136
137
  },
137
- manifest: {
138
- ...this._options.manifest ?? {},
139
- filePath: isServer ? "" : "/static/chunks"
140
- },
138
+ manifest: normalizeManifestOptions(this._options.manifest, isServer),
141
139
  dts: this._options.dts ?? false,
142
140
  shareStrategy: this._options.shareStrategy ?? "loaded-first",
143
141
  experiments: { asyncStartup: true }
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["CopyFederationPlugin"],"sources":["../../../../src/plugins/NextFederationPlugin/index.ts"],"sourcesContent":["/**\n * MIT License http://www.opensource.org/licenses/mit-license.php\n * Author Zackary Jackson @ScriptedAlchemy\n * This module contains the NextFederationPlugin class which is a webpack plugin that handles Next.js application federation using Module Federation.\n */\n'use strict';\n\nimport type {\n NextFederationPluginExtraOptions,\n NextFederationPluginOptions,\n} from './next-fragments';\nimport type { Compiler, WebpackPluginInstance } from 'webpack';\nimport path from 'path';\nimport { getWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport CopyFederationPlugin from '../CopyFederationPlugin';\nimport { exposeNextjsPages } from '../../loaders/nextPageMapLoader';\nimport { retrieveDefaultShared, applyPathFixes } from './next-fragments';\nimport { setOptions } from './set-options';\nimport {\n validateCompilerOptions,\n validatePluginOptions,\n} from './validate-options';\nimport {\n applyServerPlugins,\n configureServerCompilerOptions,\n configureServerLibraryAndFilename,\n handleServerExternals,\n} from './apply-server-plugins';\nimport { applyClientPlugins } from './apply-client-plugins';\nimport { ModuleFederationPlugin } from '@module-federation/enhanced/webpack';\nimport { bindLoggerToCompiler } from '@module-federation/sdk';\nimport type { moduleFederationPlugin } from '@module-federation/sdk';\nimport logger from '../../logger';\n\nconst resolveRuntimePluginPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/plugins/container/runtimePlugin.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/plugins/container/runtimePlugin.js');\n\nconst resolveNoopPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/federation-noop.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/federation-noop.js');\n\nconst resolveNodeRuntimePluginPath = (): string => {\n const nodePackageRoot = path.dirname(\n require.resolve('@module-federation/node/package.json'),\n );\n\n return require.resolve(\n path.join(\n nodePackageRoot,\n process.env.IS_ESM_BUILD === 'true'\n ? 'dist/src/runtimePlugin.mjs'\n : 'dist/src/runtimePlugin.js',\n ),\n );\n};\n/**\n * NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.\n */\nexport class NextFederationPlugin {\n private _options: moduleFederationPlugin.ModuleFederationPluginOptions;\n private _extraOptions: NextFederationPluginExtraOptions;\n public name: string;\n /**\n * Constructs the NextFederationPlugin with the provided options.\n *\n * @param options The options to configure the plugin.\n */\n constructor(options: NextFederationPluginOptions) {\n const { mainOptions, extraOptions } = setOptions(options);\n this._options = mainOptions;\n this._extraOptions = extraOptions;\n this.name = 'ModuleFederationPlugin';\n }\n\n /**\n * The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.\n * @param compiler The webpack compiler object.\n */\n apply(compiler: Compiler) {\n bindLoggerToCompiler(logger, compiler, 'NextFederationPlugin');\n process.env['FEDERATION_WEBPACK_PATH'] =\n process.env['FEDERATION_WEBPACK_PATH'] ||\n getWebpackPath(compiler, { framework: 'nextjs' });\n if (!this.validateOptions(compiler)) return;\n const isServer = this.isServerCompiler(compiler);\n new CopyFederationPlugin(isServer).apply(compiler);\n const normalFederationPluginOptions = this.getNormalFederationPluginOptions(\n compiler,\n isServer,\n );\n this._options = normalFederationPluginOptions;\n this.applyConditionalPlugins(compiler, isServer);\n\n new ModuleFederationPlugin(normalFederationPluginOptions).apply(compiler);\n\n const noop = this.getNoopPath();\n\n if (!this._extraOptions.skipSharingNextInternals) {\n compiler.hooks.make.tapAsync(\n 'NextFederationPlugin',\n (compilation, callback) => {\n const dep = compiler.webpack.EntryPlugin.createDependency(\n noop,\n 'noop',\n );\n compilation.addEntry(\n compiler.context,\n dep,\n { name: 'noop' },\n (err, module) => {\n if (err) {\n return callback(err);\n }\n callback();\n },\n );\n },\n );\n }\n\n if (!compiler.options.ignoreWarnings) {\n compiler.options.ignoreWarnings = [\n //@ts-ignore\n (message) => /your target environment does not appear/.test(message),\n ];\n }\n }\n\n private validateOptions(compiler: Compiler): boolean {\n const manifestPlugin = compiler.options.plugins.find(\n (p): p is WebpackPluginInstance =>\n p?.constructor?.name === 'BuildManifestPlugin',\n );\n\n if (manifestPlugin) {\n //@ts-ignore\n if (manifestPlugin?.appDirEnabled) {\n throw new Error(\n 'App Directory is not supported by nextjs-mf. Use only pages directory, do not open git issues about this',\n );\n }\n }\n\n const compilerValid = validateCompilerOptions(compiler);\n const pluginValid = validatePluginOptions(this._options);\n const envValid = process.env['NEXT_PRIVATE_LOCAL_WEBPACK'];\n if (compilerValid === undefined) logger.error('Compiler validation failed');\n if (pluginValid === undefined) logger.error('Plugin validation failed');\n const validCompilerTarget =\n compiler.options.name === 'server' || compiler.options.name === 'client';\n if (!envValid)\n throw new Error(\n 'process.env.NEXT_PRIVATE_LOCAL_WEBPACK is not set to true, please set it to true, and \"npm install webpack\"',\n );\n return (\n compilerValid !== undefined &&\n pluginValid !== undefined &&\n validCompilerTarget\n );\n }\n\n private isServerCompiler(compiler: Compiler): boolean {\n return compiler.options.name === 'server';\n }\n\n private applyConditionalPlugins(compiler: Compiler, isServer: boolean) {\n compiler.options.output.uniqueName = this._options.name;\n compiler.options.output.environment = {\n ...compiler.options.output.environment,\n asyncFunction: true,\n };\n\n // Add layer rules for resource queries\n if (!compiler.options.module.rules) {\n compiler.options.module.rules = [];\n }\n\n // Add layer rules for RSC, client and SSR\n compiler.options.module.rules.push({\n resourceQuery: /\\?rsc/,\n layer: 'rsc',\n });\n\n compiler.options.module.rules.push({\n resourceQuery: /\\?client/,\n layer: 'client',\n });\n\n compiler.options.module.rules.push({\n resourceQuery: /\\?ssr/,\n layer: 'ssr',\n });\n\n applyPathFixes(compiler, this._options, this._extraOptions);\n if (this._extraOptions.debug) {\n compiler.options.devtool = false;\n }\n\n if (isServer) {\n configureServerCompilerOptions(compiler);\n configureServerLibraryAndFilename(this._options);\n applyServerPlugins(compiler, this._options);\n handleServerExternals(compiler, {\n ...this._options,\n shared: { ...retrieveDefaultShared(isServer), ...this._options.shared },\n });\n } else {\n applyClientPlugins(compiler, this._options, this._extraOptions);\n }\n }\n\n private getNormalFederationPluginOptions(\n compiler: Compiler,\n isServer: boolean,\n ): moduleFederationPlugin.ModuleFederationPluginOptions {\n const defaultShared = this._extraOptions.skipSharingNextInternals\n ? {}\n : retrieveDefaultShared(isServer);\n\n return {\n ...this._options,\n runtime: false,\n remoteType: 'script',\n runtimePlugins: [\n ...(isServer ? [resolveNodeRuntimePluginPath()] : []),\n resolveRuntimePluginPath(),\n ...(this._options.runtimePlugins || []),\n ].map((plugin) => plugin + '?runtimePlugin'),\n //@ts-ignore\n exposes: {\n ...this._options.exposes,\n ...(this._extraOptions.exposePages\n ? exposeNextjsPages(compiler.options.context as string)\n : {}),\n },\n remotes: {\n ...this._options.remotes,\n },\n shared: {\n ...defaultShared,\n ...this._options.shared,\n },\n manifest: {\n ...(this._options.manifest ?? {}),\n filePath: isServer ? '' : '/static/chunks',\n },\n // nextjs project needs to add config.watchOptions = ['**/node_modules/**', '**/@mf-types/**'] to prevent loop types update\n dts: this._options.dts ?? false,\n shareStrategy: this._options.shareStrategy ?? 'loaded-first',\n experiments: {\n asyncStartup: true,\n },\n };\n }\n\n private getNoopPath(): string {\n return resolveNoopPath();\n }\n}\n\nexport default NextFederationPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,2CAEQ,QAAQ,4EAA4E;AAGlG,MAAM,kCAEQ,QAAQ,4DAA4D;AAGlF,MAAM,qCAA6C;CACjD,MAAM,kBAAkB,KAAK,kBACnB,QAAQ,uCAAuC,CACxD;AAED,kBAAe,QACb,KAAK,KACH,iBAEI,6BAEL,CACF;;;;;AAKH,IAAa,uBAAb,MAAkC;;;;;;CAShC,YAAY,SAAsC;EAChD,MAAM,E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AI,WAAW,CAAC,8BAA8B,CAAC,GAAG,EAAE;IACpD,0BAA0B;IAC1B,GAAI,KAAK,SAAS,kBAAkB,EAAE;IACvC,CAAC,KAAK,WAAW,SAAS,iBAAiB;GAE5C,SAAS;IACP,GAAG,KAAK,SAAS;IACjB,GAAI,KAAK,cAAc,cACnB,kBAAkB,SAAS,QAAQ,QAAkB,GACrD,EAAE;IACP;GACD,SAAS,EACP,GAAG,KAAK,SAAS,SAClB;GACD,QAAQ;IACN,GAAG;IACH,GAAG,KAAK,SAAS;IAClB;GACD,UAAU;IACR,GAAI,KAAK,SAAS,YAAY,EAAE;IAChC,UAAU,WAAW,KAAK;IAC3B;GAED,KAAK,KAAK,SAAS,OAAO;GAC1B,eAAe,KAAK,SAAS,iBAAiB;GAC9C,aAAa,EACX,cAAc,MACf;GACF;;CAGH,AAAQ,cAAsB;AAC5B,SAAO,iBAAiB"}
1
+ {"version":3,"file":"index.mjs","names":["CopyFederationPlugin"],"sources":["../../../../src/plugins/NextFederationPlugin/index.ts"],"sourcesContent":["/**\n * MIT License http://www.opensource.org/licenses/mit-license.php\n * Author Zackary Jackson @ScriptedAlchemy\n * This module contains the NextFederationPlugin class which is a webpack plugin that handles Next.js application federation using Module Federation.\n */\n'use strict';\n\nimport type {\n NextFederationPluginExtraOptions,\n NextFederationPluginOptions,\n} from './next-fragments';\nimport type { Compiler, WebpackPluginInstance } from 'webpack';\nimport path from 'path';\nimport { getWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport CopyFederationPlugin from '../CopyFederationPlugin';\nimport { exposeNextjsPages } from '../../loaders/nextPageMapLoader';\nimport { retrieveDefaultShared, applyPathFixes } from './next-fragments';\nimport { setOptions } from './set-options';\nimport {\n validateCompilerOptions,\n validatePluginOptions,\n} from './validate-options';\nimport {\n applyServerPlugins,\n configureServerCompilerOptions,\n configureServerLibraryAndFilename,\n handleServerExternals,\n} from './apply-server-plugins';\nimport { applyClientPlugins } from './apply-client-plugins';\nimport { ModuleFederationPlugin } from '@module-federation/enhanced/webpack';\nimport { bindLoggerToCompiler } from '@module-federation/sdk';\nimport type { moduleFederationPlugin } from '@module-federation/sdk';\nimport logger from '../../logger';\nimport { normalizeManifestOptions } from './manifest-options';\n\nconst resolveRuntimePluginPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/plugins/container/runtimePlugin.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/plugins/container/runtimePlugin.js');\n\nconst resolveNoopPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/federation-noop.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/federation-noop.js');\n\nconst resolveNodeRuntimePluginPath = (): string => {\n const nodePackageRoot = path.dirname(\n require.resolve('@module-federation/node/package.json'),\n );\n\n return require.resolve(\n path.join(\n nodePackageRoot,\n process.env.IS_ESM_BUILD === 'true'\n ? 'dist/src/runtimePlugin.mjs'\n : 'dist/src/runtimePlugin.js',\n ),\n );\n};\n/**\n * NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.\n */\nexport class NextFederationPlugin {\n private _options: moduleFederationPlugin.ModuleFederationPluginOptions;\n private _extraOptions: NextFederationPluginExtraOptions;\n public name: string;\n /**\n * Constructs the NextFederationPlugin with the provided options.\n *\n * @param options The options to configure the plugin.\n */\n constructor(options: NextFederationPluginOptions) {\n const { mainOptions, extraOptions } = setOptions(options);\n this._options = mainOptions;\n this._extraOptions = extraOptions;\n this.name = 'ModuleFederationPlugin';\n }\n\n /**\n * The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.\n * @param compiler The webpack compiler object.\n */\n apply(compiler: Compiler) {\n bindLoggerToCompiler(logger, compiler, 'NextFederationPlugin');\n process.env['FEDERATION_WEBPACK_PATH'] =\n process.env['FEDERATION_WEBPACK_PATH'] ||\n getWebpackPath(compiler, { framework: 'nextjs' });\n if (!this.validateOptions(compiler)) return;\n const isServer = this.isServerCompiler(compiler);\n new CopyFederationPlugin(isServer).apply(compiler);\n const normalFederationPluginOptions = this.getNormalFederationPluginOptions(\n compiler,\n isServer,\n );\n this._options = normalFederationPluginOptions;\n this.applyConditionalPlugins(compiler, isServer);\n\n new ModuleFederationPlugin(normalFederationPluginOptions).apply(compiler);\n\n const noop = this.getNoopPath();\n\n if (!this._extraOptions.skipSharingNextInternals) {\n compiler.hooks.make.tapAsync(\n 'NextFederationPlugin',\n (compilation, callback) => {\n const dep = compiler.webpack.EntryPlugin.createDependency(\n noop,\n 'noop',\n );\n compilation.addEntry(\n compiler.context,\n dep,\n { name: 'noop' },\n (err, module) => {\n if (err) {\n return callback(err);\n }\n callback();\n },\n );\n },\n );\n }\n\n if (!compiler.options.ignoreWarnings) {\n compiler.options.ignoreWarnings = [\n //@ts-ignore\n (message) => /your target environment does not appear/.test(message),\n ];\n }\n }\n\n private validateOptions(compiler: Compiler): boolean {\n const manifestPlugin = compiler.options.plugins.find(\n (p): p is WebpackPluginInstance =>\n p?.constructor?.name === 'BuildManifestPlugin',\n );\n\n if (manifestPlugin) {\n //@ts-ignore\n if (manifestPlugin?.appDirEnabled) {\n throw new Error(\n 'App Directory is not supported by nextjs-mf. Use only pages directory, do not open git issues about this',\n );\n }\n }\n\n const compilerValid = validateCompilerOptions(compiler);\n const pluginValid = validatePluginOptions(this._options);\n const envValid = process.env['NEXT_PRIVATE_LOCAL_WEBPACK'];\n if (compilerValid === undefined) logger.error('Compiler validation failed');\n if (pluginValid === undefined) logger.error('Plugin validation failed');\n const validCompilerTarget =\n compiler.options.name === 'server' || compiler.options.name === 'client';\n if (!envValid)\n throw new Error(\n 'process.env.NEXT_PRIVATE_LOCAL_WEBPACK is not set to true, please set it to true, and \"npm install webpack\"',\n );\n return (\n compilerValid !== undefined &&\n pluginValid !== undefined &&\n validCompilerTarget\n );\n }\n\n private isServerCompiler(compiler: Compiler): boolean {\n return compiler.options.name === 'server';\n }\n\n private applyConditionalPlugins(compiler: Compiler, isServer: boolean) {\n compiler.options.output.uniqueName = this._options.name;\n compiler.options.output.environment = {\n ...compiler.options.output.environment,\n asyncFunction: true,\n };\n\n // Add layer rules for resource queries\n if (!compiler.options.module.rules) {\n compiler.options.module.rules = [];\n }\n\n // Add layer rules for RSC, client and SSR\n compiler.options.module.rules.push({\n resourceQuery: /\\?rsc/,\n layer: 'rsc',\n });\n\n compiler.options.module.rules.push({\n resourceQuery: /\\?client/,\n layer: 'client',\n });\n\n compiler.options.module.rules.push({\n resourceQuery: /\\?ssr/,\n layer: 'ssr',\n });\n\n applyPathFixes(compiler, this._options, this._extraOptions);\n if (this._extraOptions.debug) {\n compiler.options.devtool = false;\n }\n\n if (isServer) {\n configureServerCompilerOptions(compiler);\n configureServerLibraryAndFilename(this._options);\n applyServerPlugins(compiler, this._options);\n handleServerExternals(compiler, {\n ...this._options,\n shared: { ...retrieveDefaultShared(isServer), ...this._options.shared },\n });\n } else {\n applyClientPlugins(compiler, this._options, this._extraOptions);\n }\n }\n\n private getNormalFederationPluginOptions(\n compiler: Compiler,\n isServer: boolean,\n ): moduleFederationPlugin.ModuleFederationPluginOptions {\n const defaultShared = this._extraOptions.skipSharingNextInternals\n ? {}\n : retrieveDefaultShared(isServer);\n return {\n ...this._options,\n runtime: false,\n remoteType: 'script',\n runtimePlugins: [\n ...(isServer ? [resolveNodeRuntimePluginPath()] : []),\n resolveRuntimePluginPath(),\n ...(this._options.runtimePlugins || []),\n ].map((plugin) => plugin + '?runtimePlugin'),\n //@ts-ignore\n exposes: {\n ...this._options.exposes,\n ...(this._extraOptions.exposePages\n ? exposeNextjsPages(compiler.options.context as string)\n : {}),\n },\n remotes: {\n ...this._options.remotes,\n },\n shared: {\n ...defaultShared,\n ...(this._options.shared as Record<string, unknown>),\n },\n manifest: normalizeManifestOptions(this._options.manifest, isServer),\n // nextjs project needs to add config.watchOptions = ['**/node_modules/**', '**/@mf-types/**'] to prevent loop types update\n dts: this._options.dts ?? false,\n shareStrategy: this._options.shareStrategy ?? 'loaded-first',\n experiments: {\n asyncStartup: true,\n },\n };\n }\n\n private getNoopPath(): string {\n return resolveNoopPath();\n }\n}\n\nexport default NextFederationPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,2CAEQ,QAAQ,4EAA4E;AAGlG,MAAM,kCAEQ,QAAQ,4DAA4D;AAGlF,MAAM,qCAA6C;CACjD,MAAM,kBAAkB,KAAK,kBACnB,QAAQ,uCAAuC,CACxD;AAED,kBAAe,QACb,KAAK,KACH,iBAEI,6BAEL,CACF;;;;;AAKH,IAAa,uBAAb,MAAkC;;;;;;CAShC,YAAY,SAAsC;EAChD,MAAM,EAAE,aAAa,iBAAiB,WAAW,QAAQ;AACzD,OAAK,WAAW;AAChB,OAAK,gBAAgB;AACrB,OAAK,OAAO;;;;;;CAOd,MAAM,UAAoB;AACxB,uBAAqB,QAAQ,UAAU,uBAAuB;AAC9D,UAAQ,IAAI,6BACV,QAAQ,IAAI,8BACZ,eAAe,UAAU,EAAE,WAAW,UAAU,CAAC;AACnD,MAAI,CAAC,KAAK,gBAAgB,SAAS,CAAE;EACrC,MAAM,WAAW,KAAK,iBAAiB,SAAS;AAChD,MAAIA,sBAAqB,SAAS,CAAC,MAAM,SAAS;EAClD,MAAM,gCAAgC,KAAK,iCACzC,UACA,SACD;AACD,OAAK,WAAW;AAChB,OAAK,wBAAwB,UAAU,SAAS;AAEhD,MAAI,uBAAuB,8BAA8B,CAAC,MAAM,SAAS;EAEzE,MAAM,OAAO,KAAK,aAAa;AAE/B,MAAI,CAAC,KAAK,cAAc,yBACtB,UAAS,MAAM,KAAK,SAClB,yBACC,aAAa,aAAa;GACzB,MAAM,MAAM,SAAS,QAAQ,YAAY,iBACvC,MACA,OACD;AACD,eAAY,SACV,SAAS,SACT,KACA,EAAE,MAAM,QAAQ,GACf,KAAK,WAAW;AACf,QAAI,IACF,QAAO,SAAS,IAAI;AAEtB,cAAU;KAEb;IAEJ;AAGH,MAAI,CAAC,SAAS,QAA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AA+B,SAAS;AACxC,qCAAkC,KAAK,SAAS;AAChD,sBAAmB,UAAU,KAAK,SAAS;AAC3C,yBAAsB,UAAU;IAC9B,GAAG,KAAK;IACR,QAAQ;KAAE,GAAG,sBAAsB,SAAS;KAAE,GAAG,KAAK,SAAS;KAAQ;IACxE,CAAC;QAEF,oBAAmB,UAAU,KAAK,UAAU,KAAK,cAAc;;CAInE,AAAQ,iCACN,UACA,UACsD;EACtD,MAAM,gBAAgB,KAAK,cAAc,2BACrC,EAAE,GACF,sBAAsB,SAAS;AACnC,SAAO;GACL,GAAG,KAAK;GACR,SAAS;GACT,YAAY;GACZ,gBAAgB;IACd,GAAI,WAAW,CAAC,8BAA8B,CAAC,GAAG,EAAE;IACpD,0BAA0B;IAC1B,GAAI,KAAK,SAAS,kBAAkB,EAAE;IACvC,CAAC,KAAK,WAAW,SAAS,iBAAiB;GAE5C,SAAS;IACP,GAAG,KAAK,SAAS;IACjB,GAAI,KAAK,cAAc,cACnB,kBAAkB,SAAS,QAAQ,QAAkB,GACrD,EAAE;IACP;GACD,SAAS,EACP,GAAG,KAAK,SAAS,SAClB;GACD,QAAQ;IACN,GAAG;IACH,GAAI,KAAK,SAAS;IACnB;GACD,UAAU,yBAAyB,KAAK,SAAS,UAAU,SAAS;GAEpE,KAAK,KAAK,SAAS,OAAO;GAC1B,eAAe,KAAK,SAAS,iBAAiB;GAC9C,aAAa,EACX,cAAc,MACf;GACF;;CAGH,AAAQ,cAAsB;AAC5B,SAAO,iBAAiB"}
@@ -0,0 +1,4 @@
1
+ import type { moduleFederationPlugin } from '@module-federation/sdk';
2
+ type ManifestOptions = moduleFederationPlugin.ModuleFederationPluginOptions['manifest'];
3
+ export declare const normalizeManifestOptions: (manifest: ManifestOptions, isServer: boolean) => ManifestOptions;
4
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { moduleFederationPlugin } from '@module-federation/sdk';
2
+ type ManifestOptions = moduleFederationPlugin.ModuleFederationPluginOptions['manifest'];
3
+ export declare const normalizeManifestOptions: (manifest: ManifestOptions, isServer: boolean) => ManifestOptions;
4
+ export {};
@@ -0,0 +1,13 @@
1
+
2
+ //#region src/plugins/NextFederationPlugin/manifest-options.ts
3
+ const normalizeManifestOptions = (manifest, isServer) => {
4
+ if (manifest === false) return false;
5
+ return {
6
+ ...typeof manifest === "object" && manifest !== null ? manifest : {},
7
+ filePath: isServer ? "" : "/static/chunks"
8
+ };
9
+ };
10
+
11
+ //#endregion
12
+ exports.normalizeManifestOptions = normalizeManifestOptions;
13
+ //# sourceMappingURL=manifest-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-options.js","names":[],"sources":["../../../../src/plugins/NextFederationPlugin/manifest-options.ts"],"sourcesContent":["import type { moduleFederationPlugin } from '@module-federation/sdk';\n\ntype ManifestOptions =\n moduleFederationPlugin.ModuleFederationPluginOptions['manifest'];\n\nexport const normalizeManifestOptions = (\n manifest: ManifestOptions,\n isServer: boolean,\n): ManifestOptions => {\n if (manifest === false) return false;\n\n return {\n ...(typeof manifest === 'object' && manifest !== null ? manifest : {}),\n filePath: isServer ? '' : '/static/chunks',\n };\n};\n"],"mappings":";;AAKA,MAAa,4BACX,UACA,aACoB;AACpB,KAAI,aAAa,MAAO,QAAO;AAE/B,QAAO;EACL,GAAI,OAAO,aAAa,YAAY,aAAa,OAAO,WAAW,EAAE;EACrE,UAAU,WAAW,KAAK;EAC3B"}
@@ -0,0 +1,12 @@
1
+ //#region src/plugins/NextFederationPlugin/manifest-options.ts
2
+ const normalizeManifestOptions = (manifest, isServer) => {
3
+ if (manifest === false) return false;
4
+ return {
5
+ ...typeof manifest === "object" && manifest !== null ? manifest : {},
6
+ filePath: isServer ? "" : "/static/chunks"
7
+ };
8
+ };
9
+
10
+ //#endregion
11
+ export { normalizeManifestOptions };
12
+ //# sourceMappingURL=manifest-options.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-options.mjs","names":[],"sources":["../../../../src/plugins/NextFederationPlugin/manifest-options.ts"],"sourcesContent":["import type { moduleFederationPlugin } from '@module-federation/sdk';\n\ntype ManifestOptions =\n moduleFederationPlugin.ModuleFederationPluginOptions['manifest'];\n\nexport const normalizeManifestOptions = (\n manifest: ManifestOptions,\n isServer: boolean,\n): ManifestOptions => {\n if (manifest === false) return false;\n\n return {\n ...(typeof manifest === 'object' && manifest !== null ? manifest : {}),\n filePath: isServer ? '' : '/static/chunks',\n };\n};\n"],"mappings":";AAKA,MAAa,4BACX,UACA,aACoB;AACpB,KAAI,aAAa,MAAO,QAAO;AAE/B,QAAO;EACL,GAAI,OAAO,aAAa,YAAY,aAAa,OAAO,WAAW,EAAE;EACrE,UAAU,WAAW,KAAK;EAC3B"}
@@ -1,18 +1,20 @@
1
- import { moduleFederationPlugin } from "@module-federation/sdk";
2
- import { Compiler } from "webpack";
3
-
4
- //#region src/plugins/NextFederationPlugin/next-fragments.d.ts
5
- interface NextFederationPluginExtraOptions {
6
- enableImageLoaderFix?: boolean;
7
- enableUrlLoaderFix?: boolean;
8
- exposePages?: boolean;
9
- skipSharingNextInternals?: boolean;
10
- automaticPageStitching?: boolean;
11
- debug?: boolean;
1
+ import type { Compiler } from 'webpack';
2
+ import type { moduleFederationPlugin } from '@module-federation/sdk';
3
+ /**
4
+ * Set up default shared values based on the environment.
5
+ * @param {boolean} isServer - Boolean indicating if the code is running on the server.
6
+ * @returns {SharedObject} The default share scope based on the environment.
7
+ */
8
+ export declare const retrieveDefaultShared: (isServer: boolean) => moduleFederationPlugin.SharedObject;
9
+ export declare const applyPathFixes: (compiler: Compiler, pluginOptions: moduleFederationPlugin.ModuleFederationPluginOptions, options: any) => void;
10
+ export interface NextFederationPluginExtraOptions {
11
+ enableImageLoaderFix?: boolean;
12
+ enableUrlLoaderFix?: boolean;
13
+ exposePages?: boolean;
14
+ skipSharingNextInternals?: boolean;
15
+ automaticPageStitching?: boolean;
16
+ debug?: boolean;
12
17
  }
13
- interface NextFederationPluginOptions extends moduleFederationPlugin.ModuleFederationPluginOptions {
14
- extraOptions: NextFederationPluginExtraOptions;
18
+ export interface NextFederationPluginOptions extends moduleFederationPlugin.ModuleFederationPluginOptions {
19
+ extraOptions: NextFederationPluginExtraOptions;
15
20
  }
16
- //#endregion
17
- export { NextFederationPluginOptions };
18
- //# sourceMappingURL=next-fragments.d.mts.map
@@ -1,18 +1,20 @@
1
- import { Compiler } from "webpack";
2
- import { moduleFederationPlugin } from "@module-federation/sdk";
3
-
4
- //#region src/plugins/NextFederationPlugin/next-fragments.d.ts
5
- interface NextFederationPluginExtraOptions {
6
- enableImageLoaderFix?: boolean;
7
- enableUrlLoaderFix?: boolean;
8
- exposePages?: boolean;
9
- skipSharingNextInternals?: boolean;
10
- automaticPageStitching?: boolean;
11
- debug?: boolean;
1
+ import type { Compiler } from 'webpack';
2
+ import type { moduleFederationPlugin } from '@module-federation/sdk';
3
+ /**
4
+ * Set up default shared values based on the environment.
5
+ * @param {boolean} isServer - Boolean indicating if the code is running on the server.
6
+ * @returns {SharedObject} The default share scope based on the environment.
7
+ */
8
+ export declare const retrieveDefaultShared: (isServer: boolean) => moduleFederationPlugin.SharedObject;
9
+ export declare const applyPathFixes: (compiler: Compiler, pluginOptions: moduleFederationPlugin.ModuleFederationPluginOptions, options: any) => void;
10
+ export interface NextFederationPluginExtraOptions {
11
+ enableImageLoaderFix?: boolean;
12
+ enableUrlLoaderFix?: boolean;
13
+ exposePages?: boolean;
14
+ skipSharingNextInternals?: boolean;
15
+ automaticPageStitching?: boolean;
16
+ debug?: boolean;
12
17
  }
13
- interface NextFederationPluginOptions extends moduleFederationPlugin.ModuleFederationPluginOptions {
14
- extraOptions: NextFederationPluginExtraOptions;
18
+ export interface NextFederationPluginOptions extends moduleFederationPlugin.ModuleFederationPluginOptions {
19
+ extraOptions: NextFederationPluginExtraOptions;
15
20
  }
16
- //#endregion
17
- export { NextFederationPluginOptions };
18
- //# sourceMappingURL=next-fragments.d.ts.map
@@ -0,0 +1,14 @@
1
+ import type { RuleSetConditionAbsolute } from 'webpack';
2
+ /**
3
+ * Compares two regular expressions or other types of conditions to see if they are equal.
4
+ *
5
+ * @param x - The first condition to compare. It can be a string, a RegExp, a function that takes a string and returns a boolean, an array of RuleSetConditionAbsolute, or undefined.
6
+ * @param y - The second condition to compare. It is always a RegExp.
7
+ * @returns True if the conditions are equal, false otherwise.
8
+ *
9
+ * @remarks
10
+ * This function compares two conditions to see if they are equal in terms of their source,
11
+ * global, ignoreCase, and multiline properties. It is used to check if two conditions match
12
+ * the same pattern. If the first condition is not a RegExp, the function will always return false.
13
+ */
14
+ export declare const regexEqual: (x: string | RegExp | ((value: string) => boolean) | RuleSetConditionAbsolute[] | undefined, y: RegExp) => boolean;
@@ -0,0 +1,14 @@
1
+ import type { RuleSetConditionAbsolute } from 'webpack';
2
+ /**
3
+ * Compares two regular expressions or other types of conditions to see if they are equal.
4
+ *
5
+ * @param x - The first condition to compare. It can be a string, a RegExp, a function that takes a string and returns a boolean, an array of RuleSetConditionAbsolute, or undefined.
6
+ * @param y - The second condition to compare. It is always a RegExp.
7
+ * @returns True if the conditions are equal, false otherwise.
8
+ *
9
+ * @remarks
10
+ * This function compares two conditions to see if they are equal in terms of their source,
11
+ * global, ignoreCase, and multiline properties. It is used to check if two conditions match
12
+ * the same pattern. If the first condition is not a RegExp, the function will always return false.
13
+ */
14
+ export declare const regexEqual: (x: string | RegExp | ((value: string) => boolean) | RuleSetConditionAbsolute[] | undefined, y: RegExp) => boolean;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Function to remove unnecessary shared keys from the default share scope.
3
+ * It iterates over each key in the shared object and checks against the default share scope.
4
+ * If a key is found in the default share scope, a warning is logged and the key is removed from the shared object.
5
+ *
6
+ * @param {Record<string, unknown>} shared - The shared object to be checked.
7
+ */
8
+ export declare function removeUnnecessarySharedKeys(shared: Record<string, unknown>): void;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Function to remove unnecessary shared keys from the default share scope.
3
+ * It iterates over each key in the shared object and checks against the default share scope.
4
+ * If a key is found in the default share scope, a warning is logged and the key is removed from the shared object.
5
+ *
6
+ * @param {Record<string, unknown>} shared - The shared object to be checked.
7
+ */
8
+ export declare function removeUnnecessarySharedKeys(shared: Record<string, unknown>): void;
@@ -0,0 +1,6 @@
1
+ import type { moduleFederationPlugin } from '@module-federation/sdk';
2
+ import type { NextFederationPluginExtraOptions, NextFederationPluginOptions } from './next-fragments';
3
+ export declare function setOptions(options: NextFederationPluginOptions): {
4
+ mainOptions: moduleFederationPlugin.ModuleFederationPluginOptions;
5
+ extraOptions: NextFederationPluginExtraOptions;
6
+ };
@@ -0,0 +1,6 @@
1
+ import type { moduleFederationPlugin } from '@module-federation/sdk';
2
+ import type { NextFederationPluginExtraOptions, NextFederationPluginOptions } from './next-fragments';
3
+ export declare function setOptions(options: NextFederationPluginOptions): {
4
+ mainOptions: moduleFederationPlugin.ModuleFederationPluginOptions;
5
+ extraOptions: NextFederationPluginExtraOptions;
6
+ };