@module-federation/nextjs-mf 0.0.0-docs-remove-invalid-lark-link-20251205062649

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 (88) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -0
  3. package/dist/client/UrlNode.d.ts +17 -0
  4. package/dist/client/UrlNode.js +150 -0
  5. package/dist/client/UrlNode.js.map +1 -0
  6. package/dist/node.d.ts +1 -0
  7. package/dist/node.js +18 -0
  8. package/dist/node.js.map +1 -0
  9. package/dist/package.json +71 -0
  10. package/dist/src/federation-noop.cjs +15 -0
  11. package/dist/src/federation-noop.d.ts +0 -0
  12. package/dist/src/federation-noop.js.map +1 -0
  13. package/dist/src/index.d.ts +3 -0
  14. package/dist/src/index.js +12 -0
  15. package/dist/src/index.js.map +1 -0
  16. package/dist/src/internal.d.ts +50 -0
  17. package/dist/src/internal.js +255 -0
  18. package/dist/src/internal.js.map +1 -0
  19. package/dist/src/loaders/fixImageLoader.d.ts +22 -0
  20. package/dist/src/loaders/fixImageLoader.js +116 -0
  21. package/dist/src/loaders/fixImageLoader.js.map +1 -0
  22. package/dist/src/loaders/fixUrlLoader.d.ts +13 -0
  23. package/dist/src/loaders/fixUrlLoader.js +24 -0
  24. package/dist/src/loaders/fixUrlLoader.js.map +1 -0
  25. package/dist/src/loaders/helpers.d.ts +17 -0
  26. package/dist/src/loaders/helpers.js +134 -0
  27. package/dist/src/loaders/helpers.js.map +1 -0
  28. package/dist/src/loaders/nextPageMapLoader.d.ts +24 -0
  29. package/dist/src/loaders/nextPageMapLoader.js +166 -0
  30. package/dist/src/loaders/nextPageMapLoader.js.map +1 -0
  31. package/dist/src/logger.d.ts +2 -0
  32. package/dist/src/logger.js +9 -0
  33. package/dist/src/logger.js.map +1 -0
  34. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.d.ts +5 -0
  35. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js +19 -0
  36. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js.map +1 -0
  37. package/dist/src/plugins/CopyFederationPlugin.d.ts +20 -0
  38. package/dist/src/plugins/CopyFederationPlugin.js +74 -0
  39. package/dist/src/plugins/CopyFederationPlugin.js.map +1 -0
  40. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.d.ts +23 -0
  41. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js +58 -0
  42. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js.map +1 -0
  43. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.d.ts +36 -0
  44. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js +135 -0
  45. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js.map +1 -0
  46. package/dist/src/plugins/NextFederationPlugin/index.d.ts +27 -0
  47. package/dist/src/plugins/NextFederationPlugin/index.js +186 -0
  48. package/dist/src/plugins/NextFederationPlugin/index.js.map +1 -0
  49. package/dist/src/plugins/NextFederationPlugin/next-fragments.d.ts +20 -0
  50. package/dist/src/plugins/NextFederationPlugin/next-fragments.js +100 -0
  51. package/dist/src/plugins/NextFederationPlugin/next-fragments.js.map +1 -0
  52. package/dist/src/plugins/NextFederationPlugin/regex-equal.d.ts +14 -0
  53. package/dist/src/plugins/NextFederationPlugin/regex-equal.js +25 -0
  54. package/dist/src/plugins/NextFederationPlugin/regex-equal.js.map +1 -0
  55. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.d.ts +8 -0
  56. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js +34 -0
  57. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js.map +1 -0
  58. package/dist/src/plugins/NextFederationPlugin/set-options.d.ts +16 -0
  59. package/dist/src/plugins/NextFederationPlugin/set-options.js +22 -0
  60. package/dist/src/plugins/NextFederationPlugin/set-options.js.map +1 -0
  61. package/dist/src/plugins/NextFederationPlugin/validate-options.d.ts +25 -0
  62. package/dist/src/plugins/NextFederationPlugin/validate-options.js +45 -0
  63. package/dist/src/plugins/NextFederationPlugin/validate-options.js.map +1 -0
  64. package/dist/src/plugins/container/InvertedContainerPlugin.d.ts +5 -0
  65. package/dist/src/plugins/container/InvertedContainerPlugin.js +28 -0
  66. package/dist/src/plugins/container/InvertedContainerPlugin.js.map +1 -0
  67. package/dist/src/plugins/container/InvertedContainerRuntimeModule.d.ts +11 -0
  68. package/dist/src/plugins/container/InvertedContainerRuntimeModule.js +69 -0
  69. package/dist/src/plugins/container/InvertedContainerRuntimeModule.js.map +1 -0
  70. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.d.ts +39 -0
  71. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js +78 -0
  72. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js.map +1 -0
  73. package/dist/src/plugins/container/runtimePlugin.cjs +216 -0
  74. package/dist/src/plugins/container/runtimePlugin.d.ts +2 -0
  75. package/dist/src/plugins/container/runtimePlugin.js.map +1 -0
  76. package/dist/src/plugins/container/types.d.ts +2 -0
  77. package/dist/src/plugins/container/types.js +3 -0
  78. package/dist/src/plugins/container/types.js.map +1 -0
  79. package/dist/src/types.d.ts +28 -0
  80. package/dist/src/types.js +3 -0
  81. package/dist/src/types.js.map +1 -0
  82. package/dist/utils/flushedChunks.d.ts +22 -0
  83. package/dist/utils/flushedChunks.js +77 -0
  84. package/dist/utils/flushedChunks.js.map +1 -0
  85. package/dist/utils/index.d.ts +20 -0
  86. package/dist/utils/index.js +66 -0
  87. package/dist/utils/index.js.map +1 -0
  88. package/package.json +71 -0
