@module-federation/nextjs-mf 0.0.0-perf-devtools-20260107043700 → 0.0.0-perf-website-code-usage-20260914033703

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 (147) hide show
  1. package/dist/LICENSE +21 -0
  2. package/dist/_virtual/_rolldown/runtime.js +29 -0
  3. package/dist/_virtual/_rolldown/runtime.mjs +8 -0
  4. package/dist/client/UrlNode.d.mts +17 -0
  5. package/dist/client/UrlNode.js +89 -147
  6. package/dist/client/UrlNode.js.map +1 -1
  7. package/dist/client/UrlNode.mjs +91 -0
  8. package/dist/client/UrlNode.mjs.map +1 -0
  9. package/dist/node.d.mts +1 -0
  10. package/dist/src/federation-noop.d.mts +0 -0
  11. package/dist/src/federation-noop.js +17 -0
  12. package/dist/src/federation-noop.js.map +1 -1
  13. package/dist/src/federation-noop.mjs +23 -0
  14. package/dist/src/federation-noop.mjs.map +1 -0
  15. package/dist/src/index.d.mts +3 -0
  16. package/dist/src/index.js +13 -11
  17. package/dist/src/index.js.map +1 -1
  18. package/dist/src/index.mjs +8 -0
  19. package/dist/src/index.mjs.map +1 -0
  20. package/dist/src/internal.d.mts +50 -0
  21. package/dist/src/internal.js +140 -243
  22. package/dist/src/internal.js.map +1 -1
  23. package/dist/src/internal.mjs +152 -0
  24. package/dist/src/internal.mjs.map +1 -0
  25. package/dist/src/loaders/fixImageLoader.d.mts +22 -0
  26. package/dist/src/loaders/fixImageLoader.js +91 -103
  27. package/dist/src/loaders/fixImageLoader.js.map +1 -1
  28. package/dist/src/loaders/fixImageLoader.mjs +101 -0
  29. package/dist/src/loaders/fixImageLoader.mjs.map +1 -0
  30. package/dist/src/loaders/fixUrlLoader.d.mts +13 -0
  31. package/dist/src/loaders/fixUrlLoader.js +17 -19
  32. package/dist/src/loaders/fixUrlLoader.js.map +1 -1
  33. package/dist/src/loaders/fixUrlLoader.mjs +19 -0
  34. package/dist/src/loaders/fixUrlLoader.mjs.map +1 -0
  35. package/dist/src/loaders/helpers.d.mts +17 -0
  36. package/dist/src/loaders/helpers.js +72 -124
  37. package/dist/src/loaders/helpers.js.map +1 -1
  38. package/dist/src/loaders/helpers.mjs +79 -0
  39. package/dist/src/loaders/helpers.mjs.map +1 -0
  40. package/dist/src/loaders/nextPageMapLoader.d.mts +24 -0
  41. package/dist/src/loaders/nextPageMapLoader.js +126 -144
  42. package/dist/src/loaders/nextPageMapLoader.js.map +1 -1
  43. package/dist/src/loaders/nextPageMapLoader.mjs +143 -0
  44. package/dist/src/loaders/nextPageMapLoader.mjs.map +1 -0
  45. package/dist/src/logger.d.mts +2 -0
  46. package/dist/src/logger.js +7 -7
  47. package/dist/src/logger.js.map +1 -1
  48. package/dist/src/logger.mjs +8 -0
  49. package/dist/src/logger.mjs.map +1 -0
  50. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.d.mts +5 -0
  51. package/dist/src/plugins/CopyFederationPlugin.d.mts +20 -0
  52. package/dist/src/plugins/CopyFederationPlugin.js +64 -71
  53. package/dist/src/plugins/CopyFederationPlugin.js.map +1 -1
  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/FederatedStatsCompatibilityPlugin.d.mts +22 -0
  57. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.d.ts +22 -0
  58. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.js +43 -0
  59. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.js.map +1 -0
  60. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.mjs +42 -0
  61. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.mjs.map +1 -0
  62. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.d.mts +23 -0
  63. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js +42 -53
  64. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js.map +1 -1
  65. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.mjs +46 -0
  66. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.mjs.map +1 -0
  67. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.d.mts +36 -0
  68. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js +103 -121
  69. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js.map +1 -1
  70. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.mjs +111 -0
  71. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.mjs.map +1 -0
  72. package/dist/src/plugins/NextFederationPlugin/index.d.mts +27 -0
  73. package/dist/src/plugins/NextFederationPlugin/index.js +149 -181
  74. package/dist/src/plugins/NextFederationPlugin/index.js.map +1 -1
  75. package/dist/src/plugins/NextFederationPlugin/index.mjs +151 -0
  76. package/dist/src/plugins/NextFederationPlugin/index.mjs.map +1 -0
  77. package/dist/src/plugins/NextFederationPlugin/manifest-options.d.mts +4 -0
  78. package/dist/src/plugins/NextFederationPlugin/manifest-options.d.ts +4 -0
  79. package/dist/src/plugins/NextFederationPlugin/manifest-options.js +13 -0
  80. package/dist/src/plugins/NextFederationPlugin/manifest-options.js.map +1 -0
  81. package/dist/src/plugins/NextFederationPlugin/manifest-options.mjs +12 -0
  82. package/dist/src/plugins/NextFederationPlugin/manifest-options.mjs.map +1 -0
  83. package/dist/src/plugins/NextFederationPlugin/next-fragments.d.mts +20 -0
  84. package/dist/src/plugins/NextFederationPlugin/next-fragments.js +58 -93
  85. package/dist/src/plugins/NextFederationPlugin/next-fragments.js.map +1 -1
  86. package/dist/src/plugins/NextFederationPlugin/next-fragments.mjs +63 -0
  87. package/dist/src/plugins/NextFederationPlugin/next-fragments.mjs.map +1 -0
  88. package/dist/src/plugins/NextFederationPlugin/{regex-equal.js → regex-equal.d.mts} +2 -13
  89. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.d.mts +8 -0
  90. package/dist/src/plugins/NextFederationPlugin/set-options.d.mts +6 -0
  91. package/dist/src/plugins/NextFederationPlugin/set-options.d.ts +1 -11
  92. package/dist/src/plugins/NextFederationPlugin/set-options.js +17 -19
  93. package/dist/src/plugins/NextFederationPlugin/set-options.js.map +1 -1
  94. package/dist/src/plugins/NextFederationPlugin/set-options.mjs +19 -0
  95. package/dist/src/plugins/NextFederationPlugin/set-options.mjs.map +1 -0
  96. package/dist/src/plugins/NextFederationPlugin/validate-options.d.mts +25 -0
  97. package/dist/src/plugins/NextFederationPlugin/validate-options.js +30 -38
  98. package/dist/src/plugins/NextFederationPlugin/validate-options.js.map +1 -1
  99. package/dist/src/plugins/NextFederationPlugin/validate-options.mjs +35 -0
  100. package/dist/src/plugins/NextFederationPlugin/validate-options.mjs.map +1 -0
  101. package/dist/src/plugins/container/InvertedContainerPlugin.d.mts +5 -0
  102. package/dist/src/plugins/container/InvertedContainerPlugin.js +23 -25
  103. package/dist/src/plugins/container/InvertedContainerPlugin.js.map +1 -1
  104. package/dist/src/plugins/container/InvertedContainerPlugin.mjs +27 -0
  105. package/dist/src/plugins/container/InvertedContainerPlugin.mjs.map +1 -0
  106. package/dist/src/plugins/container/InvertedContainerRuntimeModule.d.mts +11 -0
  107. package/dist/src/plugins/container/InvertedContainerRuntimeModule.d.ts +1 -1
  108. package/dist/src/plugins/container/InvertedContainerRuntimeModule.js +55 -67
  109. package/dist/src/plugins/container/InvertedContainerRuntimeModule.js.map +1 -1
  110. package/dist/src/plugins/container/InvertedContainerRuntimeModule.mjs +57 -0
  111. package/dist/src/plugins/container/InvertedContainerRuntimeModule.mjs.map +1 -0
  112. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.d.mts +39 -0
  113. package/dist/src/plugins/container/runtimePlugin.d.mts +2 -0
  114. package/dist/src/plugins/container/runtimePlugin.d.ts +1 -1
  115. package/dist/src/plugins/container/runtimePlugin.js +170 -0
  116. package/dist/src/plugins/container/runtimePlugin.js.map +1 -1
  117. package/dist/src/plugins/container/runtimePlugin.mjs +169 -0
  118. package/dist/src/plugins/container/runtimePlugin.mjs.map +1 -0
  119. package/dist/src/plugins/container/types.d.mts +2 -0
  120. package/dist/src/types.d.mts +28 -0
  121. package/dist/utils/flushedChunks.d.mts +22 -0
  122. package/dist/utils/flushedChunks.js +32 -72
  123. package/dist/utils/flushedChunks.js.map +1 -1
  124. package/dist/utils/flushedChunks.mjs +35 -0
  125. package/dist/utils/flushedChunks.mjs.map +1 -0
  126. package/dist/utils/index.d.mts +20 -0
  127. package/dist/utils/index.js +27 -62
  128. package/dist/utils/index.js.map +1 -1
  129. package/dist/utils/index.mjs +22 -0
  130. package/dist/utils/index.mjs.map +1 -0
  131. package/package.json +45 -10
  132. package/dist/node.js +0 -18
  133. package/dist/node.js.map +0 -1
  134. package/dist/package.json +0 -71
  135. package/dist/src/federation-noop.cjs +0 -15
  136. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js +0 -19
  137. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js.map +0 -1
  138. package/dist/src/plugins/NextFederationPlugin/regex-equal.js.map +0 -1
  139. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js +0 -34
  140. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js.map +0 -1
  141. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js +0 -78
  142. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js.map +0 -1
  143. package/dist/src/plugins/container/runtimePlugin.cjs +0 -216
  144. package/dist/src/plugins/container/types.js +0 -3
  145. package/dist/src/plugins/container/types.js.map +0 -1
  146. package/dist/src/types.js +0 -3
  147. package/dist/src/types.js.map +0 -1
