@module-federation/modern-js 0.0.0-next-20240620090145 → 0.0.0-next-20240620115801
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 +1 -1
- package/dist/cjs/cli/utils.js +0 -3
- package/dist/cjs/cli/utils.spec.js +148 -0
- package/dist/cjs/runtime/MFReactComponent.js +1 -1
- package/dist/esm/cli/index.js +1 -1
- package/dist/esm/cli/utils.js +0 -3
- package/dist/esm/cli/utils.spec.js +161 -0
- package/dist/esm/runtime/MFReactComponent.js +1 -1
- package/dist/esm-node/cli/index.js +1 -1
- package/dist/esm-node/cli/utils.js +0 -3
- package/dist/esm-node/cli/utils.spec.js +125 -0
- package/dist/esm-node/runtime/MFReactComponent.js +1 -1
- package/dist/types/cli/utils.spec.d.ts +1 -0
- package/package.json +5 -5
package/dist/cjs/cli/index.js
CHANGED
|
@@ -99,7 +99,7 @@ const moduleFederationPlugin = (userConfig = {}) => ({
|
|
|
99
99
|
var _modernjsConfig_source;
|
|
100
100
|
modifyBundlerConfig(config, isServer);
|
|
101
101
|
const enableAsyncEntry = (_modernjsConfig_source = modernjsConfig.source) === null || _modernjsConfig_source === void 0 ? void 0 : _modernjsConfig_source.enableAsyncEntry;
|
|
102
|
-
if (
|
|
102
|
+
if (!enableAsyncEntry && mfConfig.async !== false) {
|
|
103
103
|
var _config_plugins;
|
|
104
104
|
const asyncBoundaryPluginOptions = typeof mfConfig.async === "object" ? mfConfig.async : {
|
|
105
105
|
eager: (module2) => module2 && /\.federation/.test((module2 === null || module2 === void 0 ? void 0 : module2.request) || ""),
|
package/dist/cjs/cli/utils.js
CHANGED
|
@@ -102,9 +102,6 @@ const patchMFConfig = (mfConfig, isServer) => {
|
|
|
102
102
|
}
|
|
103
103
|
injectRuntimePlugins(import_path.default.resolve(__dirname, "./mfRuntimePlugins/inject-node-fetch.js"), runtimePlugins);
|
|
104
104
|
}
|
|
105
|
-
if (typeof mfConfig.async === "undefined") {
|
|
106
|
-
mfConfig.async = true;
|
|
107
|
-
}
|
|
108
105
|
if (!isServer) {
|
|
109
106
|
return {
|
|
110
107
|
...mfConfig,
|
|
@@ -0,0 +1,148 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var import_vitest = require("vitest");
|
|
25
|
+
var import_path = __toESM(require("path"));
|
|
26
|
+
var import_utils = require("./utils");
|
|
27
|
+
const mfConfig = {
|
|
28
|
+
name: "host",
|
|
29
|
+
filename: "remoteEntry.js",
|
|
30
|
+
remotes: {
|
|
31
|
+
remote: "http://localhost:3000/remoteEntry.js"
|
|
32
|
+
},
|
|
33
|
+
shared: {
|
|
34
|
+
react: {
|
|
35
|
+
singleton: true,
|
|
36
|
+
eager: true
|
|
37
|
+
},
|
|
38
|
+
"react-dom": {
|
|
39
|
+
singleton: true,
|
|
40
|
+
eager: true
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
(0, import_vitest.describe)("getTargetEnvConfig", async () => {
|
|
45
|
+
(0, import_vitest.it)("getTargetEnvConfig: server", async () => {
|
|
46
|
+
const targetEnvConfig = (0, import_utils.getTargetEnvConfig)(mfConfig, true);
|
|
47
|
+
(0, import_vitest.expect)(targetEnvConfig).toStrictEqual({
|
|
48
|
+
dev: false,
|
|
49
|
+
dts: false,
|
|
50
|
+
filename: "remoteEntry.js",
|
|
51
|
+
library: {
|
|
52
|
+
name: "host",
|
|
53
|
+
type: "commonjs-module"
|
|
54
|
+
},
|
|
55
|
+
name: "host",
|
|
56
|
+
remotes: {
|
|
57
|
+
remote: "http://localhost:3000/remoteEntry.js"
|
|
58
|
+
},
|
|
59
|
+
runtimePlugins: [
|
|
60
|
+
import_path.default.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js"),
|
|
61
|
+
import_path.default.resolve(__dirname, "./mfRuntimePlugins/inject-node-fetch.js")
|
|
62
|
+
],
|
|
63
|
+
shared: {
|
|
64
|
+
react: {
|
|
65
|
+
eager: true,
|
|
66
|
+
singleton: true
|
|
67
|
+
},
|
|
68
|
+
"react-dom": {
|
|
69
|
+
eager: true,
|
|
70
|
+
singleton: true
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
(0, import_vitest.it)("getTargetEnvConfig: client", async () => {
|
|
76
|
+
const targetEnvConfig = (0, import_utils.getTargetEnvConfig)(mfConfig, false);
|
|
77
|
+
(0, import_vitest.expect)(targetEnvConfig).toStrictEqual({
|
|
78
|
+
filename: "remoteEntry.js",
|
|
79
|
+
name: "host",
|
|
80
|
+
remotes: {
|
|
81
|
+
remote: "http://localhost:3000/remoteEntry.js"
|
|
82
|
+
},
|
|
83
|
+
runtimePlugins: [
|
|
84
|
+
import_path.default.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js")
|
|
85
|
+
],
|
|
86
|
+
shared: {
|
|
87
|
+
react: {
|
|
88
|
+
eager: true,
|
|
89
|
+
singleton: true
|
|
90
|
+
},
|
|
91
|
+
"react-dom": {
|
|
92
|
+
eager: true,
|
|
93
|
+
singleton: true
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
(0, import_vitest.describe)("patchWebpackConfig", async () => {
|
|
100
|
+
(0, import_vitest.it)("patchWebpackConfig: server", async () => {
|
|
101
|
+
const bundlerConfig = {
|
|
102
|
+
output: {
|
|
103
|
+
publicPath: "auto"
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
(0, import_utils.patchWebpackConfig)({
|
|
107
|
+
bundlerConfig,
|
|
108
|
+
isServer: true,
|
|
109
|
+
modernjsConfig: {
|
|
110
|
+
server: {
|
|
111
|
+
ssr: {
|
|
112
|
+
mode: "stream"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
mfConfig
|
|
117
|
+
});
|
|
118
|
+
(0, import_vitest.expect)(bundlerConfig).toStrictEqual({
|
|
119
|
+
output: {
|
|
120
|
+
publicPath: "http://localhost:8080/"
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
(0, import_vitest.it)("patchWebpackConfig: client", async () => {
|
|
125
|
+
const bundlerConfig = {
|
|
126
|
+
output: {
|
|
127
|
+
publicPath: "auto"
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
(0, import_utils.patchWebpackConfig)({
|
|
131
|
+
bundlerConfig,
|
|
132
|
+
isServer: false,
|
|
133
|
+
modernjsConfig: {
|
|
134
|
+
server: {
|
|
135
|
+
ssr: {
|
|
136
|
+
mode: "stream"
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
mfConfig
|
|
141
|
+
});
|
|
142
|
+
(0, import_vitest.expect)(bundlerConfig).toStrictEqual({
|
|
143
|
+
output: {
|
|
144
|
+
publicPath: "http://localhost:8080/"
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
});
|
|
@@ -36,7 +36,7 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
36
36
|
var import_react = __toESM(require("react"));
|
|
37
37
|
var import_runtime = require("@module-federation/enhanced/runtime");
|
|
38
38
|
function getLoadedRemoteInfos(instance, id) {
|
|
39
|
-
const { name, expose } = instance.remoteHandler.idToRemoteMap[id];
|
|
39
|
+
const { name, expose } = instance.remoteHandler.idToRemoteMap[id] || {};
|
|
40
40
|
if (!name) {
|
|
41
41
|
return;
|
|
42
42
|
}
|
package/dist/esm/cli/index.js
CHANGED
|
@@ -88,7 +88,7 @@ var moduleFederationPlugin = function() {
|
|
|
88
88
|
var _modernjsConfig_source;
|
|
89
89
|
modifyBundlerConfig(config, isServer);
|
|
90
90
|
var enableAsyncEntry = (_modernjsConfig_source = modernjsConfig.source) === null || _modernjsConfig_source === void 0 ? void 0 : _modernjsConfig_source.enableAsyncEntry;
|
|
91
|
-
if (
|
|
91
|
+
if (!enableAsyncEntry && mfConfig.async !== false) {
|
|
92
92
|
var _config_plugins;
|
|
93
93
|
var asyncBoundaryPluginOptions = typeof mfConfig.async === "object" ? mfConfig.async : {
|
|
94
94
|
eager: function(module) {
|
package/dist/esm/cli/utils.js
CHANGED
|
@@ -121,9 +121,6 @@ var patchMFConfig = function(mfConfig, isServer) {
|
|
|
121
121
|
}
|
|
122
122
|
injectRuntimePlugins(path.resolve(__dirname, "./mfRuntimePlugins/inject-node-fetch.js"), runtimePlugins);
|
|
123
123
|
}
|
|
124
|
-
if (typeof mfConfig.async === "undefined") {
|
|
125
|
-
mfConfig.async = true;
|
|
126
|
-
}
|
|
127
124
|
if (!isServer) {
|
|
128
125
|
return _object_spread_props(_object_spread({}, mfConfig), {
|
|
129
126
|
runtimePlugins
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
+
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
|
+
import { it, expect, describe } from "vitest";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { getTargetEnvConfig, patchWebpackConfig } from "./utils";
|
|
6
|
+
var mfConfig = {
|
|
7
|
+
name: "host",
|
|
8
|
+
filename: "remoteEntry.js",
|
|
9
|
+
remotes: {
|
|
10
|
+
remote: "http://localhost:3000/remoteEntry.js"
|
|
11
|
+
},
|
|
12
|
+
shared: {
|
|
13
|
+
react: {
|
|
14
|
+
singleton: true,
|
|
15
|
+
eager: true
|
|
16
|
+
},
|
|
17
|
+
"react-dom": {
|
|
18
|
+
singleton: true,
|
|
19
|
+
eager: true
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
describe("getTargetEnvConfig", /* @__PURE__ */ _async_to_generator(function() {
|
|
24
|
+
return _ts_generator(this, function(_state) {
|
|
25
|
+
it("getTargetEnvConfig: server", /* @__PURE__ */ _async_to_generator(function() {
|
|
26
|
+
var targetEnvConfig;
|
|
27
|
+
return _ts_generator(this, function(_state2) {
|
|
28
|
+
targetEnvConfig = getTargetEnvConfig(mfConfig, true);
|
|
29
|
+
expect(targetEnvConfig).toStrictEqual({
|
|
30
|
+
dev: false,
|
|
31
|
+
dts: false,
|
|
32
|
+
filename: "remoteEntry.js",
|
|
33
|
+
library: {
|
|
34
|
+
name: "host",
|
|
35
|
+
type: "commonjs-module"
|
|
36
|
+
},
|
|
37
|
+
name: "host",
|
|
38
|
+
remotes: {
|
|
39
|
+
remote: "http://localhost:3000/remoteEntry.js"
|
|
40
|
+
},
|
|
41
|
+
runtimePlugins: [
|
|
42
|
+
path.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js"),
|
|
43
|
+
path.resolve(__dirname, "./mfRuntimePlugins/inject-node-fetch.js")
|
|
44
|
+
],
|
|
45
|
+
shared: {
|
|
46
|
+
react: {
|
|
47
|
+
eager: true,
|
|
48
|
+
singleton: true
|
|
49
|
+
},
|
|
50
|
+
"react-dom": {
|
|
51
|
+
eager: true,
|
|
52
|
+
singleton: true
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return [
|
|
57
|
+
2
|
|
58
|
+
];
|
|
59
|
+
});
|
|
60
|
+
}));
|
|
61
|
+
it("getTargetEnvConfig: client", /* @__PURE__ */ _async_to_generator(function() {
|
|
62
|
+
var targetEnvConfig;
|
|
63
|
+
return _ts_generator(this, function(_state2) {
|
|
64
|
+
targetEnvConfig = getTargetEnvConfig(mfConfig, false);
|
|
65
|
+
expect(targetEnvConfig).toStrictEqual({
|
|
66
|
+
filename: "remoteEntry.js",
|
|
67
|
+
name: "host",
|
|
68
|
+
remotes: {
|
|
69
|
+
remote: "http://localhost:3000/remoteEntry.js"
|
|
70
|
+
},
|
|
71
|
+
runtimePlugins: [
|
|
72
|
+
path.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js")
|
|
73
|
+
],
|
|
74
|
+
shared: {
|
|
75
|
+
react: {
|
|
76
|
+
eager: true,
|
|
77
|
+
singleton: true
|
|
78
|
+
},
|
|
79
|
+
"react-dom": {
|
|
80
|
+
eager: true,
|
|
81
|
+
singleton: true
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
return [
|
|
86
|
+
2
|
|
87
|
+
];
|
|
88
|
+
});
|
|
89
|
+
}));
|
|
90
|
+
return [
|
|
91
|
+
2
|
|
92
|
+
];
|
|
93
|
+
});
|
|
94
|
+
}));
|
|
95
|
+
describe("patchWebpackConfig", /* @__PURE__ */ _async_to_generator(function() {
|
|
96
|
+
return _ts_generator(this, function(_state) {
|
|
97
|
+
it("patchWebpackConfig: server", /* @__PURE__ */ _async_to_generator(function() {
|
|
98
|
+
var bundlerConfig;
|
|
99
|
+
return _ts_generator(this, function(_state2) {
|
|
100
|
+
bundlerConfig = {
|
|
101
|
+
output: {
|
|
102
|
+
publicPath: "auto"
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
patchWebpackConfig({
|
|
106
|
+
bundlerConfig,
|
|
107
|
+
isServer: true,
|
|
108
|
+
modernjsConfig: {
|
|
109
|
+
server: {
|
|
110
|
+
ssr: {
|
|
111
|
+
mode: "stream"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
mfConfig
|
|
116
|
+
});
|
|
117
|
+
expect(bundlerConfig).toStrictEqual({
|
|
118
|
+
output: {
|
|
119
|
+
publicPath: "http://localhost:8080/"
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
return [
|
|
123
|
+
2
|
|
124
|
+
];
|
|
125
|
+
});
|
|
126
|
+
}));
|
|
127
|
+
it("patchWebpackConfig: client", /* @__PURE__ */ _async_to_generator(function() {
|
|
128
|
+
var bundlerConfig;
|
|
129
|
+
return _ts_generator(this, function(_state2) {
|
|
130
|
+
bundlerConfig = {
|
|
131
|
+
output: {
|
|
132
|
+
publicPath: "auto"
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
patchWebpackConfig({
|
|
136
|
+
bundlerConfig,
|
|
137
|
+
isServer: false,
|
|
138
|
+
modernjsConfig: {
|
|
139
|
+
server: {
|
|
140
|
+
ssr: {
|
|
141
|
+
mode: "stream"
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
mfConfig
|
|
146
|
+
});
|
|
147
|
+
expect(bundlerConfig).toStrictEqual({
|
|
148
|
+
output: {
|
|
149
|
+
publicPath: "http://localhost:8080/"
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
return [
|
|
153
|
+
2
|
|
154
|
+
];
|
|
155
|
+
});
|
|
156
|
+
}));
|
|
157
|
+
return [
|
|
158
|
+
2
|
|
159
|
+
];
|
|
160
|
+
});
|
|
161
|
+
}));
|
|
@@ -5,7 +5,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
5
5
|
import React from "react";
|
|
6
6
|
import { loadRemote, getInstance } from "@module-federation/enhanced/runtime";
|
|
7
7
|
function getLoadedRemoteInfos(instance, id) {
|
|
8
|
-
var
|
|
8
|
+
var _ref = instance.remoteHandler.idToRemoteMap[id] || {}, name = _ref.name, expose = _ref.expose;
|
|
9
9
|
if (!name) {
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
@@ -63,7 +63,7 @@ const moduleFederationPlugin = (userConfig = {}) => ({
|
|
|
63
63
|
var _modernjsConfig_source;
|
|
64
64
|
modifyBundlerConfig(config, isServer);
|
|
65
65
|
const enableAsyncEntry = (_modernjsConfig_source = modernjsConfig.source) === null || _modernjsConfig_source === void 0 ? void 0 : _modernjsConfig_source.enableAsyncEntry;
|
|
66
|
-
if (
|
|
66
|
+
if (!enableAsyncEntry && mfConfig.async !== false) {
|
|
67
67
|
var _config_plugins;
|
|
68
68
|
const asyncBoundaryPluginOptions = typeof mfConfig.async === "object" ? mfConfig.async : {
|
|
69
69
|
eager: (module) => module && /\.federation/.test((module === null || module === void 0 ? void 0 : module.request) || ""),
|
|
@@ -65,9 +65,6 @@ const patchMFConfig = (mfConfig, isServer) => {
|
|
|
65
65
|
}
|
|
66
66
|
injectRuntimePlugins(path.resolve(__dirname, "./mfRuntimePlugins/inject-node-fetch.js"), runtimePlugins);
|
|
67
67
|
}
|
|
68
|
-
if (typeof mfConfig.async === "undefined") {
|
|
69
|
-
mfConfig.async = true;
|
|
70
|
-
}
|
|
71
68
|
if (!isServer) {
|
|
72
69
|
return {
|
|
73
70
|
...mfConfig,
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { it, expect, describe } from "vitest";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { getTargetEnvConfig, patchWebpackConfig } from "./utils";
|
|
4
|
+
const mfConfig = {
|
|
5
|
+
name: "host",
|
|
6
|
+
filename: "remoteEntry.js",
|
|
7
|
+
remotes: {
|
|
8
|
+
remote: "http://localhost:3000/remoteEntry.js"
|
|
9
|
+
},
|
|
10
|
+
shared: {
|
|
11
|
+
react: {
|
|
12
|
+
singleton: true,
|
|
13
|
+
eager: true
|
|
14
|
+
},
|
|
15
|
+
"react-dom": {
|
|
16
|
+
singleton: true,
|
|
17
|
+
eager: true
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
describe("getTargetEnvConfig", async () => {
|
|
22
|
+
it("getTargetEnvConfig: server", async () => {
|
|
23
|
+
const targetEnvConfig = getTargetEnvConfig(mfConfig, true);
|
|
24
|
+
expect(targetEnvConfig).toStrictEqual({
|
|
25
|
+
dev: false,
|
|
26
|
+
dts: false,
|
|
27
|
+
filename: "remoteEntry.js",
|
|
28
|
+
library: {
|
|
29
|
+
name: "host",
|
|
30
|
+
type: "commonjs-module"
|
|
31
|
+
},
|
|
32
|
+
name: "host",
|
|
33
|
+
remotes: {
|
|
34
|
+
remote: "http://localhost:3000/remoteEntry.js"
|
|
35
|
+
},
|
|
36
|
+
runtimePlugins: [
|
|
37
|
+
path.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js"),
|
|
38
|
+
path.resolve(__dirname, "./mfRuntimePlugins/inject-node-fetch.js")
|
|
39
|
+
],
|
|
40
|
+
shared: {
|
|
41
|
+
react: {
|
|
42
|
+
eager: true,
|
|
43
|
+
singleton: true
|
|
44
|
+
},
|
|
45
|
+
"react-dom": {
|
|
46
|
+
eager: true,
|
|
47
|
+
singleton: true
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
it("getTargetEnvConfig: client", async () => {
|
|
53
|
+
const targetEnvConfig = getTargetEnvConfig(mfConfig, false);
|
|
54
|
+
expect(targetEnvConfig).toStrictEqual({
|
|
55
|
+
filename: "remoteEntry.js",
|
|
56
|
+
name: "host",
|
|
57
|
+
remotes: {
|
|
58
|
+
remote: "http://localhost:3000/remoteEntry.js"
|
|
59
|
+
},
|
|
60
|
+
runtimePlugins: [
|
|
61
|
+
path.resolve(__dirname, "./mfRuntimePlugins/shared-strategy.js")
|
|
62
|
+
],
|
|
63
|
+
shared: {
|
|
64
|
+
react: {
|
|
65
|
+
eager: true,
|
|
66
|
+
singleton: true
|
|
67
|
+
},
|
|
68
|
+
"react-dom": {
|
|
69
|
+
eager: true,
|
|
70
|
+
singleton: true
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
describe("patchWebpackConfig", async () => {
|
|
77
|
+
it("patchWebpackConfig: server", async () => {
|
|
78
|
+
const bundlerConfig = {
|
|
79
|
+
output: {
|
|
80
|
+
publicPath: "auto"
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
patchWebpackConfig({
|
|
84
|
+
bundlerConfig,
|
|
85
|
+
isServer: true,
|
|
86
|
+
modernjsConfig: {
|
|
87
|
+
server: {
|
|
88
|
+
ssr: {
|
|
89
|
+
mode: "stream"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
mfConfig
|
|
94
|
+
});
|
|
95
|
+
expect(bundlerConfig).toStrictEqual({
|
|
96
|
+
output: {
|
|
97
|
+
publicPath: "http://localhost:8080/"
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
it("patchWebpackConfig: client", async () => {
|
|
102
|
+
const bundlerConfig = {
|
|
103
|
+
output: {
|
|
104
|
+
publicPath: "auto"
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
patchWebpackConfig({
|
|
108
|
+
bundlerConfig,
|
|
109
|
+
isServer: false,
|
|
110
|
+
modernjsConfig: {
|
|
111
|
+
server: {
|
|
112
|
+
ssr: {
|
|
113
|
+
mode: "stream"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
mfConfig
|
|
118
|
+
});
|
|
119
|
+
expect(bundlerConfig).toStrictEqual({
|
|
120
|
+
output: {
|
|
121
|
+
publicPath: "http://localhost:8080/"
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
});
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { loadRemote, getInstance } from "@module-federation/enhanced/runtime";
|
|
4
4
|
function getLoadedRemoteInfos(instance, id) {
|
|
5
|
-
const { name, expose } = instance.remoteHandler.idToRemoteMap[id];
|
|
5
|
+
const { name, expose } = instance.remoteHandler.idToRemoteMap[id] || {};
|
|
6
6
|
if (!name) {
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
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-20240620115801",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist/",
|
|
6
6
|
"types.d.ts",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"@modern-js/utils": "^2.49.2",
|
|
47
47
|
"@modern-js/node-bundle-require": "^2.49.2",
|
|
48
48
|
"node-fetch": "~3.3.0",
|
|
49
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
50
|
-
"@module-federation/enhanced": "0.0.0-next-
|
|
51
|
-
"@module-federation/node": "0.0.0-next-
|
|
49
|
+
"@module-federation/sdk": "0.0.0-next-20240620115801",
|
|
50
|
+
"@module-federation/enhanced": "0.0.0-next-20240620115801",
|
|
51
|
+
"@module-federation/node": "0.0.0-next-20240620115801"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"@modern-js/app-tools": "^2.49.2",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"@modern-js/runtime": "^2.49.2",
|
|
57
57
|
"@modern-js/module-tools": "^2.35.0",
|
|
58
58
|
"@modern-js/tsconfig": "^2.35.0",
|
|
59
|
-
"@module-federation/manifest": "0.0.0-next-
|
|
59
|
+
"@module-federation/manifest": "0.0.0-next-20240620115801"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"react": ">=17",
|