@module-federation/nextjs-mf 0.0.0-chore-bump-node-22-20260710161714

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 (110) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -0
  3. package/dist/LICENSE +21 -0
  4. package/dist/_virtual/_rolldown/runtime.js +29 -0
  5. package/dist/_virtual/_rolldown/runtime.mjs +8 -0
  6. package/dist/client/UrlNode.js +92 -0
  7. package/dist/client/UrlNode.js.map +1 -0
  8. package/dist/client/UrlNode.mjs +91 -0
  9. package/dist/client/UrlNode.mjs.map +1 -0
  10. package/dist/src/federation-noop.d.mts +1 -0
  11. package/dist/src/federation-noop.d.ts +1 -0
  12. package/dist/src/federation-noop.js +17 -0
  13. package/dist/src/federation-noop.js.map +1 -0
  14. package/dist/src/federation-noop.mjs +23 -0
  15. package/dist/src/federation-noop.mjs.map +1 -0
  16. package/dist/src/index.d.mts +2 -0
  17. package/dist/src/index.d.ts +2 -0
  18. package/dist/src/index.js +14 -0
  19. package/dist/src/index.js.map +1 -0
  20. package/dist/src/index.mjs +8 -0
  21. package/dist/src/index.mjs.map +1 -0
  22. package/dist/src/internal.js +152 -0
  23. package/dist/src/internal.js.map +1 -0
  24. package/dist/src/internal.mjs +152 -0
  25. package/dist/src/internal.mjs.map +1 -0
  26. package/dist/src/loaders/fixImageLoader.d.mts +27 -0
  27. package/dist/src/loaders/fixImageLoader.d.ts +27 -0
  28. package/dist/src/loaders/fixImageLoader.js +104 -0
  29. package/dist/src/loaders/fixImageLoader.js.map +1 -0
  30. package/dist/src/loaders/fixImageLoader.mjs +101 -0
  31. package/dist/src/loaders/fixImageLoader.mjs.map +1 -0
  32. package/dist/src/loaders/fixUrlLoader.d.mts +16 -0
  33. package/dist/src/loaders/fixUrlLoader.d.ts +16 -0
  34. package/dist/src/loaders/fixUrlLoader.js +22 -0
  35. package/dist/src/loaders/fixUrlLoader.js.map +1 -0
  36. package/dist/src/loaders/fixUrlLoader.mjs +19 -0
  37. package/dist/src/loaders/fixUrlLoader.mjs.map +1 -0
  38. package/dist/src/loaders/helpers.js +82 -0
  39. package/dist/src/loaders/helpers.js.map +1 -0
  40. package/dist/src/loaders/helpers.mjs +79 -0
  41. package/dist/src/loaders/helpers.mjs.map +1 -0
  42. package/dist/src/loaders/nextPageMapLoader.d.mts +29 -0
  43. package/dist/src/loaders/nextPageMapLoader.d.ts +29 -0
  44. package/dist/src/loaders/nextPageMapLoader.js +148 -0
  45. package/dist/src/loaders/nextPageMapLoader.js.map +1 -0
  46. package/dist/src/loaders/nextPageMapLoader.mjs +143 -0
  47. package/dist/src/loaders/nextPageMapLoader.mjs.map +1 -0
  48. package/dist/src/logger.js +9 -0
  49. package/dist/src/logger.js.map +1 -0
  50. package/dist/src/logger.mjs +8 -0
  51. package/dist/src/logger.mjs.map +1 -0
  52. package/dist/src/plugins/CopyFederationPlugin.js +67 -0
  53. package/dist/src/plugins/CopyFederationPlugin.js.map +1 -0
  54. package/dist/src/plugins/CopyFederationPlugin.mjs +65 -0
  55. package/dist/src/plugins/CopyFederationPlugin.mjs.map +1 -0
  56. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js +41 -0
  57. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js.map +1 -0
  58. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.mjs +40 -0
  59. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.mjs.map +1 -0
  60. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js +117 -0
  61. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js.map +1 -0
  62. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.mjs +111 -0
  63. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.mjs.map +1 -0
  64. package/dist/src/plugins/NextFederationPlugin/index.d.mts +31 -0
  65. package/dist/src/plugins/NextFederationPlugin/index.d.ts +31 -0
  66. package/dist/src/plugins/NextFederationPlugin/index.js +156 -0
  67. package/dist/src/plugins/NextFederationPlugin/index.js.map +1 -0
  68. package/dist/src/plugins/NextFederationPlugin/index.mjs +153 -0
  69. package/dist/src/plugins/NextFederationPlugin/index.mjs.map +1 -0
  70. package/dist/src/plugins/NextFederationPlugin/next-fragments.d.mts +18 -0
  71. package/dist/src/plugins/NextFederationPlugin/next-fragments.d.ts +18 -0
  72. package/dist/src/plugins/NextFederationPlugin/next-fragments.js +65 -0
  73. package/dist/src/plugins/NextFederationPlugin/next-fragments.js.map +1 -0
  74. package/dist/src/plugins/NextFederationPlugin/next-fragments.mjs +63 -0
  75. package/dist/src/plugins/NextFederationPlugin/next-fragments.mjs.map +1 -0
  76. package/dist/src/plugins/NextFederationPlugin/set-options.js +20 -0
  77. package/dist/src/plugins/NextFederationPlugin/set-options.js.map +1 -0
  78. package/dist/src/plugins/NextFederationPlugin/set-options.mjs +19 -0
  79. package/dist/src/plugins/NextFederationPlugin/set-options.mjs.map +1 -0
  80. package/dist/src/plugins/NextFederationPlugin/validate-options.js +37 -0
  81. package/dist/src/plugins/NextFederationPlugin/validate-options.js.map +1 -0
  82. package/dist/src/plugins/NextFederationPlugin/validate-options.mjs +35 -0
  83. package/dist/src/plugins/NextFederationPlugin/validate-options.mjs.map +1 -0
  84. package/dist/src/plugins/container/InvertedContainerPlugin.js +26 -0
  85. package/dist/src/plugins/container/InvertedContainerPlugin.js.map +1 -0
  86. package/dist/src/plugins/container/InvertedContainerPlugin.mjs +27 -0
  87. package/dist/src/plugins/container/InvertedContainerPlugin.mjs.map +1 -0
  88. package/dist/src/plugins/container/InvertedContainerRuntimeModule.js +57 -0
  89. package/dist/src/plugins/container/InvertedContainerRuntimeModule.js.map +1 -0
  90. package/dist/src/plugins/container/InvertedContainerRuntimeModule.mjs +57 -0
  91. package/dist/src/plugins/container/InvertedContainerRuntimeModule.mjs.map +1 -0
  92. package/dist/src/plugins/container/runtimePlugin.d.mts +7 -0
  93. package/dist/src/plugins/container/runtimePlugin.d.ts +6 -0
  94. package/dist/src/plugins/container/runtimePlugin.js +168 -0
  95. package/dist/src/plugins/container/runtimePlugin.js.map +1 -0
  96. package/dist/src/plugins/container/runtimePlugin.mjs +167 -0
  97. package/dist/src/plugins/container/runtimePlugin.mjs.map +1 -0
  98. package/dist/utils/flushedChunks.d.mts +29 -0
  99. package/dist/utils/flushedChunks.d.ts +29 -0
  100. package/dist/utils/flushedChunks.js +37 -0
  101. package/dist/utils/flushedChunks.js.map +1 -0
  102. package/dist/utils/flushedChunks.mjs +35 -0
  103. package/dist/utils/flushedChunks.mjs.map +1 -0
  104. package/dist/utils/index.d.mts +14 -0
  105. package/dist/utils/index.d.ts +14 -0
  106. package/dist/utils/index.js +31 -0
  107. package/dist/utils/index.js.map +1 -0
  108. package/dist/utils/index.mjs +22 -0
  109. package/dist/utils/index.mjs.map +1 -0
  110. package/package.json +106 -0
