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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/dist/LICENSE +21 -0
  2. package/dist/_virtual/_rolldown/runtime.js +29 -0
  3. package/dist/_virtual/_rolldown/runtime.mjs +8 -0
  4. package/dist/client/UrlNode.d.mts +17 -0
  5. package/dist/client/UrlNode.js +89 -147
  6. package/dist/client/UrlNode.js.map +1 -1
  7. package/dist/client/UrlNode.mjs +91 -0
  8. package/dist/client/UrlNode.mjs.map +1 -0
  9. package/dist/node.d.mts +1 -0
  10. package/dist/src/federation-noop.d.mts +0 -0
  11. package/dist/src/federation-noop.js +17 -0
  12. package/dist/src/federation-noop.js.map +1 -1
  13. package/dist/src/federation-noop.mjs +23 -0
  14. package/dist/src/federation-noop.mjs.map +1 -0
  15. package/dist/src/index.d.mts +3 -0
  16. package/dist/src/index.js +13 -11
  17. package/dist/src/index.js.map +1 -1
  18. package/dist/src/index.mjs +8 -0
  19. package/dist/src/index.mjs.map +1 -0
  20. package/dist/src/internal.d.mts +50 -0
  21. package/dist/src/internal.js +140 -243
  22. package/dist/src/internal.js.map +1 -1
  23. package/dist/src/internal.mjs +152 -0
  24. package/dist/src/internal.mjs.map +1 -0
  25. package/dist/src/loaders/fixImageLoader.d.mts +22 -0
  26. package/dist/src/loaders/fixImageLoader.js +91 -103
  27. package/dist/src/loaders/fixImageLoader.js.map +1 -1
  28. package/dist/src/loaders/fixImageLoader.mjs +101 -0
  29. package/dist/src/loaders/fixImageLoader.mjs.map +1 -0
  30. package/dist/src/loaders/fixUrlLoader.d.mts +13 -0
  31. package/dist/src/loaders/fixUrlLoader.js +17 -19
  32. package/dist/src/loaders/fixUrlLoader.js.map +1 -1
  33. package/dist/src/loaders/fixUrlLoader.mjs +19 -0
  34. package/dist/src/loaders/fixUrlLoader.mjs.map +1 -0
  35. package/dist/src/loaders/helpers.d.mts +17 -0
  36. package/dist/src/loaders/helpers.js +72 -124
  37. package/dist/src/loaders/helpers.js.map +1 -1
  38. package/dist/src/loaders/helpers.mjs +79 -0
  39. package/dist/src/loaders/helpers.mjs.map +1 -0
  40. package/dist/src/loaders/nextPageMapLoader.d.mts +24 -0
  41. package/dist/src/loaders/nextPageMapLoader.js +126 -144
  42. package/dist/src/loaders/nextPageMapLoader.js.map +1 -1
  43. package/dist/src/loaders/nextPageMapLoader.mjs +143 -0
  44. package/dist/src/loaders/nextPageMapLoader.mjs.map +1 -0
  45. package/dist/src/logger.d.mts +2 -0
  46. package/dist/src/logger.js +7 -7
  47. package/dist/src/logger.js.map +1 -1
  48. package/dist/src/logger.mjs +8 -0
  49. package/dist/src/logger.mjs.map +1 -0
  50. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.d.mts +5 -0
  51. package/dist/src/plugins/CopyFederationPlugin.d.mts +20 -0
  52. package/dist/src/plugins/CopyFederationPlugin.js +64 -71
  53. package/dist/src/plugins/CopyFederationPlugin.js.map +1 -1
  54. package/dist/src/plugins/CopyFederationPlugin.mjs +65 -0
  55. package/dist/src/plugins/CopyFederationPlugin.mjs.map +1 -0
  56. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.d.mts +22 -0
  57. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.d.ts +22 -0
  58. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.js +43 -0
  59. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.js.map +1 -0
  60. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.mjs +42 -0
  61. package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.mjs.map +1 -0
  62. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.d.mts +23 -0
  63. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js +42 -53
  64. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js.map +1 -1
  65. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.mjs +46 -0
  66. package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.mjs.map +1 -0
  67. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.d.mts +36 -0
  68. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js +103 -121
  69. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js.map +1 -1
  70. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.mjs +111 -0
  71. package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.mjs.map +1 -0
  72. package/dist/src/plugins/NextFederationPlugin/index.d.mts +27 -0
  73. package/dist/src/plugins/NextFederationPlugin/index.js +149 -181
  74. package/dist/src/plugins/NextFederationPlugin/index.js.map +1 -1
  75. package/dist/src/plugins/NextFederationPlugin/index.mjs +151 -0
  76. package/dist/src/plugins/NextFederationPlugin/index.mjs.map +1 -0
  77. package/dist/src/plugins/NextFederationPlugin/manifest-options.d.mts +4 -0
  78. package/dist/src/plugins/NextFederationPlugin/manifest-options.d.ts +4 -0
  79. package/dist/src/plugins/NextFederationPlugin/manifest-options.js +13 -0
  80. package/dist/src/plugins/NextFederationPlugin/manifest-options.js.map +1 -0
  81. package/dist/src/plugins/NextFederationPlugin/manifest-options.mjs +12 -0
  82. package/dist/src/plugins/NextFederationPlugin/manifest-options.mjs.map +1 -0
  83. package/dist/src/plugins/NextFederationPlugin/next-fragments.d.mts +20 -0
  84. package/dist/src/plugins/NextFederationPlugin/next-fragments.js +58 -93
  85. package/dist/src/plugins/NextFederationPlugin/next-fragments.js.map +1 -1
  86. package/dist/src/plugins/NextFederationPlugin/next-fragments.mjs +63 -0
  87. package/dist/src/plugins/NextFederationPlugin/next-fragments.mjs.map +1 -0
  88. package/dist/src/plugins/NextFederationPlugin/{regex-equal.js → regex-equal.d.mts} +2 -13
  89. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.d.mts +8 -0
  90. package/dist/src/plugins/NextFederationPlugin/set-options.d.mts +6 -0
  91. package/dist/src/plugins/NextFederationPlugin/set-options.d.ts +1 -11
  92. package/dist/src/plugins/NextFederationPlugin/set-options.js +17 -19
  93. package/dist/src/plugins/NextFederationPlugin/set-options.js.map +1 -1
  94. package/dist/src/plugins/NextFederationPlugin/set-options.mjs +19 -0
  95. package/dist/src/plugins/NextFederationPlugin/set-options.mjs.map +1 -0
  96. package/dist/src/plugins/NextFederationPlugin/validate-options.d.mts +25 -0
  97. package/dist/src/plugins/NextFederationPlugin/validate-options.js +30 -38
  98. package/dist/src/plugins/NextFederationPlugin/validate-options.js.map +1 -1
  99. package/dist/src/plugins/NextFederationPlugin/validate-options.mjs +35 -0
  100. package/dist/src/plugins/NextFederationPlugin/validate-options.mjs.map +1 -0
  101. package/dist/src/plugins/container/InvertedContainerPlugin.d.mts +5 -0
  102. package/dist/src/plugins/container/InvertedContainerPlugin.js +23 -25
  103. package/dist/src/plugins/container/InvertedContainerPlugin.js.map +1 -1
  104. package/dist/src/plugins/container/InvertedContainerPlugin.mjs +27 -0
  105. package/dist/src/plugins/container/InvertedContainerPlugin.mjs.map +1 -0
  106. package/dist/src/plugins/container/InvertedContainerRuntimeModule.d.mts +11 -0
  107. package/dist/src/plugins/container/InvertedContainerRuntimeModule.d.ts +1 -1
  108. package/dist/src/plugins/container/InvertedContainerRuntimeModule.js +55 -67
  109. package/dist/src/plugins/container/InvertedContainerRuntimeModule.js.map +1 -1
  110. package/dist/src/plugins/container/InvertedContainerRuntimeModule.mjs +57 -0
  111. package/dist/src/plugins/container/InvertedContainerRuntimeModule.mjs.map +1 -0
  112. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.d.mts +39 -0
  113. package/dist/src/plugins/container/runtimePlugin.d.mts +2 -0
  114. package/dist/src/plugins/container/runtimePlugin.d.ts +1 -1
  115. package/dist/src/plugins/container/runtimePlugin.js +170 -0
  116. package/dist/src/plugins/container/runtimePlugin.js.map +1 -1
  117. package/dist/src/plugins/container/runtimePlugin.mjs +169 -0
  118. package/dist/src/plugins/container/runtimePlugin.mjs.map +1 -0
  119. package/dist/src/plugins/container/types.d.mts +2 -0
  120. package/dist/src/types.d.mts +28 -0
  121. package/dist/utils/flushedChunks.d.mts +22 -0
  122. package/dist/utils/flushedChunks.js +32 -72
  123. package/dist/utils/flushedChunks.js.map +1 -1
  124. package/dist/utils/flushedChunks.mjs +35 -0
  125. package/dist/utils/flushedChunks.mjs.map +1 -0
  126. package/dist/utils/index.d.mts +20 -0
  127. package/dist/utils/index.js +27 -62
  128. package/dist/utils/index.js.map +1 -1
  129. package/dist/utils/index.mjs +22 -0
  130. package/dist/utils/index.mjs.map +1 -0
  131. package/package.json +45 -10
  132. package/dist/node.js +0 -18
  133. package/dist/node.js.map +0 -1
  134. package/dist/package.json +0 -71
  135. package/dist/src/federation-noop.cjs +0 -15
  136. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js +0 -19
  137. package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js.map +0 -1
  138. package/dist/src/plugins/NextFederationPlugin/regex-equal.js.map +0 -1
  139. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js +0 -34
  140. package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js.map +0 -1
  141. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js +0 -78
  142. package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js.map +0 -1
  143. package/dist/src/plugins/container/runtimePlugin.cjs +0 -216
  144. package/dist/src/plugins/container/types.js +0 -3
  145. package/dist/src/plugins/container/types.js.map +0 -1
  146. package/dist/src/types.js +0 -3
  147. package/dist/src/types.js.map +0 -1
