@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.
- package/dist/LICENSE +21 -0
- package/dist/_virtual/_rolldown/runtime.js +29 -0
- package/dist/_virtual/_rolldown/runtime.mjs +8 -0
- package/dist/client/UrlNode.d.mts +17 -0
- package/dist/client/UrlNode.js +89 -147
- package/dist/client/UrlNode.js.map +1 -1
- package/dist/client/UrlNode.mjs +91 -0
- package/dist/client/UrlNode.mjs.map +1 -0
- package/dist/node.d.mts +1 -0
- package/dist/src/federation-noop.d.mts +0 -0
- package/dist/src/federation-noop.js +17 -0
- package/dist/src/federation-noop.js.map +1 -1
- package/dist/src/federation-noop.mjs +23 -0
- package/dist/src/federation-noop.mjs.map +1 -0
- package/dist/src/index.d.mts +3 -0
- package/dist/src/index.js +13 -11
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +8 -0
- package/dist/src/index.mjs.map +1 -0
- package/dist/src/internal.d.mts +50 -0
- package/dist/src/internal.js +140 -243
- package/dist/src/internal.js.map +1 -1
- package/dist/src/internal.mjs +152 -0
- package/dist/src/internal.mjs.map +1 -0
- package/dist/src/loaders/fixImageLoader.d.mts +22 -0
- package/dist/src/loaders/fixImageLoader.js +91 -103
- package/dist/src/loaders/fixImageLoader.js.map +1 -1
- package/dist/src/loaders/fixImageLoader.mjs +101 -0
- package/dist/src/loaders/fixImageLoader.mjs.map +1 -0
- package/dist/src/loaders/fixUrlLoader.d.mts +13 -0
- package/dist/src/loaders/fixUrlLoader.js +17 -19
- package/dist/src/loaders/fixUrlLoader.js.map +1 -1
- package/dist/src/loaders/fixUrlLoader.mjs +19 -0
- package/dist/src/loaders/fixUrlLoader.mjs.map +1 -0
- package/dist/src/loaders/helpers.d.mts +17 -0
- package/dist/src/loaders/helpers.js +72 -124
- package/dist/src/loaders/helpers.js.map +1 -1
- package/dist/src/loaders/helpers.mjs +79 -0
- package/dist/src/loaders/helpers.mjs.map +1 -0
- package/dist/src/loaders/nextPageMapLoader.d.mts +24 -0
- package/dist/src/loaders/nextPageMapLoader.js +126 -144
- package/dist/src/loaders/nextPageMapLoader.js.map +1 -1
- package/dist/src/loaders/nextPageMapLoader.mjs +143 -0
- package/dist/src/loaders/nextPageMapLoader.mjs.map +1 -0
- package/dist/src/logger.d.mts +2 -0
- package/dist/src/logger.js +7 -7
- package/dist/src/logger.js.map +1 -1
- package/dist/src/logger.mjs +8 -0
- package/dist/src/logger.mjs.map +1 -0
- package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.d.mts +5 -0
- package/dist/src/plugins/CopyFederationPlugin.d.mts +20 -0
- package/dist/src/plugins/CopyFederationPlugin.js +64 -71
- package/dist/src/plugins/CopyFederationPlugin.js.map +1 -1
- package/dist/src/plugins/CopyFederationPlugin.mjs +65 -0
- package/dist/src/plugins/CopyFederationPlugin.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.d.mts +22 -0
- package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.d.ts +22 -0
- package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.js +43 -0
- package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.js.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.mjs +42 -0
- package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.d.mts +23 -0
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js +42 -53
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.mjs +46 -0
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.d.mts +36 -0
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js +103 -121
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.mjs +111 -0
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/index.d.mts +27 -0
- package/dist/src/plugins/NextFederationPlugin/index.js +149 -181
- package/dist/src/plugins/NextFederationPlugin/index.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/index.mjs +151 -0
- package/dist/src/plugins/NextFederationPlugin/index.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/manifest-options.d.mts +4 -0
- package/dist/src/plugins/NextFederationPlugin/manifest-options.d.ts +4 -0
- package/dist/src/plugins/NextFederationPlugin/manifest-options.js +13 -0
- package/dist/src/plugins/NextFederationPlugin/manifest-options.js.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/manifest-options.mjs +12 -0
- package/dist/src/plugins/NextFederationPlugin/manifest-options.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/next-fragments.d.mts +20 -0
- package/dist/src/plugins/NextFederationPlugin/next-fragments.js +58 -93
- package/dist/src/plugins/NextFederationPlugin/next-fragments.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/next-fragments.mjs +63 -0
- package/dist/src/plugins/NextFederationPlugin/next-fragments.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/{regex-equal.js → regex-equal.d.mts} +2 -13
- package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.d.mts +8 -0
- package/dist/src/plugins/NextFederationPlugin/set-options.d.mts +6 -0
- package/dist/src/plugins/NextFederationPlugin/set-options.d.ts +1 -11
- package/dist/src/plugins/NextFederationPlugin/set-options.js +17 -19
- package/dist/src/plugins/NextFederationPlugin/set-options.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/set-options.mjs +19 -0
- package/dist/src/plugins/NextFederationPlugin/set-options.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/validate-options.d.mts +25 -0
- package/dist/src/plugins/NextFederationPlugin/validate-options.js +30 -38
- package/dist/src/plugins/NextFederationPlugin/validate-options.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/validate-options.mjs +35 -0
- package/dist/src/plugins/NextFederationPlugin/validate-options.mjs.map +1 -0
- package/dist/src/plugins/container/InvertedContainerPlugin.d.mts +5 -0
- package/dist/src/plugins/container/InvertedContainerPlugin.js +23 -25
- package/dist/src/plugins/container/InvertedContainerPlugin.js.map +1 -1
- package/dist/src/plugins/container/InvertedContainerPlugin.mjs +27 -0
- package/dist/src/plugins/container/InvertedContainerPlugin.mjs.map +1 -0
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.d.mts +11 -0
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.d.ts +1 -1
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.js +55 -67
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.js.map +1 -1
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.mjs +57 -0
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.mjs.map +1 -0
- package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.d.mts +39 -0
- package/dist/src/plugins/container/runtimePlugin.d.mts +2 -0
- package/dist/src/plugins/container/runtimePlugin.d.ts +1 -1
- package/dist/src/plugins/container/runtimePlugin.js +170 -0
- package/dist/src/plugins/container/runtimePlugin.js.map +1 -1
- package/dist/src/plugins/container/runtimePlugin.mjs +169 -0
- package/dist/src/plugins/container/runtimePlugin.mjs.map +1 -0
- package/dist/src/plugins/container/types.d.mts +2 -0
- package/dist/src/types.d.mts +28 -0
- package/dist/utils/flushedChunks.d.mts +22 -0
- package/dist/utils/flushedChunks.js +32 -72
- package/dist/utils/flushedChunks.js.map +1 -1
- package/dist/utils/flushedChunks.mjs +35 -0
- package/dist/utils/flushedChunks.mjs.map +1 -0
- package/dist/utils/index.d.mts +20 -0
- package/dist/utils/index.js +27 -62
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +22 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +45 -10
- package/dist/node.js +0 -18
- package/dist/node.js.map +0 -1
- package/dist/package.json +0 -71
- package/dist/src/federation-noop.cjs +0 -15
- package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js +0 -19
- package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js.map +0 -1
- package/dist/src/plugins/NextFederationPlugin/regex-equal.js.map +0 -1
- package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js +0 -34
- package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js.map +0 -1
- package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js +0 -78
- package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js.map +0 -1
- package/dist/src/plugins/container/runtimePlugin.cjs +0 -216
- package/dist/src/plugins/container/types.js +0 -3
- package/dist/src/plugins/container/types.js.map +0 -1
- package/dist/src/types.js +0 -3
- package/dist/src/types.js.map +0 -1
|
@@ -1,74 +1,67 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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","
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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","
|
|
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"}
|