@module-federation/nextjs-mf 7.0.8 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/CHANGELOG.md +423 -340
  2. package/README.md +26 -12
  3. package/client/MFClient.js +1 -2
  4. package/client/MFClient.js.map +1 -1
  5. package/client/RemoteContainer.js +2 -1
  6. package/client/RemoteContainer.js.map +1 -1
  7. package/client/RemotePages.js +2 -1
  8. package/client/RemotePages.js.map +1 -1
  9. package/client/UrlNode.js +2 -10
  10. package/client/UrlNode.js.map +1 -1
  11. package/node.d.ts +1 -1
  12. package/node.js.map +1 -1
  13. package/package.json +5 -9
  14. package/src/default-delegate.js +64 -9
  15. package/src/default-delegate.js.map +1 -1
  16. package/src/index.d.ts +1 -1
  17. package/src/internal.d.ts +18 -12
  18. package/src/internal.js +49 -45
  19. package/src/internal.js.map +1 -1
  20. package/src/loaders/delegateLoader.d.ts +5 -2
  21. package/src/loaders/delegateLoader.js +19 -9
  22. package/src/loaders/delegateLoader.js.map +1 -1
  23. package/src/loaders/fixImageLoader.d.ts +12 -11
  24. package/src/loaders/fixImageLoader.js +14 -12
  25. package/src/loaders/fixImageLoader.js.map +1 -1
  26. package/src/loaders/fixUrlLoader.d.ts +7 -7
  27. package/src/loaders/fixUrlLoader.js +11 -11
  28. package/src/loaders/fixUrlLoader.js.map +1 -1
  29. package/src/loaders/helpers.d.ts +10 -3
  30. package/src/loaders/helpers.js +22 -13
  31. package/src/loaders/helpers.js.map +1 -1
  32. package/src/loaders/inject-hoist.d.ts +11 -0
  33. package/src/loaders/inject-hoist.js +7 -0
  34. package/src/loaders/inject-hoist.js.map +1 -1
  35. package/src/loaders/nextPageMapLoader.d.ts +12 -3
  36. package/src/loaders/nextPageMapLoader.js +45 -29
  37. package/src/loaders/nextPageMapLoader.js.map +1 -1
  38. package/src/loaders/patchDefaultSharedLoader.d.ts +9 -0
  39. package/src/loaders/patchDefaultSharedLoader.js +11 -0
  40. package/src/loaders/patchDefaultSharedLoader.js.map +1 -1
  41. package/src/loaders/patchNextClientPageLoader.d.ts +4 -2
  42. package/src/loaders/patchNextClientPageLoader.js +36 -18
  43. package/src/loaders/patchNextClientPageLoader.js.map +1 -1
  44. package/src/plugins/CopyFederationPlugin.d.ts +13 -0
  45. package/src/plugins/CopyFederationPlugin.js +40 -19
  46. package/src/plugins/CopyFederationPlugin.js.map +1 -1
  47. package/src/plugins/JsonpChunkLoading.d.ts +11 -0
  48. package/src/plugins/JsonpChunkLoading.js +25 -4
  49. package/src/plugins/JsonpChunkLoading.js.map +1 -1
  50. package/src/plugins/NextFederationPlugin/apply-client-plugins.d.ts +2 -2
  51. package/src/plugins/NextFederationPlugin/apply-client-plugins.js +2 -2
  52. package/src/plugins/NextFederationPlugin/apply-server-plugins.d.ts +17 -10
  53. package/src/plugins/NextFederationPlugin/apply-server-plugins.js +18 -10
  54. package/src/plugins/NextFederationPlugin/apply-server-plugins.js.map +1 -1
  55. package/src/plugins/NextFederationPlugin/index.d.ts +8 -2
  56. package/src/plugins/NextFederationPlugin/index.js +20 -17
  57. package/src/plugins/NextFederationPlugin/index.js.map +1 -1
  58. package/src/plugins/NextFederationPlugin/next-fragments.d.ts +22 -16
  59. package/src/plugins/NextFederationPlugin/next-fragments.js +23 -16
  60. package/src/plugins/NextFederationPlugin/next-fragments.js.map +1 -1
  61. package/src/plugins/NextFederationPlugin/regex-equal.d.ts +8 -8
  62. package/src/plugins/NextFederationPlugin/regex-equal.js +7 -7
  63. package/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.d.ts +7 -0
  64. package/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js +20 -9
  65. package/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js.map +1 -1
  66. package/src/plugins/NextFederationPlugin/set-options.d.ts +6 -6
  67. package/src/plugins/NextFederationPlugin/set-options.js +10 -6
  68. package/src/plugins/NextFederationPlugin/set-options.js.map +1 -1
  69. package/src/plugins/NextFederationPlugin/validate-options.d.ts +12 -13
  70. package/src/plugins/NextFederationPlugin/validate-options.js +14 -15
  71. package/src/plugins/NextFederationPlugin/validate-options.js.map +1 -1
  72. package/src/plugins/container/InvertedContainerPlugin.d.ts +1 -0
  73. package/src/plugins/container/InvertedContainerPlugin.js +8 -4
  74. package/src/plugins/container/InvertedContainerPlugin.js.map +1 -1
  75. package/src/plugins/container/InvertedContainerRuntimeModule.d.ts +16 -4
  76. package/src/plugins/container/InvertedContainerRuntimeModule.js +67 -32
  77. package/src/plugins/container/InvertedContainerRuntimeModule.js.map +1 -1
  78. package/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.d.ts +27 -5
  79. package/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js +34 -57
  80. package/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js.map +1 -1
  81. package/src/plugins/container/types.d.ts +1 -1
  82. package/src/types.d.ts +3 -0
  83. package/utilities.js.map +1 -1
  84. package/utils/Template.d.ts +1 -1
  85. package/utils/Template.js +23 -15
  86. package/utils/Template.js.map +1 -1
  87. package/utils/build-utils.d.ts +9 -0
  88. package/utils/build-utils.js +9 -0
  89. package/utils/build-utils.js.map +1 -1
  90. package/utils/flushedChunks.d.ts +15 -0
  91. package/utils/flushedChunks.js +8 -0
  92. package/utils/flushedChunks.js.map +1 -1
  93. package/utils/index.d.ts +26 -2
  94. package/utils/index.js +21 -0
  95. package/utils/index.js.map +1 -1