@@ -1,186 +1,154 @@
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
1
  'use strict';
7
- var __importDefault = (this && this.__importDefault) || function (mod) {
8
- return (mod && mod.__esModule) ? mod : { "default": mod };
2
+
3
+ const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
4
+ const require_logger = require('../../logger.js');
5
+ const require_CopyFederationPlugin = require('../CopyFederationPlugin.js');
6
+ const require_src_loaders_nextPageMapLoader = require('../../loaders/nextPageMapLoader.js');
7
+ const require_next_fragments = require('./next-fragments.js');
8
+ const require_set_options = require('./set-options.js');
9
+ const require_validate_options = require('./validate-options.js');
10
+ const require_apply_server_plugins = require('./apply-server-plugins.js');
11
+ const require_apply_client_plugins = require('./apply-client-plugins.js');
12
+ const require_manifest_options = require('./manifest-options.js');
13
+ let path = require("path");
14
+ path = require_runtime.__toESM(path);
15
+ let _module_federation_sdk_normalize_webpack_path = require("@module-federation/sdk/normalize-webpack-path");
16
+ let _module_federation_sdk = require("@module-federation/sdk");
17
+ let _module_federation_enhanced_webpack = require("@module-federation/enhanced/webpack");
18
+
19
+ //#region src/plugins/NextFederationPlugin/index.ts
20
+ /**
21
+ * MIT License http://www.opensource.org/licenses/mit-license.php
22
+ * Author Zackary Jackson @ScriptedAlchemy
23
+ * This module contains the NextFederationPlugin class which is a webpack plugin that handles Next.js application federation using Module Federation.
24
+ */
25
+ const resolveRuntimePluginPath = () => require.resolve("@module-federation/nextjs-mf/dist/src/plugins/container/runtimePlugin.js");
26
+ const resolveNoopPath = () => require.resolve("@module-federation/nextjs-mf/dist/src/federation-noop.js");
27
+ const resolveNodeRuntimePluginPath = () => {
28
+ const nodePackageRoot = path.default.dirname(require.resolve("@module-federation/node/package.json"));
29
+ return require.resolve(path.default.join(nodePackageRoot, "dist/src/runtimePlugin.js"));
9
30
  };
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
31
  /**
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;
32
+ * NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.
33
+ */
34
+ var NextFederationPlugin = class {
35
+ /**
36
+ * Constructs the NextFederationPlugin with the provided options.
37
+ *
38
+ * @param options The options to configure the plugin.
39
+ */
40
+ constructor(options) {
41
+ const { mainOptions, extraOptions } = require_set_options.setOptions(options);
42
+ this._options = mainOptions;
43
+ this._extraOptions = extraOptions;
44
+ this.name = "ModuleFederationPlugin";
45
+ }
46
+ /**
47
+ * The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.
48
+ * @param compiler The webpack compiler object.
49
+ */
50
+ apply(compiler) {
51
+ (0, _module_federation_sdk.bindLoggerToCompiler)(require_logger.default, compiler, "NextFederationPlugin");
52
+ process.env["FEDERATION_WEBPACK_PATH"] = process.env["FEDERATION_WEBPACK_PATH"] || (0, _module_federation_sdk_normalize_webpack_path.getWebpackPath)(compiler, { framework: "nextjs" });
53
+ if (!this.validateOptions(compiler)) return;
54
+ const isServer = this.isServerCompiler(compiler);
55
+ new require_CopyFederationPlugin.default(isServer).apply(compiler);
56
+ const normalFederationPluginOptions = this.getNormalFederationPluginOptions(compiler, isServer);
57
+ this._options = normalFederationPluginOptions;
58
+ this.applyConditionalPlugins(compiler, isServer);
59
+ new _module_federation_enhanced_webpack.ModuleFederationPlugin(normalFederationPluginOptions).apply(compiler);
60
+ const noop = this.getNoopPath();
61
+ if (!this._extraOptions.skipSharingNextInternals) compiler.hooks.make.tapAsync("NextFederationPlugin", (compilation, callback) => {
62
+ const dep = compiler.webpack.EntryPlugin.createDependency(noop, "noop");
63
+ compilation.addEntry(compiler.context, dep, { name: "noop" }, (err, module) => {
64
+ if (err) return callback(err);
65
+ callback();
66
+ });
67
+ });
68
+ if (!compiler.options.ignoreWarnings) compiler.options.ignoreWarnings = [(message) => /your target environment does not appear/.test(message)];
69
+ }
70
+ validateOptions(compiler) {
71
+ const manifestPlugin = compiler.options.plugins.find((p) => p?.constructor?.name === "BuildManifestPlugin");
72
+ if (manifestPlugin) {
73
+ if (manifestPlugin?.appDirEnabled) throw new Error("App Directory is not supported by nextjs-mf. Use only pages directory, do not open git issues about this");
74
+ }
75
+ const compilerValid = require_validate_options.validateCompilerOptions(compiler);
76
+ const pluginValid = require_validate_options.validatePluginOptions(this._options);
77
+ const envValid = process.env["NEXT_PRIVATE_LOCAL_WEBPACK"];
78
+ if (compilerValid === void 0) require_logger.default.error("Compiler validation failed");
79
+ if (pluginValid === void 0) require_logger.default.error("Plugin validation failed");
80
+ const validCompilerTarget = compiler.options.name === "server" || compiler.options.name === "client";
81
+ if (!envValid) throw new Error("process.env.NEXT_PRIVATE_LOCAL_WEBPACK is not set to true, please set it to true, and \"npm install webpack\"");
82
+ return compilerValid !== void 0 && pluginValid !== void 0 && 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
+ compiler.options.output.environment = {
90
+ ...compiler.options.output.environment,
91
+ asyncFunction: true
92
+ };
93
+ if (!compiler.options.module.rules) compiler.options.module.rules = [];
94
+ compiler.options.module.rules.push({
95
+ resourceQuery: /\?rsc/,
96
+ layer: "rsc"
97
+ });
98
+ compiler.options.module.rules.push({
99
+ resourceQuery: /\?client/,
100
+ layer: "client"
101
+ });
102
+ compiler.options.module.rules.push({
103
+ resourceQuery: /\?ssr/,
104
+ layer: "ssr"
105
+ });
106
+ require_next_fragments.applyPathFixes(compiler, this._options, this._extraOptions);
107
+ if (this._extraOptions.debug) compiler.options.devtool = false;
108
+ if (isServer) {
109
+ require_apply_server_plugins.configureServerCompilerOptions(compiler);
110
+ require_apply_server_plugins.configureServerLibraryAndFilename(this._options);
111
+ require_apply_server_plugins.applyServerPlugins(compiler, this._options);
112
+ require_apply_server_plugins.handleServerExternals(compiler, {
113
+ ...this._options,
114
+ shared: {
115
+ ...require_next_fragments.retrieveDefaultShared(isServer),
116
+ ...this._options.shared
117
+ }
118
+ });
119
+ } else require_apply_client_plugins.applyClientPlugins(compiler, this._options, this._extraOptions);
120
+ }
121
+ getNormalFederationPluginOptions(compiler, isServer) {
122
+ const defaultShared = this._extraOptions.skipSharingNextInternals ? {} : require_next_fragments.retrieveDefaultShared(isServer);
123
+ return {
124
+ ...this._options,
125
+ runtime: false,
126
+ remoteType: "script",
127
+ runtimePlugins: [
128
+ ...isServer ? [resolveNodeRuntimePluginPath()] : [],
129
+ resolveRuntimePluginPath(),
130
+ ...this._options.runtimePlugins || []
131
+ ].map((plugin) => plugin + "?runtimePlugin"),
132
+ exposes: {
133
+ ...this._options.exposes,
134
+ ...this._extraOptions.exposePages ? require_src_loaders_nextPageMapLoader.exposeNextjsPages(compiler.options.context) : {}
135
+ },
136
+ remotes: { ...this._options.remotes },
137
+ shared: {
138
+ ...defaultShared,
139
+ ...this._options.shared
140
+ },
141
+ manifest: require_manifest_options.normalizeManifestOptions(this._options.manifest, isServer),
142
+ dts: this._options.dts ?? false,
143
+ shareStrategy: this._options.shareStrategy ?? "loaded-first",
144
+ experiments: { asyncStartup: true }
145
+ };
146
+ }
147
+ getNoopPath() {
148
+ return resolveNoopPath();
149
+ }
150
+ };
151
+
152
+ //#endregion
185
153
  exports.default = NextFederationPlugin;
186
154
  //# sourceMappingURL=index.js.map
@@ -1 +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,i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ACnB;SACF,CAAC;IACJ,CAAC;IAEO,WAAW;QACjB,OAAO,OAAO,CAAC,OAAO,CAAC,2BAA2B,CAAC,CAAC;IACtD,CAAC;CACF;AAzMD,oDAyMC;AAED,kBAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","names":["setOptions","logger","CopyFederationPlugin","ModuleFederationPlugin","validateCompilerOptions","validatePluginOptions","retrieveDefaultShared","exposeNextjsPages","normalizeManifestOptions"],"sources":["../../../../src/plugins/NextFederationPlugin/index.ts"],"sourcesContent":["/**\n * MIT License http://www.opensource.org/licenses/mit-license.php\n * Author Zackary Jackson @ScriptedAlchemy\n * This module contains the NextFederationPlugin class which is a webpack plugin that handles Next.js application federation using Module Federation.\n */\n'use strict';\n\nimport type {\n NextFederationPluginExtraOptions,\n NextFederationPluginOptions,\n} from './next-fragments';\nimport type { Compiler, WebpackPluginInstance } from 'webpack';\nimport path from 'path';\nimport { getWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport CopyFederationPlugin from '../CopyFederationPlugin';\nimport { exposeNextjsPages } from '../../loaders/nextPageMapLoader';\nimport { retrieveDefaultShared, applyPathFixes } from './next-fragments';\nimport { setOptions } from './set-options';\nimport {\n validateCompilerOptions,\n validatePluginOptions,\n} from './validate-options';\nimport {\n applyServerPlugins,\n configureServerCompilerOptions,\n configureServerLibraryAndFilename,\n handleServerExternals,\n} from './apply-server-plugins';\nimport { applyClientPlugins } from './apply-client-plugins';\nimport { ModuleFederationPlugin } from '@module-federation/enhanced/webpack';\nimport { bindLoggerToCompiler } from '@module-federation/sdk';\nimport type { moduleFederationPlugin } from '@module-federation/sdk';\nimport logger from '../../logger';\nimport { normalizeManifestOptions } from './manifest-options';\n\nconst resolveRuntimePluginPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/plugins/container/runtimePlugin.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/plugins/container/runtimePlugin.js');\n\nconst resolveNoopPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/federation-noop.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/federation-noop.js');\n\nconst resolveNodeRuntimePluginPath = (): string => {\n const nodePackageRoot = path.dirname(\n require.resolve('@module-federation/node/package.json'),\n );\n\n return require.resolve(\n path.join(\n nodePackageRoot,\n process.env.IS_ESM_BUILD === 'true'\n ? 'dist/src/runtimePlugin.mjs'\n : 'dist/src/runtimePlugin.js',\n ),\n );\n};\n/**\n * NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.\n */\nexport class NextFederationPlugin {\n private _options: moduleFederationPlugin.ModuleFederationPluginOptions;\n private _extraOptions: NextFederationPluginExtraOptions;\n public name: string;\n /**\n * Constructs the NextFederationPlugin with the provided options.\n *\n * @param options The options to configure the plugin.\n */\n constructor(options: NextFederationPluginOptions) {\n const { mainOptions, extraOptions } = setOptions(options);\n this._options = mainOptions;\n this._extraOptions = extraOptions;\n this.name = 'ModuleFederationPlugin';\n }\n\n /**\n * The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.\n * @param compiler The webpack compiler object.\n */\n apply(compiler: Compiler) {\n bindLoggerToCompiler(logger, compiler, 'NextFederationPlugin');\n process.env['FEDERATION_WEBPACK_PATH'] =\n process.env['FEDERATION_WEBPACK_PATH'] ||\n getWebpackPath(compiler, { framework: 'nextjs' });\n if (!this.validateOptions(compiler)) return;\n const isServer = this.isServerCompiler(compiler);\n new CopyFederationPlugin(isServer).apply(compiler);\n const normalFederationPluginOptions = this.getNormalFederationPluginOptions(\n compiler,\n isServer,\n );\n this._options = normalFederationPluginOptions;\n this.applyConditionalPlugins(compiler, isServer);\n\n new ModuleFederationPlugin(normalFederationPluginOptions).apply(compiler);\n\n const noop = this.getNoopPath();\n\n if (!this._extraOptions.skipSharingNextInternals) {\n compiler.hooks.make.tapAsync(\n 'NextFederationPlugin',\n (compilation, callback) => {\n const dep = compiler.webpack.EntryPlugin.createDependency(\n noop,\n 'noop',\n );\n compilation.addEntry(\n compiler.context,\n dep,\n { name: 'noop' },\n (err, module) => {\n if (err) {\n return callback(err);\n }\n callback();\n },\n );\n },\n );\n }\n\n if (!compiler.options.ignoreWarnings) {\n compiler.options.ignoreWarnings = [\n //@ts-ignore\n (message) => /your target environment does not appear/.test(message),\n ];\n }\n }\n\n private validateOptions(compiler: Compiler): boolean {\n const manifestPlugin = compiler.options.plugins.find(\n (p): p is WebpackPluginInstance =>\n p?.constructor?.name === 'BuildManifestPlugin',\n );\n\n if (manifestPlugin) {\n //@ts-ignore\n if (manifestPlugin?.appDirEnabled) {\n throw new Error(\n 'App Directory is not supported by nextjs-mf. Use only pages directory, do not open git issues about this',\n );\n }\n }\n\n const compilerValid = validateCompilerOptions(compiler);\n const pluginValid = validatePluginOptions(this._options);\n const envValid = process.env['NEXT_PRIVATE_LOCAL_WEBPACK'];\n if (compilerValid === undefined) logger.error('Compiler validation failed');\n if (pluginValid === undefined) logger.error('Plugin validation failed');\n const validCompilerTarget =\n compiler.options.name === 'server' || compiler.options.name === 'client';\n if (!envValid)\n throw new Error(\n 'process.env.NEXT_PRIVATE_LOCAL_WEBPACK is not set to true, please set it to true, and \"npm install webpack\"',\n );\n return (\n compilerValid !== undefined &&\n pluginValid !== undefined &&\n validCompilerTarget\n );\n }\n\n private isServerCompiler(compiler: Compiler): boolean {\n return compiler.options.name === 'server';\n }\n\n private applyConditionalPlugins(compiler: Compiler, isServer: boolean) {\n compiler.options.output.uniqueName = this._options.name;\n compiler.options.output.environment = {\n ...compiler.options.output.environment,\n asyncFunction: true,\n };\n\n // Add layer rules for resource queries\n if (!compiler.options.module.rules) {\n compiler.options.module.rules = [];\n }\n\n // Add layer rules for RSC, client and SSR\n compiler.options.module.rules.push({\n resourceQuery: /\\?rsc/,\n layer: 'rsc',\n });\n\n compiler.options.module.rules.push({\n resourceQuery: /\\?client/,\n layer: 'client',\n });\n\n compiler.options.module.rules.push({\n resourceQuery: /\\?ssr/,\n layer: 'ssr',\n });\n\n applyPathFixes(compiler, this._options, this._extraOptions);\n if (this._extraOptions.debug) {\n compiler.options.devtool = false;\n }\n\n if (isServer) {\n configureServerCompilerOptions(compiler);\n configureServerLibraryAndFilename(this._options);\n applyServerPlugins(compiler, this._options);\n handleServerExternals(compiler, {\n ...this._options,\n shared: { ...retrieveDefaultShared(isServer), ...this._options.shared },\n });\n } else {\n applyClientPlugins(compiler, this._options, this._extraOptions);\n }\n }\n\n private getNormalFederationPluginOptions(\n compiler: Compiler,\n isServer: boolean,\n ): moduleFederationPlugin.ModuleFederationPluginOptions {\n const defaultShared = this._extraOptions.skipSharingNextInternals\n ? {}\n : retrieveDefaultShared(isServer);\n return {\n ...this._options,\n runtime: false,\n remoteType: 'script',\n runtimePlugins: [\n ...(isServer ? [resolveNodeRuntimePluginPath()] : []),\n resolveRuntimePluginPath(),\n ...(this._options.runtimePlugins || []),\n ].map((plugin) => plugin + '?runtimePlugin'),\n //@ts-ignore\n exposes: {\n ...this._options.exposes,\n ...(this._extraOptions.exposePages\n ? exposeNextjsPages(compiler.options.context as string)\n : {}),\n },\n remotes: {\n ...this._options.remotes,\n },\n shared: {\n ...defaultShared,\n ...(this._options.shared as Record<string, unknown>),\n },\n manifest: normalizeManifestOptions(this._options.manifest, isServer),\n // nextjs project needs to add config.watchOptions = ['**/node_modules/**', '**/@mf-types/**'] to prevent loop types update\n dts: this._options.dts ?? false,\n shareStrategy: this._options.shareStrategy ?? 'loaded-first',\n experiments: {\n asyncStartup: true,\n },\n };\n }\n\n private getNoopPath(): string {\n return resolveNoopPath();\n }\n}\n\nexport default NextFederationPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,iCAGA,QAAQ,QAAQ,2EAA2E;AAEjG,MAAM,wBAGA,QAAQ,QAAQ,2DAA2D;AAEjF,MAAM,qCAA6C;CACjD,MAAM,kBAAkB,aAAK,QAC3B,QAAQ,QAAQ,uCAAuC,CACxD;AA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AAgB,KAAK,cAAc,2BACrC,EAAE,GACFA,6CAAsB,SAAS;AACnC,SAAO;GACL,GAAG,KAAK;GACR,SAAS;GACT,YAAY;GACZ,gBAAgB;IACd,GAAI,WAAW,CAAC,8BAA8B,CAAC,GAAG,EAAE;IACpD,0BAA0B;IAC1B,GAAI,KAAK,SAAS,kBAAkB,EAAE;IACvC,CAAC,KAAK,WAAW,SAAS,iBAAiB;GAE5C,SAAS;IACP,GAAG,KAAK,SAAS;IACjB,GAAI,KAAK,cAAc,cACnBC,wDAAkB,SAAS,QAAQ,QAAkB,GACrD,EAAE;IACP;GACD,SAAS,EACP,GAAG,KAAK,SAAS,SAClB;GACD,QAAQ;IACN,GAAG;IACH,GAAI,KAAK,SAAS;IACnB;GACD,UAAUC,kDAAyB,KAAK,SAAS,UAAU,SAAS;GAEpE,KAAK,KAAK,SAAS,OAAO;GAC1B,eAAe,KAAK,SAAS,iBAAiB;GAC9C,aAAa,EACX,cAAc,MACf;GACF;;CAGH,AAAQ,cAAsB;AAC5B,SAAO,iBAAiB"}
@@ -0,0 +1,151 @@
1
+ import { __require } from "../../../_virtual/_rolldown/runtime.mjs";
2
+ import logger from "../../logger.mjs";
3
+ import CopyBuildOutputPlugin from "../CopyFederationPlugin.mjs";
4
+ import { exposeNextjsPages } from "../../loaders/nextPageMapLoader.mjs";
5
+ import { applyPathFixes, retrieveDefaultShared } from "./next-fragments.mjs";
6
+ import { setOptions } from "./set-options.mjs";
7
+ import { validateCompilerOptions, validatePluginOptions } from "./validate-options.mjs";
8
+ import { applyServerPlugins, configureServerCompilerOptions, configureServerLibraryAndFilename, handleServerExternals } from "./apply-server-plugins.mjs";
9
+ import { applyClientPlugins } from "./apply-client-plugins.mjs";
10
+ import { normalizeManifestOptions } from "./manifest-options.mjs";
11
+ import path from "path";
12
+ import { getWebpackPath } from "@module-federation/sdk/normalize-webpack-path";
13
+ import { bindLoggerToCompiler } from "@module-federation/sdk";
14
+ import { ModuleFederationPlugin } from "@module-federation/enhanced/webpack";
15
+
16
+ //#region src/plugins/NextFederationPlugin/index.ts
17
+ /**
18
+ * MIT License http://www.opensource.org/licenses/mit-license.php
19
+ * Author Zackary Jackson @ScriptedAlchemy
20
+ * This module contains the NextFederationPlugin class which is a webpack plugin that handles Next.js application federation using Module Federation.
21
+ */
22
+ const resolveRuntimePluginPath = () => __require.resolve("@module-federation/nextjs-mf/dist/src/plugins/container/runtimePlugin.mjs");
23
+ const resolveNoopPath = () => __require.resolve("@module-federation/nextjs-mf/dist/src/federation-noop.mjs");
24
+ const resolveNodeRuntimePluginPath = () => {
25
+ const nodePackageRoot = path.dirname(__require.resolve("@module-federation/node/package.json"));
26
+ return __require.resolve(path.join(nodePackageRoot, "dist/src/runtimePlugin.mjs"));
27
+ };
28
+ /**
29
+ * NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.
30
+ */
31
+ var NextFederationPlugin = class {
32
+ /**
33
+ * Constructs the NextFederationPlugin with the provided options.
34
+ *
35
+ * @param options The options to configure the plugin.
36
+ */
37
+ constructor(options) {
38
+ const { mainOptions, extraOptions } = setOptions(options);
39
+ this._options = mainOptions;
40
+ this._extraOptions = extraOptions;
41
+ this.name = "ModuleFederationPlugin";
42
+ }
43
+ /**
44
+ * The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.
45
+ * @param compiler The webpack compiler object.
46
+ */
47
+ apply(compiler) {
48
+ bindLoggerToCompiler(logger, compiler, "NextFederationPlugin");
49
+ process.env["FEDERATION_WEBPACK_PATH"] = process.env["FEDERATION_WEBPACK_PATH"] || getWebpackPath(compiler, { framework: "nextjs" });
50
+ if (!this.validateOptions(compiler)) return;
51
+ const isServer = this.isServerCompiler(compiler);
52
+ new CopyBuildOutputPlugin(isServer).apply(compiler);
53
+ const normalFederationPluginOptions = this.getNormalFederationPluginOptions(compiler, isServer);
54
+ this._options = normalFederationPluginOptions;
55
+ this.applyConditionalPlugins(compiler, isServer);
56
+ new ModuleFederationPlugin(normalFederationPluginOptions).apply(compiler);
57
+ const noop = this.getNoopPath();
58
+ if (!this._extraOptions.skipSharingNextInternals) 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) return callback(err);
62
+ callback();
63
+ });
64
+ });
65
+ if (!compiler.options.ignoreWarnings) compiler.options.ignoreWarnings = [(message) => /your target environment does not appear/.test(message)];
66
+ }
67
+ validateOptions(compiler) {
68
+ const manifestPlugin = compiler.options.plugins.find((p) => p?.constructor?.name === "BuildManifestPlugin");
69
+ if (manifestPlugin) {
70
+ if (manifestPlugin?.appDirEnabled) throw new Error("App Directory is not supported by nextjs-mf. Use only pages directory, do not open git issues about this");
71
+ }
72
+ const compilerValid = validateCompilerOptions(compiler);
73
+ const pluginValid = validatePluginOptions(this._options);
74
+ const envValid = process.env["NEXT_PRIVATE_LOCAL_WEBPACK"];
75
+ if (compilerValid === void 0) logger.error("Compiler validation failed");
76
+ if (pluginValid === void 0) logger.error("Plugin validation failed");
77
+ const validCompilerTarget = compiler.options.name === "server" || compiler.options.name === "client";
78
+ if (!envValid) throw new Error("process.env.NEXT_PRIVATE_LOCAL_WEBPACK is not set to true, please set it to true, and \"npm install webpack\"");
79
+ return compilerValid !== void 0 && pluginValid !== void 0 && validCompilerTarget;
80
+ }
81
+ isServerCompiler(compiler) {
82
+ return compiler.options.name === "server";
83
+ }
84
+ applyConditionalPlugins(compiler, isServer) {
85
+ compiler.options.output.uniqueName = this._options.name;
86
+ compiler.options.output.environment = {
87
+ ...compiler.options.output.environment,
88
+ asyncFunction: true
89
+ };
90
+ if (!compiler.options.module.rules) compiler.options.module.rules = [];
91
+ compiler.options.module.rules.push({
92
+ resourceQuery: /\?rsc/,
93
+ layer: "rsc"
94
+ });
95
+ compiler.options.module.rules.push({
96
+ resourceQuery: /\?client/,
97
+ layer: "client"
98
+ });
99
+ compiler.options.module.rules.push({
100
+ resourceQuery: /\?ssr/,
101
+ layer: "ssr"
102
+ });
103
+ applyPathFixes(compiler, this._options, this._extraOptions);
104
+ if (this._extraOptions.debug) compiler.options.devtool = false;
105
+ if (isServer) {
106
+ configureServerCompilerOptions(compiler);
107
+ configureServerLibraryAndFilename(this._options);
108
+ applyServerPlugins(compiler, this._options);
109
+ handleServerExternals(compiler, {
110
+ ...this._options,
111
+ shared: {
112
+ ...retrieveDefaultShared(isServer),
113
+ ...this._options.shared
114
+ }
115
+ });
116
+ } else applyClientPlugins(compiler, this._options, this._extraOptions);
117
+ }
118
+ getNormalFederationPluginOptions(compiler, isServer) {
119
+ const defaultShared = this._extraOptions.skipSharingNextInternals ? {} : retrieveDefaultShared(isServer);
120
+ return {
121
+ ...this._options,
122
+ runtime: false,
123
+ remoteType: "script",
124
+ runtimePlugins: [
125
+ ...isServer ? [resolveNodeRuntimePluginPath()] : [],
126
+ resolveRuntimePluginPath(),
127
+ ...this._options.runtimePlugins || []
128
+ ].map((plugin) => plugin + "?runtimePlugin"),
129
+ exposes: {
130
+ ...this._options.exposes,
131
+ ...this._extraOptions.exposePages ? exposeNextjsPages(compiler.options.context) : {}
132
+ },
133
+ remotes: { ...this._options.remotes },
134
+ shared: {
135
+ ...defaultShared,
136
+ ...this._options.shared
137
+ },
138
+ manifest: normalizeManifestOptions(this._options.manifest, isServer),
139
+ dts: this._options.dts ?? false,
140
+ shareStrategy: this._options.shareStrategy ?? "loaded-first",
141
+ experiments: { asyncStartup: true }
142
+ };
143
+ }
144
+ getNoopPath() {
145
+ return resolveNoopPath();
146
+ }
147
+ };
148
+
149
+ //#endregion
150
+ export { NextFederationPlugin as default };
151
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["CopyFederationPlugin"],"sources":["../../../../src/plugins/NextFederationPlugin/index.ts"],"sourcesContent":["/**\n * MIT License http://www.opensource.org/licenses/mit-license.php\n * Author Zackary Jackson @ScriptedAlchemy\n * This module contains the NextFederationPlugin class which is a webpack plugin that handles Next.js application federation using Module Federation.\n */\n'use strict';\n\nimport type {\n NextFederationPluginExtraOptions,\n NextFederationPluginOptions,\n} from './next-fragments';\nimport type { Compiler, WebpackPluginInstance } from 'webpack';\nimport path from 'path';\nimport { getWebpackPath } from '@module-federation/sdk/normalize-webpack-path';\nimport CopyFederationPlugin from '../CopyFederationPlugin';\nimport { exposeNextjsPages } from '../../loaders/nextPageMapLoader';\nimport { retrieveDefaultShared, applyPathFixes } from './next-fragments';\nimport { setOptions } from './set-options';\nimport {\n validateCompilerOptions,\n validatePluginOptions,\n} from './validate-options';\nimport {\n applyServerPlugins,\n configureServerCompilerOptions,\n configureServerLibraryAndFilename,\n handleServerExternals,\n} from './apply-server-plugins';\nimport { applyClientPlugins } from './apply-client-plugins';\nimport { ModuleFederationPlugin } from '@module-federation/enhanced/webpack';\nimport { bindLoggerToCompiler } from '@module-federation/sdk';\nimport type { moduleFederationPlugin } from '@module-federation/sdk';\nimport logger from '../../logger';\nimport { normalizeManifestOptions } from './manifest-options';\n\nconst resolveRuntimePluginPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/plugins/container/runtimePlugin.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/plugins/container/runtimePlugin.js');\n\nconst resolveNoopPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/federation-noop.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/federation-noop.js');\n\nconst resolveNodeRuntimePluginPath = (): string => {\n const nodePackageRoot = path.dirname(\n require.resolve('@module-federation/node/package.json'),\n );\n\n return require.resolve(\n path.join(\n nodePackageRoot,\n process.env.IS_ESM_BUILD === 'true'\n ? 'dist/src/runtimePlugin.mjs'\n : 'dist/src/runtimePlugin.js',\n ),\n );\n};\n/**\n * NextFederationPlugin is a webpack plugin that handles Next.js application federation using Module Federation.\n */\nexport class NextFederationPlugin {\n private _options: moduleFederationPlugin.ModuleFederationPluginOptions;\n private _extraOptions: NextFederationPluginExtraOptions;\n public name: string;\n /**\n * Constructs the NextFederationPlugin with the provided options.\n *\n * @param options The options to configure the plugin.\n */\n constructor(options: NextFederationPluginOptions) {\n const { mainOptions, extraOptions } = setOptions(options);\n this._options = mainOptions;\n this._extraOptions = extraOptions;\n this.name = 'ModuleFederationPlugin';\n }\n\n /**\n * The apply method is called by the webpack compiler and allows the plugin to hook into the webpack process.\n * @param compiler The webpack compiler object.\n */\n apply(compiler: Compiler) {\n bindLoggerToCompiler(logger, compiler, 'NextFederationPlugin');\n process.env['FEDERATION_WEBPACK_PATH'] =\n process.env['FEDERATION_WEBPACK_PATH'] ||\n getWebpackPath(compiler, { framework: 'nextjs' });\n if (!this.validateOptions(compiler)) return;\n const isServer = this.isServerCompiler(compiler);\n new CopyFederationPlugin(isServer).apply(compiler);\n const normalFederationPluginOptions = this.getNormalFederationPluginOptions(\n compiler,\n isServer,\n );\n this._options = normalFederationPluginOptions;\n this.applyConditionalPlugins(compiler, isServer);\n\n new ModuleFederationPlugin(normalFederationPluginOptions).apply(compiler);\n\n const noop = this.getNoopPath();\n\n if (!this._extraOptions.skipSharingNextInternals) {\n compiler.hooks.make.tapAsync(\n 'NextFederationPlugin',\n (compilation, callback) => {\n const dep = compiler.webpack.EntryPlugin.createDependency(\n noop,\n 'noop',\n );\n compilation.addEntry(\n compiler.context,\n dep,\n { name: 'noop' },\n (err, module) => {\n if (err) {\n return callback(err);\n }\n callback();\n },\n );\n },\n );\n }\n\n if (!compiler.options.ignoreWarnings) {\n compiler.options.ignoreWarnings = [\n //@ts-ignore\n (message) => /your target environment does not appear/.test(message),\n ];\n }\n }\n\n private validateOptions(compiler: Compiler): boolean {\n const manifestPlugin = compiler.options.plugins.find(\n (p): p is WebpackPluginInstance =>\n p?.constructor?.name === 'BuildManifestPlugin',\n );\n\n if (manifestPlugin) {\n //@ts-ignore\n if (manifestPlugin?.appDirEnabled) {\n throw new Error(\n 'App Directory is not supported by nextjs-mf. Use only pages directory, do not open git issues about this',\n );\n }\n }\n\n const compilerValid = validateCompilerOptions(compiler);\n const pluginValid = validatePluginOptions(this._options);\n const envValid = process.env['NEXT_PRIVATE_LOCAL_WEBPACK'];\n if (compilerValid === undefined) logger.error('Compiler validation failed');\n if (pluginValid === undefined) logger.error('Plugin validation failed');\n const validCompilerTarget =\n compiler.options.name === 'server' || compiler.options.name === 'client';\n if (!envValid)\n throw new Error(\n 'process.env.NEXT_PRIVATE_LOCAL_WEBPACK is not set to true, please set it to true, and \"npm install webpack\"',\n );\n return (\n compilerValid !== undefined &&\n pluginValid !== undefined &&\n validCompilerTarget\n );\n }\n\n private isServerCompiler(compiler: Compiler): boolean {\n return compiler.options.name === 'server';\n }\n\n private applyConditionalPlugins(compiler: Compiler, isServer: boolean) {\n compiler.options.output.uniqueName = this._options.name;\n compiler.options.output.environment = {\n ...compiler.options.output.environment,\n asyncFunction: true,\n };\n\n // Add layer rules for resource queries\n if (!compiler.options.module.rules) {\n compiler.options.module.rules = [];\n }\n\n // Add layer rules for RSC, client and SSR\n compiler.options.module.rules.push({\n resourceQuery: /\\?rsc/,\n layer: 'rsc',\n });\n\n compiler.options.module.rules.push({\n resourceQuery: /\\?client/,\n layer: 'client',\n });\n\n compiler.options.module.rules.push({\n resourceQuery: /\\?ssr/,\n layer: 'ssr',\n });\n\n applyPathFixes(compiler, this._options, this._extraOptions);\n if (this._extraOptions.debug) {\n compiler.options.devtool = false;\n }\n\n if (isServer) {\n configureServerCompilerOptions(compiler);\n configureServerLibraryAndFilename(this._options);\n applyServerPlugins(compiler, this._options);\n handleServerExternals(compiler, {\n ...this._options,\n shared: { ...retrieveDefaultShared(isServer), ...this._options.shared },\n });\n } else {\n applyClientPlugins(compiler, this._options, this._extraOptions);\n }\n }\n\n private getNormalFederationPluginOptions(\n compiler: Compiler,\n isServer: boolean,\n ): moduleFederationPlugin.ModuleFederationPluginOptions {\n const defaultShared = this._extraOptions.skipSharingNextInternals\n ? {}\n : retrieveDefaultShared(isServer);\n return {\n ...this._options,\n runtime: false,\n remoteType: 'script',\n runtimePlugins: [\n ...(isServer ? [resolveNodeRuntimePluginPath()] : []),\n resolveRuntimePluginPath(),\n ...(this._options.runtimePlugins || []),\n ].map((plugin) => plugin + '?runtimePlugin'),\n //@ts-ignore\n exposes: {\n ...this._options.exposes,\n ...(this._extraOptions.exposePages\n ? exposeNextjsPages(compiler.options.context as string)\n : {}),\n },\n remotes: {\n ...this._options.remotes,\n },\n shared: {\n ...defaultShared,\n ...(this._options.shared as Record<string, unknown>),\n },\n manifest: normalizeManifestOptions(this._options.manifest, isServer),\n // nextjs project needs to add config.watchOptions = ['**/node_modules/**', '**/@mf-types/**'] to prevent loop types update\n dts: this._options.dts ?? false,\n shareStrategy: this._options.shareStrategy ?? 'loaded-first',\n experiments: {\n asyncStartup: true,\n },\n };\n }\n\n private getNoopPath(): string {\n return resolveNoopPath();\n }\n}\n\nexport default NextFederationPlugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmCA,MAAM,2CAEQ,QAAQ,4EAA4E;AAGlG,MAAM,kCAEQ,QAAQ,4DAA4D;AAGlF,MAAM,qCAA6C;CACjD,MAAM,kBAAkB,KAAK,kBACnB,QAAQ,uCAAuC,CACxD;AAED,kBAAe,QACb,KAAK,KACH,iBAEI,6BAEL,CACF;;;;;AAKH,IAAa,uBAAb,MAAkC;;;;;;CAShC,YAAY,SAAsC;EAChD,MAAM,EAAE,aAAa,iBAAiB,WAAW,QAAQ;AACzD,OAAK,WAAW;AAChB,OAAK,gBAAgB;AACrB,OAAK,OAAO;;;;;;CAOd,MAAM,UAAoB;AACxB,uBAAqB,QAAQ,UAAU,uBAAuB;AAC9D,UAAQ,IAAI,6BACV,QAAQ,IAAI,8BACZ,eAAe,UAAU,EAAE,WAAW,UAAU,CAAC;AACnD,MAAI,CAAC,KAAK,gBAAgB,SAAS,CAAE;EACrC,MAAM,WAAW,KAAK,iBAAiB,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H,GAAI,KAAK,SAAS;IACnB;GACD,UAAU,yBAAyB,KAAK,SAAS,UAAU,SAAS;GAEpE,KAAK,KAAK,SAAS,OAAO;GAC1B,eAAe,KAAK,SAAS,iBAAiB;GAC9C,aAAa,EACX,cAAc,MACf;GACF;;CAGH,AAAQ,cAAsB;AAC5B,SAAO,iBAAiB"}
@@ -0,0 +1,4 @@
1
+ import type { moduleFederationPlugin } from '@module-federation/sdk';
2
+ type ManifestOptions = moduleFederationPlugin.ModuleFederationPluginOptions['manifest'];
3
+ export declare const normalizeManifestOptions: (manifest: ManifestOptions, isServer: boolean) => ManifestOptions;
4
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { moduleFederationPlugin } from '@module-federation/sdk';
2
+ type ManifestOptions = moduleFederationPlugin.ModuleFederationPluginOptions['manifest'];
3
+ export declare const normalizeManifestOptions: (manifest: ManifestOptions, isServer: boolean) => ManifestOptions;
4
+ export {};
@@ -0,0 +1,13 @@
1
+
2
+ //#region src/plugins/NextFederationPlugin/manifest-options.ts
3
+ const normalizeManifestOptions = (manifest, isServer) => {
4
+ if (manifest === false) return false;
5
+ return {
6
+ ...typeof manifest === "object" && manifest !== null ? manifest : {},
7
+ filePath: isServer ? "" : "/static/chunks"
8
+ };
9
+ };
10
+
11
+ //#endregion
12
+ exports.normalizeManifestOptions = normalizeManifestOptions;
13
+ //# sourceMappingURL=manifest-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-options.js","names":[],"sources":["../../../../src/plugins/NextFederationPlugin/manifest-options.ts"],"sourcesContent":["import type { moduleFederationPlugin } from '@module-federation/sdk';\n\ntype ManifestOptions =\n moduleFederationPlugin.ModuleFederationPluginOptions['manifest'];\n\nexport const normalizeManifestOptions = (\n manifest: ManifestOptions,\n isServer: boolean,\n): ManifestOptions => {\n if (manifest === false) return false;\n\n return {\n ...(typeof manifest === 'object' && manifest !== null ? manifest : {}),\n filePath: isServer ? '' : '/static/chunks',\n };\n};\n"],"mappings":";;AAKA,MAAa,4BACX,UACA,aACoB;AACpB,KAAI,aAAa,MAAO,QAAO;AAE/B,QAAO;EACL,GAAI,OAAO,aAAa,YAAY,aAAa,OAAO,WAAW,EAAE;EACrE,UAAU,WAAW,KAAK;EAC3B"}
@@ -0,0 +1,12 @@
1
+ //#region src/plugins/NextFederationPlugin/manifest-options.ts
2
+ const normalizeManifestOptions = (manifest, isServer) => {
3
+ if (manifest === false) return false;
4
+ return {
5
+ ...typeof manifest === "object" && manifest !== null ? manifest : {},
6
+ filePath: isServer ? "" : "/static/chunks"
7
+ };
8
+ };
9
+
10
+ //#endregion
11
+ export { normalizeManifestOptions };
12
+ //# sourceMappingURL=manifest-options.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-options.mjs","names":[],"sources":["../../../../src/plugins/NextFederationPlugin/manifest-options.ts"],"sourcesContent":["import type { moduleFederationPlugin } from '@module-federation/sdk';\n\ntype ManifestOptions =\n moduleFederationPlugin.ModuleFederationPluginOptions['manifest'];\n\nexport const normalizeManifestOptions = (\n manifest: ManifestOptions,\n isServer: boolean,\n): ManifestOptions => {\n if (manifest === false) return false;\n\n return {\n ...(typeof manifest === 'object' && manifest !== null ? manifest : {}),\n filePath: isServer ? '' : '/static/chunks',\n };\n};\n"],"mappings":";AAKA,MAAa,4BACX,UACA,aACoB;AACpB,KAAI,aAAa,MAAO,QAAO;AAE/B,QAAO;EACL,GAAI,OAAO,aAAa,YAAY,aAAa,OAAO,WAAW,EAAE;EACrE,UAAU,WAAW,KAAK;EAC3B"}