@@ -1,74 +1,67 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const fs_1 = require("fs");
7
- const path_1 = __importDefault(require("path"));
8
- const sdk_1 = require("@module-federation/sdk");
9
- const logger_1 = __importDefault(require("../logger"));
1
+ const require_runtime = require('../../_virtual/_rolldown/runtime.js');
2
+ const require_logger = require('../logger.js');
3
+ let path = require("path");
4
+ path = require_runtime.__toESM(path);
5
+ let fs = require("fs");
6
+ let _module_federation_sdk = require("@module-federation/sdk");
7
+
8
+ //#region src/plugins/CopyFederationPlugin.ts
10
9
  /**
11
- * Plugin to copy build output files.
12
- * @class
13
- */
14
- class CopyBuildOutputPlugin {
15
- /**
16
- * @param {boolean} isServer - Indicates if the current environment is server.
17
- * @constructor
18
- */
19
- constructor(isServer) {
20
- this.isServer = isServer;
21
- }
22
- /**
23
- * Applies the plugin to the compiler.
24
- * @param {Compiler} compiler - The webpack compiler object.
25
- * @method
26
- */
27
- apply(compiler) {
28
- (0, sdk_1.bindLoggerToCompiler)(logger_1.default, compiler, 'CopyBuildOutputPlugin');
29
- /**
30
- * Copies files from source to destination.
31
- * @param {string} source - The source directory.
32
- * @param {string} destination - The destination directory.
33
- * @async
34
- * @function
35
- */
36
- const copyFiles = async (source, destination) => {
37
- const files = await fs_1.promises.readdir(source);
38
- await Promise.all(files.map(async (file) => {
39
- const sourcePath = path_1.default.join(source, file);
40
- const destinationPath = path_1.default.join(destination, file);
41
- if ((await fs_1.promises.lstat(sourcePath)).isDirectory()) {
42
- await fs_1.promises.mkdir(destinationPath, { recursive: true });
43
- await copyFiles(sourcePath, destinationPath);
44
- }
45
- else {
46
- await fs_1.promises.copyFile(sourcePath, destinationPath);
47
- }
48
- }));
49
- };
50
- compiler.hooks.afterEmit.tapPromise('CopyBuildOutputPlugin', async (compilation) => {
51
- const { outputPath } = compiler;
52
- const outputString = outputPath.split('server')[0];
53
- const isProd = compiler.options.mode === 'production';
54
- if (!isProd && !this.isServer) {
55
- return;
56
- }
57
- const serverLoc = path_1.default.join(outputString, this.isServer && isProd ? '/ssr' : '/static/ssr');
58
- const servingLoc = path_1.default.join(outputPath, 'ssr');
59
- await fs_1.promises.mkdir(serverLoc, { recursive: true });
60
- const sourcePath = this.isServer ? outputPath : servingLoc;
61
- try {
62
- await fs_1.promises.access(sourcePath);
63
- // If the promise resolves, the file exists and you can proceed with copying.
64
- await copyFiles(sourcePath, serverLoc);
65
- }
66
- catch (error) {
67
- // If the promise rejects, the file does not exist.
68
- logger_1.default.error(`File at ${sourcePath} does not exist.`);
69
- }
70
- });
71
- }
72
- }
10
+ * Plugin to copy build output files.
11
+ * @class
12
+ */
13
+ var CopyBuildOutputPlugin = class {
14
+ /**
15
+ * @param {boolean} isServer - Indicates if the current environment is server.
16
+ * @constructor
17
+ */
18
+ constructor(isServer) {
19
+ this.isServer = isServer;
20
+ }
21
+ /**
22
+ * Applies the plugin to the compiler.
23
+ * @param {Compiler} compiler - The webpack compiler object.
24
+ * @method
25
+ */
26
+ apply(compiler) {
27
+ (0, _module_federation_sdk.bindLoggerToCompiler)(require_logger.default, compiler, "CopyBuildOutputPlugin");
28
+ /**
29
+ * Copies files from source to destination.
30
+ * @param {string} source - The source directory.
31
+ * @param {string} destination - The destination directory.
32
+ * @async
33
+ * @function
34
+ */
35
+ const copyFiles = async (source, destination) => {
36
+ const files = await fs.promises.readdir(source);
37
+ await Promise.all(files.map(async (file) => {
38
+ const sourcePath = path.default.join(source, file);
39
+ const destinationPath = path.default.join(destination, file);
40
+ if ((await fs.promises.lstat(sourcePath)).isDirectory()) {
41
+ await fs.promises.mkdir(destinationPath, { recursive: true });
42
+ await copyFiles(sourcePath, destinationPath);
43
+ } else await fs.promises.copyFile(sourcePath, destinationPath);
44
+ }));
45
+ };
46
+ compiler.hooks.afterEmit.tapPromise("CopyBuildOutputPlugin", async (compilation) => {
47
+ const { outputPath } = compiler;
48
+ const outputString = outputPath.split("server")[0];
49
+ const isProd = compiler.options.mode === "production";
50
+ if (!isProd && !this.isServer) return;
51
+ const serverLoc = path.default.join(outputString, this.isServer && isProd ? "/ssr" : "/static/ssr");
52
+ const servingLoc = path.default.join(outputPath, "ssr");
53
+ await fs.promises.mkdir(serverLoc, { recursive: true });
54
+ const sourcePath = this.isServer ? outputPath : servingLoc;
55
+ try {
56
+ await fs.promises.access(sourcePath);
57
+ await copyFiles(sourcePath, serverLoc);
58
+ } catch (error) {
59
+ require_logger.default.error(`File at ${sourcePath} does not exist.`);
60
+ }
61
+ });
62
+ }
63
+ };
64
+
65
+ //#endregion
73
66
  exports.default = CopyBuildOutputPlugin;
