@module-federation/nextjs-mf 0.0.0-perf-devtools-20260108034446 → 0.0.0-perf-website-code-usage-20260914033703
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LICENSE +21 -0
- package/dist/_virtual/_rolldown/runtime.js +29 -0
- package/dist/_virtual/_rolldown/runtime.mjs +8 -0
- package/dist/client/UrlNode.d.mts +17 -0
- package/dist/client/UrlNode.js +89 -147
- package/dist/client/UrlNode.js.map +1 -1
- package/dist/client/UrlNode.mjs +91 -0
- package/dist/client/UrlNode.mjs.map +1 -0
- package/dist/node.d.mts +1 -0
- package/dist/src/federation-noop.d.mts +0 -0
- package/dist/src/federation-noop.js +17 -0
- package/dist/src/federation-noop.js.map +1 -1
- package/dist/src/federation-noop.mjs +23 -0
- package/dist/src/federation-noop.mjs.map +1 -0
- package/dist/src/index.d.mts +3 -0
- package/dist/src/index.js +13 -11
- package/dist/src/index.js.map +1 -1
- package/dist/src/index.mjs +8 -0
- package/dist/src/index.mjs.map +1 -0
- package/dist/src/internal.d.mts +50 -0
- package/dist/src/internal.js +140 -243
- package/dist/src/internal.js.map +1 -1
- package/dist/src/internal.mjs +152 -0
- package/dist/src/internal.mjs.map +1 -0
- package/dist/src/loaders/fixImageLoader.d.mts +22 -0
- package/dist/src/loaders/fixImageLoader.js +91 -103
- package/dist/src/loaders/fixImageLoader.js.map +1 -1
- package/dist/src/loaders/fixImageLoader.mjs +101 -0
- package/dist/src/loaders/fixImageLoader.mjs.map +1 -0
- package/dist/src/loaders/fixUrlLoader.d.mts +13 -0
- package/dist/src/loaders/fixUrlLoader.js +17 -19
- package/dist/src/loaders/fixUrlLoader.js.map +1 -1
- package/dist/src/loaders/fixUrlLoader.mjs +19 -0
- package/dist/src/loaders/fixUrlLoader.mjs.map +1 -0
- package/dist/src/loaders/helpers.d.mts +17 -0
- package/dist/src/loaders/helpers.js +72 -124
- package/dist/src/loaders/helpers.js.map +1 -1
- package/dist/src/loaders/helpers.mjs +79 -0
- package/dist/src/loaders/helpers.mjs.map +1 -0
- package/dist/src/loaders/nextPageMapLoader.d.mts +24 -0
- package/dist/src/loaders/nextPageMapLoader.js +126 -144
- package/dist/src/loaders/nextPageMapLoader.js.map +1 -1
- package/dist/src/loaders/nextPageMapLoader.mjs +143 -0
- package/dist/src/loaders/nextPageMapLoader.mjs.map +1 -0
- package/dist/src/logger.d.mts +2 -0
- package/dist/src/logger.js +7 -7
- package/dist/src/logger.js.map +1 -1
- package/dist/src/logger.mjs +8 -0
- package/dist/src/logger.mjs.map +1 -0
- package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.d.mts +5 -0
- package/dist/src/plugins/CopyFederationPlugin.d.mts +20 -0
- package/dist/src/plugins/CopyFederationPlugin.js +64 -71
- package/dist/src/plugins/CopyFederationPlugin.js.map +1 -1
- package/dist/src/plugins/CopyFederationPlugin.mjs +65 -0
- package/dist/src/plugins/CopyFederationPlugin.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.d.mts +22 -0
- package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.d.ts +22 -0
- package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.js +43 -0
- package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.js.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.mjs +42 -0
- package/dist/src/plugins/NextFederationPlugin/FederatedStatsCompatibilityPlugin.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.d.mts +23 -0
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js +42 -53
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.mjs +46 -0
- package/dist/src/plugins/NextFederationPlugin/apply-client-plugins.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.d.mts +36 -0
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js +103 -121
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.mjs +111 -0
- package/dist/src/plugins/NextFederationPlugin/apply-server-plugins.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/index.d.mts +27 -0
- package/dist/src/plugins/NextFederationPlugin/index.js +149 -181
- package/dist/src/plugins/NextFederationPlugin/index.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/index.mjs +151 -0
- package/dist/src/plugins/NextFederationPlugin/index.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/manifest-options.d.mts +4 -0
- package/dist/src/plugins/NextFederationPlugin/manifest-options.d.ts +4 -0
- package/dist/src/plugins/NextFederationPlugin/manifest-options.js +13 -0
- package/dist/src/plugins/NextFederationPlugin/manifest-options.js.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/manifest-options.mjs +12 -0
- package/dist/src/plugins/NextFederationPlugin/manifest-options.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/next-fragments.d.mts +20 -0
- package/dist/src/plugins/NextFederationPlugin/next-fragments.js +58 -93
- package/dist/src/plugins/NextFederationPlugin/next-fragments.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/next-fragments.mjs +63 -0
- package/dist/src/plugins/NextFederationPlugin/next-fragments.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/{regex-equal.js → regex-equal.d.mts} +2 -13
- package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.d.mts +8 -0
- package/dist/src/plugins/NextFederationPlugin/set-options.d.mts +6 -0
- package/dist/src/plugins/NextFederationPlugin/set-options.d.ts +1 -11
- package/dist/src/plugins/NextFederationPlugin/set-options.js +17 -19
- package/dist/src/plugins/NextFederationPlugin/set-options.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/set-options.mjs +19 -0
- package/dist/src/plugins/NextFederationPlugin/set-options.mjs.map +1 -0
- package/dist/src/plugins/NextFederationPlugin/validate-options.d.mts +25 -0
- package/dist/src/plugins/NextFederationPlugin/validate-options.js +30 -38
- package/dist/src/plugins/NextFederationPlugin/validate-options.js.map +1 -1
- package/dist/src/plugins/NextFederationPlugin/validate-options.mjs +35 -0
- package/dist/src/plugins/NextFederationPlugin/validate-options.mjs.map +1 -0
- package/dist/src/plugins/container/InvertedContainerPlugin.d.mts +5 -0
- package/dist/src/plugins/container/InvertedContainerPlugin.js +23 -25
- package/dist/src/plugins/container/InvertedContainerPlugin.js.map +1 -1
- package/dist/src/plugins/container/InvertedContainerPlugin.mjs +27 -0
- package/dist/src/plugins/container/InvertedContainerPlugin.mjs.map +1 -0
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.d.mts +11 -0
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.d.ts +1 -1
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.js +55 -67
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.js.map +1 -1
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.mjs +57 -0
- package/dist/src/plugins/container/InvertedContainerRuntimeModule.mjs.map +1 -0
- package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.d.mts +39 -0
- package/dist/src/plugins/container/runtimePlugin.d.mts +2 -0
- package/dist/src/plugins/container/runtimePlugin.d.ts +1 -1
- package/dist/src/plugins/container/runtimePlugin.js +170 -0
- package/dist/src/plugins/container/runtimePlugin.js.map +1 -1
- package/dist/src/plugins/container/runtimePlugin.mjs +169 -0
- package/dist/src/plugins/container/runtimePlugin.mjs.map +1 -0
- package/dist/src/plugins/container/types.d.mts +2 -0
- package/dist/src/types.d.mts +28 -0
- package/dist/utils/flushedChunks.d.mts +22 -0
- package/dist/utils/flushedChunks.js +32 -72
- package/dist/utils/flushedChunks.js.map +1 -1
- package/dist/utils/flushedChunks.mjs +35 -0
- package/dist/utils/flushedChunks.mjs.map +1 -0
- package/dist/utils/index.d.mts +20 -0
- package/dist/utils/index.js +27 -62
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +22 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +45 -10
- package/dist/node.js +0 -18
- package/dist/node.js.map +0 -1
- package/dist/package.json +0 -71
- package/dist/src/federation-noop.cjs +0 -15
- package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js +0 -19
- package/dist/src/plugins/AddRuntimeRequirementToPromiseExternalPlugin.js.map +0 -1
- package/dist/src/plugins/NextFederationPlugin/regex-equal.js.map +0 -1
- package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js +0 -34
- package/dist/src/plugins/NextFederationPlugin/remove-unnecessary-shared-keys.js.map +0 -1
- package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js +0 -78
- package/dist/src/plugins/container/RemoveEagerModulesFromRuntimePlugin.js.map +0 -1
- package/dist/src/plugins/container/runtimePlugin.cjs +0 -216
- package/dist/src/plugins/container/types.js +0 -3
- package/dist/src/plugins/container/types.js.map +0 -1
- package/dist/src/types.js +0 -3
- package/dist/src/types.js.map +0 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Compiler } from 'webpack';
|
|
2
|
+
import type { moduleFederationPlugin } from '@module-federation/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* Set up default shared values based on the environment.
|
|
5
|
+
* @param {boolean} isServer - Boolean indicating if the code is running on the server.
|
|
6
|
+
* @returns {SharedObject} The default share scope based on the environment.
|
|
7
|
+
*/
|
|
8
|
+
export declare const retrieveDefaultShared: (isServer: boolean) => moduleFederationPlugin.SharedObject;
|
|
9
|
+
export declare const applyPathFixes: (compiler: Compiler, pluginOptions: moduleFederationPlugin.ModuleFederationPluginOptions, options: any) => void;
|
|
10
|
+
export interface NextFederationPluginExtraOptions {
|
|
11
|
+
enableImageLoaderFix?: boolean;
|
|
12
|
+
enableUrlLoaderFix?: boolean;
|
|
13
|
+
exposePages?: boolean;
|
|
14
|
+
skipSharingNextInternals?: boolean;
|
|
15
|
+
automaticPageStitching?: boolean;
|
|
16
|
+
debug?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface NextFederationPluginOptions extends moduleFederationPlugin.ModuleFederationPluginOptions {
|
|
19
|
+
extraOptions: NextFederationPluginExtraOptions;
|
|
20
|
+
}
|
|
@@ -1,100 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
1
|
+
const require_runtime = require('../../../_virtual/_rolldown/runtime.js');
|
|
2
|
+
const require_internal = require('../../internal.js');
|
|
3
|
+
const require_helpers = require('../../loaders/helpers.js');
|
|
4
|
+
let path = require("path");
|
|
5
|
+
path = require_runtime.__toESM(path);
|
|
6
|
+
|
|
7
|
+
//#region src/plugins/NextFederationPlugin/next-fragments.ts
|
|
8
|
+
const resolveFixImageLoaderPath = () => require.resolve("@module-federation/nextjs-mf/dist/src/loaders/fixImageLoader.js");
|
|
9
|
+
const resolveFixUrlLoaderPath = () => require.resolve("@module-federation/nextjs-mf/dist/src/loaders/fixUrlLoader.js");
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
* Set up default shared values based on the environment.
|
|
12
|
+
* @param {boolean} isServer - Boolean indicating if the code is running on the server.
|
|
13
|
+
* @returns {SharedObject} The default share scope based on the environment.
|
|
14
|
+
*/
|
|
15
15
|
const retrieveDefaultShared = (isServer) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (isServer) {
|
|
19
|
-
return internal_1.DEFAULT_SHARE_SCOPE;
|
|
20
|
-
}
|
|
21
|
-
// If the code is running on the client/browser, always bundle Next.js internals
|
|
22
|
-
return internal_1.DEFAULT_SHARE_SCOPE_BROWSER;
|
|
16
|
+
if (isServer) return require_internal.DEFAULT_SHARE_SCOPE;
|
|
17
|
+
return require_internal.DEFAULT_SHARE_SCOPE_BROWSER;
|
|
23
18
|
};
|
|
24
|
-
exports.retrieveDefaultShared = retrieveDefaultShared;
|
|
25
19
|
const applyPathFixes = (compiler, pluginOptions, options) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
: match.use;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
matchCopy = { ...match };
|
|
71
|
-
}
|
|
72
|
-
const descriptionDataRule = {
|
|
73
|
-
...matchCopy,
|
|
74
|
-
descriptionData: {
|
|
75
|
-
name: /^(@module-federation)/,
|
|
76
|
-
},
|
|
77
|
-
exclude: undefined,
|
|
78
|
-
include: undefined,
|
|
79
|
-
};
|
|
80
|
-
const testRule = {
|
|
81
|
-
...matchCopy,
|
|
82
|
-
resourceQuery: /runtimePlugin/,
|
|
83
|
-
exclude: undefined,
|
|
84
|
-
include: undefined,
|
|
85
|
-
};
|
|
86
|
-
const oneOfRule = compiler.options.module.rules.find((rule) => {
|
|
87
|
-
return !!rule && typeof rule === 'object' && 'oneOf' in rule;
|
|
88
|
-
});
|
|
89
|
-
if (!oneOfRule) {
|
|
90
|
-
compiler.options.module.rules.unshift({
|
|
91
|
-
oneOf: [descriptionDataRule, testRule],
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
else if (oneOfRule.oneOf) {
|
|
95
|
-
oneOfRule.oneOf.unshift(descriptionDataRule, testRule);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
20
|
+
const match = require_helpers.findLoaderForResource(compiler.options.module.rules, {
|
|
21
|
+
path: path.default.join(compiler.context, "/something/thing.js"),
|
|
22
|
+
issuerLayer: void 0,
|
|
23
|
+
layer: void 0
|
|
24
|
+
});
|
|
25
|
+
compiler.options.module.rules.forEach((rule) => {
|
|
26
|
+
if (typeof rule === "object" && rule !== null) {
|
|
27
|
+
const typedRule = rule;
|
|
28
|
+
if (options.enableImageLoaderFix && require_helpers.hasLoader(typedRule, "next-image-loader")) require_helpers.injectRuleLoader(typedRule, { loader: resolveFixImageLoaderPath() });
|
|
29
|
+
if (options.enableUrlLoaderFix && require_helpers.hasLoader(typedRule, "url-loader")) require_helpers.injectRuleLoader(typedRule, { loader: resolveFixUrlLoaderPath() });
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
if (match) {
|
|
33
|
+
let matchCopy;
|
|
34
|
+
if (match.use) {
|
|
35
|
+
matchCopy = { ...match };
|
|
36
|
+
if (Array.isArray(match.use)) matchCopy.use = match.use.filter((loader) => {
|
|
37
|
+
return typeof loader === "object" && loader.loader && !loader.loader.includes("react");
|
|
38
|
+
});
|
|
39
|
+
else if (typeof match.use === "string") matchCopy.use = match.use.includes("react") ? "" : match.use;
|
|
40
|
+
else if (typeof match.use === "object" && match.use !== null) matchCopy.use = match.use.loader && match.use.loader.includes("react") ? {} : match.use;
|
|
41
|
+
} else matchCopy = { ...match };
|
|
42
|
+
const descriptionDataRule = {
|
|
43
|
+
...matchCopy,
|
|
44
|
+
descriptionData: { name: /^(@module-federation)/ },
|
|
45
|
+
exclude: void 0,
|
|
46
|
+
include: void 0
|
|
47
|
+
};
|
|
48
|
+
const testRule = {
|
|
49
|
+
...matchCopy,
|
|
50
|
+
resourceQuery: /runtimePlugin/,
|
|
51
|
+
exclude: void 0,
|
|
52
|
+
include: void 0
|
|
53
|
+
};
|
|
54
|
+
const oneOfRule = compiler.options.module.rules.find((rule) => {
|
|
55
|
+
return !!rule && typeof rule === "object" && "oneOf" in rule;
|
|
56
|
+
});
|
|
57
|
+
if (!oneOfRule) compiler.options.module.rules.unshift({ oneOf: [descriptionDataRule, testRule] });
|
|
58
|
+
else if (oneOfRule.oneOf) oneOfRule.oneOf.unshift(descriptionDataRule, testRule);
|
|
59
|
+
}
|
|
98
60
|
};
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
99
63
|
exports.applyPathFixes = applyPathFixes;
|
|
64
|
+
exports.retrieveDefaultShared = retrieveDefaultShared;
|
|
100
65
|
//# sourceMappingURL=next-fragments.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"next-fragments.js","
|
|
1
|
+
{"version":3,"file":"next-fragments.js","names":["DEFAULT_SHARE_SCOPE","DEFAULT_SHARE_SCOPE_BROWSER","findLoaderForResource","hasLoader"],"sources":["../../../../src/plugins/NextFederationPlugin/next-fragments.ts"],"sourcesContent":["import type { Compiler, RuleSetRule } from 'webpack';\nimport type {\n moduleFederationPlugin,\n sharePlugin,\n} from '@module-federation/sdk';\nimport {\n DEFAULT_SHARE_SCOPE,\n DEFAULT_SHARE_SCOPE_BROWSER,\n} from '../../internal';\nimport {\n hasLoader,\n injectRuleLoader,\n findLoaderForResource,\n} from '../../loaders/helpers';\nimport path from 'path';\n\nconst resolveFixImageLoaderPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/loaders/fixImageLoader.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/loaders/fixImageLoader.js');\n\nconst resolveFixUrlLoaderPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/loaders/fixUrlLoader.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/loaders/fixUrlLoader.js');\n/**\n * Set up default shared values based on the environment.\n * @param {boolean} isServer - Boolean indicating if the code is running on the server.\n * @returns {SharedObject} The default share scope based on the environment.\n */\nexport const retrieveDefaultShared = (\n isServer: boolean,\n): moduleFederationPlugin.SharedObject => {\n // If the code is running on the server, treat some Next.js internals as import false to make them external\n // This is because they will be provided by the server environment and not by the remote container\n if (isServer) {\n return DEFAULT_SHARE_SCOPE;\n }\n // If the code is running on the client/browser, always bundle Next.js internals\n return DEFAULT_SHARE_SCOPE_BROWSER;\n};\nexport const applyPathFixes = (\n compiler: Compiler,\n pluginOptions: moduleFederationPlugin.ModuleFederationPluginOptions,\n options: any,\n) => {\n const match = findLoaderForResource(\n compiler.options.module.rules as RuleSetRule[],\n {\n path: path.join(compiler.context, '/something/thing.js'),\n issuerLayer: undefined,\n layer: undefined,\n },\n );\n\n compiler.options.module.rules.forEach((rule) => {\n if (typeof rule === 'object' && rule !== null) {\n const typedRule = rule as RuleSetRule;\n // next-image-loader fix which adds remote's hostname to the assets url\n if (\n options.enableImageLoaderFix &&\n hasLoader(typedRule, 'next-image-loader')\n ) {\n injectRuleLoader(typedRule, {\n loader: resolveFixImageLoaderPath(),\n });\n }\n\n if (options.enableUrlLoaderFix && hasLoader(typedRule, 'url-loader')) {\n injectRuleLoader(typedRule, {\n loader: resolveFixUrlLoaderPath(),\n });\n }\n }\n });\n\n if (match) {\n let matchCopy: RuleSetRule;\n if (match.use) {\n matchCopy = { ...match };\n if (Array.isArray(match.use)) {\n matchCopy.use = match.use.filter((loader: any) => {\n return (\n typeof loader === 'object' &&\n loader.loader &&\n !loader.loader.includes('react')\n );\n });\n } else if (typeof match.use === 'string') {\n matchCopy.use = match.use.includes('react') ? '' : match.use;\n } else if (typeof match.use === 'object' && match.use !== null) {\n matchCopy.use =\n match.use.loader && match.use.loader.includes('react')\n ? {}\n : match.use;\n }\n } else {\n matchCopy = { ...match };\n }\n\n const descriptionDataRule: RuleSetRule = {\n ...matchCopy,\n descriptionData: {\n name: /^(@module-federation)/,\n },\n exclude: undefined,\n include: undefined,\n };\n\n const testRule: RuleSetRule = {\n ...matchCopy,\n resourceQuery: /runtimePlugin/,\n exclude: undefined,\n include: undefined,\n };\n\n const oneOfRule = compiler.options.module.rules.find(\n (rule): rule is RuleSetRule => {\n return !!rule && typeof rule === 'object' && 'oneOf' in rule;\n },\n ) as RuleSetRule | undefined;\n\n if (!oneOfRule) {\n compiler.options.module.rules.unshift({\n oneOf: [descriptionDataRule, testRule],\n });\n } else if (oneOfRule.oneOf) {\n oneOfRule.oneOf.unshift(descriptionDataRule, testRule);\n }\n }\n};\n\nexport interface NextFederationPluginExtraOptions {\n enableImageLoaderFix?: boolean;\n enableUrlLoaderFix?: boolean;\n exposePages?: boolean;\n skipSharingNextInternals?: boolean;\n automaticPageStitching?: boolean;\n debug?: boolean;\n}\n\nexport interface NextFederationPluginOptions\n extends moduleFederationPlugin.ModuleFederationPluginOptions {\n extraOptions: NextFederationPluginExtraOptions;\n}\n"],"mappings":";;;;;;;AAgBA,MAAM,kCAGA,QAAQ,QAAQ,kEAAkE;AAExF,MAAM,gCAGA,QAAQ,QAAQ,gEAAgE;;;;;;AAMtF,MAAa,yBACX,aACwC;AAGxC,KAAI,SACF,QAAOA;AAGT,QAAOC;;AAET,MAAa,kBACX,UACA,eACA,YACG;CACH,MAAM,QAAQC,sCACZ,SAAS,QAAQ,OAAO,OACxB;EACE,MAAM,aAAK,KAAK,SAAS,SAAS,sBAAsB;EACxD,aAAa;EACb,OAAO;EACR,CACF;AAED,UAAS,QAAQ,OAAO,MAAM,SAAS,SAAS;AAC9C,MAAI,OAAO,SAAS,YAAY,SAAS,MAAM;GAC7C,MAAM,YAAY;AAElB,OACE,QAAQ,wBACRC,0BAAU,WAAW,oBAAoB,CAEzC,kCAAiB,WAAW,EAC1B,QAAQ,2BAA2B,EACpC,CAAC;AAGJ,OAAI,QAAQ,sBAAsBA,0BAAU,WAAW,aAAa,CAClE,kCAAiB,WAAW,EAC1B,QAAQ,yBAAyB,EAClC,CAAC;;GAGN;AAEF,KAAI,OAAO;EACT,IAAI;AACJ,MAAI,MAAM,KAAK;AACb,eAAY,EAAE,GAAG,OAAO;AACxB,OAAI,MAAM,QAAQ,MAAM,IAAI,CAC1B,WAAU,MAAM,MAAM,IAAI,QAAQ,WAAgB;AAChD,WACE,OAAO,WAAW,YAClB,OAAO,UACP,CAAC,OAAO,OAAO,SAAS,QAAQ;KAElC;YACO,OAAO,MAAM,QAAQ,SAC9B,WAAU,MAAM,MAAM,IAAI,SAAS,QAAQ,GAAG,KAAK,MAAM;YAChD,OAAO,MAAM,QAAQ,YAAY,MAAM,QAAQ,KACxD,WAAU,MACR,MAAM,IAAI,UAAU,MAAM,IAAI,OAAO,SAAS,QAAQ,GAClD,EAAE,GACF,MAAM;QAGd,aAAY,EAAE,GAAG,OAAO;EAG1B,MAAM,sBAAmC;GACvC,GAAG;GACH,iBAAiB,EACf,MAAM,yBACP;GACD,SAAS;GACT,SAAS;GACV;EAED,MAAM,WAAwB;GAC5B,GAAG;GACH,eAAe;GACf,SAAS;GACT,SAAS;GACV;EAED,MAAM,YAAY,SAAS,QAAQ,OAAO,MAAM,MAC7C,SAA8B;AAC7B,UAAO,CAAC,CAAC,QAAQ,OAAO,SAAS,YAAY,WAAW;IAE3D;AAED,MAAI,CAAC,UACH,UAAS,QAAQ,OAAO,MAAM,QAAQ,EACpC,OAAO,CAAC,qBAAqB,SAAS,EACvC,CAAC;WACO,UAAU,MACnB,WAAU,MAAM,QAAQ,qBAAqB,SAAS"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { __require } from "../../../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { DEFAULT_SHARE_SCOPE, DEFAULT_SHARE_SCOPE_BROWSER } from "../../internal.mjs";
|
|
3
|
+
import { findLoaderForResource, hasLoader, injectRuleLoader } from "../../loaders/helpers.mjs";
|
|
4
|
+
import path from "path";
|
|
5
|
+
|
|
6
|
+
//#region src/plugins/NextFederationPlugin/next-fragments.ts
|
|
7
|
+
const resolveFixImageLoaderPath = () => __require.resolve("@module-federation/nextjs-mf/dist/src/loaders/fixImageLoader.mjs");
|
|
8
|
+
const resolveFixUrlLoaderPath = () => __require.resolve("@module-federation/nextjs-mf/dist/src/loaders/fixUrlLoader.mjs");
|
|
9
|
+
/**
|
|
10
|
+
* Set up default shared values based on the environment.
|
|
11
|
+
* @param {boolean} isServer - Boolean indicating if the code is running on the server.
|
|
12
|
+
* @returns {SharedObject} The default share scope based on the environment.
|
|
13
|
+
*/
|
|
14
|
+
const retrieveDefaultShared = (isServer) => {
|
|
15
|
+
if (isServer) return DEFAULT_SHARE_SCOPE;
|
|
16
|
+
return DEFAULT_SHARE_SCOPE_BROWSER;
|
|
17
|
+
};
|
|
18
|
+
const applyPathFixes = (compiler, pluginOptions, options) => {
|
|
19
|
+
const match = findLoaderForResource(compiler.options.module.rules, {
|
|
20
|
+
path: path.join(compiler.context, "/something/thing.js"),
|
|
21
|
+
issuerLayer: void 0,
|
|
22
|
+
layer: void 0
|
|
23
|
+
});
|
|
24
|
+
compiler.options.module.rules.forEach((rule) => {
|
|
25
|
+
if (typeof rule === "object" && rule !== null) {
|
|
26
|
+
const typedRule = rule;
|
|
27
|
+
if (options.enableImageLoaderFix && hasLoader(typedRule, "next-image-loader")) injectRuleLoader(typedRule, { loader: resolveFixImageLoaderPath() });
|
|
28
|
+
if (options.enableUrlLoaderFix && hasLoader(typedRule, "url-loader")) injectRuleLoader(typedRule, { loader: resolveFixUrlLoaderPath() });
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
if (match) {
|
|
32
|
+
let matchCopy;
|
|
33
|
+
if (match.use) {
|
|
34
|
+
matchCopy = { ...match };
|
|
35
|
+
if (Array.isArray(match.use)) matchCopy.use = match.use.filter((loader) => {
|
|
36
|
+
return typeof loader === "object" && loader.loader && !loader.loader.includes("react");
|
|
37
|
+
});
|
|
38
|
+
else if (typeof match.use === "string") matchCopy.use = match.use.includes("react") ? "" : match.use;
|
|
39
|
+
else if (typeof match.use === "object" && match.use !== null) matchCopy.use = match.use.loader && match.use.loader.includes("react") ? {} : match.use;
|
|
40
|
+
} else matchCopy = { ...match };
|
|
41
|
+
const descriptionDataRule = {
|
|
42
|
+
...matchCopy,
|
|
43
|
+
descriptionData: { name: /^(@module-federation)/ },
|
|
44
|
+
exclude: void 0,
|
|
45
|
+
include: void 0
|
|
46
|
+
};
|
|
47
|
+
const testRule = {
|
|
48
|
+
...matchCopy,
|
|
49
|
+
resourceQuery: /runtimePlugin/,
|
|
50
|
+
exclude: void 0,
|
|
51
|
+
include: void 0
|
|
52
|
+
};
|
|
53
|
+
const oneOfRule = compiler.options.module.rules.find((rule) => {
|
|
54
|
+
return !!rule && typeof rule === "object" && "oneOf" in rule;
|
|
55
|
+
});
|
|
56
|
+
if (!oneOfRule) compiler.options.module.rules.unshift({ oneOf: [descriptionDataRule, testRule] });
|
|
57
|
+
else if (oneOfRule.oneOf) oneOfRule.oneOf.unshift(descriptionDataRule, testRule);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
export { applyPathFixes, retrieveDefaultShared };
|
|
63
|
+
//# sourceMappingURL=next-fragments.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next-fragments.mjs","names":[],"sources":["../../../../src/plugins/NextFederationPlugin/next-fragments.ts"],"sourcesContent":["import type { Compiler, RuleSetRule } from 'webpack';\nimport type {\n moduleFederationPlugin,\n sharePlugin,\n} from '@module-federation/sdk';\nimport {\n DEFAULT_SHARE_SCOPE,\n DEFAULT_SHARE_SCOPE_BROWSER,\n} from '../../internal';\nimport {\n hasLoader,\n injectRuleLoader,\n findLoaderForResource,\n} from '../../loaders/helpers';\nimport path from 'path';\n\nconst resolveFixImageLoaderPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/loaders/fixImageLoader.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/loaders/fixImageLoader.js');\n\nconst resolveFixUrlLoaderPath = (): string =>\n process.env.IS_ESM_BUILD === 'true'\n ? require.resolve('@module-federation/nextjs-mf/dist/src/loaders/fixUrlLoader.mjs')\n : require.resolve('@module-federation/nextjs-mf/dist/src/loaders/fixUrlLoader.js');\n/**\n * Set up default shared values based on the environment.\n * @param {boolean} isServer - Boolean indicating if the code is running on the server.\n * @returns {SharedObject} The default share scope based on the environment.\n */\nexport const retrieveDefaultShared = (\n isServer: boolean,\n): moduleFederationPlugin.SharedObject => {\n // If the code is running on the server, treat some Next.js internals as import false to make them external\n // This is because they will be provided by the server environment and not by the remote container\n if (isServer) {\n return DEFAULT_SHARE_SCOPE;\n }\n // If the code is running on the client/browser, always bundle Next.js internals\n return DEFAULT_SHARE_SCOPE_BROWSER;\n};\nexport const applyPathFixes = (\n compiler: Compiler,\n pluginOptions: moduleFederationPlugin.ModuleFederationPluginOptions,\n options: any,\n) => {\n const match = findLoaderForResource(\n compiler.options.module.rules as RuleSetRule[],\n {\n path: path.join(compiler.context, '/something/thing.js'),\n issuerLayer: undefined,\n layer: undefined,\n },\n );\n\n compiler.options.module.rules.forEach((rule) => {\n if (typeof rule === 'object' && rule !== null) {\n const typedRule = rule as RuleSetRule;\n // next-image-loader fix which adds remote's hostname to the assets url\n if (\n options.enableImageLoaderFix &&\n hasLoader(typedRule, 'next-image-loader')\n ) {\n injectRuleLoader(typedRule, {\n loader: resolveFixImageLoaderPath(),\n });\n }\n\n if (options.enableUrlLoaderFix && hasLoader(typedRule, 'url-loader')) {\n injectRuleLoader(typedRule, {\n loader: resolveFixUrlLoaderPath(),\n });\n }\n }\n });\n\n if (match) {\n let matchCopy: RuleSetRule;\n if (match.use) {\n matchCopy = { ...match };\n if (Array.isArray(match.use)) {\n matchCopy.use = match.use.filter((loader: any) => {\n return (\n typeof loader === 'object' &&\n loader.loader &&\n !loader.loader.includes('react')\n );\n });\n } else if (typeof match.use === 'string') {\n matchCopy.use = match.use.includes('react') ? '' : match.use;\n } else if (typeof match.use === 'object' && match.use !== null) {\n matchCopy.use =\n match.use.loader && match.use.loader.includes('react')\n ? {}\n : match.use;\n }\n } else {\n matchCopy = { ...match };\n }\n\n const descriptionDataRule: RuleSetRule = {\n ...matchCopy,\n descriptionData: {\n name: /^(@module-federation)/,\n },\n exclude: undefined,\n include: undefined,\n };\n\n const testRule: RuleSetRule = {\n ...matchCopy,\n resourceQuery: /runtimePlugin/,\n exclude: undefined,\n include: undefined,\n };\n\n const oneOfRule = compiler.options.module.rules.find(\n (rule): rule is RuleSetRule => {\n return !!rule && typeof rule === 'object' && 'oneOf' in rule;\n },\n ) as RuleSetRule | undefined;\n\n if (!oneOfRule) {\n compiler.options.module.rules.unshift({\n oneOf: [descriptionDataRule, testRule],\n });\n } else if (oneOfRule.oneOf) {\n oneOfRule.oneOf.unshift(descriptionDataRule, testRule);\n }\n }\n};\n\nexport interface NextFederationPluginExtraOptions {\n enableImageLoaderFix?: boolean;\n enableUrlLoaderFix?: boolean;\n exposePages?: boolean;\n skipSharingNextInternals?: boolean;\n automaticPageStitching?: boolean;\n debug?: boolean;\n}\n\nexport interface NextFederationPluginOptions\n extends moduleFederationPlugin.ModuleFederationPluginOptions {\n extraOptions: NextFederationPluginExtraOptions;\n}\n"],"mappings":";;;;;;AAgBA,MAAM,4CAEQ,QAAQ,mEAAmE;AAGzF,MAAM,0CAEQ,QAAQ,iEAAiE;;;;;;AAOvF,MAAa,yBACX,aACwC;AAGxC,KAAI,SACF,QAAO;AAGT,QAAO;;AAET,MAAa,kBACX,UACA,eACA,YACG;CACH,MAAM,QAAQ,sBACZ,SAAS,QAAQ,OAAO,OACxB;EACE,MAAM,KAAK,KAAK,SAAS,SAAS,sBAAsB;EACxD,aAAa;EACb,OAAO;EACR,CACF;AAED,UAAS,QAAQ,OAAO,MAAM,SAAS,SAAS;AAC9C,MAAI,OAAO,SAAS,YAAY,SAAS,MAAM;GAC7C,MAAM,YAAY;AAElB,OACE,QAAQ,wBACR,UAAU,WAAW,oBAAoB,CAEzC,kBAAiB,WAAW,EAC1B,QAAQ,2BAA2B,EACpC,CAAC;AAGJ,OAAI,QAAQ,sBAAsB,UAAU,WAAW,aAAa,CAClE,kBAAiB,WAAW,EAC1B,QAAQ,yBAAyB,EAClC,CAAC;;GAGN;AAEF,KAAI,OAAO;EACT,IAAI;AACJ,MAAI,MAAM,KAAK;AACb,eAAY,EAAE,GAAG,OAAO;AACxB,OAAI,MAAM,QAAQ,MAAM,IAAI,CAC1B,WAAU,MAAM,MAAM,IAAI,QAAQ,WAAgB;AAChD,WACE,OAAO,WAAW,YAClB,OAAO,UACP,CAAC,OAAO,OAAO,SAAS,QAAQ;KAElC;YACO,OAAO,MAAM,QAAQ,SAC9B,WAAU,MAAM,MAAM,IAAI,SAAS,QAAQ,GAAG,KAAK,MAAM;YAChD,OAAO,MAAM,QAAQ,YAAY,MAAM,QAAQ,KACxD,WAAU,MACR,MAAM,IAAI,UAAU,MAAM,IAAI,OAAO,SAAS,QAAQ,GAClD,EAAE,GACF,MAAM;QAGd,aAAY,EAAE,GAAG,OAAO;EAG1B,MAAM,sBAAmC;GACvC,GAAG;GACH,iBAAiB,EACf,MAAM,yBACP;GACD,SAAS;GACT,SAAS;GACV;EAED,MAAM,WAAwB;GAC5B,GAAG;GACH,eAAe;GACf,SAAS;GACT,SAAS;GACV;EAED,MAAM,YAAY,SAAS,QAAQ,OAAO,MAAM,MAC7C,SAA8B;AAC7B,UAAO,CAAC,CAAC,QAAQ,OAAO,SAAS,YAAY,WAAW;IAE3D;AAED,MAAI,CAAC,UACH,UAAS,QAAQ,OAAO,MAAM,QAAQ,EACpC,OAAO,CAAC,qBAAqB,SAAS,EACvC,CAAC;WACO,UAAU,MACnB,WAAU,MAAM,QAAQ,qBAAqB,SAAS"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.regexEqual = void 0;
|
|
1
|
+
import type { RuleSetConditionAbsolute } from 'webpack';
|
|
4
2
|
/**
|
|
5
3
|
* Compares two regular expressions or other types of conditions to see if they are equal.
|
|
6
4
|
*
|
|
@@ -13,13 +11,4 @@ exports.regexEqual = void 0;
|
|
|
13
11
|
* global, ignoreCase, and multiline properties. It is used to check if two conditions match
|
|
14
12
|
* the same pattern. If the first condition is not a RegExp, the function will always return false.
|
|
15
13
|
*/
|
|
16
|
-
const regexEqual
|
|
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
|
|
14
|
+
export declare const regexEqual: (x: string | RegExp | ((value: string) => boolean) | RuleSetConditionAbsolute[] | undefined, y: RegExp) => boolean;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function to remove unnecessary shared keys from the default share scope.
|
|
3
|
+
* It iterates over each key in the shared object and checks against the default share scope.
|
|
4
|
+
* If a key is found in the default share scope, a warning is logged and the key is removed from the shared object.
|
|
5
|
+
*
|
|
6
|
+
* @param {Record<string, unknown>} shared - The shared object to be checked.
|
|
7
|
+
*/
|
|
8
|
+
export declare function removeUnnecessarySharedKeys(shared: Record<string, unknown>): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { moduleFederationPlugin } from '@module-federation/sdk';
|
|
2
|
+
import type { NextFederationPluginExtraOptions, NextFederationPluginOptions } from './next-fragments';
|
|
3
|
+
export declare function setOptions(options: NextFederationPluginOptions): {
|
|
4
|
+
mainOptions: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
5
|
+
extraOptions: NextFederationPluginExtraOptions;
|
|
6
|
+
};
|
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import type { moduleFederationPlugin } from '@module-federation/sdk';
|
|
2
|
-
|
|
3
|
-
enableImageLoaderFix?: boolean;
|
|
4
|
-
enableUrlLoaderFix?: boolean;
|
|
5
|
-
exposePages?: boolean;
|
|
6
|
-
skipSharingNextInternals?: boolean;
|
|
7
|
-
automaticPageStitching?: boolean;
|
|
8
|
-
debug?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export interface NextFederationPluginOptions extends moduleFederationPlugin.ModuleFederationPluginOptions {
|
|
11
|
-
extraOptions: NextFederationPluginExtraOptions;
|
|
12
|
-
}
|
|
2
|
+
import type { NextFederationPluginExtraOptions, NextFederationPluginOptions } from './next-fragments';
|
|
13
3
|
export declare function setOptions(options: NextFederationPluginOptions): {
|
|
14
4
|
mainOptions: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
15
5
|
extraOptions: NextFederationPluginExtraOptions;
|
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.setOptions = setOptions;
|
|
1
|
+
|
|
2
|
+
//#region src/plugins/NextFederationPlugin/set-options.ts
|
|
4
3
|
function setOptions(options) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
mainOptions: mainOpts,
|
|
19
|
-
extraOptions: { ...defaultExtraOptions, ...extraOptions },
|
|
20
|
-
};
|
|
4
|
+
const { extraOptions, ...mainOpts } = options;
|
|
5
|
+
return {
|
|
6
|
+
mainOptions: mainOpts,
|
|
7
|
+
extraOptions: {
|
|
8
|
+
automaticPageStitching: false,
|
|
9
|
+
enableImageLoaderFix: false,
|
|
10
|
+
enableUrlLoaderFix: false,
|
|
11
|
+
skipSharingNextInternals: false,
|
|
12
|
+
debug: false,
|
|
13
|
+
...extraOptions
|
|
14
|
+
}
|
|
15
|
+
};
|
|
21
16
|
}
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
exports.setOptions = setOptions;
|
|
22
20
|
//# sourceMappingURL=set-options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set-options.js","
|
|
1
|
+
{"version":3,"file":"set-options.js","names":[],"sources":["../../../../src/plugins/NextFederationPlugin/set-options.ts"],"sourcesContent":["import type { moduleFederationPlugin } from '@module-federation/sdk';\nimport type {\n NextFederationPluginExtraOptions,\n NextFederationPluginOptions,\n} from './next-fragments';\n\nexport function setOptions(options: NextFederationPluginOptions): {\n mainOptions: moduleFederationPlugin.ModuleFederationPluginOptions;\n extraOptions: NextFederationPluginExtraOptions;\n} {\n const { extraOptions, ...mainOpts } = options;\n\n /**\n * Default extra options for NextFederationPlugin.\n * @type {NextFederationPluginExtraOptions}\n */\n const defaultExtraOptions: NextFederationPluginExtraOptions = {\n automaticPageStitching: false,\n enableImageLoaderFix: false,\n enableUrlLoaderFix: false,\n skipSharingNextInternals: false,\n debug: false,\n };\n\n return {\n mainOptions: mainOpts,\n extraOptions: { ...defaultExtraOptions, ...extraOptions },\n };\n}\n"],"mappings":";;AAMA,SAAgB,WAAW,SAGzB;CACA,MAAM,EAAE,cAAc,GAAG,aAAa;AActC,QAAO;EACL,aAAa;EACb,cAAc;GATd,wBAAwB;GACxB,sBAAsB;GACtB,oBAAoB;GACpB,0BAA0B;GAC1B,OAAO;GAKiC,GAAG;GAAc;EAC1D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/plugins/NextFederationPlugin/set-options.ts
|
|
2
|
+
function setOptions(options) {
|
|
3
|
+
const { extraOptions, ...mainOpts } = options;
|
|
4
|
+
return {
|
|
5
|
+
mainOptions: mainOpts,
|
|
6
|
+
extraOptions: {
|
|
7
|
+
automaticPageStitching: false,
|
|
8
|
+
enableImageLoaderFix: false,
|
|
9
|
+
enableUrlLoaderFix: false,
|
|
10
|
+
skipSharingNextInternals: false,
|
|
11
|
+
debug: false,
|
|
12
|
+
...extraOptions
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//#endregion
|
|
18
|
+
export { setOptions };
|
|
19
|
+
//# sourceMappingURL=set-options.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-options.mjs","names":[],"sources":["../../../../src/plugins/NextFederationPlugin/set-options.ts"],"sourcesContent":["import type { moduleFederationPlugin } from '@module-federation/sdk';\nimport type {\n NextFederationPluginExtraOptions,\n NextFederationPluginOptions,\n} from './next-fragments';\n\nexport function setOptions(options: NextFederationPluginOptions): {\n mainOptions: moduleFederationPlugin.ModuleFederationPluginOptions;\n extraOptions: NextFederationPluginExtraOptions;\n} {\n const { extraOptions, ...mainOpts } = options;\n\n /**\n * Default extra options for NextFederationPlugin.\n * @type {NextFederationPluginExtraOptions}\n */\n const defaultExtraOptions: NextFederationPluginExtraOptions = {\n automaticPageStitching: false,\n enableImageLoaderFix: false,\n enableUrlLoaderFix: false,\n skipSharingNextInternals: false,\n debug: false,\n };\n\n return {\n mainOptions: mainOpts,\n extraOptions: { ...defaultExtraOptions, ...extraOptions },\n };\n}\n"],"mappings":";AAMA,SAAgB,WAAW,SAGzB;CACA,MAAM,EAAE,cAAc,GAAG,aAAa;AActC,QAAO;EACL,aAAa;EACb,cAAc;GATd,wBAAwB;GACxB,sBAAsB;GACtB,oBAAoB;GACpB,0BAA0B;GAC1B,OAAO;GAKiC,GAAG;GAAc;EAC1D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Compiler } from 'webpack';
|
|
2
|
+
import type { moduleFederationPlugin } from '@module-federation/sdk';
|
|
3
|
+
/**
|
|
4
|
+
* Validates the compiler options.
|
|
5
|
+
*
|
|
6
|
+
* @param {Compiler} compiler - The Webpack compiler instance.
|
|
7
|
+
* @returns {boolean} - Returns true if the compiler options are valid, false otherwise.
|
|
8
|
+
*
|
|
9
|
+
* @throws Will throw an error if the name option is not defined in the options.
|
|
10
|
+
* @remarks
|
|
11
|
+
* This function validates the options passed to the Webpack compiler. It checks if the name option is set to either "server" or
|
|
12
|
+
* "client", as Module Federation is only applied to the main server and client builds in Next.js.
|
|
13
|
+
*/
|
|
14
|
+
export declare function validateCompilerOptions(compiler: Compiler): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Validates the NextFederationPlugin options.
|
|
17
|
+
*
|
|
18
|
+
* @param {moduleFederationPlugin.ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
|
|
19
|
+
*
|
|
20
|
+
* @throws Will throw an error if the filename option is not defined in the options or if the name option is not specified.
|
|
21
|
+
* @remarks
|
|
22
|
+
* This function validates the options passed to NextFederationPlugin. It ensures that the filename and name options are defined,
|
|
23
|
+
* as they are required for using Module Federation.
|
|
24
|
+
*/
|
|
25
|
+
export declare function validatePluginOptions(options: moduleFederationPlugin.ModuleFederationPluginOptions): boolean | void;
|
|
@@ -1,45 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.validateCompilerOptions = validateCompilerOptions;
|
|
4
|
-
exports.validatePluginOptions = validatePluginOptions;
|
|
1
|
+
|
|
2
|
+
//#region src/plugins/NextFederationPlugin/validate-options.ts
|
|
5
3
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
* Validates the compiler options.
|
|
5
|
+
*
|
|
6
|
+
* @param {Compiler} compiler - The Webpack compiler instance.
|
|
7
|
+
* @returns {boolean} - Returns true if the compiler options are valid, false otherwise.
|
|
8
|
+
*
|
|
9
|
+
* @throws Will throw an error if the name option is not defined in the options.
|
|
10
|
+
* @remarks
|
|
11
|
+
* This function validates the options passed to the Webpack compiler. It checks if the name option is set to either "server" or
|
|
12
|
+
* "client", as Module Federation is only applied to the main server and client builds in Next.js.
|
|
13
|
+
*/
|
|
16
14
|
function validateCompilerOptions(compiler) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
throw new Error('name is not defined in Compiler options');
|
|
20
|
-
}
|
|
21
|
-
// Only apply Module Federation to the main server and client builds in Next.js
|
|
22
|
-
return ['server', 'client'].includes(compiler.options.name);
|
|
15
|
+
if (!compiler.options.name) throw new Error("name is not defined in Compiler options");
|
|
16
|
+
return ["server", "client"].includes(compiler.options.name);
|
|
23
17
|
}
|
|
24
18
|
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
19
|
+
* Validates the NextFederationPlugin options.
|
|
20
|
+
*
|
|
21
|
+
* @param {moduleFederationPlugin.ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
|
|
22
|
+
*
|
|
23
|
+
* @throws Will throw an error if the filename option is not defined in the options or if the name option is not specified.
|
|
24
|
+
* @remarks
|
|
25
|
+
* This function validates the options passed to NextFederationPlugin. It ensures that the filename and name options are defined,
|
|
26
|
+
* as they are required for using Module Federation.
|
|
27
|
+
*/
|
|
34
28
|
function validatePluginOptions(options) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
// A requirement for using Module Federation is that a name must be specified
|
|
40
|
-
if (!options.name) {
|
|
41
|
-
throw new Error('Module federation "name" option must be specified');
|
|
42
|
-
}
|
|
43
|
-
return true;
|
|
29
|
+
if (!options.filename) throw new Error("filename is not defined in NextFederation options");
|
|
30
|
+
if (!options.name) throw new Error("Module federation \"name\" option must be specified");
|
|
31
|
+
return true;
|
|
44
32
|
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
exports.validateCompilerOptions = validateCompilerOptions;
|
|
36
|
+
exports.validatePluginOptions = validatePluginOptions;
|
|
45
37
|
//# sourceMappingURL=validate-options.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-options.js","
|
|
1
|
+
{"version":3,"file":"validate-options.js","names":[],"sources":["../../../../src/plugins/NextFederationPlugin/validate-options.ts"],"sourcesContent":["import type { Compiler } from 'webpack';\nimport type { moduleFederationPlugin } from '@module-federation/sdk';\n\n/**\n * Validates the compiler options.\n *\n * @param {Compiler} compiler - The Webpack compiler instance.\n * @returns {boolean} - Returns true if the compiler options are valid, false otherwise.\n *\n * @throws Will throw an error if the name option is not defined in the options.\n * @remarks\n * This function validates the options passed to the Webpack compiler. It checks if the name option is set to either \"server\" or\n * \"client\", as Module Federation is only applied to the main server and client builds in Next.js.\n */\nexport function validateCompilerOptions(compiler: Compiler): boolean {\n // Throw an error if the name option is not defined in the options\n if (!compiler.options.name) {\n throw new Error('name is not defined in Compiler options');\n }\n\n // Only apply Module Federation to the main server and client builds in Next.js\n return ['server', 'client'].includes(compiler.options.name);\n}\n\n/**\n * Validates the NextFederationPlugin options.\n *\n * @param {moduleFederationPlugin.ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.\n *\n * @throws Will throw an error if the filename option is not defined in the options or if the name option is not specified.\n * @remarks\n * This function validates the options passed to NextFederationPlugin. It ensures that the filename and name options are defined,\n * as they are required for using Module Federation.\n */\nexport function validatePluginOptions(\n options: moduleFederationPlugin.ModuleFederationPluginOptions,\n): boolean | void {\n // Throw an error if the filename option is not defined in the options\n if (!options.filename) {\n throw new Error('filename is not defined in NextFederation options');\n }\n\n // A requirement for using Module Federation is that a name must be specified\n if (!options.name) {\n throw new Error('Module federation \"name\" option must be specified');\n }\n return true;\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,SAAgB,wBAAwB,UAA6B;AAEnE,KAAI,CAAC,SAAS,QAAQ,KACpB,OAAM,IAAI,MAAM,0CAA0C;AAI5D,QAAO,CAAC,UAAU,SAAS,CAAC,SAAS,SAAS,QAAQ,KAAK;;;;;;;;;;;;AAa7D,SAAgB,sBACd,SACgB;AAEhB,KAAI,CAAC,QAAQ,SACX,OAAM,IAAI,MAAM,oDAAoD;AAItE,KAAI,CAAC,QAAQ,KACX,OAAM,IAAI,MAAM,sDAAoD;AAEtE,QAAO"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
//#region src/plugins/NextFederationPlugin/validate-options.ts
|
|
2
|
+
/**
|
|
3
|
+
* Validates the compiler options.
|
|
4
|
+
*
|
|
5
|
+
* @param {Compiler} compiler - The Webpack compiler instance.
|
|
6
|
+
* @returns {boolean} - Returns true if the compiler options are valid, false otherwise.
|
|
7
|
+
*
|
|
8
|
+
* @throws Will throw an error if the name option is not defined in the options.
|
|
9
|
+
* @remarks
|
|
10
|
+
* This function validates the options passed to the Webpack compiler. It checks if the name option is set to either "server" or
|
|
11
|
+
* "client", as Module Federation is only applied to the main server and client builds in Next.js.
|
|
12
|
+
*/
|
|
13
|
+
function validateCompilerOptions(compiler) {
|
|
14
|
+
if (!compiler.options.name) throw new Error("name is not defined in Compiler options");
|
|
15
|
+
return ["server", "client"].includes(compiler.options.name);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Validates the NextFederationPlugin options.
|
|
19
|
+
*
|
|
20
|
+
* @param {moduleFederationPlugin.ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.
|
|
21
|
+
*
|
|
22
|
+
* @throws Will throw an error if the filename option is not defined in the options or if the name option is not specified.
|
|
23
|
+
* @remarks
|
|
24
|
+
* This function validates the options passed to NextFederationPlugin. It ensures that the filename and name options are defined,
|
|
25
|
+
* as they are required for using Module Federation.
|
|
26
|
+
*/
|
|
27
|
+
function validatePluginOptions(options) {
|
|
28
|
+
if (!options.filename) throw new Error("filename is not defined in NextFederation options");
|
|
29
|
+
if (!options.name) throw new Error("Module federation \"name\" option must be specified");
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
//#endregion
|
|
34
|
+
export { validateCompilerOptions, validatePluginOptions };
|
|
35
|
+
//# sourceMappingURL=validate-options.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-options.mjs","names":[],"sources":["../../../../src/plugins/NextFederationPlugin/validate-options.ts"],"sourcesContent":["import type { Compiler } from 'webpack';\nimport type { moduleFederationPlugin } from '@module-federation/sdk';\n\n/**\n * Validates the compiler options.\n *\n * @param {Compiler} compiler - The Webpack compiler instance.\n * @returns {boolean} - Returns true if the compiler options are valid, false otherwise.\n *\n * @throws Will throw an error if the name option is not defined in the options.\n * @remarks\n * This function validates the options passed to the Webpack compiler. It checks if the name option is set to either \"server\" or\n * \"client\", as Module Federation is only applied to the main server and client builds in Next.js.\n */\nexport function validateCompilerOptions(compiler: Compiler): boolean {\n // Throw an error if the name option is not defined in the options\n if (!compiler.options.name) {\n throw new Error('name is not defined in Compiler options');\n }\n\n // Only apply Module Federation to the main server and client builds in Next.js\n return ['server', 'client'].includes(compiler.options.name);\n}\n\n/**\n * Validates the NextFederationPlugin options.\n *\n * @param {moduleFederationPlugin.ModuleFederationPluginOptions} options - The ModuleFederationPluginOptions instance.\n *\n * @throws Will throw an error if the filename option is not defined in the options or if the name option is not specified.\n * @remarks\n * This function validates the options passed to NextFederationPlugin. It ensures that the filename and name options are defined,\n * as they are required for using Module Federation.\n */\nexport function validatePluginOptions(\n options: moduleFederationPlugin.ModuleFederationPluginOptions,\n): boolean | void {\n // Throw an error if the filename option is not defined in the options\n if (!options.filename) {\n throw new Error('filename is not defined in NextFederation options');\n }\n\n // A requirement for using Module Federation is that a name must be specified\n if (!options.name) {\n throw new Error('Module federation \"name\" option must be specified');\n }\n return true;\n}\n"],"mappings":";;;;;;;;;;;;AAcA,SAAgB,wBAAwB,UAA6B;AAEnE,KAAI,CAAC,SAAS,QAAQ,KACpB,OAAM,IAAI,MAAM,0CAA0C;AAI5D,QAAO,CAAC,UAAU,SAAS,CAAC,SAAS,SAAS,QAAQ,KAAK;;;;;;;;;;;;AAa7D,SAAgB,sBACd,SACgB;AAEhB,KAAI,CAAC,QAAQ,SACX,OAAM,IAAI,MAAM,oDAAoD;AAItE,KAAI,CAAC,QAAQ,KACX,OAAM,IAAI,MAAM,sDAAoD;AAEtE,QAAO"}
|