@@ -0,0 +1,37 @@
1
+
2
+ //#region src/plugins/NextFederationPlugin/validate-options.ts
3
+ /**
4
+ * Validates the compiler options.
5
+ *
6
+ * @param {Compiler} compiler - The Webpack compiler instance.
7
+ * @returns {boolean} - Returns true if the compiler options are valid, false otherwise.
8
+ *
9
+ * @throws Will throw an error if the name option is not defined in the options.
10
+ * @remarks
11
+ * This function validates the options passed to the Webpack compiler. It checks if the name option is set to either "server" or
12
+ * "client", as Module Federation is only applied to the main server and client builds in Next.js.
13
+ */
14
+ function validateCompilerOptions(compiler) {
15
+ if (!compiler.options.name) throw new Error("name is not defined in Compiler options");
16
+ return ["server", "client"].includes(compiler.options.name);
17
+ }
18
+ /**
19
+ * Validates the NextFederationPlugin options.
20
+ *
21
+ * @param {moduleFederationPlugin.ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
22
+ *
23
+ * @throws Will throw an error if the filename option is not defined in the options or if the name option is not specified.
24
+ * @remarks
25
+ * This function validates the options passed to NextFederationPlugin. It ensures that the filename and name options are defined,
26
+ * as they are required for using Module Federation.
27
+ */
28
+ function validatePluginOptions(options) {
29
+ if (!options.filename) throw new Error("filename is not defined in NextFederation options");
30
+ if (!options.name) throw new Error("Module federation \"name\" option must be specified");
31
+ return true;
32
+ }
33
+
34
+ //#endregion
35
+ exports.validateCompilerOptions = validateCompilerOptions;
36
+ exports.validatePluginOptions = validatePluginOptions;
37
+ //# sourceMappingURL=validate-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-options.js","names":[],"sources":["../../../../src/plugins/NextFederationPlugin/validate-options.ts"],"sourcesContent":["import type { Compiler } from 'webpack';\nimport type { moduleFederationPlugin } from '@module-federation/sdk';\n\n/**\n * Validates the compiler options.\n *\n * @param {Compiler} compiler - The Webpack compiler instance.\n * @returns {boolean} - Returns true if the compiler options are valid, false otherwise.\n *\n * @throws Will throw an error if the name option is not defined in the options.\n * @remarks\n * This function validates the options passed to the Webpack compiler. It checks if the name option is set to either \"server\" or\n * \"client\", as Module Federation is only applied to the main server and client builds in Next.js.\n */\nexport function validateCompilerOptions(compiler: Compiler): boolean {\n // Throw an error if the name option is not defined in the options\n if (!compiler.options.name) {\n throw new Error('name is not defined in Compiler options');\n }\n\n // Only apply Module Federation to the main server and client builds in Next.js\n return ['server', 'client'].includes(compiler.options.name);\n}\n\n/**\n * Validates the NextFederationPlugin options.\n *\n * @param {moduleFederationPlugin.ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.\n *\n * @throws Will throw an error if the filename option is not defined in the options or if the name option is not specified.\n * @remarks\n * This function validates the options passed to NextFederationPlugin. It ensures that the filename and name options are defined,\n * as they are required for using Module Federation.\n */\nexport function validatePluginOptions(\n options: moduleFederationPlugin.ModuleFederationPluginOptions,\n): boolean | void {\n // Throw an error if the filename option is not defined in the options\n if (!options.filename) {\n throw new Error('filename is not defined in NextFederation options');\n }\n\n // A requirement for using Module Federation is that a name must be specified\n if (!options.name) {\n throw new Error('Module federation \"name\" option must be specified');\n }\n return true;\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,SAAgB,wBAAwB,UAA6B;AAEnE,KAAI,CAAC,SAAS,QAAQ,KACpB,OAAM,IAAI,MAAM,0CAA0C;AAI5D,QAAO,CAAC,UAAU,SAAS,CAAC,SAAS,SAAS,QAAQ,KAAK;;;;;;;;;;;;AAa7D,SAAgB,sBACd,SACgB;AAEhB,KAAI,CAAC,QAAQ,SACX,OAAM,IAAI,MAAM,oDAAoD;AAItE,KAAI,CAAC,QAAQ,KACX,OAAM,IAAI,MAAM,sDAAoD;AAEtE,QAAO"}
@@ -0,0 +1,35 @@
1
+ //#region src/plugins/NextFederationPlugin/validate-options.ts
2
+ /**
3
+ * Validates the compiler options.
4
+ *
5
+ * @param {Compiler} compiler - The Webpack compiler instance.
6
+ * @returns {boolean} - Returns true if the compiler options are valid, false otherwise.
7
+ *
8
+ * @throws Will throw an error if the name option is not defined in the options.
9
+ * @remarks
10
+ * This function validates the options passed to the Webpack compiler. It checks if the name option is set to either "server" or
11
+ * "client", as Module Federation is only applied to the main server and client builds in Next.js.
12
+ */
13
+ function validateCompilerOptions(compiler) {
14
+ if (!compiler.options.name) throw new Error("name is not defined in Compiler options");
15
+ return ["server", "client"].includes(compiler.options.name);
16
+ }
17
+ /**
18
+ * Validates the NextFederationPlugin options.
19
+ *
20
+ * @param {moduleFederationPlugin.ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
21
+ *
22
+ * @throws Will throw an error if the filename option is not defined in the options or if the name option is not specified.
23
+ * @remarks
24
+ * This function validates the options passed to NextFederationPlugin. It ensures that the filename and name options are defined,
25
+ * as they are required for using Module Federation.
26
+ */
27
+ function validatePluginOptions(options) {
28
+ if (!options.filename) throw new Error("filename is not defined in NextFederation options");
29
+ if (!options.name) throw new Error("Module federation \"name\" option must be specified");
30
+ return true;
31
+ }
32
+
33
+ //#endregion
34
+ export { validateCompilerOptions, validatePluginOptions };
35
+ //# sourceMappingURL=validate-options.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-options.mjs","names":[],"sources":["../../../../src/plugins/NextFederationPlugin/validate-options.ts"],"sourcesContent":["import type { Compiler } from 'webpack';\nimport type { moduleFederationPlugin } from '@module-federation/sdk';\n\n/**\n * Validates the compiler options.\n *\n * @param {Compiler} compiler - The Webpack compiler instance.\n * @returns {boolean} - Returns true if the compiler options are valid, false otherwise.\n *\n * @throws Will throw an error if the name option is not defined in the options.\n * @remarks\n * This function validates the options passed to the Webpack compiler. It checks if the name option is set to either \"server\" or\n * \"client\", as Module Federation is only applied to the main server and client builds in Next.js.\n */\nexport function validateCompilerOptions(compiler: Compiler): boolean {\n // Throw an error if the name option is not defined in the options\n if (!compiler.options.name) {\n throw new Error('name is not defined in Compiler options');\n }\n\n // Only apply Module Federation to the main server and client builds in Next.js\n return ['server', 'client'].includes(compiler.options.name);\n}\n\n/**\n * Validates the NextFederationPlugin options.\n *\n * @param {moduleFederationPlugin.ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.\n *\n * @throws Will throw an error if the filename option is not defined in the options or if the name option is not specified.\n * @remarks\n * This function validates the options passed to NextFederationPlugin. It ensures that the filename and name options are defined,\n * as they are required for using Module Federation.\n */\nexport function validatePluginOptions(\n options: moduleFederationPlugin.ModuleFederationPluginOptions,\n): boolean | void {\n // Throw an error if the filename option is not defined in the options\n if (!options.filename) {\n throw new Error('filename is not defined in NextFederation options');\n }\n\n // A requirement for using Module Federation is that a name must be specified\n if (!options.name) {\n throw new Error('Module federation \"name\" option must be specified');\n }\n return true;\n}\n"],"mappings":";;;;;;;;;;;;AAcA,SAAgB,wBAAwB,UAA6B;AAEnE,KAAI,CAAC,SAAS,QAAQ,KACpB,OAAM,IAAI,MAAM,0CAA0C;AAI5D,QAAO,CAAC,UAAU,SAAS,CAAC,SAAS,SAAS,QAAQ,KAAK;;;;;;;;;;;;AAa7D,SAAgB,sBACd,SACgB;AAEhB,KAAI,CAAC,QAAQ,SACX,OAAM,IAAI,MAAM,oDAAoD;AAItE,KAAI,CAAC,QAAQ,KACX,OAAM,IAAI,MAAM,sDAAoD;AAEtE,QAAO"}
@@ -0,0 +1,26 @@
1
+ const require_InvertedContainerRuntimeModule = require('./InvertedContainerRuntimeModule.js');
2
+
3
+ //#region src/plugins/container/InvertedContainerPlugin.ts
4
+ const loadEnhanced = () => {
5
+ const enhancedModule = require("@module-federation/enhanced");
6
+ return enhancedModule.default ? enhancedModule.default : enhancedModule;
7
+ };
8
+ var InvertedContainerPlugin = class {
9
+ apply(compiler) {
10
+ const { FederationModulesPlugin, dependencies } = loadEnhanced();
11
+ compiler.hooks.thisCompilation.tap("EmbeddedContainerPlugin", (compilation) => {
12
+ const hooks = FederationModulesPlugin.getCompilationHooks(compilation);
13
+ const containers = /* @__PURE__ */ new Set();
14
+ hooks.addContainerEntryDependency.tap("EmbeddedContainerPlugin", (dependency) => {
15
+ if (dependency instanceof dependencies.ContainerEntryDependency) containers.add(dependency);
16
+ });
17
+ compilation.hooks.additionalTreeRuntimeRequirements.tap("EmbeddedContainerPlugin", (chunk, set) => {
18
+ compilation.addRuntimeModule(chunk, new require_InvertedContainerRuntimeModule.default({ containers }));
19
+ });
20
+ });
21
+ }
22
+ };
23
+
24
+ //#endregion
25
+ exports.default = InvertedContainerPlugin;
26
+ //# sourceMappingURL=InvertedContainerPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InvertedContainerPlugin.js","names":["InvertedContainerRuntimeModule"],"sources":["../../../../src/plugins/container/InvertedContainerPlugin.ts"],"sourcesContent":["import type { Compilation, Compiler, Chunk } from 'webpack';\nimport InvertedContainerRuntimeModule from './InvertedContainerRuntimeModule';\n\ntype EnhancedModuleExports = typeof import('@module-federation/enhanced');\n\nconst loadEnhanced = (): EnhancedModuleExports => {\n const enhancedModule = require('@module-federation/enhanced') as\n | EnhancedModuleExports\n | { default: EnhancedModuleExports };\n\n return (enhancedModule as { default?: EnhancedModuleExports }).default\n ? (enhancedModule as { default: EnhancedModuleExports }).default\n : (enhancedModule as EnhancedModuleExports);\n};\n\nclass InvertedContainerPlugin {\n public apply(compiler: Compiler): void {\n const { FederationModulesPlugin, dependencies } = loadEnhanced();\n\n compiler.hooks.thisCompilation.tap(\n 'EmbeddedContainerPlugin',\n (compilation: Compilation) => {\n const hooks = FederationModulesPlugin.getCompilationHooks(compilation);\n const containers = new Set();\n hooks.addContainerEntryDependency.tap(\n 'EmbeddedContainerPlugin',\n (dependency) => {\n if (dependency instanceof dependencies.ContainerEntryDependency) {\n containers.add(dependency);\n }\n },\n );\n // Adding the runtime module\n compilation.hooks.additionalTreeRuntimeRequirements.tap(\n 'EmbeddedContainerPlugin',\n (chunk, set) => {\n compilation.addRuntimeModule(\n chunk,\n new InvertedContainerRuntimeModule({\n containers,\n }),\n );\n },\n );\n },\n );\n }\n}\n\nexport default InvertedContainerPlugin;\n"],"mappings":";;;AAKA,MAAM,qBAA4C;CAChD,MAAM,iBAAiB,QAAQ,8BAA8B;AAI7D,QAAQ,eAAuD,UAC1D,eAAsD,UACtD;;AAGP,IAAM,0BAAN,MAA8B;CAC5B,AAAO,MAAM,UAA0B;EACrC,MAAM,EAAE,yBAAyB,iBAAiB,cAAc;AAEhE,WAAS,MAAM,gBAAgB,IAC7B,4BACC,gBAA6B;GAC5B,MAAM,QAAQ,wBAAwB,oBAAoB,YAAY;GACtE,MAAM,6BAAa,IAAI,KAAK;AAC5B,SAAM,4BAA4B,IAChC,4BACC,eAAe;AACd,QAAI,sBAAsB,aAAa,yBACrC,YAAW,IAAI,WAAW;KAG/B;AAED,eAAY,MAAM,kCAAkC,IAClD,4BACC,OAAO,QAAQ;AACd,gBAAY,iBACV,OACA,IAAIA,+CAA+B,EACjC,YACD,CAAC,CACH;KAEJ;IAEJ"}
@@ -0,0 +1,27 @@
1
+ import { __require } from "../../../_virtual/_rolldown/runtime.mjs";
2
+ import InvertedContainerRuntimeModule from "./InvertedContainerRuntimeModule.mjs";
3
+
4
+ //#region src/plugins/container/InvertedContainerPlugin.ts
5
+ const loadEnhanced = () => {
6
+ const enhancedModule = __require("@module-federation/enhanced");
7
+ return enhancedModule.default ? enhancedModule.default : enhancedModule;
8
+ };
9
+ var InvertedContainerPlugin = class {
10
+ apply(compiler) {
11
+ const { FederationModulesPlugin, dependencies } = loadEnhanced();
12
+ compiler.hooks.thisCompilation.tap("EmbeddedContainerPlugin", (compilation) => {
13
+ const hooks = FederationModulesPlugin.getCompilationHooks(compilation);
14
+ const containers = /* @__PURE__ */ new Set();
15
+ hooks.addContainerEntryDependency.tap("EmbeddedContainerPlugin", (dependency) => {
16
+ if (dependency instanceof dependencies.ContainerEntryDependency) containers.add(dependency);
17
+ });
18
+ compilation.hooks.additionalTreeRuntimeRequirements.tap("EmbeddedContainerPlugin", (chunk, set) => {
19
+ compilation.addRuntimeModule(chunk, new InvertedContainerRuntimeModule({ containers }));
20
+ });
21
+ });
22
+ }
23
+ };
24
+
25
+ //#endregion
26
+ export { InvertedContainerPlugin as default };
27
+ //# sourceMappingURL=InvertedContainerPlugin.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InvertedContainerPlugin.mjs","names":[],"sources":["../../../../src/plugins/container/InvertedContainerPlugin.ts"],"sourcesContent":["import type { Compilation, Compiler, Chunk } from 'webpack';\nimport InvertedContainerRuntimeModule from './InvertedContainerRuntimeModule';\n\ntype EnhancedModuleExports = typeof import('@module-federation/enhanced');\n\nconst loadEnhanced = (): EnhancedModuleExports => {\n const enhancedModule = require('@module-federation/enhanced') as\n | EnhancedModuleExports\n | { default: EnhancedModuleExports };\n\n return (enhancedModule as { default?: EnhancedModuleExports }).default\n ? (enhancedModule as { default: EnhancedModuleExports }).default\n : (enhancedModule as EnhancedModuleExports);\n};\n\nclass InvertedContainerPlugin {\n public apply(compiler: Compiler): void {\n const { FederationModulesPlugin, dependencies } = loadEnhanced();\n\n compiler.hooks.thisCompilation.tap(\n 'EmbeddedContainerPlugin',\n (compilation: Compilation) => {\n const hooks = FederationModulesPlugin.getCompilationHooks(compilation);\n const containers = new Set();\n hooks.addContainerEntryDependency.tap(\n 'EmbeddedContainerPlugin',\n (dependency) => {\n if (dependency instanceof dependencies.ContainerEntryDependency) {\n containers.add(dependency);\n }\n },\n );\n // Adding the runtime module\n compilation.hooks.additionalTreeRuntimeRequirements.tap(\n 'EmbeddedContainerPlugin',\n (chunk, set) => {\n compilation.addRuntimeModule(\n chunk,\n new InvertedContainerRuntimeModule({\n containers,\n }),\n );\n },\n );\n },\n );\n }\n}\n\nexport default InvertedContainerPlugin;\n"],"mappings":";;;;AAKA,MAAM,qBAA4C;CAChD,MAAM,2BAAyB,8BAA8B;AAI7D,QAAQ,eAAuD,UAC1D,eAAsD,UACtD;;AAGP,IAAM,0BAAN,MAA8B;CAC5B,AAAO,MAAM,UAA0B;EACrC,MAAM,EAAE,yBAAyB,iBAAiB,cAAc;AAEhE,WAAS,MAAM,gBAAgB,IAC7B,4BACC,gBAA6B;GAC5B,MAAM,QAAQ,wBAAwB,oBAAoB,YAAY;GACtE,MAAM,6BAAa,IAAI,KAAK;AAC5B,SAAM,4BAA4B,IAChC,4BACC,eAAe;AACd,QAAI,sBAAsB,aAAa,yBACrC,YAAW,IAAI,WAAW;KAG/B;AAED,eAAY,MAAM,kCAAkC,IAClD,4BACC,OAAO,QAAQ;AACd,gBAAY,iBACV,OACA,IAAI,+BAA+B,EACjC,YACD,CAAC,CACH;KAEJ;IAEJ"}
@@ -0,0 +1,57 @@
1
+ const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
2
+ let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
3
+
4
+ //#region src/plugins/container/InvertedContainerRuntimeModule.ts
5
+ const { RuntimeModule, Template, RuntimeGlobals } = require((0, _module_federation_sdk_normalize_webpack_path.normalizeWebpackPath)("webpack"));
6
+ var InvertedContainerRuntimeModule = class extends RuntimeModule {
7
+ constructor(options) {
8
+ super("inverted container startup", RuntimeModule.STAGE_TRIGGER);
9
+ this.options = options;
10
+ }
11
+ generate() {
12
+ const { compilation, chunk, chunkGraph } = this;
13
+ if (!compilation || !chunk || !chunkGraph) return "";
14
+ if (chunk.runtime === "webpack-api-runtime") return "";
15
+ const runtimeChunk = compilation.options.optimization?.runtimeChunk;
16
+ if (typeof runtimeChunk === "object" && runtimeChunk !== null) compilation.getLogger("InvertedContainerRuntimeModule").info("Runtime chunk is configured. Consider adding runtime: false to your ModuleFederationPlugin configuration to prevent runtime conflicts.");
17
+ let containerEntryModule;
18
+ for (const containerDep of this.options.containers) {
19
+ const mod = compilation.moduleGraph.getModule(containerDep);
20
+ if (!mod) continue;
21
+ if (chunkGraph.isModuleInChunk(mod, chunk)) containerEntryModule = mod;
22
+ }
23
+ if (!containerEntryModule) return "";
24
+ if (compilation.chunkGraph.isEntryModuleInChunk(containerEntryModule, chunk)) return "";
25
+ const initRuntimeModuleGetter = compilation.runtimeTemplate.moduleRaw({
26
+ module: containerEntryModule,
27
+ chunkGraph,
28
+ weak: false,
29
+ runtimeRequirements: /* @__PURE__ */ new Set()
30
+ });
31
+ const nameJSON = JSON.stringify(containerEntryModule._name);
32
+ return Template.asString([
33
+ `var prevStartup = ${RuntimeGlobals.startup};`,
34
+ `var hasRun = false;`,
35
+ `var cachedRemote;`,
36
+ `${RuntimeGlobals.startup} = ${compilation.runtimeTemplate.basicFunction("", Template.asString([
37
+ `if (!hasRun) {`,
38
+ Template.indent(Template.asString([
39
+ `hasRun = true;`,
40
+ `if (typeof prevStartup === 'function') {`,
41
+ Template.indent(Template.asString([`prevStartup();`])),
42
+ `}`,
43
+ `cachedRemote = ${initRuntimeModuleGetter};`,
44
+ `var gs = ${RuntimeGlobals.global} || globalThis;`,
45
+ `gs[${nameJSON}] = cachedRemote;`
46
+ ])),
47
+ `} else if (typeof prevStartup === 'function') {`,
48
+ Template.indent(`prevStartup();`),
49
+ `}`
50
+ ]))};`
51
+ ]);
52
+ }
53
+ };
54
+
55
+ //#endregion
56
+ exports.default = InvertedContainerRuntimeModule;
57
+ //# sourceMappingURL=InvertedContainerRuntimeModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InvertedContainerRuntimeModule.js","names":[],"sources":["../../../../src/plugins/container/InvertedContainerRuntimeModule.ts"],"sourcesContent":["import { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport type ContainerEntryModule from '@module-federation/enhanced/src/lib/container/ContainerEntryModule';\nconst { RuntimeModule, Template, RuntimeGlobals } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\ninterface InvertedContainerRuntimeModuleOptions {\n name?: string;\n containers: Set<any>; // Adjust the type as necessary\n}\n\nclass InvertedContainerRuntimeModule extends RuntimeModule {\n private options: InvertedContainerRuntimeModuleOptions;\n\n constructor(options: InvertedContainerRuntimeModuleOptions) {\n super('inverted container startup', RuntimeModule.STAGE_TRIGGER);\n this.options = options;\n }\n\n override generate(): string {\n const { compilation, chunk, chunkGraph } = this;\n if (!compilation || !chunk || !chunkGraph) {\n return '';\n }\n if (chunk.runtime === 'webpack-api-runtime') {\n return '';\n }\n\n const runtimeChunk = compilation.options.optimization?.runtimeChunk;\n if (typeof runtimeChunk === 'object' && runtimeChunk !== null) {\n const logger = compilation.getLogger('InvertedContainerRuntimeModule');\n logger.info(\n 'Runtime chunk is configured. Consider adding runtime: false to your ModuleFederationPlugin configuration to prevent runtime conflicts.',\n );\n }\n\n let containerEntryModule;\n for (const containerDep of this.options.containers) {\n const mod = compilation.moduleGraph.getModule(containerDep);\n if (!mod) continue;\n if (chunkGraph.isModuleInChunk(mod, chunk)) {\n containerEntryModule = mod as ContainerEntryModule;\n }\n }\n\n if (!containerEntryModule) return '';\n\n if (\n compilation.chunkGraph.isEntryModuleInChunk(containerEntryModule, chunk)\n ) {\n // Don't apply to the remote entry itself\n return '';\n }\n const initRuntimeModuleGetter = compilation.runtimeTemplate.moduleRaw({\n module: containerEntryModule,\n chunkGraph,\n weak: false,\n runtimeRequirements: new Set(),\n });\n\n //@ts-ignore\n const nameJSON = JSON.stringify(containerEntryModule._name);\n\n return Template.asString([\n `var prevStartup = ${RuntimeGlobals.startup};`,\n `var hasRun = false;`,\n `var cachedRemote;`,\n `${RuntimeGlobals.startup} = ${compilation.runtimeTemplate.basicFunction(\n '',\n Template.asString([\n `if (!hasRun) {`,\n Template.indent(\n Template.asString([\n `hasRun = true;`,\n `if (typeof prevStartup === 'function') {`,\n Template.indent(Template.asString([`prevStartup();`])),\n `}`,\n `cachedRemote = ${initRuntimeModuleGetter};`,\n `var gs = ${RuntimeGlobals.global} || globalThis;`,\n `gs[${nameJSON}] = cachedRemote;`,\n ]),\n ),\n `} else if (typeof prevStartup === 'function') {`,\n Template.indent(`prevStartup();`),\n `}`,\n ]),\n )};`,\n ]);\n }\n}\n\nexport default InvertedContainerRuntimeModule;\n"],"mappings":";;;;AAEA,MAAM,EAAE,eAAe,UAAU,mBAAmB,gFAC7B,UAAU,CAChC;AAOD,IAAM,iCAAN,cAA6C,cAAc;CAGzD,YAAY,SAAgD;AAC1D,QAAM,8BAA8B,cAAc,cAAc;AAChE,OAAK,UAAU;;CAGjB,AAAS,WAAmB;EAC1B,MAAM,EAAE,aAAa,OAAO,eAAe;AAC3C,MAAI,CAAC,eAAe,CAAC,SAAS,CAAC,WAC7B,QAAO;AAET,MAAI,MAAM,YAAY,sBACpB,QAAO;EAGT,MAAM,eAAe,YAAY,QAAQ,cAAc;AACvD,MAAI,OAAO,iBAAiB,YAAY,iBAAiB,KAEvD,CADe,YAAY,UAAU,iCAAiC,CAC/D,KACL,yIACD;EAGH,IAAI;AACJ,OAAK,MAAM,gBAAgB,KAAK,QAAQ,YAAY;GAClD,MAAM,MAAM,YAAY,YAAY,UAAU,aAAa;AAC3D,OAAI,CAAC,IAAK;AACV,OAAI,WAAW,gBAAgB,KAAK,MAAM,CACxC,wBAAuB;;AAI3B,MAAI,CAAC,qBAAsB,QAAO;AAElC,MACE,YAAY,WAAW,qBAAqB,sBAAsB,MAAM,CAGxE,QAAO;EAET,MAAM,0BAA0B,YAAY,gBAAgB,UAAU;GACpE,QAAQ;GACR;GACA,MAAM;GACN,qCAAqB,IAAI,KAAK;GAC/B,CAAC;EAGF,MAAM,WAAW,KAAK,UAAU,qBAAqB,MAAM;AAE3D,SAAO,SAAS,SAAS;GACvB,qBAAqB,eAAe,QAAQ;GAC5C;GACA;GACA,GAAG,eAAe,QAAQ,KAAK,YAAY,gBAAgB,cACzD,IACA,SAAS,SAAS;IAChB;IACA,SAAS,OACP,SAAS,SAAS;KAChB;KACA;KACA,SAAS,OAAO,SAAS,SAAS,CAAC,iBAAiB,CAAC,CAAC;KACtD;KACA,kBAAkB,wBAAwB;KAC1C,YAAY,eAAe,OAAO;KAClC,MAAM,SAAS;KAChB,CAAC,CACH;IACD;IACA,SAAS,OAAO,iBAAiB;IACjC;IACD,CAAC,CACH,CAAC;GACH,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { __require } from "../../../_virtual/_rolldown/runtime.mjs";
2
+ import { normalizeWebpackPath } from "@module-federation/sdk/normalize-webpack-path";
3
+
4
+ //#region src/plugins/container/InvertedContainerRuntimeModule.ts
5
+ const { RuntimeModule, Template, RuntimeGlobals } = __require(normalizeWebpackPath("webpack"));
6
+ var InvertedContainerRuntimeModule = class extends RuntimeModule {
7
+ constructor(options) {
8
+ super("inverted container startup", RuntimeModule.STAGE_TRIGGER);
9
+ this.options = options;
10
+ }
11
+ generate() {
12
+ const { compilation, chunk, chunkGraph } = this;
13
+ if (!compilation || !chunk || !chunkGraph) return "";
14
+ if (chunk.runtime === "webpack-api-runtime") return "";
15
+ const runtimeChunk = compilation.options.optimization?.runtimeChunk;
16
+ if (typeof runtimeChunk === "object" && runtimeChunk !== null) compilation.getLogger("InvertedContainerRuntimeModule").info("Runtime chunk is configured. Consider adding runtime: false to your ModuleFederationPlugin configuration to prevent runtime conflicts.");
17
+ let containerEntryModule;
18
+ for (const containerDep of this.options.containers) {
19
+ const mod = compilation.moduleGraph.getModule(containerDep);
20
+ if (!mod) continue;
21
+ if (chunkGraph.isModuleInChunk(mod, chunk)) containerEntryModule = mod;
22
+ }
23
+ if (!containerEntryModule) return "";
24
+ if (compilation.chunkGraph.isEntryModuleInChunk(containerEntryModule, chunk)) return "";
25
+ const initRuntimeModuleGetter = compilation.runtimeTemplate.moduleRaw({
26
+ module: containerEntryModule,
27
+ chunkGraph,
28
+ weak: false,
29
+ runtimeRequirements: /* @__PURE__ */ new Set()
30
+ });
31
+ const nameJSON = JSON.stringify(containerEntryModule._name);
32
+ return Template.asString([
33
+ `var prevStartup = ${RuntimeGlobals.startup};`,
34
+ `var hasRun = false;`,
35
+ `var cachedRemote;`,
36
+ `${RuntimeGlobals.startup} = ${compilation.runtimeTemplate.basicFunction("", Template.asString([
37
+ `if (!hasRun) {`,
38
+ Template.indent(Template.asString([
39
+ `hasRun = true;`,
40
+ `if (typeof prevStartup === 'function') {`,
41
+ Template.indent(Template.asString([`prevStartup();`])),
42
+ `}`,
43
+ `cachedRemote = ${initRuntimeModuleGetter};`,
44
+ `var gs = ${RuntimeGlobals.global} || globalThis;`,
45
+ `gs[${nameJSON}] = cachedRemote;`
46
+ ])),
47
+ `} else if (typeof prevStartup === 'function') {`,
48
+ Template.indent(`prevStartup();`),
49
+ `}`
50
+ ]))};`
51
+ ]);
52
+ }
53
+ };
54
+
55
+ //#endregion
56
+ export { InvertedContainerRuntimeModule as default };
57
+ //# sourceMappingURL=InvertedContainerRuntimeModule.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InvertedContainerRuntimeModule.mjs","names":[],"sources":["../../../../src/plugins/container/InvertedContainerRuntimeModule.ts"],"sourcesContent":["import { normalizeWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport type ContainerEntryModule from '@module-federation/enhanced/src/lib/container/ContainerEntryModule';\nconst { RuntimeModule, Template, RuntimeGlobals } = require(\n normalizeWebpackPath('webpack'),\n) as typeof import('webpack');\n\ninterface InvertedContainerRuntimeModuleOptions {\n name?: string;\n containers: Set<any>; // Adjust the type as necessary\n}\n\nclass InvertedContainerRuntimeModule extends RuntimeModule {\n private options: InvertedContainerRuntimeModuleOptions;\n\n constructor(options: InvertedContainerRuntimeModuleOptions) {\n super('inverted container startup', RuntimeModule.STAGE_TRIGGER);\n this.options = options;\n }\n\n override generate(): string {\n const { compilation, chunk, chunkGraph } = this;\n if (!compilation || !chunk || !chunkGraph) {\n return '';\n }\n if (chunk.runtime === 'webpack-api-runtime') {\n return '';\n }\n\n const runtimeChunk = compilation.options.optimization?.runtimeChunk;\n if (typeof runtimeChunk === 'object' && runtimeChunk !== null) {\n const logger = compilation.getLogger('InvertedContainerRuntimeModule');\n logger.info(\n 'Runtime chunk is configured. Consider adding runtime: false to your ModuleFederationPlugin configuration to prevent runtime conflicts.',\n );\n }\n\n let containerEntryModule;\n for (const containerDep of this.options.containers) {\n const mod = compilation.moduleGraph.getModule(containerDep);\n if (!mod) continue;\n if (chunkGraph.isModuleInChunk(mod, chunk)) {\n containerEntryModule = mod as ContainerEntryModule;\n }\n }\n\n if (!containerEntryModule) return '';\n\n if (\n compilation.chunkGraph.isEntryModuleInChunk(containerEntryModule, chunk)\n ) {\n // Don't apply to the remote entry itself\n return '';\n }\n const initRuntimeModuleGetter = compilation.runtimeTemplate.moduleRaw({\n module: containerEntryModule,\n chunkGraph,\n weak: false,\n runtimeRequirements: new Set(),\n });\n\n //@ts-ignore\n const nameJSON = JSON.stringify(containerEntryModule._name);\n\n return Template.asString([\n `var prevStartup = ${RuntimeGlobals.startup};`,\n `var hasRun = false;`,\n `var cachedRemote;`,\n `${RuntimeGlobals.startup} = ${compilation.runtimeTemplate.basicFunction(\n '',\n Template.asString([\n `if (!hasRun) {`,\n Template.indent(\n Template.asString([\n `hasRun = true;`,\n `if (typeof prevStartup === 'function') {`,\n Template.indent(Template.asString([`prevStartup();`])),\n `}`,\n `cachedRemote = ${initRuntimeModuleGetter};`,\n `var gs = ${RuntimeGlobals.global} || globalThis;`,\n `gs[${nameJSON}] = cachedRemote;`,\n ]),\n ),\n `} else if (typeof prevStartup === 'function') {`,\n Template.indent(`prevStartup();`),\n `}`,\n ]),\n )};`,\n ]);\n }\n}\n\nexport default Inverted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AAO,iBAAiB;IACjC;IACD,CAAC,CACH,CAAC;GACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { ModuleFederationRuntimePlugin } from "@module-federation/runtime";
2
+
3
+ //#region src/plugins/container/runtimePlugin.d.ts
4
+ declare function export_default(): ModuleFederationRuntimePlugin;
5
+ //#endregion
6
+ export { export_default as default };
7
+ //# sourceMappingURL=runtimePlugin.d.mts.map
@@ -0,0 +1,6 @@
1
+ import { ModuleFederationRuntimePlugin } from "@module-federation/runtime";
2
+
3
+ //#region src/plugins/container/runtimePlugin.d.ts
4
+ declare function export_default(): ModuleFederationRuntimePlugin;
5
+ export = export_default;
6
+ //# sourceMappingURL=runtimePlugin.d.ts.map
@@ -0,0 +1,168 @@
1
+ const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
2
+ let _module_federation_runtime_core = require("@module-federation/runtime-core");
3
+
4
+ //#region src/plugins/container/runtimePlugin.ts
5
+ function runtimePlugin_default() {
6
+ return {
7
+ name: "next-internal-plugin",
8
+ createScript: function(args) {
9
+ const url = args.url;
10
+ const attrs = args.attrs;
11
+ if (typeof window !== "undefined") {
12
+ const script = document.createElement("script");
13
+ script.src = url;
14
+ script.async = true;
15
+ delete attrs?.["crossorigin"];
16
+ return {
17
+ script,
18
+ timeout: 8e3
19
+ };
20
+ }
21
+ },
22
+ errorLoadRemote: function(args) {
23
+ const id = args.id;
24
+ const error = args.error;
25
+ const from = args.from;
26
+ globalThis.moduleGraphDirty = true;
27
+ console.error(id, "offline");
28
+ const pg = function() {
29
+ console.error(id, "offline", error);
30
+ return null;
31
+ };
32
+ pg.getInitialProps = function(ctx) {
33
+ return {};
34
+ };
35
+ let mod;
36
+ if (from === "build") mod = function() {
37
+ return {
38
+ __esModule: true,
39
+ default: pg,
40
+ getServerSideProps: function() {
41
+ return { props: {} };
42
+ }
43
+ };
44
+ };
45
+ else mod = {
46
+ default: pg,
47
+ getServerSideProps: function() {
48
+ return { props: {} };
49
+ }
50
+ };
51
+ return mod;
52
+ },
53
+ beforeInit: function(args) {
54
+ if (!globalThis.usedChunks) globalThis.usedChunks = /* @__PURE__ */ new Set();
55
+ if (typeof __webpack_runtime_id__ === "string" && !__webpack_runtime_id__.startsWith("webpack")) return args;
56
+ const moduleCache = args.origin.moduleCache;
57
+ const name = args.origin.name;
58
+ let gs;
59
+ try {
60
+ gs = new Function("return globalThis")();
61
+ } catch (e) {
62
+ gs = globalThis;
63
+ }
64
+ const attachedRemote = gs[name];
65
+ if (attachedRemote) moduleCache.set(name, attachedRemote);
66
+ return args;
67
+ },
68
+ init: function(args) {
69
+ return args;
70
+ },
71
+ beforeRequest: function(args) {
72
+ const options = args.options;
73
+ const id = args.id;
74
+ const match = (0, _module_federation_runtime_core.matchRemoteWithNameAndExpose)(options.remotes, id);
75
+ if (!match) return args;
76
+ const remote = match.remote;
77
+ if (!("entry" in remote) || !remote.entry || /[?&]t=/.test(remote.entry)) return args;
78
+ remote.entry = remote.entry + (remote.entry.includes("?") ? "&" : "?") + "t=" + Date.now();
79
+ return args;
80
+ },
81
+ afterResolve: function(args) {
82
+ return args;
83
+ },
84
+ onLoad: function(args) {
85
+ const exposeModuleFactory = args.exposeModuleFactory;
86
+ const exposeModule = args.exposeModule;
87
+ const id = args.id;
88
+ const moduleOrFactory = exposeModuleFactory || exposeModule;
89
+ if (!moduleOrFactory) return args;
90
+ if (typeof window === "undefined") {
91
+ let exposedModuleExports;
92
+ try {
93
+ exposedModuleExports = moduleOrFactory();
94
+ } catch (e) {
95
+ exposedModuleExports = moduleOrFactory;
96
+ }
97
+ const handler = { get: function(target, prop, receiver) {
98
+ if (target === exposedModuleExports && typeof exposedModuleExports[prop] === "function") return function() {
99
+ globalThis.usedChunks.add(id);
100
+ return exposedModuleExports[prop].apply(this, arguments);
101
+ };
102
+ const originalMethod = target[prop];
103
+ if (typeof originalMethod === "function") {
104
+ const proxiedFunction = function() {
105
+ globalThis.usedChunks.add(id);
106
+ return originalMethod.apply(this, arguments);
107
+ };
108
+ Object.keys(originalMethod).forEach(function(prop) {
109
+ Object.defineProperty(proxiedFunction, prop, {
110
+ value: originalMethod[prop],
111
+ writable: true,
112
+ enumerable: true,
113
+ configurable: true
114
+ });
115
+ });
116
+ return proxiedFunction;
117
+ }
118
+ return Reflect.get(target, prop, receiver);
119
+ } };
120
+ if (typeof exposedModuleExports === "function") {
121
+ exposedModuleExports = new Proxy(exposedModuleExports, handler);
122
+ Object.getOwnPropertyNames(exposedModuleExports).forEach(function(prop) {
123
+ if (typeof exposedModuleExports[prop] === "function") exposedModuleExports[prop] = new Proxy(exposedModuleExports[prop], handler);
124
+ });
125
+ return function() {
126
+ return exposedModuleExports;
127
+ };
128
+ } else exposedModuleExports = new Proxy(exposedModuleExports, handler);
129
+ return exposedModuleExports;
130
+ }
131
+ return args;
132
+ },
133
+ loadRemoteSnapshot(args) {
134
+ const { from, remoteSnapshot, manifestUrl, manifestJson, options } = args;
135
+ if (from !== "manifest" || !manifestUrl || !manifestJson || !("publicPath" in remoteSnapshot)) return args;
136
+ const { publicPath } = remoteSnapshot;
137
+ if (options.inBrowser && publicPath.includes("/_next/")) remoteSnapshot.publicPath = publicPath.substring(0, publicPath.lastIndexOf("/_next/") + 7);
138
+ else remoteSnapshot.publicPath = manifestUrl.substring(0, manifestUrl.indexOf("mf-manifest.json"));
139
+ if ("publicPath" in manifestJson.metaData) manifestJson.metaData.publicPath = remoteSnapshot.publicPath;
140
+ return args;
141
+ },
142
+ resolveShare: function(args) {
143
+ if (args.pkgName !== "react" && args.pkgName !== "react-dom" && !args.pkgName.startsWith("next/")) return args;
144
+ const shareScopeMap = args.shareScopeMap;
145
+ const scope = args.scope;
146
+ const pkgName = args.pkgName;
147
+ const version = args.version;
148
+ const host = args.GlobalFederation["__INSTANCES__"][0];
149
+ if (!host) return args;
150
+ if (!host.options.shared[pkgName]) return args;
151
+ args.resolver = function() {
152
+ shareScopeMap[scope][pkgName][version] = host.options.shared[pkgName][0];
153
+ return {
154
+ shared: shareScopeMap[scope][pkgName][version],
155
+ useTreesShaking: false
156
+ };
157
+ };
158
+ return args;
159
+ },
160
+ beforeLoadShare: async function(args) {
161
+ return args;
162
+ }
163
+ };
164
+ }
165
+
166
+ //#endregion
167
+ module.exports = runtimePlugin_default;
168
+ //# sourceMappingURL=runtimePlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimePlugin.js","names":[],"sources":["../../../../src/plugins/container/runtimePlugin.ts"],"sourcesContent":["import { ModuleFederationRuntimePlugin } from '@module-federation/runtime';\nimport { matchRemoteWithNameAndExpose } from '@module-federation/runtime-core';\n\nexport default function (): ModuleFederationRuntimePlugin {\n return {\n name: 'next-internal-plugin',\n createScript: function (args: {\n url: string;\n attrs?: Record<string, any>;\n }) {\n const url = args.url;\n const attrs = args.attrs;\n if (typeof window !== 'undefined') {\n const script = document.createElement('script');\n script.src = url;\n script.async = true;\n delete attrs?.['crossorigin'];\n\n return { script: script, timeout: 8000 };\n }\n return undefined;\n },\n errorLoadRemote: function (args: {\n id: string;\n error: any;\n from: string;\n origin: any;\n }) {\n const id = args.id;\n const error = args.error;\n const from = args.from;\n //@ts-ignore\n globalThis.moduleGraphDirty = true;\n console.error(id, 'offline');\n const pg = function () {\n console.error(id, 'offline', error);\n return null;\n };\n\n (pg as any).getInitialProps = function (ctx: any) {\n return {};\n };\n let mod;\n if (from === 'build') {\n mod = function () {\n return {\n __esModule: true,\n default: pg,\n getServerSideProps: function () {\n return { props: {} };\n },\n };\n };\n } else {\n mod = {\n default: pg,\n getServerSideProps: function () {\n return { props: {} };\n },\n };\n }\n\n return mod;\n },\n beforeInit: function (args) {\n if (!globalThis.usedChunks) globalThis.usedChunks = new Set();\n if (\n typeof __webpack_runtime_id__ === 'string' &&\n !__webpack_runtime_id__.startsWith('webpack')\n ) {\n return args;\n }\n\n const moduleCache = args.origin.moduleCache;\n const name = args.origin.name;\n let gs;\n try {\n gs = new Function('return globalThis')();\n } catch (e) {\n gs = globalThis; // fallback for browsers without 'unsafe-eval' CSP policy enabled\n }\n //@ts-ignore\n const attachedRemote = gs[name];\n if (attachedRemote) {\n moduleCache.set(name, attachedRemote);\n }\n\n return args;\n },\n init: function (args: any) {\n return args;\n },\n beforeRequest: function (args: any) {\n const options = args.options;\n const id = args.id;\n const match = matchRemoteWithNameAndExpose(options.remotes, id);\n if (!match) return args;\n const remote = match.remote;\n if (\n !('entry' in remote) ||\n !remote.entry ||\n /[?&]t=/.test(remote.entry)\n ) {\n return args;\n }\n remote.entry =\n remote.entry +\n (remote.entry.includes('?') ? '&' : '?') +\n 't=' +\n Date.now();\n return args;\n },\n afterResolve: function (args: any) {\n return args;\n },\n onLoad: function (args: any) {\n const exposeModuleFactory = args.exposeModuleFactory;\n const exposeModule = args.exposeModule;\n const id = args.id;\n const moduleOrFactory = exposeModuleFactory || exposeModule;\n if (!moduleOrFactory) return args;\n\n if (typeof window === 'undefined') {\n let exposedModuleExports: any;\n try {\n exposedModuleExports = moduleOrFactory();\n } catch (e) {\n exposedModuleExports = moduleOrFactory;\n }\n\n const handler: ProxyHandler<any> = {\n get: function (target, prop, receiver) {\n if (\n target === exposedModuleExports &&\n typeof exposedModuleExports[prop] === 'function'\n ) {\n return function (this: unknown) {\n globalThis.usedChunks.add(id);\n //eslint-disable-next-line\n return exposedModuleExports[prop].apply(this, arguments);\n };\n }\n\n const originalMethod = target[prop];\n if (typeof originalMethod === 'function') {\n const proxiedFunction = function (this: unknown) {\n globalThis.usedChunks.add(id);\n //eslint-disable-next-line\n return originalMethod.apply(this, arguments);\n };\n\n Object.keys(originalMethod).forEach(function (prop) {\n Object.defineProperty(proxiedFunction, prop, {\n value: originalMethod[prop],\n writable: true,\n enumerable: true,\n configurable: true,\n });\n });\n\n return proxiedFunction;\n }\n\n return Reflect.get(target, prop, receiver);\n },\n };\n\n if (typeof exposedModuleExports === 'function') {\n exposedModuleExports = new Proxy(exposedModuleExports, handler);\n\n const staticProps = Object.getOwnPropertyNames(exposedModuleExports);\n staticProps.forEach(function (prop) {\n if (typeof exposedModuleExports[prop] === 'function') {\n exposedModuleExports[prop] = new Proxy(\n exposedModuleExports[prop],\n handler,\n );\n }\n });\n return function () {\n return exposedModuleExports;\n };\n } else {\n exposedModuleExports = new Proxy(exposedModuleExports, handler);\n }\n\n return exposedModuleExports;\n }\n\n return args;\n },\n loadRemoteSnapshot(args) {\n const { from, remoteSnapshot, manifestUrl, manifestJson, options } = args;\n\n // ensure snapshot is loaded from manifest\n if (\n from !== 'manifest' ||\n !manifestUrl ||\n !manifestJson ||\n !('publicPath' in remoteSnapshot)\n ) {\n return args;\n }\n\n // re-assign publicPath based on remoteEntry location if in browser nextjs remote\n const { publicPath } = remoteSnapshot;\n if (options.inBrowser && publicPath.includes('/_next/')) {\n remoteSnapshot.publicPath = publicPath.substring(\n 0,\n publicPath.lastIndexOf('/_next/') + 7,\n );\n } else {\n const serverPublicPath = manifestUrl.substring(\n 0,\n manifestUrl.indexOf('mf-manifest.json'),\n );\n remoteSnapshot.publicPath = serverPublicPath;\n }\n\n if ('publicPath' in manifestJson.metaData) {\n manifestJson.metaData.publicPath = remoteSnapshot.publicPath;\n }\n\n return args;\n },\n resolveShare: function (args: any) {\n if (\n args.pkgName !== 'react' &&\n args.pkgName !== 'react-dom' &&\n !args.pkgName.startsWith('next/')\n ) {\n return args;\n }\n const shareScopeMap = args.shareScopeMap;\n const scope = args.scope;\n const pkgName = args.pkgName;\n const version = args.version;\n const GlobalFederation = args.GlobalFederation;\n const host = GlobalFederation['__INSTANCES__'][0];\n if (!host) {\n return args;\n }\n\n if (!host.options.shared[pkgName]) {\n return args;\n }\n args.resolver = function () {\n shareScopeMap[scope][pkgName][version] =\n host.options.shared[pkgName][0];\n return {\n shared: shareScopeMap[scope][pkgName][version],\n useTreesShaking: false,\n };\n };\n return args;\n },\n beforeLoadShare: async function (args: any) {\n return args;\n },\n };\n}\n"],"mappings":";;;;AAGA,iCAA0D;AACxD,QAAO;EACL,MAAM;EACN,cAAc,SAAU,MAGrB;GACD,MAAM,MAAM,KAAK;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