@@ -9,16 +9,18 @@ const path_1 = __importDefault(require("path"));
9
9
  const InvertedContainerPlugin_1 = __importDefault(require("../container/InvertedContainerPlugin"));
10
10
  const JsonpChunkLoading_1 = __importDefault(require("../JsonpChunkLoading"));
11
11
  /**
12
- * Applies server-specific plugins.
12
+ * This function applies server-specific plugins to the webpack compiler.
13
13
  *
14
- * @param compiler - The Webpack compiler instance.
15
- * @param options - The ModuleFederationPluginOptions instance.
14
+ * @param {Compiler} compiler - The Webpack compiler instance.
15
+ * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
16
16
  *
17
+ * @returns {void}
17
18
  */
18
19
  function applyServerPlugins(compiler, options) {
19
20
  // Import the StreamingTargetPlugin from @module-federation/node
20
21
  const { StreamingTargetPlugin } = require('@module-federation/node');
21
22
  new JsonpChunkLoading_1.default({ server: true }).apply(compiler);
23
+ // Apply the DelegatesModulePlugin to the compiler
22
24
  new DelegateModulesPlugin_1.default({
23
25
  runtime: 'webpack-runtime',
24
26
  remotes: options.remotes,
@@ -38,9 +40,11 @@ function applyServerPlugins(compiler, options) {
38
40
  }
39
41
  exports.applyServerPlugins = applyServerPlugins;
40
42
  /**
41
- * Configures server-specific library and filename options.
43
+ * This function configures server-specific library and filename options.
42
44
  *
43
- * @param options - The ModuleFederationPluginOptions instance.
45
+ * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
46
+ *
47
+ * @returns {void}
44
48
  *
45
49
  * @remarks
46
50
  * This function configures the library and filename options for server builds. The library option is
@@ -59,10 +63,12 @@ function configureServerLibraryAndFilename(options) {
59
63
  }
60
64
  exports.configureServerLibraryAndFilename = configureServerLibraryAndFilename;
61
65
  /**
62
- * Patches Next.js' default externals function to make sure shared modules are bundled and not treated as external.
66
+ * This function patches Next.js' default externals function to make sure shared modules are bundled and not treated as external.
67
+ *
68
+ * @param {Compiler} compiler - The Webpack compiler instance.
69
+ * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
63
70
  *
64
- * @param compiler - The Webpack compiler instance.
65
- * @param options - The ModuleFederationPluginOptions instance.
71
+ * @returns {void}
66
72
  *
67
73
  * @remarks
68
74
  * In server builds, all node modules are treated as external, which prevents them from being shared
@@ -129,9 +135,11 @@ function handleServerExternals(compiler, options) {
129
135
  }
130
136
  exports.handleServerExternals = handleServerExternals;
131
137
  /**
132
- * Configures server-specific compiler options.
138
+ * This function configures server-specific compiler options.
139
+ *
140
+ * @param {Compiler} compiler - The Webpack compiler instance.
133
141
  *
134
- * @param compiler - The Webpack compiler instance.
142
+ * @returns {void}
135
143
  *
136
144
  * @remarks
137
145
  * This function configures the compiler options for server builds. It turns off the compiler target on node
@@ -1 +1 @@
1
- {"version":3,"file":"apply-server-plugins.js","sourceRoot":"","sources":["../../../../../../packages/nextjs-mf/src/plugins/NextFederationPlugin/apply-server-plugins.ts"],"names":[],"mappings":";;;;;;AAEA,2HAAmG;AACnG,gDAAwB;AACxB,mGAA2E;AAC3E,6EAAqD;AAErD;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAChC,QAAkB,EAClB,OAAsC;IAEtC,gEAAgE;IAChE,MAAM,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACrE,IAAI,2BAAiB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAExD,IAAI,+BAAqB,CAAC;QACxB,OAAO,EAAE,iBAAiB;QAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,SAAS,EAAE,OAAO,CAAC,IAAI;KACxB,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAEnB,2FAA2F;IAC3F,IAAI,qBAAqB,CAAC,OAAO,EAAE;QACjC,sBAAsB,EAAE,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,sBAAsB;KAC1E,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAEnB,0DAA0D;IAC1D,IAAI,iCAAuB,CAAC;QAC1B,OAAO,EAAE,iBAAiB;QAC1B,SAAS,EAAE,OAAO,CAAC,IAAI;QACvB,OAAO,EAAE,OAAO,CAAC,OAAiC;QAClD,KAAK,EAAE,KAAK;KACb,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AACrB,CAAC;AA1BD,gDA0BC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,iCAAiC,CAC/C,OAAsC;IAEtC,yFAAyF;IACzF,OAAO,CAAC,OAAO,GAAG;QAChB,IA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;IACpD,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,YAAY,GAAG;QAC3C,IAAI,EAAE,iBAAiB;KACxB,CAAC;AACJ,CAAC;AAtBD,wEAsBC"}
1
+ {"version":3,"file":"apply-server-plugins.js","sourceRoot":"","sources":["../../../../../../packages/nextjs-mf/src/plugins/NextFederationPlugin/apply-server-plugins.ts"],"names":[],"mappings":";;;;;;AAEA,2HAAmG;AACnG,gDAAwB;AACxB,mGAA2E;AAC3E,6EAAqD;AAErD;;;;;;;GAOG;AACH,SAAgB,kBAAkB,CAChC,QAAkB,EAClB,OAAsC;IAEtC,gEAAgE;IAChE,MAAM,EAAE,qBAAqB,EAAE,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACrE,IAAI,2BAAiB,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAExD,kDAAkD;IAClD,IAAI,+BAAqB,CAAC;QACxB,OAAO,EAAE,iBAAiB;QAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,SAAS,EAAE,OAAO,CAAC,IAAI;KACxB,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAEnB,2FAA2F;IAC3F,IAAI,qBAAqB,CAAC,OAAO,EAAE;QACjC,sBAAsB,EAAE,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,sBAAsB;KAC1E,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAEnB,0DAA0D;IAC1D,IAAI,iCAAuB,CAAC;QAC1B,OAAO,EAAE,iBAAiB;QAC1B,SAAS,EAAE,OAAO,CAAC,IAAI;QACvB,OAAO,EAAE,OAAO,CAAC,OAAiC;QAClD,KAAK,EAAE,KAAK;KACb,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AACrB,CAAC;AA3BD,gDA2BC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,iCAAiC,CAC/C,OAAsC;IAEtC,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AAW,GAAG,SAAS,CAAC;IAEtD,iEAAiE;IACjE,oDAAoD;IACpD,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,YAAY,GAAG;QAC3C,IAAI,EAAE,iBAAiB;KACxB,CAAC;AACJ,CAAC;AAtBD,wEAsBC"}
@@ -1,8 +1,7 @@
1
1
  import type { ModuleFederationPluginOptions, NextFederationPluginExtraOptions, NextFederationPluginOptions } from '@module-federation/utilities';
2
2
  import type { Compiler } from 'webpack';
3
3
  /**
4
- * NextFederationPlugin is a webpack plugin that handles Next.js application
5
- * federation using Module Federation.
4
+ * NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.
6
5
  */
7
6
  export declare class NextFederationPlugin {
8
7
  _options: ModuleFederationPluginOptions;
@@ -13,6 +12,13 @@ export declare class NextFederationPlugin {
13
12
  * @param options The options to configure the plugin.
14
13
  */
15
14
  constructor(options: NextFederationPluginOptions);
15
+ /**
16
+ * The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.
17
+ * @param compiler The webpack compiler object.
18
+ */
16
19
  apply(compiler: Compiler): void;
17
20
  }
21
+ /**
22
+ * Exporting NextFederationPlugin as default
23
+ */
18
24
  export default NextFederationPlugin;
@@ -1,7 +1,8 @@
1
- /*
2
- MIT License http://www.opensource.org/licenses/mit-license.php
3
- Author Zackary Jackson @ScriptedAlchemy
4
- */
1
+ /**
2
+ * MIT License http://www.opensource.org/licenses/mit-license.php
3
+ * Author Zackary Jackson @ScriptedAlchemy
4
+ * This module contains the NextFederationPlugin class which is a webpack plugin that handles Next.js application federation using Module Federation.
5
+ */
5
6
  'use strict';
6
7
  var __importDefault = (this && this.__importDefault) || function (mod) {
7
8
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -20,8 +21,7 @@ const validate_options_1 = require("./validate-options");
20
21
  const apply_server_plugins_1 = require("./apply-server-plugins");
21
22
  const apply_client_plugins_1 = require("./apply-client-plugins");
22
23
  /**
23
- * NextFederationPlugin is a webpack plugin that handles Next.js application
24
- * federation using Module Federation.
24
+ * NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.
25
25
  */
26
26
  class NextFederationPlugin {
27
27
  /**
@@ -34,11 +34,16 @@ class NextFederationPlugin {
34
34
  this._options = mainOptions;
35
35
  this._extraOptions = extraOptions;
36
36
  }
37
+ /**
38
+ * The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.
39
+ * @param compiler The webpack compiler object.
40
+ */
37
41
  apply(compiler) {
38
42
  // Validate the compiler options
39
43
  const validCompile = (0, validate_options_1.validateCompilerOptions)(compiler);
40
- if (!validCompile)
44
+ if (!validCompile) {
41
45
  return;
46
+ }
42
47
  // Validate the NextFederationPlugin options
43
48
  (0, validate_options_1.validatePluginOptions)(this._options);
44
49
  // Check if the compiler is for the server or client
@@ -70,6 +75,7 @@ class NextFederationPlugin {
70
75
  else {
71
76
  (0, apply_client_plugins_1.applyClientPlugins)(compiler, this._options, this._extraOptions);
72
77
  }
78
+ //@ts-ignore
73
79
  (0, next_fragments_1.applyPathFixes)(compiler, this._extraOptions);
74
80
  // @ts-ignore
75
81
  const hostFederationPluginOptions = {
@@ -110,21 +116,15 @@ class NextFederationPlugin {
110
116
  }).apply(compiler);
111
117
  // @ts-ignore
112
118
  new ModuleFederationPlugin(hostFederationPluginOptions).apply(compiler);
113
- if (Object.keys(this._options?.remotes || {}).length > 0 ||
114
- Object.keys(this._options?.exposes || {}).length > 0) {
119
+ const hasRemotesOrExposes = Object.keys(this._options?.remotes || {}).length > 0 || Object.keys(this._options?.exposes || {}).length > 0;
120
+ if (hasRemotesOrExposes) {
115
121
  const commonOptions = {
116
122
  ...hostFederationPluginOptions,
117
123
  name: 'host_inner_ctn',
118
124
  runtime: isServer ? 'webpack-runtime' : 'webpack',
119
125
  filename: `host_inner_ctn.js`,
120
- library: {
121
- ...hostFederationPluginOptions.library,
122
- name: this._options.name,
123
- },
124
- shared: {
125
- ...hostFederationPluginOptions.shared,
126
- ...defaultShared,
127
- },
126
+ library: { ...hostFederationPluginOptions.library, name: this._options.name },
127
+ shared: { ...hostFederationPluginOptions.shared, ...defaultShared },
128
128
  };
129
129
  // @ts-ignore
130
130
  new ModuleFederationPlugin({
@@ -135,5 +135,8 @@ class NextFederationPlugin {
135
135
  }
136
136
  }
137
137
  exports.NextFederationPlugin = NextFederationPlugin;
138
+ /**
139
+ * Exporting NextFederationPlugin as default
140
+ */
138
141
  exports.default = NextFederationPlugin;
139
142
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/nextjs-mf/src/plugins/NextFederationPlugin/index.ts"],"names":[],"mappings":"AAAA;;;EAGE;AACF,YAAY,CAAC;;;;;;AAQb,4DAAsE;AAEtE,mFAA2D;AAC3D,qDAK0B;AAE1B,6CAA8C;AAC9C,mIAAqG;AACrG,uEAAoE;AACpE,qFAA+E;AAC/E,+CAA2C;AAC3C,yDAG4B;AAC5B,iEAKgC;AAChC,iEAA4D;AAE5D;;;GAGG;AACH,MAAa,oBAAoB;IAI/B;;;;OAIG;IACH,YAAY,OAAoC;QAC9C,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,IAAA,wBAAU,EAAC,OAAO,CAAC,CAAC;QAC1D,IAAI,CAAC,QAAQ,GAAG,WAAW,CAAC;QAC5B,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,QAAkB;QACtB,gCAAgC;QAChC,MAAM,YAAY,GAAG,IAAA,0CAAuB,EAAC,QAAQ,CAAC,CAAC;QACvD,IAAI,CAAC,YAAY;YAAE,OAAO;QAC1B,4CAA4C;QAC5C,IAAA,wCAAqB,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAErC,oDAAoD;QACpD,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ,CAAC;QACpD,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;QAE7B,iCAAiC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CAAC;QACxE,IACE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC;YACpD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,EACpD;YACA,MAAM,aAAa,GAAG;gBACpB,GAAG,2BAA2B;gBAC9B,IAAI,EAAE,gBAAgB;gBACtB,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS;gBACjD,QAAQ,EAAE,mBAAmB;gBAC7B,OAAO,EAAE;oBACP,GAAG,2BAA2B,CAAC,OAAO;oBACtC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI;iBACzB;gBACD,MAAM,EAAE;oBACN,GAAG,2BAA2B,CAAC,MAAM;oBACrC,GAAG,aAAa;iBACjB;aACF,CAAC;YAEF,aAAa;YACb,IAAI,sBAAsB,CAAC;gBACzB,GAAG,aAAa;aACjB,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;SACpB;QAED,IAAI,sDAAsC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC/D,CAAC;CACF;AAlID,oDAkIC;AAED,kBAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/nextjs-mf/src/plugins/NextFederationPlugin/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,YAAY,CAAC;;;;;;AASb,4DAAsE;AAEtE,mFAA2D;AAC3D,qDAK0B;AAC1B,6CAA8C;AAC9C,mIAAqG;AACrG,uEAAoE;AACpE,qFAA+E;AAC/E,+CAA2C;AAC3C,yDAG4B;AAC5B,iEAKgC;AAEhC,iEAA4D;AAE5D;;GAEG;AACH,MAAa,oBAAoB;IAI/B;;;;OAIG;IACH,YAAY,OAAoC;QAC9C,MAAM,EAAE,WAA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BAAsB,CAAC;gBACzB,GAAG,aAAa;aACjB,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;SACpB;QAED,IAAI,sDAAsC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC/D,CAAC;CACF;AAjID,oDAiIC;AAED;;GAEG;AACH,kBAAe,oBAAoB,CAAC"}
@@ -10,25 +10,31 @@ type ConstructableModuleFederationPlugin = new (options: ModuleFederationPluginO
10
10
  */
11
11
  export declare function getModuleFederationPluginConstructor(isServer: boolean, compiler: Compiler): ConstructableModuleFederationPlugin;
12
12
  /**
13
-
14
- Set up default shared values based on the environment.
15
- @param isServer - Boolean indicating if the code is running on the server.
16
- @returns The default share scope based on the environment.
13
+ * Set up default shared values based on the environment.
14
+ * @param {boolean} isServer - Boolean indicating if the code is running on the server.
15
+ * @returns {SharedObject} The default share scope based on the environment.
17
16
  */
18
17
  export declare const retrieveDefaultShared: (isServer: boolean) => SharedObject;
19
18
  /**
20
-
21
- Apply remote delegates.
22
-
23
- This function adds the remote delegates feature by configuring and injecting the appropriate loader that will look
24
- for internal delegate hoist or delegate hoist container and load it using a custom delegateLoader.
25
- Once loaded, it will then look for the available delegates that will be used to configure the remote
26
- that the hoisted module will be dependent upon.
27
-
28
- @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
29
-
30
- @param {Compiler} compiler - The Webpack compiler instance.
19
+ * Apply remote delegates.
20
+ *
21
+ * This function adds the remote delegates feature by configuring and injecting the appropriate loader that will look
22
+ * for internal delegate hoist or delegate hoist container and load it using a custom delegateLoader.
23
+ * Once loaded, it will then look for the available delegates that will be used to configure the remote
24
+ * that the hoisted module will be dependent upon.
25
+ *
26
+ * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
27
+ * @param {Compiler} compiler - The Webpack compiler instance.
31
28
  */
32
29
  export declare function applyRemoteDelegates(options: ModuleFederationPluginOptions, compiler: Compiler): void;
33
- export declare const applyPathFixes: (compiler: any, options: any) => void;
30
+ /**
31
+ * Apply path fixes.
32
+ *
33
+ * This function applies fixes to the path for certain loaders. It checks if the fix is enabled in the options
34
+ * and if the loader is present in the rule. If both conditions are met, it injects the fix loader.
35
+ *
36
+ * @param {Compiler} compiler - The Webpack compiler instance.
37
+ * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
38
+ */
39
+ export declare const applyPathFixes: (compiler: Compiler, options: ModuleFederationPluginOptions) => void;
34
40
  export {};
@@ -19,10 +19,9 @@ function getModuleFederationPluginConstructor(isServer, compiler) {
19
19
  }
20
20
  exports.getModuleFederationPluginConstructor = getModuleFederationPluginConstructor;
21
21
  /**
22
-
23
- Set up default shared values based on the environment.
24
- @param isServer - Boolean indicating if the code is running on the server.
25
- @returns The default share scope based on the environment.
22
+ * Set up default shared values based on the environment.
23
+ * @param {boolean} isServer - Boolean indicating if the code is running on the server.
24
+ * @returns {SharedObject} The default share scope based on the environment.
26
25
  */
27
26
  const retrieveDefaultShared = (isServer) => {
28
27
  // If the code is running on the server, treat some Next.js internals as import false to make them external
@@ -35,17 +34,15 @@ const retrieveDefaultShared = (isServer) => {
35
34
  };
36
35
  exports.retrieveDefaultShared = retrieveDefaultShared;
37
36
  /**
38
-
39
- Apply remote delegates.
40
-
41
- This function adds the remote delegates feature by configuring and injecting the appropriate loader that will look
42
- for internal delegate hoist or delegate hoist container and load it using a custom delegateLoader.
43
- Once loaded, it will then look for the available delegates that will be used to configure the remote
44
- that the hoisted module will be dependent upon.
45
-
46
- @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
47
-
48
- @param {Compiler} compiler - The Webpack compiler instance.
37
+ * Apply remote delegates.
38
+ *
39
+ * This function adds the remote delegates feature by configuring and injecting the appropriate loader that will look
40
+ * for internal delegate hoist or delegate hoist container and load it using a custom delegateLoader.
41
+ * Once loaded, it will then look for the available delegates that will be used to configure the remote
42
+ * that the hoisted module will be dependent upon.
43
+ *
44
+ * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
45
+ * @param {Compiler} compiler - The Webpack compiler instance.
49
46
  */
50
47
  function applyRemoteDelegates(options, compiler) {
51
48
  if (options.remotes) {
@@ -75,11 +72,20 @@ function applyRemoteDelegates(options, compiler) {
75
72
  }
76
73
  }
77
74
  exports.applyRemoteDelegates = applyRemoteDelegates;
78
- // @ts-ignore
75
+ /**
76
+ * Apply path fixes.
77
+ *
78
+ * This function applies fixes to the path for certain loaders. It checks if the fix is enabled in the options
79
+ * and if the loader is present in the rule. If both conditions are met, it injects the fix loader.
80
+ *
81
+ * @param {Compiler} compiler - The Webpack compiler instance.
82
+ * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
83
+ */
79
84
  const applyPathFixes = (compiler, options) => {
80
85
  //@ts-ignore
81
86
  compiler.options.module.rules.forEach((rule) => {
82
87
  // next-image-loader fix which adds remote's hostname to the assets url
88
+ //@ts-ignore
83
89
  if (options.enableImageLoaderFix && (0, helpers_1.hasLoader)(rule, 'next-image-loader')) {
84
90
  // childCompiler.options.module.parser.javascript?.url = 'relative';
85
91
  (0, helpers_1.injectRuleLoader)(rule, {
@@ -87,6 +93,7 @@ const applyPathFixes = (compiler, options) => {
87
93
  });
88
94
  }
89
95
  // url-loader fix for which adds remote's hostname to the assets url
96
+ //@ts-ignore
90
97
  if (options.enableUrlLoaderFix && (0, helpers_1.hasLoader)(rule, 'url-loader')) {
91
98
  (0, helpers_1.injectRuleLoader)({
92
99
  loader: require.resolve('../../loaders/fixUrlLoader'),
@@ -1 +1 @@
1
- {"version":3,"file":"next-fragments.js","sourceRoot":"","sources":["../../../../../../packages/nextjs-mf/src/plugins/NextFederationPlugin/next-fragments.ts"],"names":[],"mappings":";;;AAOA,6CAIwB;AACxB,mDAAoE;AAMpE;;;;;GAKG;AACH,SAAgB,oCAAoC,CAClD,QAAiB,EACjB,QAAkB;IAElB,IAAI,QAAQ,EAAE;QACZ,OAAO,OAAO,CAAC,yBAAyB,CAAC;aACtC,oBAA2D,CAA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,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC7C,uEAAuE;QACvE,IAAI,OAAO,CAAC,oBAAoB,IAAI,IAAA,mBAAS,EAAC,IAAI,EAAE,mBAAmB,CAAC,EAAE;YACxE,oEAAoE;YACpE,IAAA,0BAAgB,EAAC,IAAI,EAAE;gBACrB,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,8BAA8B,CAAC;aACxD,CAAC,CAAC;SACJ;QAED,oEAAoE;QACpE,IAAI,OAAO,CAAC,kBAAkB,IAAI,IAAA,mBAAS,EAAC,IAAI,EAAE,YAAY,CAAC,EAAE;YAC/D,IAAA,0BAAgB,EAAC;gBACf,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,4BAA4B,CAAC;aACtD,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAlBW,QAAA,cAAc,kBAkBzB"}
1
+ {"version":3,"file":"next-fragments.js","sourceRoot":"","sources":["../../../../../../packages/nextjs-mf/src/plugins/NextFederationPlugin/next-fragments.ts"],"names":[],"mappings":";;;AAOA,6CAIwB;AACxB,mDAAoE;AAMpE;;;;;GAKG;AACH,SAAgB,oCAAoC,CAClD,QAAiB,EACjB,QAAkB;IAElB,IAAI,QAAQ,EAAE;QACZ,OAAO,OAAO,CAAC,yBAAyB,CAAC;aACtC,oBAA2D,CAAC;KAChE;IACD,OAAO,QAAQ,CAAC,OAAO,CAAC,SAAS;SAC9B,sBAAwE,CAAC;AAC9E,CAAC;AAVD,oFAUC;AAED;;;;GAIG;AACI,MAAM,qBAAqB,GAAG,CAAC,QAAiB,EAAgB,EAAE;IACvE,2GAA2G;IAC3G,kGAAkG;IAClG,IAAI,QAAQ,EAAE;QACZ,OAAO,8BAAmB,CAAC;KAC5B;IACD,gFAAgF;IAChF,OAAO,sCAA2B,CAAC;AACrC,CAAC,CAAC;AARW,QAAA,qBAAqB,yBAQhC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AC;SACJ;QAED,oEAAoE;QACpE,YAAY;QACZ,IAAI,OAAO,CAAC,kBAAkB,IAAI,IAAA,mBAAS,EAAC,IAAI,EAAE,YAAY,CAAC,EAAE;YAC/D,IAAA,0BAAgB,EAAC;gBACf,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,4BAA4B,CAAC;aACtD,CAAC,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AApBW,QAAA,cAAc,kBAoBzB"}
@@ -1,14 +1,14 @@
1
- import { RuleSetConditionAbsolute } from "webpack";
1
+ import { RuleSetConditionAbsolute } from 'webpack';
2
2
  /**
3
- * Compares two regular expressions to see if they are equal.
3
+ * Compares two regular expressions or other types of conditions to see if they are equal.
4
4
  *
5
- * @param x - The first regular expression to compare.
6
- * @param y - The second regular expression to compare.
7
- * @returns True if the regular expressions are equal, false otherwise.
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
8
  *
9
9
  * @remarks
10
- * This function compares two regular expressions to see if they are equal in terms of their source,
11
- * global, ignoreCase, and multiline properties. It is used to check if two regular expressions match
12
- * the same pattern.
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
13
  */
14
14
  export declare const regexEqual: (x: string | RegExp | RuleSetConditionAbsolute[] | ((value: string) => boolean) | undefined, y: RegExp) => boolean;
@@ -2,16 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.regexEqual = void 0;
4
4
  /**
5
- * Compares two regular expressions to see if they are equal.
5
+ * Compares two regular expressions or other types of conditions to see if they are equal.
6
6
  *
7
- * @param x - The first regular expression to compare.
8
- * @param y - The second regular expression to compare.
9
- * @returns True if the regular expressions are equal, false otherwise.
7
+ * @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.
8
+ * @param y - The second condition to compare. It is always a RegExp.
9
+ * @returns True if the conditions are equal, false otherwise.
10
10
  *
11
11
  * @remarks
12
- * This function compares two regular expressions to see if they are equal in terms of their source,
13
- * global, ignoreCase, and multiline properties. It is used to check if two regular expressions match
14
- * the same pattern.
12
+ * This function compares two conditions to see if they are equal in terms of their source,
13
+ * global, ignoreCase, and multiline properties. It is used to check if two conditions match
14
+ * the same pattern. If the first condition is not a RegExp, the function will always return false.
15
15
  */
16
16
  const regexEqual = (x, y) => {
17
17
  return (x instanceof RegExp &&
@@ -1 +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
+ */
1
8
  export declare function removeUnnecessarySharedKeys(shared: Record<string, unknown>): void;
@@ -1,20 +1,31 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.removeUnnecessarySharedKeys = void 0;
4
- // Utility function to remove unnecessary shared keys from the default share scope
4
+ /**
5
+ * Utility function to remove unnecessary shared keys from the default share scope.
6
+ * It checks each key in the shared object against the default share scope.
7
+ * If a key is found in the default share scope, a warning is logged and the key is removed from the shared object.
8
+ *
9
+ * @param {Record<string, unknown>} shared - The shared object to be checked.
10
+ */
5
11
  const internal_1 = require("../../internal");
12
+ /**
13
+ * Function to remove unnecessary shared keys from the default share scope.
14
+ * It iterates over each key in the shared object and checks against the default share scope.
15
+ * If a key is found in the default share scope, a warning is logged and the key is removed from the shared object.
16
+ *
17
+ * @param {Record<string, unknown>} shared - The shared object to be checked.
18
+ */
6
19
  function removeUnnecessarySharedKeys(shared) {
7
- const warnings = Object.keys(shared).reduce((acc, key) => {
20
+ Object.keys(shared).forEach((key) => {
21
+ /**
22
+ * If the key is found in the default share scope, log a warning and remove the key from the shared object.
23
+ */
8
24
  if (internal_1.DEFAULT_SHARE_SCOPE[key]) {
9
- acc.push(`[nextjs-mf] You are sharing ${key} from the default share scope. This is not necessary and can be removed.`);
10
- // Use a type assertion to inform TypeScript that 'key' can be used as an index for the 'shared' object
25
+ console.warn(`%c[nextjs-mf] You are sharing ${key} from the default share scope. This is not necessary and can be removed.`, 'color: red');
11
26
  delete shared[key];
12
27
  }
13
- return acc;
14
- }, []);
15
- if (warnings.length > 0) {
16
- console.warn('%c' + warnings.join('\n'), 'color: red');
17
- }
28
+ });
18
29
  }
19
30
  exports.removeUnnecessarySharedKeys = removeUnnecessarySharedKeys;
20
31
  //# sourceMappingURL=remove-unnecessary-shared-keys.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"remove-unnecessary-shared-keys.js","sourceRoot":"","sources":["../../../../../../packages/nextjs-mf/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.ts"],"names":[],"mappings":";;;AAAA,kFAAkF;AAClF,6CAAqD;AAErD,SAAgB,2BAA2B,CACzC,MAA+B;IAE/B,MAAM,QAAQ,GAAa,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CACnD,CAAC,GAAa,EAAE,GAAW,EAAE,EAAE;QAC7B,IAAI,8BAAmB,CAAC,GAAG,CAAC,EAAE;YAC5B,GAAG,CAAC,IAAI,CACN,+BAA+B,GAAG,0EAA0E,CAC7G,CAAC;YACF,uGAAuG;YACvG,OAAQ,MAAqC,CAAC,GAAG,CAAC,CAAC;SACpD;QACD,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAE,CACH,CAAC;IAEF,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE;QACvB,OAAO,CAAC,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,CAAC;KACxD;AACH,CAAC;AApBD,kEAoBC"}
1
+ {"version":3,"file":"remove-unnecessary-shared-keys.js","sourceRoot":"","sources":["../../../../../../packages/nextjs-mf/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,6CAAqD;AAErD;;;;;;GAMG;AACH,SAAgB,2BAA2B,CAAC,MAA+B;IACzE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE;QAC1C;;WAEG;QACH,IAAI,8BAAmB,CAAC,GAAG,CAAC,EAAE;YAC5B,OAAO,CAAC,IAAI,CACV,iCAAiC,GAAG,0EAA0E,EAC9G,YAAY,CACb,CAAC;YACF,OAAQ,MAAqC,CAAC,GAAG,CAAC,CAAC;SACpD;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAbD,kEAaC"}
@@ -1,18 +1,18 @@
1
1
  import { ModuleFederationPluginOptions, NextFederationPluginExtraOptions, NextFederationPluginOptions } from '@module-federation/utilities';
2
2
  /**
3
- * Utility function to set the main and extra options.
3
+ * This function sets the main and extra options for NextFederationPlugin. It splits the options object into
4
+ * the main options and extra options, and sets default values for any options that are not defined.
4
5
  *
5
- * @param options - The NextFederationPluginOptions instance.
6
- * @returns An object containing the main options and extra options.
6
+ * @param {NextFederationPluginOptions} options - The options for NextFederationPlugin.
7
+ * @returns {Object} An object containing the main options and extra options.
7
8
  *
8
9
  * @remarks
9
- * This function sets the main and extra options for NextFederationPlugin. It splits the options object into
10
- * the main options and extra options, and sets default values for any options that are not defined. The default
11
- * extra options are:
10
+ * The default extra options are:
12
11
  * - automaticPageStitching: false
13
12
  * - enableImageLoaderFix: false
14
13
  * - enableUrlLoaderFix: false
15
14
  * - skipSharingNextInternals: false
15
+ * - debug: false
16
16
  */
17
17
  export declare function setOptions(options: NextFederationPluginOptions): {
18
18
  mainOptions: ModuleFederationPluginOptions;
@@ -2,22 +2,26 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setOptions = void 0;
4
4
  /**
5
- * Utility function to set the main and extra options.
5
+ * This function sets the main and extra options for NextFederationPlugin. It splits the options object into
6
+ * the main options and extra options, and sets default values for any options that are not defined.
6
7
  *
7
- * @param options - The NextFederationPluginOptions instance.
8
- * @returns An object containing the main options and extra options.
8
+ * @param {NextFederationPluginOptions} options - The options for NextFederationPlugin.
9
+ * @returns {Object} An object containing the main options and extra options.
9
10
  *
10
11
  * @remarks
11
- * This function sets the main and extra options for NextFederationPlugin. It splits the options object into
12
- * the main options and extra options, and sets default values for any options that are not defined. The default
13
- * extra options are:
12
+ * The default extra options are:
14
13
  * - automaticPageStitching: false
15
14
  * - enableImageLoaderFix: false
16
15
  * - enableUrlLoaderFix: false
17
16
  * - skipSharingNextInternals: false
17
+ * - debug: false
18
18
  */
19
19
  function setOptions(options) {
20
20
  const { extraOptions, ...mainOpts } = options;
21
+ /**
22
+ * Default extra options for NextFederationPlugin.
23
+ * @type {NextFederationPluginExtraOptions}
24
+ */
21
25
  const defaultExtraOptions = {
22
26
  automaticPageStitching: false,
23
27
  enableImageLoaderFix: false,
@@ -1 +1 @@
1
- {"version":3,"file":"set-options.js","sourceRoot":"","sources":["../../../../../../packages/nextjs-mf/src/plugins/NextFederationPlugin/set-options.ts"],"names":[],"mappings":";;;AAMA;;;;;;;;;;;;;;GAcG;AACH,SAAgB,UAAU,CAAC,OAAoC;IAI7D,MAAM,EAAE,YAAY,EAAE,GAAG,QAAQ,EAAE,GAAG,OAAO,CAAC;IAE9C,MAAM,mBAAmB,GAAqC;QAC5D,sBAAsB,EAAE,KAAK;QAC7B,oBAAoB,EAAE,KAAK;QAC3B,kBAAkB,EAAE,KAAK;QACzB,wBAAwB,EAAE,KAAK;QAC/B,KAAK,EAAE,KAAK;KACb,CAAC;IAEF,OAAO;QACL,WAAW,EAAE,QAAQ;QACrB,YAAY,EAAE,EAAE,GAAG,mBAAmB,EAAE,GAAG,YAAY,EAAE;KAC1D,CAAC;AACJ,CAAC;AAlBD,gCAkBC"}
1
+ {"version":3,"file":"set-options.js","sourceRoot":"","sources":["../../../../../../packages/nextjs-mf/src/plugins/NextFederationPlugin/set-options.ts"],"names":[],"mappings":";;;AAMA;;;;;;;;;;;;;;GAcG;AACH,SAAgB,UAAU,CAAC,OAAoC;IAI7D,MAAM,EAAE,YAAY,EAAE,GAAG,QAAQ,EAAE,GAAG,OAAO,CAAC;IAE9C;;;OAGG;IACH,MAAM,mBAAmB,GAAqC;QAC5D,sBAAsB,EAAE,KAAK;QAC7B,oBAAoB,EAAE,KAAK;QAC3B,kBAAkB,EAAE,KAAK;QACzB,wBAAwB,EAAE,KAAK;QAC/B,KAAK,EAAE,KAAK;KACb,CAAC;IAEF,OAAO;QACL,WAAW,EAAE,QAAQ;QACrB,YAAY,EAAE,EAAE,GAAG,mBAAmB,EAAE,GAAG,YAAY,EAAE;KAC1D,CAAC;AACJ,CAAC;AAtBD,gCAsBC"}
@@ -1,26 +1,25 @@
1
- import { Compiler } from "webpack";
2
- import { ModuleFederationPluginOptions } from "@module-federation/utilities";
1
+ import { Compiler } from 'webpack';
2
+ import { ModuleFederationPluginOptions } from '@module-federation/utilities';
3
3
  /**
4
- * Utility function to validate compiler options.
4
+ * Validates the compiler options.
5
5
  *
6
- * @param compiler - The Webpack compiler instance.
7
- * @returns True if the compiler options are valid, false otherwise.
6
+ * @param {Compiler} compiler - The Webpack compiler instance.
7
+ * @returns {boolean} - Returns true if the compiler options are valid, false otherwise.
8
8
  *
9
+ * @throws Will throw an error if the name option is not defined in the options.
9
10
  * @remarks
10
- * This function validates the options passed to the Webpack compiler. It throws an error if the name
11
- * option is not defined in the options. It also checks if the name option is set to either "server" or
11
+ * This function validates the options passed to the Webpack compiler. It checks if the name option is set to either "server" or
12
12
  * "client", as Module Federation is only applied to the main server and client builds in Next.js.
13
13
  */
14
14
  export declare function validateCompilerOptions(compiler: Compiler): boolean;
15
15
  /**
16
- * Utility function to validate NextFederationPlugin options.
16
+ * Validates the NextFederationPlugin options.
17
17
  *
18
- * @param options - The ModuleFederationPluginOptions instance.
18
+ * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
19
19
  *
20
+ * @throws Will throw an error if the filename option is not defined in the options or if the name option is not specified.
20
21
  * @remarks
21
- * This function validates the options passed to NextFederationPlugin. It throws an error if the filename
22
- * option is not defined in the options.
23
- *
24
- * A requirement for using Module Federation is that a name must be specified.
22
+ * This function validates the options passed to NextFederationPlugin. It ensures that the filename and name options are defined,
23
+ * as they are required for using Module Federation.
25
24
  */
26
25
  export declare function validatePluginOptions(options: ModuleFederationPluginOptions): void;
@@ -2,44 +2,43 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validatePluginOptions = exports.validateCompilerOptions = void 0;
4
4
  /**
5
- * Utility function to validate compiler options.
5
+ * Validates the compiler options.
6
6
  *
7
- * @param compiler - The Webpack compiler instance.
8
- * @returns True if the compiler options are valid, false otherwise.
7
+ * @param {Compiler} compiler - The Webpack compiler instance.
8
+ * @returns {boolean} - Returns true if the compiler options are valid, false otherwise.
9
9
  *
10
+ * @throws Will throw an error if the name option is not defined in the options.
10
11
  * @remarks
11
- * This function validates the options passed to the Webpack compiler. It throws an error if the name
12
- * option is not defined in the options. It also checks if the name option is set to either "server" or
12
+ * This function validates the options passed to the Webpack compiler. It checks if the name option is set to either "server" or
13
13
  * "client", as Module Federation is only applied to the main server and client builds in Next.js.
14
14
  */
15
15
  function validateCompilerOptions(compiler) {
16
16
  // Throw an error if the name option is not defined in the options
17
17
  if (!compiler.options.name) {
18
- throw new Error("name is not defined in Compiler options");
18
+ throw new Error('name is not defined in Compiler options');
19
19
  }
20
20
  // Only apply Module Federation to the main server and client builds in Next.js
21
- return ["server", "client"].includes(compiler.options.name);
21
+ return ['server', 'client'].includes(compiler.options.name);
22
22
  }
23
23
  exports.validateCompilerOptions = validateCompilerOptions;
24
24
  /**
25
- * Utility function to validate NextFederationPlugin options.
25
+ * Validates the NextFederationPlugin options.
26
26
  *
27
- * @param options - The ModuleFederationPluginOptions instance.
27
+ * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
28
28
  *
29
+ * @throws Will throw an error if the filename option is not defined in the options or if the name option is not specified.
29
30
  * @remarks
30
- * This function validates the options passed to NextFederationPlugin. It throws an error if the filename
31
- * option is not defined in the options.
32
- *
33
- * A requirement for using Module Federation is that a name must be specified.
31
+ * This function validates the options passed to NextFederationPlugin. It ensures that the filename and name options are defined,
32
+ * as they are required for using Module Federation.
34
33
  */
35
34
  function validatePluginOptions(options) {
36
35
  // Throw an error if the filename option is not defined in the options
37
36
  if (!options.filename) {
38
- throw new Error("filename is not defined in NextFederation options");
37
+ throw new Error('filename is not defined in NextFederation options');
39
38
  }
40
39
  // A requirement for using Module Federation is that a name must be specified
41
40
  if (!options.name) {
42
- throw new Error("Module federation \"name\" option must be specified");
41
+ throw new Error('Module federation "name" option must be specified');
43
42
  }
44
43
  }
45
44
  exports.validatePluginOptions = validatePluginOptions;