@module-federation/modern-js 0.0.0-next-20240519120858 → 0.0.0-next-20240520072517
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/cjs/cli/index.js +38 -0
- package/dist/cjs/cli/mfRuntimePlugins/inject-node-fetch.js +44 -0
- package/dist/cjs/cli/mfRuntimePlugins/shared-strategy.js +1 -1
- package/dist/cjs/cli/utils.js +45 -17
- package/dist/cjs/ssr-runtime/index.js +22 -0
- package/dist/cjs/ssr-runtime/plugin.js +59 -0
- package/dist/esm/cli/index.js +40 -0
- package/dist/esm/cli/mfRuntimePlugins/inject-node-fetch.js +16 -0
- package/dist/esm/cli/mfRuntimePlugins/shared-strategy.js +1 -1
- package/dist/esm/cli/utils.js +42 -17
- package/dist/esm/ssr-runtime/index.js +1 -0
- package/dist/esm/ssr-runtime/plugin.js +58 -0
- package/dist/esm-node/cli/index.js +38 -0
- package/dist/esm-node/cli/mfRuntimePlugins/inject-node-fetch.js +14 -0
- package/dist/esm-node/cli/mfRuntimePlugins/shared-strategy.js +1 -1
- package/dist/esm-node/cli/utils.js +45 -17
- package/dist/esm-node/ssr-runtime/index.js +1 -0
- package/dist/esm-node/ssr-runtime/plugin.js +25 -0
- package/dist/types/cli/mfRuntimePlugins/inject-node-fetch.d.ts +3 -0
- package/dist/types/cli/utils.d.ts +34 -2
- package/dist/types/ssr-runtime/index.d.ts +1 -0
- package/dist/types/ssr-runtime/plugin.d.ts +2 -0
- package/package.json +13 -5
- package/dist/cjs/runtime/ssr-runtime.js +0 -1
- package/dist/esm/runtime/ssr-runtime.js +0 -0
- package/dist/esm-node/runtime/ssr-runtime.js +0 -0
- package/dist/types/runtime/ssr-runtime.d.ts +0 -0
package/dist/cjs/cli/index.js
CHANGED
|
@@ -42,6 +42,8 @@ var import_utils2 = require("./utils");
|
|
|
42
42
|
var import_manifest = require("./manifest");
|
|
43
43
|
var import_constant = require("../constant");
|
|
44
44
|
var import_enhanced2 = require("@module-federation/enhanced");
|
|
45
|
+
const SSR_PLUGIN_IDENTIFIER = "mfPluginSSR";
|
|
46
|
+
const isDev = process.env.NODE_ENV === "development";
|
|
45
47
|
const moduleFederationPlugin = (userConfig = {}) => ({
|
|
46
48
|
name: "@modern-js/plugin-module-federation",
|
|
47
49
|
setup: async ({ useConfigContext, useAppContext }) => {
|
|
@@ -144,6 +146,42 @@ const moduleFederationPlugin = (userConfig = {}) => ({
|
|
|
144
146
|
}
|
|
145
147
|
};
|
|
146
148
|
},
|
|
149
|
+
modifyEntryImports({ entrypoint, imports }) {
|
|
150
|
+
if (!enableSSR || !isDev) {
|
|
151
|
+
return {
|
|
152
|
+
entrypoint,
|
|
153
|
+
imports
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
imports.push({
|
|
157
|
+
value: "@module-federation/modern-js/ssr-runtime",
|
|
158
|
+
specifiers: [
|
|
159
|
+
{
|
|
160
|
+
imported: SSR_PLUGIN_IDENTIFIER
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
});
|
|
164
|
+
return {
|
|
165
|
+
entrypoint,
|
|
166
|
+
imports
|
|
167
|
+
};
|
|
168
|
+
},
|
|
169
|
+
modifyEntryRuntimePlugins({ entrypoint, plugins }) {
|
|
170
|
+
if (!enableSSR || !isDev) {
|
|
171
|
+
return {
|
|
172
|
+
entrypoint,
|
|
173
|
+
plugins
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
plugins.unshift({
|
|
177
|
+
name: SSR_PLUGIN_IDENTIFIER,
|
|
178
|
+
options: JSON.stringify({})
|
|
179
|
+
});
|
|
180
|
+
return {
|
|
181
|
+
entrypoint,
|
|
182
|
+
plugins
|
|
183
|
+
};
|
|
184
|
+
},
|
|
147
185
|
afterBuild: () => {
|
|
148
186
|
if (enableSSR) {
|
|
149
187
|
(0, import_manifest.updateStatsAndManifest)(nodePlugin, browserPlugin, outputDir);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var inject_node_fetch_exports = {};
|
|
30
|
+
__export(inject_node_fetch_exports, {
|
|
31
|
+
default: () => inject_node_fetch_default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(inject_node_fetch_exports);
|
|
34
|
+
var import_node_fetch = __toESM(require("node-fetch"));
|
|
35
|
+
const injectNodeFetchPlugin = () => ({
|
|
36
|
+
name: "inject-node-fetch-plugin",
|
|
37
|
+
beforeInit(args) {
|
|
38
|
+
if (!globalThis.fetch) {
|
|
39
|
+
globalThis.fetch = import_node_fetch.default;
|
|
40
|
+
}
|
|
41
|
+
return args;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
var inject_node_fetch_default = injectNodeFetchPlugin;
|
|
@@ -22,7 +22,7 @@ __export(shared_strategy_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(shared_strategy_exports);
|
|
24
24
|
const sharedStrategy = () => ({
|
|
25
|
-
name: "shared-strategy",
|
|
25
|
+
name: "shared-strategy-plugin",
|
|
26
26
|
beforeInit(args) {
|
|
27
27
|
const { shareInfo } = args;
|
|
28
28
|
if (shareInfo) {
|
package/dist/cjs/cli/utils.js
CHANGED
|
@@ -47,55 +47,74 @@ const getMFConfig = async (userConfig) => {
|
|
|
47
47
|
const mfConfig = (await Promise.resolve().then(() => __toESM(require(preBundlePath)))).default;
|
|
48
48
|
return mfConfig;
|
|
49
49
|
};
|
|
50
|
-
const patchMFConfig = (mfConfig) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
const patchMFConfig = (mfConfig, isServer) => {
|
|
51
|
+
const runtimePlugins = [
|
|
52
|
+
...mfConfig.runtimePlugins || []
|
|
53
|
+
];
|
|
54
|
+
const sharedStrategyRuntimePluginPath = import_path.default.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js");
|
|
55
|
+
if (!runtimePlugins.includes(sharedStrategyRuntimePluginPath)) {
|
|
56
|
+
runtimePlugins.push(sharedStrategyRuntimePluginPath);
|
|
57
|
+
}
|
|
58
|
+
if (isServer) {
|
|
59
|
+
const isDev = process.env.NODE_ENV === "development";
|
|
60
|
+
if (isDev) {
|
|
61
|
+
const nodeHmrPluginPath = require.resolve("@module-federation/node/record-dynamic-remote-entry-hash-plugin");
|
|
62
|
+
if (!runtimePlugins.includes(nodeHmrPluginPath)) {
|
|
63
|
+
runtimePlugins.push(nodeHmrPluginPath);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const injectNodeFetchRuntimePluginPath = import_path.default.resolve(__dirname, "./mfRuntimePlugins/inject-node-fetch.js");
|
|
67
|
+
if (!runtimePlugins.includes(injectNodeFetchRuntimePluginPath)) {
|
|
68
|
+
runtimePlugins.push(injectNodeFetchRuntimePluginPath);
|
|
69
|
+
}
|
|
55
70
|
}
|
|
56
71
|
if (typeof mfConfig.async === "undefined") {
|
|
57
72
|
mfConfig.async = true;
|
|
58
73
|
}
|
|
74
|
+
return {
|
|
75
|
+
...mfConfig,
|
|
76
|
+
runtimePlugins
|
|
77
|
+
};
|
|
59
78
|
};
|
|
60
79
|
function getTargetEnvConfig(mfConfig, isServer) {
|
|
61
|
-
var
|
|
62
|
-
patchMFConfig(mfConfig);
|
|
80
|
+
var _patchedMFConfig_library;
|
|
81
|
+
const patchedMFConfig = patchMFConfig(mfConfig, isServer);
|
|
63
82
|
if (isServer) {
|
|
64
83
|
return {
|
|
65
84
|
library: {
|
|
66
85
|
type: "commonjs-module",
|
|
67
86
|
name: mfConfig.name
|
|
68
87
|
},
|
|
69
|
-
...
|
|
88
|
+
...patchedMFConfig
|
|
70
89
|
};
|
|
71
90
|
}
|
|
72
|
-
if (((
|
|
91
|
+
if (((_patchedMFConfig_library = patchedMFConfig.library) === null || _patchedMFConfig_library === void 0 ? void 0 : _patchedMFConfig_library.type) === "commonjs-module") {
|
|
73
92
|
return {
|
|
74
|
-
...
|
|
93
|
+
...patchedMFConfig,
|
|
75
94
|
library: {
|
|
76
95
|
...mfConfig.library,
|
|
77
96
|
type: "global"
|
|
78
97
|
}
|
|
79
98
|
};
|
|
80
99
|
}
|
|
81
|
-
return
|
|
100
|
+
return patchedMFConfig;
|
|
82
101
|
}
|
|
83
102
|
function patchWebpackConfig(options) {
|
|
84
|
-
var _modernjsConfig_server,
|
|
103
|
+
var _modernjsConfig_server, _bundlerConfig_optimization, _bundlerConfig_optimization1, _bundlerConfig_output;
|
|
85
104
|
const { bundlerConfig, modernjsConfig, isServer, mfConfig } = options;
|
|
86
|
-
const
|
|
105
|
+
const enableSSR = Boolean((_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
|
|
87
106
|
(_bundlerConfig_optimization = bundlerConfig.optimization) === null || _bundlerConfig_optimization === void 0 ? true : delete _bundlerConfig_optimization.runtimeChunk;
|
|
88
|
-
if (!isServer &&
|
|
107
|
+
if (!isServer && enableSSR && typeof ((_bundlerConfig_optimization1 = bundlerConfig.optimization) === null || _bundlerConfig_optimization1 === void 0 ? void 0 : _bundlerConfig_optimization1.splitChunks) === "object" && bundlerConfig.optimization.splitChunks.cacheGroups) {
|
|
89
108
|
bundlerConfig.optimization.splitChunks.chunks = "async";
|
|
90
109
|
console.warn('[Modern.js Module Federation] splitChunks.chunks = async is not allowed with stream SSR mode, it will auto changed to "async"');
|
|
91
110
|
}
|
|
92
111
|
if (((_bundlerConfig_output = bundlerConfig.output) === null || _bundlerConfig_output === void 0 ? void 0 : _bundlerConfig_output.publicPath) === "auto") {
|
|
93
|
-
var _modernjsConfig_dev,
|
|
94
|
-
const port = ((_modernjsConfig_dev = modernjsConfig.dev) === null || _modernjsConfig_dev === void 0 ? void 0 : _modernjsConfig_dev.port) || ((
|
|
112
|
+
var _modernjsConfig_dev, _modernjsConfig_server1;
|
|
113
|
+
const port = ((_modernjsConfig_dev = modernjsConfig.dev) === null || _modernjsConfig_dev === void 0 ? void 0 : _modernjsConfig_dev.port) || ((_modernjsConfig_server1 = modernjsConfig.server) === null || _modernjsConfig_server1 === void 0 ? void 0 : _modernjsConfig_server1.port) || 8080;
|
|
95
114
|
const publicPath = `http://localhost:${port}/`;
|
|
96
115
|
bundlerConfig.output.publicPath = publicPath;
|
|
97
116
|
}
|
|
98
|
-
if (isServer &&
|
|
117
|
+
if (isServer && enableSSR) {
|
|
99
118
|
const { output } = bundlerConfig;
|
|
100
119
|
const uniqueName = mfConfig.name || (output === null || output === void 0 ? void 0 : output.uniqueName);
|
|
101
120
|
const chunkFileName = output === null || output === void 0 ? void 0 : output.chunkFilename;
|
|
@@ -104,6 +123,15 @@ function patchWebpackConfig(options) {
|
|
|
104
123
|
output.chunkFilename = chunkFileName.replace(".js", suffix);
|
|
105
124
|
}
|
|
106
125
|
}
|
|
126
|
+
const isDev = process.env.NODE_ENV === "development";
|
|
127
|
+
if (isDev && enableSSR && !isServer) {
|
|
128
|
+
bundlerConfig.resolve.fallback = {
|
|
129
|
+
...bundlerConfig.resolve.fallback,
|
|
130
|
+
crypto: false,
|
|
131
|
+
stream: false,
|
|
132
|
+
vm: false
|
|
133
|
+
};
|
|
134
|
+
}
|
|
107
135
|
}
|
|
108
136
|
// Annotate the CommonJS export names for ESM import in node:
|
|
109
137
|
0 && (module.exports = {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var ssr_runtime_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(ssr_runtime_exports);
|
|
18
|
+
__reExport(ssr_runtime_exports, require("./plugin"), module.exports);
|
|
19
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
+
0 && (module.exports = {
|
|
21
|
+
...require("./plugin")
|
|
22
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var plugin_exports = {};
|
|
30
|
+
__export(plugin_exports, {
|
|
31
|
+
mfPluginSSR: () => mfPluginSSR
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(plugin_exports);
|
|
34
|
+
const mfPluginSSR = () => ({
|
|
35
|
+
name: "@module-federation/modern-js",
|
|
36
|
+
// eslint-disable-next-line max-lines-per-function
|
|
37
|
+
setup: () => ({
|
|
38
|
+
// eslint-disable-next-line max-lines-per-function
|
|
39
|
+
async init({ context }, next) {
|
|
40
|
+
if (typeof window !== "undefined") {
|
|
41
|
+
return next({
|
|
42
|
+
context
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const nodeUtils = await Promise.resolve().then(() => __toESM(require("@module-federation/node/utils")));
|
|
46
|
+
const shouldUpdate = await nodeUtils.revalidate();
|
|
47
|
+
if (shouldUpdate) {
|
|
48
|
+
console.log("should HMR", shouldUpdate);
|
|
49
|
+
}
|
|
50
|
+
return next({
|
|
51
|
+
context
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
mfPluginSSR
|
|
59
|
+
});
|
package/dist/esm/cli/index.js
CHANGED
|
@@ -8,6 +8,8 @@ import { StreamingTargetPlugin } from "@module-federation/node";
|
|
|
8
8
|
import { getMFConfig, getTargetEnvConfig, patchWebpackConfig } from "./utils";
|
|
9
9
|
import { updateStatsAndManifest } from "./manifest";
|
|
10
10
|
import { MODERN_JS_SERVER_DIR } from "../constant";
|
|
11
|
+
var SSR_PLUGIN_IDENTIFIER = "mfPluginSSR";
|
|
12
|
+
var isDev = process.env.NODE_ENV === "development";
|
|
11
13
|
var moduleFederationPlugin = function() {
|
|
12
14
|
var userConfig = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
13
15
|
return {
|
|
@@ -127,6 +129,44 @@ var moduleFederationPlugin = function() {
|
|
|
127
129
|
}
|
|
128
130
|
};
|
|
129
131
|
},
|
|
132
|
+
modifyEntryImports: function modifyEntryImports(param2) {
|
|
133
|
+
var entrypoint = param2.entrypoint, imports = param2.imports;
|
|
134
|
+
if (!enableSSR || !isDev) {
|
|
135
|
+
return {
|
|
136
|
+
entrypoint,
|
|
137
|
+
imports
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
imports.push({
|
|
141
|
+
value: "@module-federation/modern-js/ssr-runtime",
|
|
142
|
+
specifiers: [
|
|
143
|
+
{
|
|
144
|
+
imported: SSR_PLUGIN_IDENTIFIER
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
});
|
|
148
|
+
return {
|
|
149
|
+
entrypoint,
|
|
150
|
+
imports
|
|
151
|
+
};
|
|
152
|
+
},
|
|
153
|
+
modifyEntryRuntimePlugins: function modifyEntryRuntimePlugins(param2) {
|
|
154
|
+
var entrypoint = param2.entrypoint, plugins = param2.plugins;
|
|
155
|
+
if (!enableSSR || !isDev) {
|
|
156
|
+
return {
|
|
157
|
+
entrypoint,
|
|
158
|
+
plugins
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
plugins.unshift({
|
|
162
|
+
name: SSR_PLUGIN_IDENTIFIER,
|
|
163
|
+
options: JSON.stringify({})
|
|
164
|
+
});
|
|
165
|
+
return {
|
|
166
|
+
entrypoint,
|
|
167
|
+
plugins
|
|
168
|
+
};
|
|
169
|
+
},
|
|
130
170
|
afterBuild: function() {
|
|
131
171
|
if (enableSSR) {
|
|
132
172
|
updateStatsAndManifest(nodePlugin, browserPlugin, outputDir);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import nodeFetch from "node-fetch";
|
|
2
|
+
var injectNodeFetchPlugin = function() {
|
|
3
|
+
return {
|
|
4
|
+
name: "inject-node-fetch-plugin",
|
|
5
|
+
beforeInit: function beforeInit(args) {
|
|
6
|
+
if (!globalThis.fetch) {
|
|
7
|
+
globalThis.fetch = nodeFetch;
|
|
8
|
+
}
|
|
9
|
+
return args;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
var inject_node_fetch_default = injectNodeFetchPlugin;
|
|
14
|
+
export {
|
|
15
|
+
inject_node_fetch_default as default
|
|
16
|
+
};
|
package/dist/esm/cli/utils.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
3
3
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
4
|
+
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
4
5
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
5
6
|
import path from "path";
|
|
6
7
|
import { bundle } from "@modern-js/node-bundle-require";
|
|
@@ -42,52 +43,68 @@ var getMFConfig = function() {
|
|
|
42
43
|
return _ref.apply(this, arguments);
|
|
43
44
|
};
|
|
44
45
|
}();
|
|
45
|
-
var patchMFConfig = function(mfConfig) {
|
|
46
|
-
|
|
47
|
-
var
|
|
48
|
-
if (!
|
|
49
|
-
|
|
46
|
+
var patchMFConfig = function(mfConfig, isServer) {
|
|
47
|
+
var runtimePlugins = _to_consumable_array(mfConfig.runtimePlugins || []);
|
|
48
|
+
var sharedStrategyRuntimePluginPath = path.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js");
|
|
49
|
+
if (!runtimePlugins.includes(sharedStrategyRuntimePluginPath)) {
|
|
50
|
+
runtimePlugins.push(sharedStrategyRuntimePluginPath);
|
|
51
|
+
}
|
|
52
|
+
if (isServer) {
|
|
53
|
+
var isDev = process.env.NODE_ENV === "development";
|
|
54
|
+
if (isDev) {
|
|
55
|
+
var nodeHmrPluginPath = require.resolve("@module-federation/node/record-dynamic-remote-entry-hash-plugin");
|
|
56
|
+
if (!runtimePlugins.includes(nodeHmrPluginPath)) {
|
|
57
|
+
runtimePlugins.push(nodeHmrPluginPath);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
var injectNodeFetchRuntimePluginPath = path.resolve(__dirname, "./mfRuntimePlugins/inject-node-fetch.js");
|
|
61
|
+
if (!runtimePlugins.includes(injectNodeFetchRuntimePluginPath)) {
|
|
62
|
+
runtimePlugins.push(injectNodeFetchRuntimePluginPath);
|
|
63
|
+
}
|
|
50
64
|
}
|
|
51
65
|
if (typeof mfConfig.async === "undefined") {
|
|
52
66
|
mfConfig.async = true;
|
|
53
67
|
}
|
|
68
|
+
return _object_spread_props(_object_spread({}, mfConfig), {
|
|
69
|
+
runtimePlugins
|
|
70
|
+
});
|
|
54
71
|
};
|
|
55
72
|
function getTargetEnvConfig(mfConfig, isServer) {
|
|
56
|
-
var
|
|
57
|
-
patchMFConfig(mfConfig);
|
|
73
|
+
var _patchedMFConfig_library;
|
|
74
|
+
var patchedMFConfig = patchMFConfig(mfConfig, isServer);
|
|
58
75
|
if (isServer) {
|
|
59
76
|
return _object_spread({
|
|
60
77
|
library: {
|
|
61
78
|
type: "commonjs-module",
|
|
62
79
|
name: mfConfig.name
|
|
63
80
|
}
|
|
64
|
-
},
|
|
81
|
+
}, patchedMFConfig);
|
|
65
82
|
}
|
|
66
|
-
if (((
|
|
67
|
-
return _object_spread_props(_object_spread({},
|
|
83
|
+
if (((_patchedMFConfig_library = patchedMFConfig.library) === null || _patchedMFConfig_library === void 0 ? void 0 : _patchedMFConfig_library.type) === "commonjs-module") {
|
|
84
|
+
return _object_spread_props(_object_spread({}, patchedMFConfig), {
|
|
68
85
|
library: _object_spread_props(_object_spread({}, mfConfig.library), {
|
|
69
86
|
type: "global"
|
|
70
87
|
})
|
|
71
88
|
});
|
|
72
89
|
}
|
|
73
|
-
return
|
|
90
|
+
return patchedMFConfig;
|
|
74
91
|
}
|
|
75
92
|
function patchWebpackConfig(options) {
|
|
76
|
-
var _modernjsConfig_server,
|
|
93
|
+
var _modernjsConfig_server, _bundlerConfig_optimization, _bundlerConfig_optimization1, _bundlerConfig_output;
|
|
77
94
|
var bundlerConfig = options.bundlerConfig, modernjsConfig = options.modernjsConfig, isServer = options.isServer, mfConfig = options.mfConfig;
|
|
78
|
-
var
|
|
95
|
+
var enableSSR = Boolean((_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
|
|
79
96
|
(_bundlerConfig_optimization = bundlerConfig.optimization) === null || _bundlerConfig_optimization === void 0 ? true : delete _bundlerConfig_optimization.runtimeChunk;
|
|
80
|
-
if (!isServer &&
|
|
97
|
+
if (!isServer && enableSSR && typeof ((_bundlerConfig_optimization1 = bundlerConfig.optimization) === null || _bundlerConfig_optimization1 === void 0 ? void 0 : _bundlerConfig_optimization1.splitChunks) === "object" && bundlerConfig.optimization.splitChunks.cacheGroups) {
|
|
81
98
|
bundlerConfig.optimization.splitChunks.chunks = "async";
|
|
82
99
|
console.warn('[Modern.js Module Federation] splitChunks.chunks = async is not allowed with stream SSR mode, it will auto changed to "async"');
|
|
83
100
|
}
|
|
84
101
|
if (((_bundlerConfig_output = bundlerConfig.output) === null || _bundlerConfig_output === void 0 ? void 0 : _bundlerConfig_output.publicPath) === "auto") {
|
|
85
|
-
var _modernjsConfig_dev,
|
|
86
|
-
var port = ((_modernjsConfig_dev = modernjsConfig.dev) === null || _modernjsConfig_dev === void 0 ? void 0 : _modernjsConfig_dev.port) || ((
|
|
102
|
+
var _modernjsConfig_dev, _modernjsConfig_server1;
|
|
103
|
+
var port = ((_modernjsConfig_dev = modernjsConfig.dev) === null || _modernjsConfig_dev === void 0 ? void 0 : _modernjsConfig_dev.port) || ((_modernjsConfig_server1 = modernjsConfig.server) === null || _modernjsConfig_server1 === void 0 ? void 0 : _modernjsConfig_server1.port) || 8080;
|
|
87
104
|
var publicPath = "http://localhost:".concat(port, "/");
|
|
88
105
|
bundlerConfig.output.publicPath = publicPath;
|
|
89
106
|
}
|
|
90
|
-
if (isServer &&
|
|
107
|
+
if (isServer && enableSSR) {
|
|
91
108
|
var output = bundlerConfig.output;
|
|
92
109
|
var uniqueName = mfConfig.name || (output === null || output === void 0 ? void 0 : output.uniqueName);
|
|
93
110
|
var chunkFileName = output === null || output === void 0 ? void 0 : output.chunkFilename;
|
|
@@ -96,6 +113,14 @@ function patchWebpackConfig(options) {
|
|
|
96
113
|
output.chunkFilename = chunkFileName.replace(".js", suffix);
|
|
97
114
|
}
|
|
98
115
|
}
|
|
116
|
+
var isDev = process.env.NODE_ENV === "development";
|
|
117
|
+
if (isDev && enableSSR && !isServer) {
|
|
118
|
+
bundlerConfig.resolve.fallback = _object_spread_props(_object_spread({}, bundlerConfig.resolve.fallback), {
|
|
119
|
+
crypto: false,
|
|
120
|
+
stream: false,
|
|
121
|
+
vm: false
|
|
122
|
+
});
|
|
123
|
+
}
|
|
99
124
|
}
|
|
100
125
|
export {
|
|
101
126
|
getMFConfig,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./plugin";
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
+
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
|
+
var mfPluginSSR = function() {
|
|
4
|
+
return {
|
|
5
|
+
name: "@module-federation/modern-js",
|
|
6
|
+
// eslint-disable-next-line max-lines-per-function
|
|
7
|
+
setup: function() {
|
|
8
|
+
return {
|
|
9
|
+
init: (
|
|
10
|
+
// eslint-disable-next-line max-lines-per-function
|
|
11
|
+
function init(param, next) {
|
|
12
|
+
var context = param.context;
|
|
13
|
+
return _async_to_generator(function() {
|
|
14
|
+
var nodeUtils, shouldUpdate;
|
|
15
|
+
return _ts_generator(this, function(_state) {
|
|
16
|
+
switch (_state.label) {
|
|
17
|
+
case 0:
|
|
18
|
+
if (typeof window !== "undefined") {
|
|
19
|
+
return [
|
|
20
|
+
2,
|
|
21
|
+
next({
|
|
22
|
+
context
|
|
23
|
+
})
|
|
24
|
+
];
|
|
25
|
+
}
|
|
26
|
+
return [
|
|
27
|
+
4,
|
|
28
|
+
import("@module-federation/node/utils")
|
|
29
|
+
];
|
|
30
|
+
case 1:
|
|
31
|
+
nodeUtils = _state.sent();
|
|
32
|
+
return [
|
|
33
|
+
4,
|
|
34
|
+
nodeUtils.revalidate()
|
|
35
|
+
];
|
|
36
|
+
case 2:
|
|
37
|
+
shouldUpdate = _state.sent();
|
|
38
|
+
if (shouldUpdate) {
|
|
39
|
+
console.log("should HMR", shouldUpdate);
|
|
40
|
+
}
|
|
41
|
+
return [
|
|
42
|
+
2,
|
|
43
|
+
next({
|
|
44
|
+
context
|
|
45
|
+
})
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
})();
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export {
|
|
57
|
+
mfPluginSSR
|
|
58
|
+
};
|
|
@@ -6,6 +6,8 @@ import { StreamingTargetPlugin } from "@module-federation/node";
|
|
|
6
6
|
import { getMFConfig, getTargetEnvConfig, patchWebpackConfig } from "./utils";
|
|
7
7
|
import { updateStatsAndManifest } from "./manifest";
|
|
8
8
|
import { MODERN_JS_SERVER_DIR } from "../constant";
|
|
9
|
+
const SSR_PLUGIN_IDENTIFIER = "mfPluginSSR";
|
|
10
|
+
const isDev = process.env.NODE_ENV === "development";
|
|
9
11
|
const moduleFederationPlugin = (userConfig = {}) => ({
|
|
10
12
|
name: "@modern-js/plugin-module-federation",
|
|
11
13
|
setup: async ({ useConfigContext, useAppContext }) => {
|
|
@@ -108,6 +110,42 @@ const moduleFederationPlugin = (userConfig = {}) => ({
|
|
|
108
110
|
}
|
|
109
111
|
};
|
|
110
112
|
},
|
|
113
|
+
modifyEntryImports({ entrypoint, imports }) {
|
|
114
|
+
if (!enableSSR || !isDev) {
|
|
115
|
+
return {
|
|
116
|
+
entrypoint,
|
|
117
|
+
imports
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
imports.push({
|
|
121
|
+
value: "@module-federation/modern-js/ssr-runtime",
|
|
122
|
+
specifiers: [
|
|
123
|
+
{
|
|
124
|
+
imported: SSR_PLUGIN_IDENTIFIER
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
});
|
|
128
|
+
return {
|
|
129
|
+
entrypoint,
|
|
130
|
+
imports
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
modifyEntryRuntimePlugins({ entrypoint, plugins }) {
|
|
134
|
+
if (!enableSSR || !isDev) {
|
|
135
|
+
return {
|
|
136
|
+
entrypoint,
|
|
137
|
+
plugins
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
plugins.unshift({
|
|
141
|
+
name: SSR_PLUGIN_IDENTIFIER,
|
|
142
|
+
options: JSON.stringify({})
|
|
143
|
+
});
|
|
144
|
+
return {
|
|
145
|
+
entrypoint,
|
|
146
|
+
plugins
|
|
147
|
+
};
|
|
148
|
+
},
|
|
111
149
|
afterBuild: () => {
|
|
112
150
|
if (enableSSR) {
|
|
113
151
|
updateStatsAndManifest(nodePlugin, browserPlugin, outputDir);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import nodeFetch from "node-fetch";
|
|
2
|
+
const injectNodeFetchPlugin = () => ({
|
|
3
|
+
name: "inject-node-fetch-plugin",
|
|
4
|
+
beforeInit(args) {
|
|
5
|
+
if (!globalThis.fetch) {
|
|
6
|
+
globalThis.fetch = nodeFetch;
|
|
7
|
+
}
|
|
8
|
+
return args;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
var inject_node_fetch_default = injectNodeFetchPlugin;
|
|
12
|
+
export {
|
|
13
|
+
inject_node_fetch_default as default
|
|
14
|
+
};
|
|
@@ -11,55 +11,74 @@ const getMFConfig = async (userConfig) => {
|
|
|
11
11
|
const mfConfig = (await import(preBundlePath)).default;
|
|
12
12
|
return mfConfig;
|
|
13
13
|
};
|
|
14
|
-
const patchMFConfig = (mfConfig) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
const patchMFConfig = (mfConfig, isServer) => {
|
|
15
|
+
const runtimePlugins = [
|
|
16
|
+
...mfConfig.runtimePlugins || []
|
|
17
|
+
];
|
|
18
|
+
const sharedStrategyRuntimePluginPath = path.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js");
|
|
19
|
+
if (!runtimePlugins.includes(sharedStrategyRuntimePluginPath)) {
|
|
20
|
+
runtimePlugins.push(sharedStrategyRuntimePluginPath);
|
|
21
|
+
}
|
|
22
|
+
if (isServer) {
|
|
23
|
+
const isDev = process.env.NODE_ENV === "development";
|
|
24
|
+
if (isDev) {
|
|
25
|
+
const nodeHmrPluginPath = require.resolve("@module-federation/node/record-dynamic-remote-entry-hash-plugin");
|
|
26
|
+
if (!runtimePlugins.includes(nodeHmrPluginPath)) {
|
|
27
|
+
runtimePlugins.push(nodeHmrPluginPath);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const injectNodeFetchRuntimePluginPath = path.resolve(__dirname, "./mfRuntimePlugins/inject-node-fetch.js");
|
|
31
|
+
if (!runtimePlugins.includes(injectNodeFetchRuntimePluginPath)) {
|
|
32
|
+
runtimePlugins.push(injectNodeFetchRuntimePluginPath);
|
|
33
|
+
}
|
|
19
34
|
}
|
|
20
35
|
if (typeof mfConfig.async === "undefined") {
|
|
21
36
|
mfConfig.async = true;
|
|
22
37
|
}
|
|
38
|
+
return {
|
|
39
|
+
...mfConfig,
|
|
40
|
+
runtimePlugins
|
|
41
|
+
};
|
|
23
42
|
};
|
|
24
43
|
function getTargetEnvConfig(mfConfig, isServer) {
|
|
25
|
-
var
|
|
26
|
-
patchMFConfig(mfConfig);
|
|
44
|
+
var _patchedMFConfig_library;
|
|
45
|
+
const patchedMFConfig = patchMFConfig(mfConfig, isServer);
|
|
27
46
|
if (isServer) {
|
|
28
47
|
return {
|
|
29
48
|
library: {
|
|
30
49
|
type: "commonjs-module",
|
|
31
50
|
name: mfConfig.name
|
|
32
51
|
},
|
|
33
|
-
...
|
|
52
|
+
...patchedMFConfig
|
|
34
53
|
};
|
|
35
54
|
}
|
|
36
|
-
if (((
|
|
55
|
+
if (((_patchedMFConfig_library = patchedMFConfig.library) === null || _patchedMFConfig_library === void 0 ? void 0 : _patchedMFConfig_library.type) === "commonjs-module") {
|
|
37
56
|
return {
|
|
38
|
-
...
|
|
57
|
+
...patchedMFConfig,
|
|
39
58
|
library: {
|
|
40
59
|
...mfConfig.library,
|
|
41
60
|
type: "global"
|
|
42
61
|
}
|
|
43
62
|
};
|
|
44
63
|
}
|
|
45
|
-
return
|
|
64
|
+
return patchedMFConfig;
|
|
46
65
|
}
|
|
47
66
|
function patchWebpackConfig(options) {
|
|
48
|
-
var _modernjsConfig_server,
|
|
67
|
+
var _modernjsConfig_server, _bundlerConfig_optimization, _bundlerConfig_optimization1, _bundlerConfig_output;
|
|
49
68
|
const { bundlerConfig, modernjsConfig, isServer, mfConfig } = options;
|
|
50
|
-
const
|
|
69
|
+
const enableSSR = Boolean((_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
|
|
51
70
|
(_bundlerConfig_optimization = bundlerConfig.optimization) === null || _bundlerConfig_optimization === void 0 ? true : delete _bundlerConfig_optimization.runtimeChunk;
|
|
52
|
-
if (!isServer &&
|
|
71
|
+
if (!isServer && enableSSR && typeof ((_bundlerConfig_optimization1 = bundlerConfig.optimization) === null || _bundlerConfig_optimization1 === void 0 ? void 0 : _bundlerConfig_optimization1.splitChunks) === "object" && bundlerConfig.optimization.splitChunks.cacheGroups) {
|
|
53
72
|
bundlerConfig.optimization.splitChunks.chunks = "async";
|
|
54
73
|
console.warn('[Modern.js Module Federation] splitChunks.chunks = async is not allowed with stream SSR mode, it will auto changed to "async"');
|
|
55
74
|
}
|
|
56
75
|
if (((_bundlerConfig_output = bundlerConfig.output) === null || _bundlerConfig_output === void 0 ? void 0 : _bundlerConfig_output.publicPath) === "auto") {
|
|
57
|
-
var _modernjsConfig_dev,
|
|
58
|
-
const port = ((_modernjsConfig_dev = modernjsConfig.dev) === null || _modernjsConfig_dev === void 0 ? void 0 : _modernjsConfig_dev.port) || ((
|
|
76
|
+
var _modernjsConfig_dev, _modernjsConfig_server1;
|
|
77
|
+
const port = ((_modernjsConfig_dev = modernjsConfig.dev) === null || _modernjsConfig_dev === void 0 ? void 0 : _modernjsConfig_dev.port) || ((_modernjsConfig_server1 = modernjsConfig.server) === null || _modernjsConfig_server1 === void 0 ? void 0 : _modernjsConfig_server1.port) || 8080;
|
|
59
78
|
const publicPath = `http://localhost:${port}/`;
|
|
60
79
|
bundlerConfig.output.publicPath = publicPath;
|
|
61
80
|
}
|
|
62
|
-
if (isServer &&
|
|
81
|
+
if (isServer && enableSSR) {
|
|
63
82
|
const { output } = bundlerConfig;
|
|
64
83
|
const uniqueName = mfConfig.name || (output === null || output === void 0 ? void 0 : output.uniqueName);
|
|
65
84
|
const chunkFileName = output === null || output === void 0 ? void 0 : output.chunkFilename;
|
|
@@ -68,6 +87,15 @@ function patchWebpackConfig(options) {
|
|
|
68
87
|
output.chunkFilename = chunkFileName.replace(".js", suffix);
|
|
69
88
|
}
|
|
70
89
|
}
|
|
90
|
+
const isDev = process.env.NODE_ENV === "development";
|
|
91
|
+
if (isDev && enableSSR && !isServer) {
|
|
92
|
+
bundlerConfig.resolve.fallback = {
|
|
93
|
+
...bundlerConfig.resolve.fallback,
|
|
94
|
+
crypto: false,
|
|
95
|
+
stream: false,
|
|
96
|
+
vm: false
|
|
97
|
+
};
|
|
98
|
+
}
|
|
71
99
|
}
|
|
72
100
|
export {
|
|
73
101
|
getMFConfig,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./plugin";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const mfPluginSSR = () => ({
|
|
2
|
+
name: "@module-federation/modern-js",
|
|
3
|
+
// eslint-disable-next-line max-lines-per-function
|
|
4
|
+
setup: () => ({
|
|
5
|
+
// eslint-disable-next-line max-lines-per-function
|
|
6
|
+
async init({ context }, next) {
|
|
7
|
+
if (typeof window !== "undefined") {
|
|
8
|
+
return next({
|
|
9
|
+
context
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
const nodeUtils = await import("@module-federation/node/utils");
|
|
13
|
+
const shouldUpdate = await nodeUtils.revalidate();
|
|
14
|
+
if (shouldUpdate) {
|
|
15
|
+
console.log("should HMR", shouldUpdate);
|
|
16
|
+
}
|
|
17
|
+
return next({
|
|
18
|
+
context
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
export {
|
|
24
|
+
mfPluginSSR
|
|
25
|
+
};
|
|
@@ -3,8 +3,40 @@ import { moduleFederationPlugin } from '@module-federation/sdk';
|
|
|
3
3
|
import { PluginOptions } from '../types';
|
|
4
4
|
export type ConfigType<T> = T extends 'webpack' ? webpack.Configuration : T extends 'rspack' ? Rspack.Configuration : never;
|
|
5
5
|
export declare const getMFConfig: (userConfig: PluginOptions) => Promise<moduleFederationPlugin.ModuleFederationPluginOptions>;
|
|
6
|
-
export declare const patchMFConfig: (mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions) =>
|
|
7
|
-
|
|
6
|
+
export declare const patchMFConfig: (mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions, isServer: boolean) => {
|
|
7
|
+
runtimePlugins: string[];
|
|
8
|
+
exposes?: moduleFederationPlugin.Exposes | undefined;
|
|
9
|
+
filename?: string | undefined;
|
|
10
|
+
library?: moduleFederationPlugin.LibraryOptions | undefined;
|
|
11
|
+
name?: string | undefined;
|
|
12
|
+
remoteType?: moduleFederationPlugin.ExternalsType | undefined;
|
|
13
|
+
remotes?: moduleFederationPlugin.Remotes | undefined;
|
|
14
|
+
runtime?: moduleFederationPlugin.EntryRuntime | undefined;
|
|
15
|
+
shareScope?: string | undefined;
|
|
16
|
+
shared?: moduleFederationPlugin.Shared | undefined;
|
|
17
|
+
implementation?: string | undefined;
|
|
18
|
+
manifest?: boolean | moduleFederationPlugin.PluginManifestOptions | undefined;
|
|
19
|
+
dev?: boolean | moduleFederationPlugin.PluginDevOptions | undefined;
|
|
20
|
+
dts?: boolean | moduleFederationPlugin.PluginDtsOptions | undefined;
|
|
21
|
+
async?: boolean | moduleFederationPlugin.AsyncBoundaryOptions | undefined;
|
|
22
|
+
};
|
|
23
|
+
export declare function getTargetEnvConfig(mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions, isServer: boolean): {
|
|
24
|
+
runtimePlugins: string[];
|
|
25
|
+
exposes?: moduleFederationPlugin.Exposes | undefined;
|
|
26
|
+
filename?: string | undefined;
|
|
27
|
+
library?: moduleFederationPlugin.LibraryOptions | undefined;
|
|
28
|
+
name?: string | undefined;
|
|
29
|
+
remoteType?: moduleFederationPlugin.ExternalsType | undefined;
|
|
30
|
+
remotes?: moduleFederationPlugin.Remotes | undefined;
|
|
31
|
+
runtime?: moduleFederationPlugin.EntryRuntime | undefined;
|
|
32
|
+
shareScope?: string | undefined;
|
|
33
|
+
shared?: moduleFederationPlugin.Shared | undefined;
|
|
34
|
+
implementation?: string | undefined;
|
|
35
|
+
manifest?: boolean | moduleFederationPlugin.PluginManifestOptions | undefined;
|
|
36
|
+
dev?: boolean | moduleFederationPlugin.PluginDevOptions | undefined;
|
|
37
|
+
dts?: boolean | moduleFederationPlugin.PluginDtsOptions | undefined;
|
|
38
|
+
async?: boolean | moduleFederationPlugin.AsyncBoundaryOptions | undefined;
|
|
39
|
+
};
|
|
8
40
|
export declare function patchWebpackConfig<T>(options: {
|
|
9
41
|
bundlerConfig: ConfigType<T>;
|
|
10
42
|
isServer: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './plugin';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@module-federation/modern-js",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20240520072517",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist/",
|
|
6
6
|
"types.d.ts",
|
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
"./runtime": {
|
|
19
19
|
"types": "./dist/types/runtime/index.d.ts",
|
|
20
20
|
"default": "./dist/esm/runtime/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./ssr-runtime": {
|
|
23
|
+
"types": "./dist/types/ssr-runtime/index.d.ts",
|
|
24
|
+
"default": "./dist/esm/ssr-runtime/index.js"
|
|
21
25
|
}
|
|
22
26
|
},
|
|
23
27
|
"typesVersions": {
|
|
@@ -27,6 +31,9 @@
|
|
|
27
31
|
],
|
|
28
32
|
"runtime": [
|
|
29
33
|
"./dist/types/runtime/index.d.ts"
|
|
34
|
+
],
|
|
35
|
+
"ssr-runtime": [
|
|
36
|
+
"./dist/types/ssr-runtime/index.d.ts"
|
|
30
37
|
]
|
|
31
38
|
}
|
|
32
39
|
},
|
|
@@ -38,9 +45,10 @@
|
|
|
38
45
|
"@swc/helpers": "0.5.3",
|
|
39
46
|
"@modern-js/utils": "^2.49.2",
|
|
40
47
|
"@modern-js/node-bundle-require": "^2.49.2",
|
|
41
|
-
"
|
|
42
|
-
"@module-federation/
|
|
43
|
-
"@module-federation/
|
|
48
|
+
"node-fetch": "~3.3.0",
|
|
49
|
+
"@module-federation/sdk": "0.0.0-next-20240520072517",
|
|
50
|
+
"@module-federation/enhanced": "0.0.0-next-20240520072517",
|
|
51
|
+
"@module-federation/node": "0.0.0-next-20240520072517"
|
|
44
52
|
},
|
|
45
53
|
"devDependencies": {
|
|
46
54
|
"@modern-js/app-tools": "^2.49.2",
|
|
@@ -48,7 +56,7 @@
|
|
|
48
56
|
"@modern-js/runtime": "^2.49.2",
|
|
49
57
|
"@modern-js/module-tools": "^2.35.0",
|
|
50
58
|
"@modern-js/tsconfig": "^2.35.0",
|
|
51
|
-
"@module-federation/manifest": "0.0.0-next-
|
|
59
|
+
"@module-federation/manifest": "0.0.0-next-20240520072517"
|
|
52
60
|
},
|
|
53
61
|
"scripts": {
|
|
54
62
|
"build": "modern build"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|