74
67
  //# sourceMappingURL=CopyFederationPlugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CopyFederationPlugin.js","sourceRoot":"","sources":["../../../src/plugins/CopyFederationPlugin.ts"],"names":[],"mappings":";;;;;AAAA,2BAAoC;AACpC,gDAAwB;AAExB,gDAA8D;AAC9D,uDAA+B;AAE/B;;;GAGG;AACH,MAAM,qBAAqB;IAGzB;;;OAGG;IACH,YAAY,QAAiB;QAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,QAAkB;QACtB,IAAA,0BAAoB,EAAC,gBAAM,EAAE,QAAQ,EAAE,uBAAuB,CAAC,CAAC;QAChE;;;;;;WAMG;QACH,MAAM,SAAS,GAAG,KAAK,EACrB,MAAc,EACd,WAAmB,EACJ,EAAE;YACjB,MAAM,KAAK,GAAG,MAAM,aAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YAEvC,MAAM,OAAO,CAAC,GAAG,CACf,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;gBACvB,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;gBAC3C,MAAM,eAAe,GAAG,cAAI,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;gBAErD,IAAI,CAAC,MAAM,aAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC;oBAC/C,MAAM,aAAE,CAAC,KAAK,CAAC,eAAe,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;oBACrD,MAAM,SAAS,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;gBAC/C,CAAC;qBAAM,CAAC;oBACN,MAAM,aAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;gBACjD,CAAC;YACH,CAAC,CAAC,CACH,CAAC;QACJ,CAAC,CAAC;QAEF,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,UAAU,CACjC,uBAAuB,EACvB,KAAK,EAAE,WAAwB,EAAE,EAAE;YACjC,MAAM,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC;YAChC,MAAM,YAAY,GAAG,UAAU,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YACnD,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC;YAEtD,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAC9B,OAAO;YACT,CAAC;YAED,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,CACzB,YAAY,EACZ,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,CACjD,CAAC;YACF,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;YAEhD,MAAM,aAAE,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;YAE/C,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC;YAE3D,IAAI,CAAC;gBACH,MAAM,aAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;gBAC5B,6EAA6E;gBAC7E,MAAM,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;YACzC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,mDAAmD;gBACnD,gBAAM,CAAC,KAAK,CAAC,WAAW,UAAU,kBAAkB,CAAC,CAAC;YACxD,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AAED,kBAAe,qBAAqB,CAAC"}
