@module-federation/nextjs-mf 8.3.4 → 8.3.6

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 (92) hide show
  1. package/package.json +6 -6
  2. package/dist/client/UrlNode.d.ts +0 -17
  3. package/dist/client/UrlNode.js +0 -150
  4. package/dist/client/UrlNode.js.map +0 -1
  5. package/dist/node.d.ts +0 -1
  6. package/dist/node.js +0 -18
  7. package/dist/node.js.map +0 -1
  8. package/dist/package.json +0 -99
  9. package/dist/src/federation-noop.d.ts +0 -0
  10. package/dist/src/federation-noop.js +0 -15
  11. package/dist/src/federation-noop.js.map +0 -1
  12. package/dist/src/index.d.ts +0 -3
  13. package/dist/src/index.js +0 -12
  14. package/dist/src/index.js.map +0 -1
  15. package/dist/src/internal.d.ts +0 -48
  16. package/dist/src/internal.js +0 -177
  17. package/dist/src/internal.js.map +0 -1
  18. package/dist/src/loaders/fixImageLoader.d.ts +0 -22
  19. package/dist/src/loaders/fixImageLoader.js +0 -114
  20. package/dist/src/loaders/fixImageLoader.js.map +0 -1
  21. package/dist/src/loaders/fixUrlLoader.d.ts +0 -13
  22. package/dist/src/loaders/fixUrlLoader.js +0 -25
  23. package/dist/src/loaders/fixUrlLoader.js.map +0 -1
  24. package/dist/src/loaders/helpers.d.ts +0 -17
  25. package/dist/src/loaders/helpers.js +0 -60
  26. package/dist/src/loaders/helpers.js.map +0 -1
  27. package/dist/src/loaders/nextPageMapLoader.d.ts +0 -24
  28. package/dist/src/loaders/nextPageMapLoader.js +0 -167
  29. package/dist/src/loaders/nextPageMapLoader.js.map +0 -1
  30. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.d.ts +0 -5
  31. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js +0 -19
  32. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js.map +0 -1
  33. package/dist/src/plugins/CopyFederationPlugin.d.ts +0 -20
  34. package/dist/src/plugins/CopyFederationPlugin.js +0 -71
  35. package/dist/src/plugins/CopyFederationPlugin.js.map +0 -1
  36. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.d.ts +0 -23
  37. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js +0 -73
  38. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js.map +0 -1
  39. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.d.ts +0 -60
  40. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js +0 -170
  41. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js.map +0 -1
  42. package/dist/src/plugins/NextFederationPlugin/index.d.ts +0 -27
  43. package/dist/src/plugins/NextFederationPlugin/index.js +0 -160
  44. package/dist/src/plugins/NextFederationPlugin/index.js.map +0 -1
  45. package/dist/src/plugins/NextFederationPlugin/next-fragments.d.ts +0 -18
  46. package/dist/src/plugins/NextFederationPlugin/next-fragments.js +0 -61
  47. package/dist/src/plugins/NextFederationPlugin/next-fragments.js.map +0 -1
  48. package/dist/src/plugins/NextFederationPlugin/regex-equal.d.ts +0 -14
  49. package/dist/src/plugins/NextFederationPlugin/regex-equal.js +0 -25
  50. package/dist/src/plugins/NextFederationPlugin/regex-equal.js.map +0 -1
  51. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.d.ts +0 -8
  52. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js +0 -31
  53. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js.map +0 -1
  54. package/dist/src/plugins/NextFederationPlugin/set-options.d.ts +0 -20
  55. package/dist/src/plugins/NextFederationPlugin/set-options.js +0 -38
  56. package/dist/src/plugins/NextFederationPlugin/set-options.js.map +0 -1
  57. package/dist/src/plugins/NextFederationPlugin/validate-options.d.ts +0 -25
  58. package/dist/src/plugins/NextFederationPlugin/validate-options.js +0 -46
  59. package/dist/src/plugins/NextFederationPlugin/validate-options.js.map +0 -1
  60. package/dist/src/plugins/container/EmbeddedContainerPlugin.d.ts +0 -11
  61. package/dist/src/plugins/container/EmbeddedContainerPlugin.js +0 -23
  62. package/dist/src/plugins/container/EmbeddedContainerPlugin.js.map +0 -1
  63. package/dist/src/plugins/container/InvertedContainerPlugin.d.ts +0 -15
  64. package/dist/src/plugins/container/InvertedContainerPlugin.js +0 -25
  65. package/dist/src/plugins/container/InvertedContainerPlugin.js.map +0 -1
  66. package/dist/src/plugins/container/InvertedContainerRuntimeModule.d.ts +0 -11
  67. package/dist/src/plugins/container/InvertedContainerRuntimeModule.js +0 -50
  68. package/dist/src/plugins/container/InvertedContainerRuntimeModule.js.map +0 -1
  69. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.d.ts +0 -39
  70. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js +0 -72
  71. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js.map +0 -1
  72. package/dist/src/plugins/container/runtimePlugin.d.ts +0 -2
  73. package/dist/src/plugins/container/runtimePlugin.js +0 -166
  74. package/dist/src/plugins/container/runtimePlugin.js.map +0 -1
  75. package/dist/src/plugins/container/types.d.ts +0 -2
  76. package/dist/src/plugins/container/types.js +0 -3
  77. package/dist/src/plugins/container/types.js.map +0 -1
  78. package/dist/src/types.d.ts +0 -28
  79. package/dist/src/types.js +0 -3
  80. package/dist/src/types.js.map +0 -1
  81. package/dist/utilities.d.ts +0 -1
  82. package/dist/utilities.js +0 -18
  83. package/dist/utilities.js.map +0 -1
  84. package/dist/utils/build-utils.d.ts +0 -10
  85. package/dist/utils/build-utils.js +0 -24
  86. package/dist/utils/build-utils.js.map +0 -1
  87. package/dist/utils/flushedChunks.d.ts +0 -22
  88. package/dist/utils/flushedChunks.js +0 -67
  89. package/dist/utils/flushedChunks.js.map +0 -1
  90. package/dist/utils/index.d.ts +0 -27
  91. package/dist/utils/index.js +0 -69
  92. package/dist/utils/index.js.map +0 -1