@@ -0,0 +1,74 @@
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"));
10
+ /**
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
+ }
73
+ exports.default = CopyBuildOutputPlugin;
74
+ //# sourceMappingURL=CopyFederationPlugin.js.map
@@ -0,0 +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,CA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kBAAkB,CAAC,CAAC;YACxD,CAAC;QACH,CAAC,CACF,CAAC;IACJ,CAAC;CACF;AAED,kBAAe,qBAAqB,CAAC"}
@@ -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;
@@ -0,0 +1,58 @@
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"));
10
+ /**
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.
24
+
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
+ */
29
+ 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);
57
+ }
58
+ //# sourceMappingURL=apply-client-plugins.js.map
@@ -0,0 +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"}
@@ -0,0 +1,36 @@
1
+ import type { WebpackOptionsNormalized, Compiler } from 'webpack';
2
+ import type { moduleFederationPlugin } from '@module-federation/sdk';
3
+ type EntryStaticNormalized = Awaited<ReturnType<Extract<WebpackOptionsNormalized['entry'], () => any>>>;
4
+ interface ModifyEntryOptions {
5
+ compiler: Compiler;
6
+ prependEntry?: (entry: EntryStaticNormalized) => void;
7
+ staticEntry?: EntryStaticNormalized;
8
+ }
9
+ export declare function modifyEntry(options: ModifyEntryOptions): void;
10
+ /**
11
+ * Applies server-specific plugins to the webpack compiler.
12
+ *
13
+ * @param {Compiler} compiler - The Webpack compiler instance.
14
+ * @param {moduleFederationPlugin.ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
15
+ */
16
+ export declare function applyServerPlugins(compiler: Compiler, options: moduleFederationPlugin.ModuleFederationPluginOptions): void;
17
+ /**
18
+ * Configures server-specific library and filename options.
19
+ *
20
+ * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
21
+ */
22
+ export declare function configureServerLibraryAndFilename(options: moduleFederationPlugin.ModuleFederationPluginOptions): void;
23
+ /**
24
+ * Patches Next.js' default externals function to ensure shared modules are bundled and not treated as external.
25
+ *
26
+ * @param {Compiler} compiler - The Webpack compiler instance.
27
+ * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
28
+ */
29
+ export declare function handleServerExternals(compiler: Compiler, options: moduleFederationPlugin.ModuleFederationPluginOptions): void;
30
+ /**
31
+ * Configures server-specific compiler options.
32
+ *
33
+ * @param {Compiler} compiler - The Webpack compiler instance.
34
+ */
35
+ export declare function configureServerCompilerOptions(compiler: Compiler): void;
36
+ export {};
@@ -0,0 +1,135 @@
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.modifyEntry = modifyEntry;
7
+ exports.applyServerPlugins = applyServerPlugins;
8
+ exports.configureServerLibraryAndFilename = configureServerLibraryAndFilename;
9
+ exports.handleServerExternals = handleServerExternals;
10
+ exports.configureServerCompilerOptions = configureServerCompilerOptions;
11
+ const path_1 = __importDefault(require("path"));
12
+ const InvertedContainerPlugin_1 = __importDefault(require("../container/InvertedContainerPlugin"));
13
+ const universe_entry_chunk_tracker_plugin_1 = __importDefault(require("@module-federation/node/universe-entry-chunk-tracker-plugin"));
14
+ // Modifies the Webpack entry configuration
15
+ function modifyEntry(options) {
16
+ const { compiler, staticEntry, prependEntry } = options;
17
+ const operator = (oriEntry, newEntry) => Object.assign(oriEntry, newEntry);
18
+ // If the entry is a function, wrap it to modify the result
19
+ if (typeof compiler.options.entry === 'function') {
20
+ const prevEntryFn = compiler.options.entry;
21
+ compiler.options.entry = async () => {
22
+ let res = await prevEntryFn();
23
+ if (staticEntry) {
24
+ res = operator(res, staticEntry);
25
+ }
26
+ if (prependEntry) {
27
+ prependEntry(res);
28
+ }
29
+ return res;
30
+ };
31
+ }
32
+ else {
33
+ // If the entry is an object, directly modify it
34
+ if (staticEntry) {
35
+ compiler.options.entry = operator(compiler.options.entry, staticEntry);
36
+ }
37
+ if (prependEntry) {
38
+ prependEntry(compiler.options.entry);
39
+ }
40
+ }
41
+ }
42
+ /**
43
+ * Applies server-specific plugins to the webpack compiler.
44
+ *
45
+ * @param {Compiler} compiler - The Webpack compiler instance.
46
+ * @param {moduleFederationPlugin.ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
47
+ */
48
+ function applyServerPlugins(compiler, options) {
49
+ const chunkFileName = compiler.options?.output?.chunkFilename;
50
+ const uniqueName = compiler?.options?.output?.uniqueName || options.name;
51
+ const suffix = `-[contenthash].js`;
52
+ // Modify chunk filename to include a unique suffix if not already present
53
+ if (typeof chunkFileName === 'string' &&
54
+ uniqueName &&
55
+ !chunkFileName.includes(uniqueName)) {
56
+ compiler.options.output.chunkFilename = chunkFileName.replace('.js', suffix);
57
+ }
58
+ new universe_entry_chunk_tracker_plugin_1.default().apply(compiler);
59
+ new InvertedContainerPlugin_1.default().apply(compiler);
60
+ }
61
+ /**
62
+ * Configures server-specific library and filename options.
63
+ *
64
+ * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
65
+ */
66
+ function configureServerLibraryAndFilename(options) {
67
+ // Set the library option to "commonjs-module" format with the name from the options
68
+ options.library = {
69
+ type: 'commonjs-module',
70
+ name: options.name,
71
+ };
72
+ // Set the filename option to the basename of the current filename
73
+ options.filename = path_1.default.basename(options.filename);
74
+ }
75
+ /**
76
+ * Patches Next.js' default externals function to ensure shared modules are bundled and not treated as external.
77
+ *
78
+ * @param {Compiler} compiler - The Webpack compiler instance.
79
+ * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
80
+ */
81
+ function handleServerExternals(compiler, options) {
82
+ if (Array.isArray(compiler.options.externals)) {
83
+ const functionIndex = compiler.options.externals.findIndex((external) => typeof external === 'function');
84
+ if (functionIndex !== -1) {
85
+ const originalExternals = compiler.options.externals[functionIndex];
86
+ compiler.options.externals[functionIndex] = async function (ctx, callback) {
87
+ const fromNext = await originalExternals(ctx, callback);
88
+ if (!fromNext) {
89
+ return;
90
+ }
91
+ const req = fromNext.split(' ')[1];
92
+ if (ctx.request &&
93
+ (ctx.request.includes('@module-federation/utilities') ||
94
+ Object.keys(options.shared || {}).some((key) => {
95
+ const sharedOptions = options.shared;
96
+ return (sharedOptions[key]?.import !== false &&
97
+ (key.endsWith('/') ? req.includes(key) : req === key));
98
+ }) ||
99
+ ctx.request.includes('@module-federation/'))) {
100
+ return;
101
+ }
102
+ if (req.startsWith('next') ||
103
+ req.startsWith('react/') ||
104
+ req.startsWith('react-dom/') ||
105
+ req === 'react' ||
106
+ req === 'styled-jsx/style' ||
107
+ req === 'react-dom') {
108
+ return fromNext;
109
+ }
110
+ return;
111
+ };
112
+ }
113
+ }
114
+ }
115
+ /**
116
+ * Configures server-specific compiler options.
117
+ *
118
+ * @param {Compiler} compiler - The Webpack compiler instance.
119
+ */
120
+ function configureServerCompilerOptions(compiler) {
121
+ // Disable the global option in node builds and set the target to "async-node"
122
+ compiler.options.node = {
123
+ ...compiler.options.node,
124
+ global: false,
125
+ };
126
+ // Set the compiler target to 'async-node' for server-side rendering compatibility
127
+ // Set the target to 'async-node' for server-side builds
128
+ compiler.options.target = 'async-node';
129
+ // Runtime chunk creation is currently disabled
130
+ // Uncomment if separate runtime chunk is needed for specific use cases
131
+ // compiler.options.optimization.runtimeChunk = {
132
+ // name: 'webpack-runtime',
133
+ // };
134
+ }
135
+ //# sourceMappingURL=apply-server-plugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply-server-plugins.js","sourceRoot":"","sources":["../../../../src/plugins/NextFederationPlugin/apply-server-plugins.ts"],"names":[],"mappings":";;;;;AAqBA,kCA6BC;AAQD,gDAqBC;AAOD,8EAWC;AAQD,sDAwDC;AAOD,wEAeC;AAjLD,gDAAwB;AACxB,mGAA2E;AAC3E,sIAA0G;AAY1G,2CAA2C;AAC3C,SAAgB,WAAW,CAAC,OAA2B;IACrD,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;IACxD,MAAM,QAAQ,GAAG,CACf,QAA+B,EAC/B,QAA+B,EACR,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAE9D,2DAA2D;IAC3D,IAAI,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;QACjD,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC;QAC3C,QAAQ,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,IAAI,EAAE;YAClC,IAAI,GAAG,GAAG,MAAM,WAAW,EAAE,CAAC;YAC9B,IAAI,WAAW,EAAE,CAAC;gBAChB,GAAG,GAAG,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC;YACnC,CAAC;YACD,IAAI,YAAY,EAAE,CAAC;gBACjB,YAAY,CAAC,GAAG,CAAC,CAAC;YACpB,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC,CAAC;IACJ,CAAC;SAAM,CAAC;QACN,gDAAgD;QAChD,IAAI,WAAW,EAAE,CAAC;YAChB,QAAQ,CAAC,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACzE,CAAC;QACD,IAAI,YAAY,EAAE,CAAC;YACjB,YAAY,CAAC,QAAQ,CA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C,UAAU,CAAC,YAAY,CAAC;oBAC5B,GAAG,KAAK,OAAO;oBACf,GAAG,KAAK,kBAAkB;oBAC1B,GAAG,KAAK,WAAW,EACnB,CAAC;oBACD,OAAO,QAAQ,CAAC;gBAClB,CAAC;gBACD,OAAO;YACT,CAAC,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAgB,8BAA8B,CAAC,QAAkB;IAC/D,8EAA8E;IAC9E,QAAQ,CAAC,OAAO,CAAC,IAAI,GAAG;QACtB,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI;QACxB,MAAM,EAAE,KAAK;KACd,CAAC;IACF,kFAAkF;IAClF,wDAAwD;IACxD,QAAQ,CAAC,OAAO,CAAC,MAAM,GAAG,YAAY,CAAC;IAEvC,+CAA+C;IAC/C,uEAAuE;IACvE,iDAAiD;IACjD,6BAA6B;IAC7B,KAAK;AACP,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { NextFederationPluginOptions } from './next-fragments';
2
+ import type { Compiler } from 'webpack';
3
+ /**
4
+ * NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.
5
+ */
6
+ export declare class NextFederationPlugin {
7
+ private _options;
8
+ private _extraOptions;
9
+ name: string;
10
+ /**
11
+ * Constructs the NextFederationPlugin with the provided options.
12
+ *
13
+ * @param options The options to configure the plugin.
14
+ */
15
+ constructor(options: NextFederationPluginOptions);
16
+ /**
17
+ * The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.
18
+ * @param compiler The webpack compiler object.
19
+ */
20
+ apply(compiler: Compiler): void;
21
+ private validateOptions;
22
+ private isServerCompiler;
23
+ private applyConditionalPlugins;
24
+ private getNormalFederationPluginOptions;
25
+ private getNoopPath;
26
+ }
27
+ export default NextFederationPlugin;
@@ -0,0 +1,186 @@
1
+ /**
2
+ * MIT License http://www.opensource.org/licenses/mit-license.php
3
+ * Author Zackary Jackson @ScriptedAlchemy
4
+ * This module contains the NextFederationPlugin class which is a webpack plugin that handles Next.js application federation using Module Federation.
5
+ */
6
+ 'use strict';
7
+ var __importDefault = (this && this.__importDefault) || function (mod) {
8
+ return (mod && mod.__esModule) ? mod : { "default": mod };
9
+ };
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.NextFederationPlugin = void 0;
12
+ const normalize_webpack_path_1 = require("@module-federation/sdk/normalize-webpack-path");
13
+ const CopyFederationPlugin_1 = __importDefault(require("../CopyFederationPlugin"));
14
+ const nextPageMapLoader_1 = require("../../loaders/nextPageMapLoader");
15
+ const next_fragments_1 = require("./next-fragments");
16
+ const set_options_1 = require("./set-options");
17
+ const validate_options_1 = require("./validate-options");
18
+ const apply_server_plugins_1 = require("./apply-server-plugins");
19
+ const apply_client_plugins_1 = require("./apply-client-plugins");
20
+ const webpack_1 = require("@module-federation/enhanced/webpack");
21
+ const sdk_1 = require("@module-federation/sdk");
22
+ const logger_1 = __importDefault(require("../../logger"));
23
+ const path_1 = __importDefault(require("path"));
24
+ /**
25
+ * NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.
26
+ */
27
+ class NextFederationPlugin {
28
+ /**
29
+ * Constructs the NextFederationPlugin with the provided options.
30
+ *
31
+ * @param options The options to configure the plugin.
32
+ */
33
+ constructor(options) {
34
+ const { mainOptions, extraOptions } = (0, set_options_1.setOptions)(options);
35
+ this._options = mainOptions;
36
+ this._extraOptions = extraOptions;
37
+ this.name = 'ModuleFederationPlugin';
38
+ }
39
+ /**
40
+ * The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.
41
+ * @param compiler The webpack compiler object.
42
+ */
43
+ apply(compiler) {
44
+ (0, sdk_1.bindLoggerToCompiler)(logger_1.default, compiler, 'NextFederationPlugin');
45
+ process.env['FEDERATION_WEBPACK_PATH'] =
46
+ process.env['FEDERATION_WEBPACK_PATH'] ||
47
+ (0, normalize_webpack_path_1.getWebpackPath)(compiler, { framework: 'nextjs' });
48
+ if (!this.validateOptions(compiler))
49
+ return;
50
+ const isServer = this.isServerCompiler(compiler);
51
+ new CopyFederationPlugin_1.default(isServer).apply(compiler);
52
+ const normalFederationPluginOptions = this.getNormalFederationPluginOptions(compiler, isServer);
53
+ this._options = normalFederationPluginOptions;
54
+ this.applyConditionalPlugins(compiler, isServer);
55
+ new webpack_1.ModuleFederationPlugin(normalFederationPluginOptions).apply(compiler);
56
+ const noop = this.getNoopPath();
57
+ if (!this._extraOptions.skipSharingNextInternals) {
58
+ compiler.hooks.make.tapAsync('NextFederationPlugin', (compilation, callback) => {
59
+ const dep = compiler.webpack.EntryPlugin.createDependency(noop, 'noop');
60
+ compilation.addEntry(compiler.context, dep, { name: 'noop' }, (err, module) => {
61
+ if (err) {
62
+ return callback(err);
63
+ }
64
+ callback();
65
+ });
66
+ });
67
+ }
68
+ if (!compiler.options.ignoreWarnings) {
69
+ compiler.options.ignoreWarnings = [
70
+ //@ts-ignore
71
+ (message) => /your target environment does not appear/.test(message),
72
+ ];
73
+ }
74
+ }
75
+ validateOptions(compiler) {
76
+ const manifestPlugin = compiler.options.plugins.find((p) => p?.constructor?.name === 'BuildManifestPlugin');
77
+ if (manifestPlugin) {
78
+ //@ts-ignore
79
+ if (manifestPlugin?.appDirEnabled) {
80
+ throw new Error('App Directory is not supported by nextjs-mf. Use only pages directory, do not open git issues about this');
81
+ }
82
+ }
83
+ const compilerValid = (0, validate_options_1.validateCompilerOptions)(compiler);
84
+ const pluginValid = (0, validate_options_1.validatePluginOptions)(this._options);
85
+ const envValid = process.env['NEXT_PRIVATE_LOCAL_WEBPACK'];
86
+ if (compilerValid === undefined)
87
+ logger_1.default.error('Compiler validation failed');
88
+ if (pluginValid === undefined)
89
+ logger_1.default.error('Plugin validation failed');
90
+ const validCompilerTarget = compiler.options.name === 'server' || compiler.options.name === 'client';
91
+ if (!envValid)
92
+ throw new Error('process.env.NEXT_PRIVATE_LOCAL_WEBPACK is not set to true, please set it to true, and "npm install webpack"');
93
+ return (compilerValid !== undefined &&
94
+ pluginValid !== undefined &&
95
+ validCompilerTarget);
96
+ }
97
+ isServerCompiler(compiler) {
98
+ return compiler.options.name === 'server';
99
+ }
100
+ applyConditionalPlugins(compiler, isServer) {
101
+ compiler.options.output.uniqueName = this._options.name;
102
+ compiler.options.output.environment = {
103
+ ...compiler.options.output.environment,
104
+ asyncFunction: true,
105
+ };
106
+ // Add layer rules for resource queries
107
+ if (!compiler.options.module.rules) {
108
+ compiler.options.module.rules = [];
109
+ }
110
+ // Add layer rules for RSC, client and SSR
111
+ compiler.options.module.rules.push({
112
+ resourceQuery: /\?rsc/,
113
+ layer: 'rsc',
114
+ });
115
+ compiler.options.module.rules.push({
116
+ resourceQuery: /\?client/,
117
+ layer: 'client',
118
+ });
119
+ compiler.options.module.rules.push({
120
+ resourceQuery: /\?ssr/,
121
+ layer: 'ssr',
122
+ });
123
+ (0, next_fragments_1.applyPathFixes)(compiler, this._options, this._extraOptions);
124
+ if (this._extraOptions.debug) {
125
+ compiler.options.devtool = false;
126
+ }
127
+ if (isServer) {
128
+ (0, apply_server_plugins_1.configureServerCompilerOptions)(compiler);
129
+ (0, apply_server_plugins_1.configureServerLibraryAndFilename)(this._options);
130
+ (0, apply_server_plugins_1.applyServerPlugins)(compiler, this._options);
131
+ (0, apply_server_plugins_1.handleServerExternals)(compiler, {
132
+ ...this._options,
133
+ shared: { ...(0, next_fragments_1.retrieveDefaultShared)(isServer), ...this._options.shared },
134
+ });
135
+ }
136
+ else {
137
+ (0, apply_client_plugins_1.applyClientPlugins)(compiler, this._options, this._extraOptions);
138
+ }
139
+ }
140
+ getNormalFederationPluginOptions(compiler, isServer) {
141
+ const defaultShared = this._extraOptions.skipSharingNextInternals
142
+ ? {}
143
+ : (0, next_fragments_1.retrieveDefaultShared)(isServer);
144
+ return {
145
+ ...this._options,
146
+ runtime: false,
147
+ remoteType: 'script',
148
+ runtimePlugins: [
149
+ ...(isServer
150
+ ? [require.resolve('@module-federation/node/runtimePlugin')]
151
+ : []),
152
+ require.resolve(path_1.default.join(__dirname, '../container/runtimePlugin.cjs')),
153
+ ...(this._options.runtimePlugins || []),
154
+ ].map((plugin) => plugin + '?runtimePlugin'),
155
+ //@ts-ignore
156
+ exposes: {
157
+ ...this._options.exposes,
158
+ ...(this._extraOptions.exposePages
159
+ ? (0, nextPageMapLoader_1.exposeNextjsPages)(compiler.options.context)
160
+ : {}),
161
+ },
162
+ remotes: {
163
+ ...this._options.remotes,
164
+ },
165
+ shared: {
166
+ ...defaultShared,
167
+ ...this._options.shared,
168
+ },
169
+ ...(isServer
170
+ ? { manifest: { filePath: '' } }
171
+ : { manifest: { filePath: '/static/chunks' } }),
172
+ // nextjs project needs to add config.watchOptions = ['**/node_modules/**', '**/@mf-types/**'] to prevent loop types update
173
+ dts: this._options.dts ?? false,
174
+ shareStrategy: this._options.shareStrategy ?? 'loaded-first',
175
+ experiments: {
176
+ asyncStartup: true,
177
+ },
178
+ };
179
+ }
180
+ getNoopPath() {
181
+ return require.resolve('../../federation-noop.cjs');
182
+ }
183
+ }
184
+ exports.NextFederationPlugin = NextFederationPlugin;
185
+ exports.default = NextFederationPlugin;
186
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/plugins/NextFederationPlugin/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,YAAY,CAAC;;;;;;AAOb,0FAA+E;AAC/E,mFAA2D;AAC3D,uEAAoE;AACpE,qDAAyE;AACzE,+CAA2C;AAC3C,yDAG4B;AAC5B,iEAKgC;AAChC,iEAA4D;AAC5D,iEAA6E;AAC7E,gDAA8D;AAE9D,0DAAkC;AAElC,gDAAwB;AACxB;;GAEG;AACH,MAAa,oBAAoB;IAI/B;;;;OAIG;IACH,YAAY,OAAoC;QAC9C,MAAM,EAAE,WAAW,EAAE,YAAY,EAAE,GAAG,IAAA,wBAAU,EAAC,OAAO,CAAC,CAAC;QAC1D,IAAI,CAAC,QAAQ,GAAG,WAAW,CAAC;QAC5B,IAAI,CAAC,aAAa,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AAC,IAAI,CAAC,SAAS,EAAE,gCAAgC,CAAC,CAAC;gBACvE,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,IAAI,EAAE,CAAC;aACxC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,GAAG,gBAAgB,CAAC;YAC5C,YAAY;YACZ,OAAO,EAAE;gBACP,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO;gBACxB,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW;oBAChC,CAAC,CAAC,IAAA,qCAAiB,EAAC,QAAQ,CAAC,OAAO,CAAC,OAAiB,CAAC;oBACvD,CAAC,CAAC,EAAE,CAAC;aACR;YACD,OAAO,EAAE;gBACP,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO;aACzB;YACD,MAAM,EAAE;gBACN,GAAG,aAAa;gBAChB,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM;aACxB;YACD,GAAG,CAAC,QAAQ;gBACV,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,EAAE;gBAChC,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,gBAAgB,EAAE,EAAE,CAAC;YACjD,2HAA2H;YAC3H,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,KAAK;YAC/B,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,aAAa,IAAI,cAAc;YAC5D,WAAW,EAAE;gBACX,YAAY,EAAE,IAAI;aACnB;SACF,CAAC;IACJ,CAAC;IAEO,WAAW;QACjB,OAAO,OAAO,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC;IACtD,CAAC;CACF;AAzMD,oDAyMC;AAED,kBAAe,oBAAoB,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { Compiler } from 'webpack';
2
+ import type { moduleFederationPlugin } from '@module-federation/sdk';
3
+ /**
4
+ * Set up default shared values based on the environment.
5
+ * @param {boolean} isServer - Boolean indicating if the code is running on the server.
6
+ * @returns {SharedObject} The default share scope based on the environment.
7
+ */
8
+ export declare const retrieveDefaultShared: (isServer: boolean) => moduleFederationPlugin.SharedObject;
9
+ export declare const applyPathFixes: (compiler: Compiler, pluginOptions: moduleFederationPlugin.ModuleFederationPluginOptions, options: any) => void;
10
+ export interface NextFederationPluginExtraOptions {
11
+ enableImageLoaderFix?: boolean;
12
+ enableUrlLoaderFix?: boolean;
13
+ exposePages?: boolean;
14
+ skipSharingNextInternals?: boolean;
15
+ automaticPageStitching?: boolean;
16
+ debug?: boolean;
17
+ }
18
+ export interface NextFederationPluginOptions extends moduleFederationPlugin.ModuleFederationPluginOptions {
19
+ extraOptions: NextFederationPluginExtraOptions;
20
+ }