1
+ {"version":3,"file":"CopyFederationPlugin.js","names":["logger"],"sources":["../../../src/plugins/CopyFederationPlugin.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport path from 'path';\nimport type { Compilation, Compiler, WebpackPluginInstance } from 'webpack';\nimport { bindLoggerToCompiler } from '@module-federation/sdk';\nimport logger from '../logger';\n\n/**\n * Plugin to copy build output files.\n * @class\n */\nclass CopyBuildOutputPlugin implements WebpackPluginInstance {\n private isServer: boolean;\n\n /**\n * @param {boolean} isServer - Indicates if the current environment is server.\n * @constructor\n */\n constructor(isServer: boolean) {\n this.isServer = isServer;\n }\n\n /**\n * Applies the plugin to the compiler.\n * @param {Compiler} compiler - The webpack compiler object.\n * @method\n */\n apply(compiler: Compiler): void {\n bindLoggerToCompiler(logger, compiler, 'CopyBuildOutputPlugin');\n /**\n * Copies files from source to destination.\n * @param {string} source - The source directory.\n * @param {string} destination - The destination directory.\n * @async\n * @function\n */\n const copyFiles = async (\n source: string,\n destination: string,\n ): Promise<void> => {\n const files = await fs.readdir(source);\n\n await Promise.all(\n files.map(async (file) => {\n const sourcePath = path.join(source, file);\n const destinationPath = path.join(destination, file);\n\n if ((await fs.lstat(sourcePath)).isDirectory()) {\n await fs.mkdir(destinationPath, { recursive: true });\n await copyFiles(sourcePath, destinationPath);\n } else {\n await fs.copyFile(sourcePath, destinationPath);\n }\n }),\n );\n };\n\n compiler.hooks.afterEmit.tapPromise(\n 'CopyBuildOutputPlugin',\n async (compilation: Compilation) => {\n const { outputPath } = compiler;\n const outputString = outputPath.split('server')[0];\n const isProd = compiler.options.mode === 'production';\n\n if (!isProd && !this.isServer) {\n return;\n }\n\n const serverLoc = path.join(\n outputString,\n this.isServer && isProd ? '/ssr' : '/static/ssr',\n );\n const servingLoc = path.join(outputPath, 'ssr');\n\n await fs.mkdir(serverLoc, { recursive: true });\n\n const sourcePath = this.isServer ? outputPath : servingLoc;\n\n try {\n await fs.access(sourcePath);\n // If the promise resolves, the file exists and you can proceed with copying.\n await copyFiles(sourcePath, serverLoc);\n } catch (error) {\n // If the promise rejects, the file does not exist.\n logger.error(`File at ${sourcePath} does not exist.`);\n }\n },\n );\n }\n}\n\nexport default CopyBuildOutputPlugin;\n"],"mappings":";;;;;;;;;;;;AAUA,IAAM,wBAAN,MAA6D;;;;;CAO3D,YAAY,UAAmB;AAC7B,OAAK,WAAW;;;;;;;CAQlB,MAAM,UAA0B;AAC9B,mDAAqBA,wBAAQ,UAAU,wBAAwB;;;;;;;;EAQ/D,MAAM,YAAY,OAChB,QACA,gBACkB;GAClB,MAAM,QAAQ,MAAM,YAAG,QAAQ,OAAO;AAEtC,SAAM,QAAQ,IACZ,MAAM,IAAI,OAAO,SAAS;IACxB,MAAM,aAAa,aAAK,KAAK,QAAQ,KAAK;IAC1C,MAAM,kBAAkB,aAAK,KAAK,aAAa,KAAK;AAEpD,SAAK,MAAM,YAAG,MAAM,WAAW,EAAE,aAAa,EAAE;AAC9C,WAAM,YAAG,MAAM,iBAAiB,EAAE,WAAW,MAAM,CAAC;AACpD,WAAM,UAAU,YAAY,gBAAgB;UAE5C,OAAM,YAAG,SAAS,YAAY,gBAAgB;KAEhD,CACH;;AAGH,WAAS,MAAM,UAAU,WACvB,yBACA,OAAO,gBAA6B;GAClC,MAAM,EAAE,eAAe;GACvB,MAAM,eAAe,WAAW,MAAM,SAAS,CAAC;GAChD,MAAM,SAAS,SAAS,QAAQ,SAAS;AAEzC,OAAI,CAAC,UAAU,CAAC,KAAK,SACnB;GAGF,MAAM,YAAY,aAAK,KACrB,cACA,KAAK,YAAY,SAAS,SAAS,cACpC;GACD,MAAM,aAAa,aAAK,KAAK,YAAY,MAAM;AAE/C,SAAM,YAAG,MAAM,WAAW,EAAE,WAAW,MAAM,CAAC;GAE9C,MAAM,aAAa,KAAK,WAAW,aAAa;AAEhD,OAAI;AACF,UAAM,YAAG,OAAO,WAAW;AAE3B,UAAM,UAAU,YAAY,UAAU;YAC/B,OAAO;AAEd,2BAAO,MAAM,WAAW,WAAW,kBAAkB;;IAG1D"}
@@ -0,0 +1,65 @@
1
+ import logger from "../logger.mjs";
2
+ import path from "path";
3
+ import { promises } from "fs";
4
+ import { bindLoggerToCompiler } from "@module-federation/sdk";
5
+
6
+ //#region src/plugins/CopyFederationPlugin.ts
7
+ /**
8
+ * Plugin to copy build output files.
9
+ * @class
10
+ */
11
+ var CopyBuildOutputPlugin = class {
12
+ /**
13
+ * @param {boolean} isServer - Indicates if the current environment is server.
14
+ * @constructor
15
+ */
16
+ constructor(isServer) {
17
+ this.isServer = isServer;
18
+ }
19
+ /**
20
+ * Applies the plugin to the compiler.
21
+ * @param {Compiler} compiler - The webpack compiler object.
22
+ * @method
23
+ */
24
+ apply(compiler) {
25
+ bindLoggerToCompiler(logger, compiler, "CopyBuildOutputPlugin");
26
+ /**
27
+ * Copies files from source to destination.
28
+ * @param {string} source - The source directory.
29
+ * @param {string} destination - The destination directory.
30
+ * @async
31
+ * @function
32
+ */
33
+ const copyFiles = async (source, destination) => {
34
+ const files = await promises.readdir(source);
35
+ await Promise.all(files.map(async (file) => {
36
+ const sourcePath = path.join(source, file);
37
+ const destinationPath = path.join(destination, file);
38
+ if ((await promises.lstat(sourcePath)).isDirectory()) {
39
+ await promises.mkdir(destinationPath, { recursive: true });
40
+ await copyFiles(sourcePath, destinationPath);
41
+ } else await promises.copyFile(sourcePath, destinationPath);
42
+ }));
43
+ };
44
+ compiler.hooks.afterEmit.tapPromise("CopyBuildOutputPlugin", async (compilation) => {
45
+ const { outputPath } = compiler;
46
+ const outputString = outputPath.split("server")[0];
47
+ const isProd = compiler.options.mode === "production";
48
+ if (!isProd && !this.isServer) return;
49
+ const serverLoc = path.join(outputString, this.isServer && isProd ? "/ssr" : "/static/ssr");
50
+ const servingLoc = path.join(outputPath, "ssr");
51
+ await promises.mkdir(serverLoc, { recursive: true });
52
+ const sourcePath = this.isServer ? outputPath : servingLoc;
53
+ try {
54
+ await promises.access(sourcePath);
55
+ await copyFiles(sourcePath, serverLoc);
56
+ } catch (error) {
57
+ logger.error(`File at ${sourcePath} does not exist.`);
58
+ }
59
+ });
60
+ }
61
+ };
62
+
63
+ //#endregion
64
+ export { CopyBuildOutputPlugin as default };
65
+ //# sourceMappingURL=CopyFederationPlugin.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CopyFederationPlugin.mjs","names":["fs"],"sources":["../../../src/plugins/CopyFederationPlugin.ts"],"sourcesContent":["import { promises as fs } from 'fs';\nimport path from 'path';\nimport type { Compilation, Compiler, WebpackPluginInstance } from 'webpack';\nimport { bindLoggerToCompiler } from '@module-federation/sdk';\nimport logger from '../logger';\n\n/**\n * Plugin to copy build output files.\n * @class\n */\nclass CopyBuildOutputPlugin implements WebpackPluginInstance {\n private isServer: boolean;\n\n /**\n * @param {boolean} isServer - Indicates if the current environment is server.\n * @constructor\n */\n constructor(isServer: boolean) {\n this.isServer = isServer;\n }\n\n /**\n * Applies the plugin to the compiler.\n * @param {Compiler} compiler - The webpack compiler object.\n * @method\n */\n apply(compiler: Compiler): void {\n bindLoggerToCompiler(logger, compiler, 'CopyBuildOutputPlugin');\n /**\n * Copies files from source to destination.\n * @param {string} source - The source directory.\n * @param {string} destination - The destination directory.\n * @async\n * @function\n */\n const copyFiles = async (\n source: string,\n destination: string,\n ): Promise<void> => {\n const files = await fs.readdir(source);\n\n await Promise.all(\n files.map(async (file) => {\n const sourcePath = path.join(source, file);\n const destinationPath = path.join(destination, file);\n\n if ((await fs.lstat(sourcePath)).isDirectory()) {\n await fs.mkdir(destinationPath, { recursive: true });\n await copyFiles(sourcePath, destinationPath);\n } else {\n await fs.copyFile(sourcePath, destinationPath);\n }\n }),\n );\n };\n\n compiler.hooks.afterEmit.tapPromise(\n 'CopyBuildOutputPlugin',\n async (compilation: Compilation) => {\n const { outputPath } = compiler;\n const outputString = outputPath.split('server')[0];\n const isProd = compiler.options.mode === 'production';\n\n if (!isProd && !this.isServer) {\n return;\n }\n\n const serverLoc = path.join(\n outputString,\n this.isServer && isProd ? '/ssr' : '/static/ssr',\n );\n const servingLoc = path.join(outputPath, 'ssr');\n\n await fs.mkdir(serverLoc, { recursive: true });\n\n const sourcePath = this.isServer ? outputPath : servingLoc;\n\n try {\n await fs.access(sourcePath);\n // If the promise resolves, the file exists and you can proceed with copying.\n await copyFiles(sourcePath, serverLoc);\n } catch (error) {\n // If the promise rejects, the file does not exist.\n logger.error(`File at ${sourcePath} does not exist.`);\n }\n },\n );\n }\n}\n\nexport default CopyBuildOutputPlugin;\n"],"mappings":";;;;;;;;;;AAUA,IAAM,wBAAN,MAA6D;;;;;CAO3D,YAAY,UAAmB;AAC7B,OAAK,WAAW;;;;;;;CAQlB,MAAM,UAA0B;AAC9B,uBAAqB,QAAQ,UAAU,wBAAwB;;;;;;;;EAQ/D,MAAM,YAAY,OAChB,QACA,gBACkB;GAClB,MAAM,QAAQ,MAAMA,SAAG,QAAQ,OAAO;AAEtC,SAAM,QAAQ,IACZ,MAAM,IAAI,OAAO,SAAS;IACxB,MAAM,aAAa,KAAK,KAAK,QAAQ,KAAK;IAC1C,MAAM,kBAAkB,KAAK,KAAK,aAAa,KAAK;AAEpD,SAAK,MAAMA,SAAG,MAAM,WAAW,EAAE,aAAa,EAAE;AAC9C,WAAMA,SAAG,MAAM,iBAAiB,EAAE,WAAW,MAAM,CAAC;AACpD,WAAM,UAAU,YAAY,gBAAgB;UAE5C,OAAMA,SAAG,SAAS,YAAY,gBAAgB;KAEhD,CACH;;AAGH,WAAS,MAAM,UAAU,WACvB,yBACA,OAAO,gBAA6B;GAClC,MAAM,EAAE,eAAe;GACvB,MAAM,eAAe,WAAW,MAAM,SAAS,CAAC;GAChD,MAAM,SAAS,SAAS,QAAQ,SAAS;AAEzC,OAAI,CAAC,UAAU,CAAC,KAAK,SACnB;GAGF,MAAM,YAAY,KAAK,KACrB,cACA,KAAK,YAAY,SAAS,SAAS,cACpC;GACD,MAAM,aAAa,KAAK,KAAK,YAAY,MAAM;AAE/C,SAAMA,SAAG,MAAM,WAAW,EAAE,WAAW,MAAM,CAAC;GAE9C,MAAM,aAAa,KAAK,WAAW,aAAa;AAEhD,OAAI;AACF,UAAMA,SAAG,OAAO,WAAW;AAE3B,UAAM,UAAU,YAAY,UAAU;YAC/B,OAAO;AAEd,WAAO,MAAM,WAAW,WAAW,kBAAkB;;IAG1D"}
@@ -0,0 +1,22 @@
1
+ import type { Compiler, WebpackPluginInstance } from 'webpack';
2
+ import { type Manifest, type moduleFederationPlugin } from '@module-federation/sdk';
3
+ type FederatedStatsCompatibilityPluginOptions = {
4
+ filenames: string[];
5
+ manifest: moduleFederationPlugin.ModuleFederationPluginOptions['manifest'];
6
+ };
7
+ export declare const createFederatedStats: (manifest: Manifest) => {
8
+ sharedModules: any[];
9
+ federatedModules: {
10
+ remote: string;
11
+ entry: string;
12
+ sharedModules: any[];
13
+ exposes: Record<string, string[]>;
14
+ remoteModules: {};
15
+ }[];
16
+ };
17
+ export declare class FederatedStatsCompatibilityPlugin implements WebpackPluginInstance {
18
+ private readonly options;
19
+ constructor(options: FederatedStatsCompatibilityPluginOptions);
20
+ apply(compiler: Compiler): void;
21
+ }
22
+ export {};
@@ -0,0 +1,22 @@
1
+ import type { Compiler, WebpackPluginInstance } from 'webpack';
2
+ import { type Manifest, type moduleFederationPlugin } from '@module-federation/sdk';
3
+ type FederatedStatsCompatibilityPluginOptions = {
4
+ filenames: string[];
5
+ manifest: moduleFederationPlugin.ModuleFederationPluginOptions['manifest'];
6
+ };
7
+ export declare const createFederatedStats: (manifest: Manifest) => {
8
+ sharedModules: any[];
9
+ federatedModules: {
10
+ remote: string;
11
+ entry: string;
12
+ sharedModules: any[];
13
+ exposes: Record<string, string[]>;
14
+ remoteModules: {};
15
+ }[];
16
+ };
17
+ export declare class FederatedStatsCompatibilityPlugin implements WebpackPluginInstance {
18
+ private readonly options;
19
+ constructor(options: FederatedStatsCompatibilityPluginOptions);
20
+ apply(compiler: Compiler): void;
21
+ }
22
+ export {};
@@ -0,0 +1,43 @@
1
+ const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
2
+ let _module_federation_sdk = require("@module-federation/sdk");
3
+
4
+ //#region src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.ts
5
+ const createFederatedStats = (manifest) => {
6
+ const exposes = {};
7
+ for (const expose of manifest.exposes) exposes[expose.path || `./${expose.name}`] = [...expose.assets.js.sync, ...expose.assets.css.sync];
8
+ return {
9
+ sharedModules: [],
10
+ federatedModules: [{
11
+ remote: manifest.name,
12
+ entry: (0, _module_federation_sdk.simpleJoinRemoteEntry)(manifest.metaData.remoteEntry.path, manifest.metaData.remoteEntry.name),
13
+ sharedModules: [],
14
+ exposes,
15
+ remoteModules: {}
16
+ }]
17
+ };
18
+ };
19
+ var FederatedStatsCompatibilityPlugin = class {
20
+ constructor(options) {
21
+ this.options = options;
22
+ }
23
+ apply(compiler) {
24
+ compiler.hooks.thisCompilation.tap("FederatedStatsCompatibilityPlugin", (compilation) => {
25
+ compilation.hooks.processAssets.tap({
26
+ name: "FederatedStatsCompatibilityPlugin",
27
+ stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT
28
+ }, () => {
29
+ const manifestFilename = (0, _module_federation_sdk.getManifestFileName)(this.options.manifest).manifestFileName;
30
+ const manifestAsset = compilation.getAsset(manifestFilename);
31
+ if (!manifestAsset) throw new Error(`Cannot emit federated-stats.json because ${manifestFilename} was not generated`);
32
+ const manifest = JSON.parse(manifestAsset.source.source().toString());
33
+ const source = new compiler.webpack.sources.RawSource(JSON.stringify(createFederatedStats(manifest)));
34
+ for (const filename of this.options.filenames) if (compilation.getAsset(filename)) compilation.updateAsset(filename, source);
35
+ else compilation.emitAsset(filename, source);
36
+ });
37
+ });
38
+ }
39
+ };
40
+
41
+ //#endregion
42
+ exports.FederatedStatsCompatibilityPlugin = FederatedStatsCompatibilityPlugin;
43
+ //# sourceMappingURL=FederatedStatsCompatibilityPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FederatedStatsCompatibilityPlugin.js","names":[],"sources":["../../../../src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.ts"],"sourcesContent":["import type { Compiler, WebpackPluginInstance } from 'webpack';\nimport {\n getManifestFileName,\n simpleJoinRemoteEntry,\n type Manifest,\n type moduleFederationPlugin,\n} from '@module-federation/sdk';\n\ntype FederatedStatsCompatibilityPluginOptions = {\n filenames: string[];\n manifest: moduleFederationPlugin.ModuleFederationPluginOptions['manifest'];\n};\n\nexport const createFederatedStats = (manifest: Manifest) => {\n const exposes: Record<string, string[]> = {};\n\n for (const expose of manifest.exposes) {\n exposes[expose.path || `./${expose.name}`] = [\n ...expose.assets.js.sync,\n ...expose.assets.css.sync,\n ];\n }\n\n return {\n sharedModules: [],\n federatedModules: [\n {\n remote: manifest.name,\n entry: simpleJoinRemoteEntry(\n manifest.metaData.remoteEntry.path,\n manifest.metaData.remoteEntry.name,\n ),\n sharedModules: [],\n exposes,\n remoteModules: {},\n },\n ],\n };\n};\n\nexport class FederatedStatsCompatibilityPlugin implements WebpackPluginInstance {\n private readonly options: FederatedStatsCompatibilityPluginOptions;\n\n constructor(options: FederatedStatsCompatibilityPluginOptions) {\n this.options = options;\n }\n\n apply(compiler: Compiler): void {\n compiler.hooks.thisCompilation.tap(\n 'FederatedStatsCompatibilityPlugin',\n (compilation) => {\n compilation.hooks.processAssets.tap(\n {\n name: 'FederatedStatsCompatibilityPlugin',\n stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT,\n },\n () => {\n const manifestFilename = getManifestFileName(\n this.options.manifest,\n ).manifestFileName;\n const manifestAsset = compilation.getAsset(manifestFilename);\n if (!manifestAsset) {\n throw new Error(\n `Cannot emit federated-stats.json because ${manifestFilename} was not generated`,\n );\n }\n\n const manifest = JSON.parse(\n manifestAsset.source.source().toString(),\n ) as Manifest;\n const source = new compiler.webpack.sources.RawSource(\n JSON.stringify(createFederatedStats(manifest)),\n );\n\n for (const filename of this.options.filenames) {\n if (compilation.getAsset(filename)) {\n compilation.updateAsset(filename, source);\n } else {\n compilation.emitAsset(filename, source);\n }\n }\n },\n );\n },\n );\n }\n}\n"],"mappings":";;;;AAaA,MAAa,wBAAwB,aAAuB;CAC1D,MAAM,UAAoC,EAAE;AAE5C,MAAK,MAAM,UAAU,SAAS,QAC5B,SAAQ,OAAO,QAAQ,KAAK,OAAO,UAAU,CAC3C,GAAG,OAAO,OAAO,GAAG,MACpB,GAAG,OAAO,OAAO,IAAI,KACtB;AAGH,QAAO;EACL,eAAe,EAAE;EACjB,kBAAkB,CAChB;GACE,QAAQ,SAAS;GACjB,yDACE,SAAS,SAAS,YAAY,MAC9B,SAAS,SAAS,YAAY,KAC/B;GACD,eAAe,EAAE;GACjB;GACA,eAAe,EAAE;GAClB,CACF;EACF;;AAGH,IAAa,oCAAb,MAAgF;CAG9E,YAAY,SAAmD;AAC7D,OAAK,UAAU;;CAGjB,MAAM,UAA0B;AAC9B,WAAS,MAAM,gBAAgB,IAC7B,sCACC,gBAAgB;AACf,eAAY,MAAM,cAAc,IAC9B;IACE,MAAM;IACN,OAAO,SAAS,QAAQ,YAAY;IACrC,QACK;IACJ,MAAM,mEACJ,KAAK,QAAQ,SACd,CAAC;IACF,MAAM,gBAAgB,YAAY,SAAS,iBAAiB;AAC5D,QAAI,CAAC,cACH,OAAM,IAAI,MACR,4CAA4C,iBAAiB,oBAC9D;IAGH,MAAM,WAAW,KAAK,MACpB,cAAc,OAAO,QAAQ,CAAC,UAAU,CACzC;IACD,MAAM,SAAS,IAAI,SAAS,QAAQ,QAAQ,UAC1C,KAAK,UAAU,qBAAqB,SAAS,CAAC,CAC/C;AAED,SAAK,MAAM,YAAY,KAAK,QAAQ,UAClC,KAAI,YAAY,SAAS,SAAS,CAChC,aAAY,YAAY,UAAU,OAAO;QAEzC,aAAY,UAAU,UAAU,OAAO;KAI9C;IAEJ"}
@@ -0,0 +1,42 @@
1
+ import { getManifestFileName, simpleJoinRemoteEntry } from "@module-federation/sdk";
2
+
3
+ //#region src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.ts
4
+ const createFederatedStats = (manifest) => {
5
+ const exposes = {};
6
+ for (const expose of manifest.exposes) exposes[expose.path || `./${expose.name}`] = [...expose.assets.js.sync, ...expose.assets.css.sync];
7
+ return {
8
+ sharedModules: [],
9
+ federatedModules: [{
10
+ remote: manifest.name,
11
+ entry: simpleJoinRemoteEntry(manifest.metaData.remoteEntry.path, manifest.metaData.remoteEntry.name),
12
+ sharedModules: [],
13
+ exposes,
14
+ remoteModules: {}
15
+ }]
16
+ };
17
+ };
18
+ var FederatedStatsCompatibilityPlugin = class {
19
+ constructor(options) {
20
+ this.options = options;
21
+ }
22
+ apply(compiler) {
23
+ compiler.hooks.thisCompilation.tap("FederatedStatsCompatibilityPlugin", (compilation) => {
24
+ compilation.hooks.processAssets.tap({
25
+ name: "FederatedStatsCompatibilityPlugin",
26
+ stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT
27
+ }, () => {
28
+ const manifestFilename = getManifestFileName(this.options.manifest).manifestFileName;
29
+ const manifestAsset = compilation.getAsset(manifestFilename);
30
+ if (!manifestAsset) throw new Error(`Cannot emit federated-stats.json because ${manifestFilename} was not generated`);
31
+ const manifest = JSON.parse(manifestAsset.source.source().toString());
32
+ const source = new compiler.webpack.sources.RawSource(JSON.stringify(createFederatedStats(manifest)));
33
+ for (const filename of this.options.filenames) if (compilation.getAsset(filename)) compilation.updateAsset(filename, source);
34
+ else compilation.emitAsset(filename, source);
35
+ });
36
+ });
37
+ }
38
+ };
39
+
40
+ //#endregion
41
+ export { FederatedStatsCompatibilityPlugin };
42
+ //# sourceMappingURL=FederatedStatsCompatibilityPlugin.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FederatedStatsCompatibilityPlugin.mjs","names":[],"sources":["../../../../src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.ts"],"sourcesContent":["import type { Compiler, WebpackPluginInstance } from 'webpack';\nimport {\n getManifestFileName,\n simpleJoinRemoteEntry,\n type Manifest,\n type moduleFederationPlugin,\n} from '@module-federation/sdk';\n\ntype FederatedStatsCompatibilityPluginOptions = {\n filenames: string[];\n manifest: moduleFederationPlugin.ModuleFederationPluginOptions['manifest'];\n};\n\nexport const createFederatedStats = (manifest: Manifest) => {\n const exposes: Record<string, string[]> = {};\n\n for (const expose of manifest.exposes) {\n exposes[expose.path || `./${expose.name}`] = [\n ...expose.assets.js.sync,\n ...expose.assets.css.sync,\n ];\n }\n\n return {\n sharedModules: [],\n federatedModules: [\n {\n remote: manifest.name,\n entry: simpleJoinRemoteEntry(\n manifest.metaData.remoteEntry.path,\n manifest.metaData.remoteEntry.name,\n ),\n sharedModules: [],\n exposes,\n remoteModules: {},\n },\n ],\n };\n};\n\nexport class FederatedStatsCompatibilityPlugin implements WebpackPluginInstance {\n private readonly options: FederatedStatsCompatibilityPluginOptions;\n\n constructor(options: FederatedStatsCompatibilityPluginOptions) {\n this.options = options;\n }\n\n apply(compiler: Compiler): void {\n compiler.hooks.thisCompilation.tap(\n 'FederatedStatsCompatibilityPlugin',\n (compilation) => {\n compilation.hooks.processAssets.tap(\n {\n name: 'FederatedStatsCompatibilityPlugin',\n stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT,\n },\n () => {\n const manifestFilename = getManifestFileName(\n this.options.manifest,\n ).manifestFileName;\n const manifestAsset = compilation.getAsset(manifestFilename);\n if (!manifestAsset) {\n throw new Error(\n `Cannot emit federated-stats.json because ${manifestFilename} was not generated`,\n );\n }\n\n const manifest = JSON.parse(\n manifestAsset.source.source().toString(),\n ) as Manifest;\n const source = new compiler.webpack.sources.RawSource(\n JSON.stringify(createFederatedStats(manifest)),\n );\n\n for (const filename of this.options.filenames) {\n if (compilation.getAsset(filename)) {\n compilation.updateAsset(filename, source);\n } else {\n compilation.emitAsset(filename, source);\n }\n }\n },\n );\n },\n );\n }\n}\n"],"mappings":";;;AAaA,MAAa,wBAAwB,aAAuB;CAC1D,MAAM,UAAoC,EAAE;AAE5C,MAAK,MAAM,UAAU,SAAS,QAC5B,SAAQ,OAAO,QAAQ,KAAK,OAAO,UAAU,CAC3C,GAAG,OAAO,OAAO,GAAG,MACpB,GAAG,OAAO,OAAO,IAAI,KACtB;AAGH,QAAO;EACL,eAAe,EAAE;EACjB,kBAAkB,CAChB;GACE,QAAQ,SAAS;GACjB,OAAO,sBACL,SAAS,SAAS,YAAY,MAC9B,SAAS,SAAS,YAAY,KAC/B;GACD,eAAe,EAAE;GACjB;GACA,eAAe,EAAE;GAClB,CACF;EACF;;AAGH,IAAa,oCAAb,MAAgF;CAG9E,YAAY,SAAmD;AAC7D,OAAK,UAAU;;CAGjB,MAAM,UAA0B;AAC9B,WAAS,MAAM,gBAAgB,IAC7B,sCACC,gBAAgB;AACf,eAAY,MAAM,cAAc,IAC9B;IACE,MAAM;IACN,OAAO,SAAS,QAAQ,YAAY;IACrC,QACK;IACJ,MAAM,mBAAmB,oBACvB,KAAK,QAAQ,SACd,CAAC;IACF,MAAM,gBAAgB,YAAY,SAAS,iBAAiB;AAC5D,QAAI,CAAC,cACH,OAAM,IAAI,MACR,4CAA4C,iBAAiB,oBAC9D;IAGH,MAAM,WAAW,KAAK,MACpB,cAAc,OAAO,QAAQ,CAAC,UAAU,CACzC;IACD,MAAM,SAAS,IAAI,SAAS,QAAQ,QAAQ,UAC1C,KAAK,UAAU,qBAAqB,SAAS,CAAC,CAC/C;AAED,SAAK,MAAM,YAAY,KAAK,QAAQ,UAClC,KAAI,YAAY,SAAS,SAAS,CAChC,aAAY,YAAY,UAAU,OAAO;QAEzC,aAAY,UAAU,UAAU,OAAO;KAI9C;IAEJ"}
@@ -0,0 +1,23 @@
1
+ import type { Compiler } from 'webpack';
2
+ import type { moduleFederationPlugin } from '@module-federation/sdk';
3
+ import type { NextFederationPluginExtraOptions } from './next-fragments';
4
+ /**
5
+ * Applies client-specific plugins.
6
+ *
7
+ * @param compiler - The Webpack compiler instance.
8
+ * @param options - The ModuleFederationPluginOptions instance.
9
+ * @param extraOptions - The NextFederationPluginExtraOptions instance.
10
+ *
11
+ * @remarks
12
+ * This function applies plugins to the Webpack compiler instance that are specific to the client build of
13
+ * a Next.js application with Module Federation enabled. These plugins include the following:
14
+ *
15
+ * - ChunkCorrelationPlugin: Collects metadata on chunks to enable proper module loading across different runtimes.
16
+ * - InvertedContainerPlugin: Adds custom runtime modules to the container runtime to allow a host to expose its
17
+ * own remote interface at startup.
18
+
19
+ * If automatic page stitching is enabled, a warning is logged indicating that it is disabled in v7.
20
+ * If a custom library is specified in the options, an error is logged. The options.library property is
21
+ * also set to `{ type: 'window', name: options.name }`.
22
+ */
23
+ export declare function applyClientPlugins(compiler: Compiler, options: moduleFederationPlugin.ModuleFederationPluginOptions, extraOptions: NextFederationPluginExtraOptions): void;
@@ -1,58 +1,47 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.applyClientPlugins = applyClientPlugins;
7
- const node_1 = require("@module-federation/node");
8
- const InvertedContainerPlugin_1 = __importDefault(require("../container/InvertedContainerPlugin"));
9
- const logger_1 = __importDefault(require("../../logger"));
1
+ const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
2
+ const require_logger = require('../../logger.js');
3
+ const require_InvertedContainerPlugin = require('../container/InvertedContainerPlugin.js');
4
+ const require_FederatedStatsCompatibilityPlugin = require('./FederatedStatsCompatibilityPlugin.js');
5
+ let _module_federation_node = require("@module-federation/node");
6
+
7
+ //#region src/plugins/NextFederationPlugin/apply-client-plugins.ts
8
+ const FEDERATED_STATS_FILENAMES = ["static/chunks/federated-stats.json", "server/federated-stats.json"];
10
9
  /**
11
- * Applies client-specific plugins.
12
- *
13
- * @param compiler - The Webpack compiler instance.
14
- * @param options - The ModuleFederationPluginOptions instance.
15
- * @param extraOptions - The NextFederationPluginExtraOptions instance.
16
- *
17
- * @remarks
18
- * This function applies plugins to the Webpack compiler instance that are specific to the client build of
19
- * a Next.js application with Module Federation enabled. These plugins include the following:
20
- *
21
- * - ChunkCorrelationPlugin: Collects metadata on chunks to enable proper module loading across different runtimes.
22
- * - InvertedContainerPlugin: Adds custom runtime modules to the container runtime to allow a host to expose its
23
- * own remote interface at startup.
10
+ * Applies client-specific plugins.
11
+ *
12
+ * @param compiler - The Webpack compiler instance.
13
+ * @param options - The ModuleFederationPluginOptions instance.
14
+ * @param extraOptions - The NextFederationPluginExtraOptions instance.
15
+ *
16
+ * @remarks
17
+ * This function applies plugins to the Webpack compiler instance that are specific to the client build of
18
+ * a Next.js application with Module Federation enabled. These plugins include the following:
19
+ *
20
+ * - ChunkCorrelationPlugin: Collects metadata on chunks to enable proper module loading across different runtimes.
21
+ * - InvertedContainerPlugin: Adds custom runtime modules to the container runtime to allow a host to expose its
22
+ * own remote interface at startup.
24
23
 
25
- * If automatic page stitching is enabled, a warning is logged indicating that it is disabled in v7.
26
- * If a custom library is specified in the options, an error is logged. The options.library property is
27
- * also set to `{ type: 'window', name: options.name }`.
28
- */
24
+ * If automatic page stitching is enabled, a warning is logged indicating that it is disabled in v7.
25
+ * If a custom library is specified in the options, an error is logged. The options.library property is
26
+ * also set to `{ type: 'window', name: options.name }`.
27
+ */
29
28
  function applyClientPlugins(compiler, options, extraOptions) {
30
- const { name } = options;
31
- // Adjust the public path if it is set to the default Next.js path
32
- if (compiler.options.output.publicPath === '/_next/') {
33
- compiler.options.output.publicPath = 'auto';
34
- }
35
- // Log a warning if automatic page stitching is enabled, as it is disabled in v7
36
- if (extraOptions.automaticPageStitching) {
37
- logger_1.default.warn('automatic page stitching is disabled in v7');
38
- }
39
- // Log an error if a custom library is set, as it is not allowed
40
- if (options.library) {
41
- logger_1.default.error('you cannot set custom library');
42
- }
43
- // Set the library option to be a window object with the name of the module federation plugin
44
- options.library = {
45
- type: 'window',
46
- name,
47
- };
48
- // Apply the ChunkCorrelationPlugin to collect metadata on chunks
49
- new node_1.ChunkCorrelationPlugin({
50
- filename: [
51
- 'static/chunks/federated-stats.json',
52
- 'server/federated-stats.json',
53
- ],
54
- }).apply(compiler);
55
- // Apply the InvertedContainerPlugin to add custom runtime modules to the container runtime
56
- new InvertedContainerPlugin_1.default().apply(compiler);
29
+ const { name } = options;
30
+ if (compiler.options.output.publicPath === "/_next/") compiler.options.output.publicPath = "auto";
31
+ if (extraOptions.automaticPageStitching) require_logger.default.warn("automatic page stitching is disabled in v7");
32
+ if (options.library) require_logger.default.error("you cannot set custom library");
33
+ options.library = {
34
+ type: "window",
35
+ name
36
+ };
37
+ if (!(options.manifest !== false && (typeof options.manifest !== "object" || !options.manifest.disableAssetsAnalyze))) new _module_federation_node.ChunkCorrelationPlugin({ filename: FEDERATED_STATS_FILENAMES }).apply(compiler);
38
+ else new require_FederatedStatsCompatibilityPlugin.FederatedStatsCompatibilityPlugin({
39
+ filenames: FEDERATED_STATS_FILENAMES,
40
+ manifest: options.manifest
41
+ }).apply(compiler);
42
+ new require_InvertedContainerPlugin.default().apply(compiler);
57
43
  }