@@ -1,73 +0,0 @@
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 = void 0;
7
- const node_1 = require("@module-federation/node");
8
- const InvertedContainerPlugin_1 = __importDefault(require("../container/InvertedContainerPlugin"));
9
- const enhanced_1 = require("@module-federation/enhanced");
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
- * - DelegateModulesPlugin: Delegates modules to the webpack container runtime that can be streamed to other runtimes.
22
- * - ChunkCorrelationPlugin: Collects metadata on chunks to enable proper module loading across different runtimes.
23
- * - InvertedContainerPlugin: Adds custom runtime modules to the container runtime to allow a host to expose its
24
- * own remote interface at startup.
25
- *
26
- * If automatic page stitching is enabled, a loader is added to process the `next/dist/client/page-loader.js`
27
- * file. If a custom library is specified in the options, an error is thrown. The options.library property is
28
- * also set to `{ type: 'window', name: options.name }`.
29
- */
30
- function applyClientPlugins(compiler, options, extraOptions) {
31
- const { webpack } = compiler;
32
- const { remotes, name } = options;
33
- //@ts-ignore
34
- compiler.options.output.publicPath = 'auto';
35
- // Build will hang without this. Likely something in my plugin
36
- compiler.options.optimization.splitChunks = undefined;
37
- // If automatic page stitching is enabled, add a new rule to the compiler's module rules
38
- if (extraOptions.automaticPageStitching) {
39
- console.warn('[nextjs-mf]', 'automatic page stitching is disabled in v7');
40
- }
41
- // If a custom library is set, log an error message
42
- if (options.library) {
43
- console.error('[nextjs-mf] you cannot set custom library');
44
- }
45
- // Set the library option to be a window object with the name of the module federation plugin
46
- options.library = {
47
- type: 'window',
48
- name,
49
- };
50
- // Add a new chunk correlation plugin to the compiler
51
- new node_1.ChunkCorrelationPlugin({
52
- filename: [
53
- 'static/chunks/federated-stats.json',
54
- 'server/federated-stats.json',
55
- ],
56
- //@ts-ignore
57
- }).apply(compiler);
58
- new enhanced_1.HoistContainerReferencesPlugin().apply(compiler);
59
- // Add a new commonjs chunk loading plugin to the compiler
60
- new InvertedContainerPlugin_1.default({
61
- runtime: 'webpack',
62
- chunkToEmbed: 'host_inner_ctn',
63
- container: options.name,
64
- remotes: options.remotes,
65
- shared: options.shared,
66
- shareScope: 'default',
67
- exposes: options.exposes,
68
- debug: extraOptions.debug,
69
- //@ts-ignore
70
- }).apply(compiler);
71
- }
72
- exports.applyClientPlugins = applyClientPlugins;
73
- //# sourceMappingURL=apply-client-plugins.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"apply-client-plugins.js","sourceRoot":"","sources":["../../../../src/plugins/NextFederationPlugin/apply-client-plugins.ts"],"names":[],"mappings":";;;;;;AAKA,kDAAiE;AACjE,mGAA2E;AAC3E,0DAA6E;AAC7E;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,kBAAkB,CAChC,QAAkB,EAClB,OAAsC,EACtC,YAA8C;IAE9C,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC;IAC7B,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IAClC,YAAY;IACZ,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,GAAG,MAAM,CAAC;IAC5C,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,GAAG,SAAS,CAAC;IAEtD,wFAAwF;IACxF,IAAI,YAAY,CAAC,sBAAsB,EAAE,CAAC;QACxC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,4CAA4C,CAAC,CAAC;IAC5E,CAAC;IAED,mDAAmD;IACnD,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC7D,CAAC;IAED,6FAA6F;IAC7F,OAAO,CAAC,OAAO,GAAG;QAChB,IAAI,EAAE,QAAQ;QACd,IAAI;KACL,CAAC;IAEF,qDAAqD;IACrD,IAAI,6BAAsB,CAAC;QACzB,QAAQ,EAAE;YACR,oCAAoC;YACpC,6BAA6B;SAC9B;QACD,YAAY;KACb,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAEnB,IAAI,yCAA8B,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAErD,0DAA0D;IAC1D,IAAI,iCAAuB,CAAC;QAC1B,OAAO,EAAE,SAAS;QAClB,YAAY,EAAE,gBAAgB;QAC9B,SAAS,EAAE,OAAO,CAAC,IAAI;QACvB,OAAO,EAAE,OAAO,CAAC,OAAiC;QAClD,MAAM,EAAE,OAAO,CAAC,MAAa;QAC7B,UAAU,EAAE,SAAS;QACrB,OAAO,EAAE,OAAO,CAAC,OAAc;QAC/B,KAAK,EAAE,YAAY,CAAC,KAAK;QACzB,YAAY;KACb,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AACrB,CAAC;AAnDD,gDAmDC"}
@@ -1,60 +0,0 @@
1
- import type { Compiler } from 'webpack';
2
- import { ModuleFederationPluginOptions } from '@module-federation/utilities';
3
- /**
4
- * This function applies server-specific plugins to the webpack compiler.
5
- *
6
- * @param {Compiler} compiler - The Webpack compiler instance.
7
- * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
8
- *
9
- * @returns {void}
10
- */
11
- export declare function applyServerPlugins(compiler: Compiler, options: ModuleFederationPluginOptions): void;
12
- /**
13
- * This function configures server-specific library and filename options.
14
- *
15
- * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
16
- *
17
- * @returns {void}
18
- *
19
- * @remarks
20
- * This function configures the library and filename options for server builds. The library option is
21
- * set to the commonjs-module format for chunks and the container, which allows them to be streamed over
22
- * to hosts with the NodeFederationPlugin. The filename option is set to the basename of the current
23
- * filename.
24
- */
25
- export declare function configureServerLibraryAndFilename(options: ModuleFederationPluginOptions): void;
26
- /**
27
- * This function patches Next.js' default externals function to make sure shared modules are bundled and not treated as external.
28
- *
29
- * @param {Compiler} compiler - The Webpack compiler instance.
30
- * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
31
- *
32
- * @returns {void}
33
- *
34
- * @remarks
35
- * In server builds, all node modules are treated as external, which prevents them from being shared
36
- * via module federation. To work around this limitation, we mark shared modules as internalizable
37
- * modules that webpack puts into chunks that can be streamed to other runtimes as needed.
38
- *
39
- * This function replaces Next.js' default externals function with a new asynchronous function that
40
- * checks whether a module should be treated as external. If the module should not be treated as
41
- * external, the function returns without calling the original externals function. Otherwise, the
42
- * function calls the original externals function and retrieves the result. If the result is null,
43
- * the function returns without further processing. If the module is from Next.js or React, the
44
- * function returns the original result. Otherwise, the function returns null.
45
- */
46
- export declare function handleServerExternals(compiler: Compiler, options: ModuleFederationPluginOptions): void;
47
- /**
48
- * This function configures server-specific compiler options.
49
- *
50
- * @param {Compiler} compiler - The Webpack compiler instance.
51
- *
52
- * @returns {void}
53
- *
54
- * @remarks
55
- * This function configures the compiler options for server builds. It turns off the compiler target on node
56
- * builds because it adds its own chunk loading runtime module with NodeFederationPlugin and StreamingTargetPlugin.
57
- * It also disables split chunks to prevent conflicts from occurring in the graph.
58
- *
59
- */
60
- export declare function configureServerCompilerOptions(compiler: Compiler): void;
@@ -1,170 +0,0 @@
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.configureServerCompilerOptions = exports.handleServerExternals = exports.configureServerLibraryAndFilename = exports.applyServerPlugins = void 0;
7
- const enhanced_1 = require("@module-federation/enhanced");
8
- const path_1 = __importDefault(require("path"));
9
- const InvertedContainerPlugin_1 = __importDefault(require("../container/InvertedContainerPlugin"));
10
- const webpack_1 = require("@module-federation/enhanced/webpack");
11
- /**
12
- * This function applies server-specific plugins to the webpack compiler.
13
- *
14
- * @param {Compiler} compiler - The Webpack compiler instance.
15
- * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
16
- *
17
- * @returns {void}
18
- */
19
- function applyServerPlugins(compiler, options) {
20
- // Import the StreamingTargetPlugin from @module-federation/node
21
- const { StreamingTargetPlugin } = require('@module-federation/node');
22
- const chunkFileName = compiler.options?.output?.chunkFilename;
23
- const uniqueName = compiler?.options?.output?.uniqueName || options.name;
24
- if (typeof chunkFileName === 'string' &&
25
- uniqueName &&
26
- !chunkFileName.includes(uniqueName)) {
27
- const suffix = `-[chunkhash].js`;
28
- compiler.options.output.chunkFilename = chunkFileName.replace('.js', suffix);
29
- }
30
- // Add the StreamingTargetPlugin with the ModuleFederationPlugin from the webpack container
31
- new StreamingTargetPlugin(options, {
32
- ModuleFederationPlugin: webpack_1.ModuleFederationPlugin,
33
- }).apply(compiler);
34
- new enhanced_1.HoistContainerReferencesPlugin().apply(compiler);
35
- // Add a new commonjs chunk loading plugin to the compiler
36
- new InvertedContainerPlugin_1.default({
37
- runtime: 'webpack-runtime',
38
- container: options.name,
39
- chunkToEmbed: 'host_inner_ctn',
40
- remotes: options.remotes,
41
- shared: options.shared,
42
- shareScope: 'default',
43
- exposes: options.exposes,
44
- debug: false,
45
- //@ts-ignore
46
- }).apply(compiler);
47
- }
48
- exports.applyServerPlugins = applyServerPlugins;
49
- /**
50
- * This function configures server-specific library and filename options.
51
- *
52
- * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
53
- *
54
- * @returns {void}
55
- *
56
- * @remarks
57
- * This function configures the library and filename options for server builds. The library option is
58
- * set to the commonjs-module format for chunks and the container, which allows them to be streamed over
59
- * to hosts with the NodeFederationPlugin. The filename option is set to the basename of the current
60
- * filename.
61
- */
62
- function configureServerLibraryAndFilename(options) {
63
- // Configure the library option with type "commonjs-module" and the name from the options
64
- options.library = {
65
- type: 'commonjs-module',
66
- name: options.name,
67
- };
68
- // Set the filename option to the basename of the current filename
69
- options.filename = path_1.default.basename(options.filename);
70
- }
71
- exports.configureServerLibraryAndFilename = configureServerLibraryAndFilename;
72
- /**
73
- * This function patches Next.js' default externals function to make sure shared modules are bundled and not treated as external.
74
- *
75
- * @param {Compiler} compiler - The Webpack compiler instance.
76
- * @param {ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
77
- *
78
- * @returns {void}
79
- *
80
- * @remarks
81
- * In server builds, all node modules are treated as external, which prevents them from being shared
82
- * via module federation. To work around this limitation, we mark shared modules as internalizable
83
- * modules that webpack puts into chunks that can be streamed to other runtimes as needed.
84
- *
85
- * This function replaces Next.js' default externals function with a new asynchronous function that
86
- * checks whether a module should be treated as external. If the module should not be treated as
87
- * external, the function returns without calling the original externals function. Otherwise, the
88
- * function calls the original externals function and retrieves the result. If the result is null,
89
- * the function returns without further processing. If the module is from Next.js or React, the
90
- * function returns the original result. Otherwise, the function returns null.
91
- */
92
- function handleServerExternals(compiler, options) {
93
- // Use a regex to match the required external modules
94
- // const crittersRegex = 'critters';
95
- // const reactRegex = /^react$/;
96
- // const reactDomRegex = /^react-dom$/;
97
- // const nextCompiledRegex = /next\/dist\/compiled\/(?!server|client|shared).*/;
98
- if (Array.isArray(compiler.options.externals) &&
99
- compiler.options.externals[0]) {
100
- // Retrieve the original externals function
101
- const originalExternals = compiler.options.externals[0];
102
- // Replace the original externals function with a new asynchronous function
103
- compiler.options.externals[0] = async function (ctx, callback) {
104
- //@ts-ignore
105
- const fromNext = await originalExternals(ctx, callback);
106
- // If the result is null, return without further processing
107
- if (!fromNext) {
108
- return;
109
- }
110
- // If the module is from Next.js or React, return the original result
111
- const req = fromNext.split(' ')[1];
112
- // Check if the module should not be treated as external
113
- if (ctx.request &&
114
- (ctx.request.includes('@module-federation/utilities') ||
115
- Object.keys(options.shared || {}).some((key) => {
116
- return (
117
- //@ts-ignore
118
- options.shared?.[key]?.import !== false &&
119
- (key.endsWith('/') ? req.includes(key) : req === key));
120
- }) ||
121
- ctx.request.includes('@module-federation/dashboard-plugin'))) {
122
- // If the module should not be treated as external, return without calling the original externals function
123
- return;
124
- }
125
- if (req.startsWith('next') ||
126
- // make sure we dont screw up package names that start with react
127
- // like react-carousel or react-spring
128
- req.startsWith('react/') ||
129
- req.startsWith('react-dom/') ||
130
- req === 'react' ||
131
- req === 'styled-jsx/style' ||
132
- req === 'react-dom') {
133
- return fromNext;
134
- }
135
- // Otherwise, return (null) to treat the module as internalizable
136
- return;
137
- };
138
- }
139
- }
140
- exports.handleServerExternals = handleServerExternals;
141
- /**
142
- * This function configures server-specific compiler options.
143
- *
144
- * @param {Compiler} compiler - The Webpack compiler instance.
145
- *
146
- * @returns {void}
147
- *
148
- * @remarks
149
- * This function configures the compiler options for server builds. It turns off the compiler target on node
150
- * builds because it adds its own chunk loading runtime module with NodeFederationPlugin and StreamingTargetPlugin.
151
- * It also disables split chunks to prevent conflicts from occurring in the graph.
152
- *
153
- */
154
- function configureServerCompilerOptions(compiler) {
155
- // Turn off the compiler target on node builds because we add our own chunk loading runtime module
156
- // with NodeFederationPlugin and StreamingTargetPlugin
157
- compiler.options.node = {
158
- ...compiler.options.node,
159
- global: false,
160
- };
161
- // no custom chunk rules
162
- compiler.options.optimization.splitChunks = undefined;
163
- // solves strange issues where next doesnt create a runtime chunk
164
- // might be related to if an api route exists or not
165
- compiler.options.optimization.runtimeChunk = {
166
- name: 'webpack-runtime',
167
- };
168
- }
169
- exports.configureServerCompilerOptions = configureServerCompilerOptions;
170
- //# sourceMappingURL=apply-server-plugins.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"apply-server-plugins.js","sourceRoot":"","sources":["../../../../src/plugins/NextFederationPlugin/apply-server-plugins.ts"],"names":[],"mappings":";;;;;;AAEA,0DAA6E;AAC7E,gDAAwB;AACxB,mGAA2E;AAC3E,iEAA6E;AAC7E;;;;;;;GAOG;AACH,SAAgB,kBAAkB,CAChC,QAAkB,EAClB,OAAsC;IAEtC,gEAAgE;IAChE,MAA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K;4BACvC,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CACtD,CAAC;oBACJ,CAAC,CAAC;oBACF,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,qCAAqC,CAAC,CAAC,EAC9D,CAAC;gBACD,0GAA0G;gBAC1G,OAAO;YACT,CAAC;YAED,IACE,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC;gBACtB,iEAAiE;gBACjE,sCAAsC;gBACtC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC;gBACxB,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC;gBAC5B,GAAG,KAAK,OAAO;gBACf,GAAG,KAAK,kBAAkB;gBAC1B,GAAG,KAAK,WAAW,EACnB,CAAC;gBACD,OAAO,QAAQ,CAAC;YAClB,CAAC;YACD,iEAAiE;YACjE,OAAO;QACT,CAAC,CAAC;IACJ,CAAC;AACH,CAAC;AA3DD,sDA2DC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,8BAA8B,CAAC,QAAkB;IAC/D,kGAAkG;IAClG,sDAAsD;IACtD,QAAQ,CAAC,OAAO,CAAC,IAAI,GAAG;QACtB,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI;QACxB,MAAM,EAAE,KAAK;KACd,CAAC;IACF,wBAAwB;IACxB,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,WAAW,GAAG,SAAS,CAAC;IAEtD,iEAAiE;IACjE,oDAAoD;IACpD,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,YAAY,GAAG;QAC3C,IAAI,EAAE,iBAAiB;KACxB,CAAC;AACJ,CAAC;AAfD,wEAeC"}
@@ -1,27 +0,0 @@
1
- import type { NextFederationPluginOptions } from '@module-federation/utilities';
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;
@@ -1,160 +0,0 @@
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 path_1 = __importDefault(require("path"));
22
- /**
23
- * NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.
24
- */
25
- class NextFederationPlugin {
26
- /**
27
- * Constructs the NextFederationPlugin with the provided options.
28
- *
29
- * @param options The options to configure the plugin.
30
- */
31
- constructor(options) {
32
- const { mainOptions, extraOptions } = (0, set_options_1.setOptions)(options);
33
- this._options = mainOptions;
34
- this._extraOptions = extraOptions;
35
- this.name = 'ModuleFederationPlugin';
36
- }
37
- /**
38
- * The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.
39
- * @param compiler The webpack compiler object.
40
- */
41
- apply(compiler) {
42
- process.env['FEDERATION_WEBPACK_PATH'] =
43
- process.env['FEDERATION_WEBPACK_PATH'] ||
44
- (0, normalize_webpack_path_1.getWebpackPath)(compiler, { framework: 'nextjs' });
45
- if (!this.validateOptions(compiler))
46
- return;
47
- const isServer = this.isServerCompiler(compiler);
48
- new CopyFederationPlugin_1.default(isServer).apply(compiler);
49
- this.applyConditionalPlugins(compiler, isServer);
50
- const normalFederationPluginOptions = this.getNormalFederationPluginOptions(compiler, isServer);
51
- // ContainerPlugin will get NextFederationPlugin._options, so NextFederationPlugin._options should be the same as normalFederationPluginOptions
52
- this._options = normalFederationPluginOptions;
53
- new webpack_1.ModuleFederationPlugin(normalFederationPluginOptions).apply(compiler);
54
- const runtimeESMPath = require.resolve('@module-federation/runtime/dist/index.esm.js');
55
- compiler.hooks.afterPlugins.tap('PatchAliasWebpackPlugin', () => {
56
- compiler.options.resolve.alias = {
57
- ...compiler.options.resolve.alias,
58
- '@module-federation/runtime$': runtimeESMPath,
59
- };
60
- });
61
- }
62
- validateOptions(compiler) {
63
- const manifestPlugin = compiler.options.plugins.find((p) => p?.constructor.name === 'BuildManifestPlugin');
64
- if (manifestPlugin) {
65
- //@ts-ignore
66
- if (manifestPlugin?.appDirEnabled) {
67
- throw new Error('App Directory is not supported by nextjs-mf. Use only pages directory, do not open git issues about this');
68
- }
69
- }
70
- const compilerValid = (0, validate_options_1.validateCompilerOptions)(compiler);
71
- const pluginValid = (0, validate_options_1.validatePluginOptions)(this._options);
72
- const envValid = process.env['NEXT_PRIVATE_LOCAL_WEBPACK'];
73
- if (compilerValid === undefined)
74
- console.error('Compiler validation failed');
75
- if (pluginValid === undefined)
76
- console.error('Plugin validation failed');
77
- const validCompilerTarget = compiler.options.name === 'server' || compiler.options.name === 'client';
78
- if (!envValid)
79
- throw new Error('process.env.NEXT_PRIVATE_LOCAL_WEBPACK is not set to true, please set it to true, and "npm install webpack"');
80
- return (compilerValid !== undefined &&
81
- pluginValid !== undefined &&
82
- validCompilerTarget);
83
- }
84
- isServerCompiler(compiler) {
85
- return compiler.options.name === 'server';
86
- }
87
- applyConditionalPlugins(compiler, isServer) {
88
- compiler.options.output.uniqueName = this._options.name;
89
- (0, next_fragments_1.applyPathFixes)(compiler, this._extraOptions);
90
- if (this._extraOptions.debug) {
91
- compiler.options.devtool = false;
92
- }
93
- if (isServer) {
94
- (0, apply_server_plugins_1.configureServerCompilerOptions)(compiler);
95
- (0, apply_server_plugins_1.configureServerLibraryAndFilename)(this._options);
96
- (0, apply_server_plugins_1.applyServerPlugins)(compiler, this._options);
97
- (0, apply_server_plugins_1.handleServerExternals)(compiler, {
98
- ...this._options,
99
- shared: { ...(0, next_fragments_1.retrieveDefaultShared)(isServer), ...this._options.shared },
100
- });
101
- }
102
- else {
103
- (0, apply_client_plugins_1.applyClientPlugins)(compiler, this._options, this._extraOptions);
104
- }
105
- }
106
- getNormalFederationPluginOptions(compiler, isServer) {
107
- console.log(this._extraOptions.skipSharingNextInternals);
108
- const defaultShared = this._extraOptions.skipSharingNextInternals
109
- ? {}
110
- : (0, next_fragments_1.retrieveDefaultShared)(isServer);
111
- const noop = this.getNoopPath();
112
- const defaultExpose = this._extraOptions.skipSharingNextInternals
113
- ? {}
114
- : {
115
- './noop': noop,
116
- './react': require.resolve('react'),
117
- './react-dom': require.resolve('react-dom'),
118
- './next/router': require.resolve('next/router'),
119
- };
120
- return {
121
- ...this._options,
122
- runtime: false,
123
- remoteType: 'script',
124
- runtimePlugins: [
125
- require.resolve(path_1.default.join(__dirname, '../container/runtimePlugin')),
126
- ...(this._options.runtimePlugins || []),
127
- ],
128
- //@ts-ignore
129
- exposes: {
130
- ...(this._extraOptions.skipSharingNextInternals ? {} : defaultExpose),
131
- ...this._options.exposes,
132
- ...(this._extraOptions.exposePages
133
- ? (0, nextPageMapLoader_1.exposeNextjsPages)(compiler.options.context)
134
- : {}),
135
- },
136
- remotes: {
137
- ...this._options.remotes,
138
- },
139
- shared: {
140
- ...defaultShared,
141
- ...this._options.shared,
142
- },
143
- // nextjs project needs to add config.watchOptions = ['**/node_modules/**', '**/@mf-types/**'] to prevent loop types update
144
- dts: this._options.dts ?? false,
145
- };
146
- }
147
- getNoopPath() {
148
- let noop;
149
- try {
150
- noop = require.resolve('../../federation-noop');
151
- }
152
- catch (e) {
153
- noop = require.resolve('../../federation-noop.cjs');
154
- }
155
- return noop;
156
- }
157
- }
158
- exports.NextFederationPlugin = NextFederationPlugin;
159
- exports.default = NextFederationPlugin;
160
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/plugins/NextFederationPlugin/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,YAAY,CAAC;;;;;;AAQb,0FAA+E;AAC/E,mFAA2D;AAC3D,uEAAoE;AACpE,qDAAyE;AACzE,+CAA2C;AAC3C,yDAG4B;AAC5B,iEAKgC;AAChC,iEAA4D;AAC5D,iEAA6E;AAG7E,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,GAAG,YAAY,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAkB;QACtB,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC;YACpC,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC;gBACtC,IAAA,uCAAc,EAAC,QAAQ,EAA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C;gBACnE,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,IAAI,EAAE,CAAC;aACxC;YACD,YAAY;YACZ,OAAO,EAAE;gBACP,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC;gBACrE,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,2HAA2H;YAC3H,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,KAAK;SAChC,CAAC;IACJ,CAAC;IAEO,WAAW;QACjB,IAAI,IAAI,CAAC;QACT,IAAI,CAAC;YACH,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,uBAAuB,CAAC,CAAC;QAClD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC;QACtD,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA/JD,oDA+JC;AAED,kBAAe,oBAAoB,CAAC"}
@@ -1,18 +0,0 @@
1
- import type { Compiler } from 'webpack';
2
- import type { SharedObject } from '@module-federation/utilities';
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) => SharedObject;
9
- /**
10
- * Apply path fixes.
11
- *
12
- * This function applies fixes to the path for certain loaders. It checks if the fix is enabled in the options
13
- * and if the loader is present in the rule. If both conditions are met, it injects the fix loader.
14
- *
15
- * @param {Compiler} compiler - The Webpack compiler instance.
16
- * @param {any} options - The ModuleFederationPluginOptions instance.
17
- */
18
- export declare const applyPathFixes: (compiler: Compiler, options: any) => void;
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.applyPathFixes = exports.retrieveDefaultShared = void 0;
4
- const internal_1 = require("../../internal");
5
- const helpers_1 = require("../../loaders/helpers");
6
- /**
7
- * Set up default shared values based on the environment.
8
- * @param {boolean} isServer - Boolean indicating if the code is running on the server.
9
- * @returns {SharedObject} The default share scope based on the environment.
10
- */
11
- const retrieveDefaultShared = (isServer) => {
12
- // If the code is running on the server, treat some Next.js internals as import false to make them external
13
- // This is because they will be provided by the server environment and not by the remote container
14
- if (isServer) {
15
- return internal_1.DEFAULT_SHARE_SCOPE;
16
- }
17
- // If the code is running on the client/browser, always bundle Next.js internals
18
- return internal_1.DEFAULT_SHARE_SCOPE_BROWSER;
19
- };
20
- exports.retrieveDefaultShared = retrieveDefaultShared;
21
- /**
22
- * Apply path fixes.
23
- *
24
- * This function applies fixes to the path for certain loaders. It checks if the fix is enabled in the options
25
- * and if the loader is present in the rule. If both conditions are met, it injects the fix loader.
26
- *
27
- * @param {Compiler} compiler - The Webpack compiler instance.
28
- * @param {any} options - The ModuleFederationPluginOptions instance.
29
- */
30
- const applyPathFixes = (compiler, options) => {
31
- //@ts-ignore
32
- compiler.options.module.rules.forEach((rule) => {
33
- // next-image-loader fix which adds remote's hostname to the assets url
34
- //@ts-ignore
35
- if (options.enableImageLoaderFix && (0, helpers_1.hasLoader)(rule, 'next-image-loader')) {
36
- // childCompiler.options.module.parser.javascript?.url = 'relative';
37
- //@ts-ignore
38
- (0, helpers_1.injectRuleLoader)(rule, {
39
- loader: require.resolve('../../loaders/fixImageLoader'),
40
- });
41
- }
42
- // url-loader fix for which adds remote's hostname to the assets url
43
- //@ts-ignore
44
- if (options.enableUrlLoaderFix && (0, helpers_1.hasLoader)(rule, 'url-loader')) {
45
- (0, helpers_1.injectRuleLoader)({
46
- loader: require.resolve('../../loaders/fixUrlLoader'),
47
- });
48
- }
49
- //@ts-ignore
50
- if (rule?.oneOf) {
51
- //@ts-ignore
52
- rule.oneOf.forEach((oneOfRule) => {
53
- if ((0, helpers_1.hasLoader)(oneOfRule, 'react-refresh-utils')) {
54
- oneOfRule.exclude = [oneOfRule.exclude, /universe\/packages/].filter((i) => i);
55
- }
56
- });
57
- }
58
- });
59
- };
60
- exports.applyPathFixes = applyPathFixes;
61
- //# sourceMappingURL=next-fragments.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"next-fragments.js","sourceRoot":"","sources":["../../../../src/plugins/NextFederationPlugin/next-fragments.ts"],"names":[],"mappings":";;;AAKA,6CAIwB;AACxB,mDAAoE;AAEpE;;;;GAIG;AACI,MAAM,qBAAqB,GAAG,CAAC,QAAiB,EAAgB,EAAE;IACvE,2GAA2G;IAC3G,kGAAkG;IAClG,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,8BAAmB,CAAC;IAC7B,CAAC;IACD,gFAAgF;IAChF,OAAO,sCAA2B,CAAC;AACrC,CAAC,CAAC;AARW,QAAA,qBAAqB,yBAQhC;AAEF;;;;;;;;GAQG;AACI,MAAM,cAAc,GAAG,CAAC,QAAkB,EAAE,OAAY,EAAE,EAAE;IACjE,YAAY;IACZ,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QAC7C,uEAAuE;QACvE,YAAY;QACZ,IAAI,OAAO,CAAC,oBAAoB,IAAI,IAAA,mBAAS,EAAC,IAAI,EAAE,mBAAmB,CAAC,EAAE,CAAC;YACzE,oEAAoE;YACpE,YAAY;YACZ,IAAA,0BAAgB,EAAC,IAAI,EAAE;gBACrB,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,8BAA8B,CAAC;aACxD,CAAC,CAAC;QACL,CAAC;QAED,oEAAoE;QACpE,YAAY;QACZ,IAAI,OAAO,CAAC,kBAAkB,IAAI,IAAA,mBAAS,EAAC,IAAI,EAAE,YAAY,CAAC,EAAE,CAAC;YAChE,IAAA,0BAAgB,EAAC;gBACf,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,4BAA4B,CAAC;aACtD,CAAC,CAAC;QACL,CAAC;QACD,YAAY;QACZ,IAAI,IAAI,EAAE,KAAK,EAAE,CAAC;YAChB,YAAY;YACZ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE;gBAC/B,IAAI,IAAA,mBAAS,EAAC,SAAS,EAAE,qBAAqB,CAAC,EAAE,CAAC;oBAChD,SAAS,CAAC,OAAO,GAAG,CAAC,SAAS,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC,MAAM,CAClE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CACT,CAAC;gBACJ,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC;AAhCW,QAAA,cAAc,kBAgCzB"}
@@ -1,14 +0,0 @@
1
- import type { RuleSetConditionAbsolute } from 'webpack';
2
- /**
3
- * Compares two regular expressions or other types of conditions to see if they are equal.
4
- *
5
- * @param x - The first condition to compare. It can be a string, a RegExp, a function that takes a string and returns a boolean, an array of RuleSetConditionAbsolute, or undefined.
6
- * @param y - The second condition to compare. It is always a RegExp.
7
- * @returns True if the conditions are equal, false otherwise.
8
- *
9
- * @remarks
10
- * This function compares two conditions to see if they are equal in terms of their source,
11
- * global, ignoreCase, and multiline properties. It is used to check if two conditions match
12
- * the same pattern. If the first condition is not a RegExp, the function will always return false.
13
- */
14
- export declare const regexEqual: (x: string | RegExp | ((value: string) => boolean) | RuleSetConditionAbsolute[] | undefined, y: RegExp) => boolean;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.regexEqual = void 0;
4
- /**
5
- * Compares two regular expressions or other types of conditions to see if they are equal.
6
- *
7
- * @param x - The first condition to compare. It can be a string, a RegExp, a function that takes a string and returns a boolean, an array of RuleSetConditionAbsolute, or undefined.
8
- * @param y - The second condition to compare. It is always a RegExp.
9
- * @returns True if the conditions are equal, false otherwise.
10
- *
11
- * @remarks
12
- * This function compares two conditions to see if they are equal in terms of their source,
13
- * global, ignoreCase, and multiline properties. It is used to check if two conditions match
14
- * the same pattern. If the first condition is not a RegExp, the function will always return false.
15
- */
16
- const regexEqual = (x, y) => {
17
- return (x instanceof RegExp &&
18
- y instanceof RegExp &&
19
- x.source === y.source &&
20
- x.global === y.global &&
21
- x.ignoreCase === y.ignoreCase &&
22
- x.multiline === y.multiline);
23
- };
24
- exports.regexEqual = regexEqual;
25
- //# sourceMappingURL=regex-equal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"regex-equal.js","sourceRoot":"","sources":["../../../../src/plugins/NextFederationPlugin/regex-equal.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;GAWG;AACI,MAAM,UAAU,GAAG,CACxB,CAKa,EACb,CAAS,EACA,EAAE;IACX,OAAO,CACL,CAAC,YAAY,MAAM;QACnB,CAAC,YAAY,MAAM;QACnB,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QACrB,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QACrB,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC,UAAU;QAC7B,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,SAAS,CAC5B,CAAC;AACJ,CAAC,CAAC;AAjBW,QAAA,UAAU,cAiBrB"}