44
+
45
+ //#endregion
46
+ exports.applyClientPlugins = applyClientPlugins;
58
47
  //# sourceMappingURL=apply-client-plugins.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"apply-client-plugins.js","sourceRoot":"","sources":["../../../../src/plugins/NextFederationPlugin/apply-client-plugins.ts"],"names":[],"mappings":";;;;;AA0BA,gDAsCC;AA/DD,kDAAiE;AACjE,mGAA2E;AAG3E,0DAAkC;AAElC;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,kBAAkB,CAChC,QAAkB,EAClB,OAA6D,EAC7D,YAA8C;IAE9C,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IAEzB,kEAAkE;IAClE,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACrD,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC;IAC9C,CAAC;IAED,gFAAgF;IAChF,IAAI,YAAY,CAAC,sBAAsB,EAAE,CAAC;QACxC,gBAAM,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAC;IAC5D,CAAC;IAED,gEAAgE;IAChE,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,gBAAM,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;IAChD,CAAC;IAED,6FAA6F;IAC7F,OAAO,CAAC,OAAO,GAAG;QAChB,IAAI,EAAE,QAAQ;QACd,IAAI;KACL,CAAC;IAEF,iEAAiE;IACjE,IAAI,6BAAsB,CAAC;QACzB,QAAQ,EAAE;YACR,oCAAoC;YACpC,6BAA6B;SAC9B;KACF,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAEnB,2FAA2F;IAC3F,IAAI,iCAAuB,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAChD,CAAC"}
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"}
@@ -0,0 +1,46 @@
1
+ import logger from "../../logger.mjs";
2
+ import InvertedContainerPlugin from "../container/InvertedContainerPlugin.mjs";
3
+ import { FederatedStatsCompatibilityPlugin } from "./FederatedStatsCompatibilityPlugin.mjs";
4
+ import { ChunkCorrelationPlugin } from "@module-federation/node";
5
+
6
+ //#region src/plugins/NextFederationPlugin/apply-client-plugins.ts
7
+ const FEDERATED_STATS_FILENAMES = ["static/chunks/federated-stats.json", "server/federated-stats.json"];
8
+ /**
9
+ * Applies client-specific plugins.
10
+ *
11
+ * @param compiler - The Webpack compiler instance.
12
+ * @param options - The ModuleFederationPluginOptions instance.
13
+ * @param extraOptions - The NextFederationPluginExtraOptions instance.
14
+ *
15
+ * @remarks
16
+ * This function applies plugins to the Webpack compiler instance that are specific to the client build of
17
+ * a Next.js application with Module Federation enabled. These plugins include the following:
18
+ *
19
+ * - ChunkCorrelationPlugin: Collects metadata on chunks to enable proper module loading across different runtimes.
20
+ * - InvertedContainerPlugin: Adds custom runtime modules to the container runtime to allow a host to expose its
21
+ * own remote interface at startup.
22
+
23
+ * If automatic page stitching is enabled, a warning is logged indicating that it is disabled in v7.
24
+ * If a custom library is specified in the options, an error is logged. The options.library property is
25
+ * also set to `{ type: 'window', name: options.name }`.
26
+ */
27
+ function applyClientPlugins(compiler, options, extraOptions) {
28
+ const { name } = options;
29
+ if (compiler.options.output.publicPath === "/_next/") compiler.options.output.publicPath = "auto";
30
+ if (extraOptions.automaticPageStitching) logger.warn("automatic page stitching is disabled in v7");
31
+ if (options.library) logger.error("you cannot set custom library");
32
+ options.library = {
33
+ type: "window",
34
+ name
35
+ };
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);
41
+ new InvertedContainerPlugin().apply(compiler);
42
+ }
43
+
44
+ //#endregion
45
+ export { applyClientPlugins };
46
+ //# sourceMappingURL=apply-client-plugins.mjs.map
@@ -0,0 +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';\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"}