@module-federation/modern-js 0.0.0-next-20241118091452 → 0.0.0-next-20241118092546
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.
|
@@ -139,54 +139,57 @@ function collectSSRAssets(options) {
|
|
|
139
139
|
];
|
|
140
140
|
}
|
|
141
141
|
function createRemoteSSRComponent(info) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
if (exportName in m && typeof Com === "function") {
|
|
156
|
-
return {
|
|
157
|
-
default: () => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
158
|
-
children: [
|
|
159
|
-
assets,
|
|
160
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Com, {
|
|
161
|
-
...props
|
|
162
|
-
})
|
|
163
|
-
]
|
|
164
|
-
})
|
|
165
|
-
};
|
|
166
|
-
} else {
|
|
167
|
-
throw Error(`Make sure that ${moduleId} has the correct export when export is ${String(exportName)}`);
|
|
168
|
-
}
|
|
169
|
-
} catch (err) {
|
|
170
|
-
if (!info.fallback) {
|
|
171
|
-
throw err;
|
|
172
|
-
}
|
|
173
|
-
const FallbackFunctionComponent = info.fallback;
|
|
174
|
-
const FallbackNode = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FallbackFunctionComponent, {
|
|
175
|
-
error: err,
|
|
176
|
-
resetErrorBoundary: () => {
|
|
177
|
-
console.log('SSR mode not support "resetErrorBoundary" !');
|
|
178
|
-
}
|
|
179
|
-
});
|
|
142
|
+
const exportName = (info === null || info === void 0 ? void 0 : info.export) || "default";
|
|
143
|
+
const LazyComponent = /* @__PURE__ */ import_react.default.lazy(async () => {
|
|
144
|
+
try {
|
|
145
|
+
const m = await info.loader();
|
|
146
|
+
if (!m) {
|
|
147
|
+
throw new Error("load remote failed");
|
|
148
|
+
}
|
|
149
|
+
const moduleId = m && m[Symbol.for("mf_module_id")];
|
|
150
|
+
const assets = collectSSRAssets({
|
|
151
|
+
id: moduleId
|
|
152
|
+
});
|
|
153
|
+
const Com = m[exportName];
|
|
154
|
+
if (exportName in m && typeof Com === "function") {
|
|
180
155
|
return {
|
|
181
|
-
default: () =>
|
|
156
|
+
default: (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
157
|
+
children: [
|
|
158
|
+
assets,
|
|
159
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Com, {
|
|
160
|
+
...props
|
|
161
|
+
})
|
|
162
|
+
]
|
|
163
|
+
})
|
|
182
164
|
};
|
|
165
|
+
} else {
|
|
166
|
+
throw Error(`Make sure that ${moduleId} has the correct export when export is ${String(exportName)}`);
|
|
183
167
|
}
|
|
184
|
-
})
|
|
168
|
+
} catch (err) {
|
|
169
|
+
if (!info.fallback) {
|
|
170
|
+
throw err;
|
|
171
|
+
}
|
|
172
|
+
const FallbackFunctionComponent = info.fallback;
|
|
173
|
+
const FallbackNode = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FallbackFunctionComponent, {
|
|
174
|
+
error: err,
|
|
175
|
+
resetErrorBoundary: () => {
|
|
176
|
+
console.log('SSR mode not support "resetErrorBoundary" !');
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
return {
|
|
180
|
+
default: () => FallbackNode
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
return (props) => {
|
|
185
|
+
const { key, ...args } = props;
|
|
185
186
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_error_boundary.ErrorBoundary, {
|
|
186
187
|
FallbackComponent: info.fallback,
|
|
187
188
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.default.Suspense, {
|
|
188
189
|
fallback: info.loading,
|
|
189
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LazyComponent, {
|
|
190
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LazyComponent, {
|
|
191
|
+
...args
|
|
192
|
+
})
|
|
190
193
|
})
|
|
191
194
|
});
|
|
192
195
|
};
|
|
@@ -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 _object_without_properties } from "@swc/helpers/_/_object_without_properties";
|
|
4
5
|
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
5
6
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
6
7
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -97,86 +98,89 @@ function collectSSRAssets(options) {
|
|
|
97
98
|
return _to_consumable_array(scripts).concat(_to_consumable_array(links));
|
|
98
99
|
}
|
|
99
100
|
function createRemoteSSRComponent(info) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
var
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (exportName in m && typeof Com === "function") {
|
|
128
|
-
return [
|
|
129
|
-
2,
|
|
130
|
-
{
|
|
131
|
-
default: function() {
|
|
132
|
-
return /* @__PURE__ */ _jsxs(_Fragment, {
|
|
133
|
-
children: [
|
|
134
|
-
assets,
|
|
135
|
-
/* @__PURE__ */ _jsx(Com, _object_spread({}, props))
|
|
136
|
-
]
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
];
|
|
141
|
-
} else {
|
|
142
|
-
throw Error("Make sure that ".concat(moduleId, " has the correct export when export is ").concat(String(exportName)));
|
|
143
|
-
}
|
|
144
|
-
return [
|
|
145
|
-
3,
|
|
146
|
-
3
|
|
147
|
-
];
|
|
148
|
-
case 2:
|
|
149
|
-
err = _state.sent();
|
|
150
|
-
if (!info.fallback) {
|
|
151
|
-
throw err;
|
|
152
|
-
}
|
|
153
|
-
FallbackFunctionComponent = info.fallback;
|
|
154
|
-
FallbackNode = /* @__PURE__ */ _jsx(FallbackFunctionComponent, {
|
|
155
|
-
error: err,
|
|
156
|
-
resetErrorBoundary: function() {
|
|
157
|
-
console.log('SSR mode not support "resetErrorBoundary" !');
|
|
158
|
-
}
|
|
159
|
-
});
|
|
101
|
+
var exportName = (info === null || info === void 0 ? void 0 : info.export) || "default";
|
|
102
|
+
var LazyComponent = /* @__PURE__ */ React.lazy(/* @__PURE__ */ _async_to_generator(function() {
|
|
103
|
+
var m, moduleId, assets, Com, err, FallbackFunctionComponent, FallbackNode;
|
|
104
|
+
return _ts_generator(this, function(_state) {
|
|
105
|
+
switch (_state.label) {
|
|
106
|
+
case 0:
|
|
107
|
+
_state.trys.push([
|
|
108
|
+
0,
|
|
109
|
+
2,
|
|
110
|
+
,
|
|
111
|
+
3
|
|
112
|
+
]);
|
|
113
|
+
return [
|
|
114
|
+
4,
|
|
115
|
+
info.loader()
|
|
116
|
+
];
|
|
117
|
+
case 1:
|
|
118
|
+
m = _state.sent();
|
|
119
|
+
if (!m) {
|
|
120
|
+
throw new Error("load remote failed");
|
|
121
|
+
}
|
|
122
|
+
moduleId = m && m[Symbol.for("mf_module_id")];
|
|
123
|
+
assets = collectSSRAssets({
|
|
124
|
+
id: moduleId
|
|
125
|
+
});
|
|
126
|
+
Com = m[exportName];
|
|
127
|
+
if (exportName in m && typeof Com === "function") {
|
|
160
128
|
return [
|
|
161
129
|
2,
|
|
162
130
|
{
|
|
163
|
-
default: function() {
|
|
164
|
-
return
|
|
131
|
+
default: function(props) {
|
|
132
|
+
return /* @__PURE__ */ _jsxs(_Fragment, {
|
|
133
|
+
children: [
|
|
134
|
+
assets,
|
|
135
|
+
/* @__PURE__ */ _jsx(Com, _object_spread({}, props))
|
|
136
|
+
]
|
|
137
|
+
});
|
|
165
138
|
}
|
|
166
139
|
}
|
|
167
140
|
];
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
141
|
+
} else {
|
|
142
|
+
throw Error("Make sure that ".concat(moduleId, " has the correct export when export is ").concat(String(exportName)));
|
|
143
|
+
}
|
|
144
|
+
return [
|
|
145
|
+
3,
|
|
146
|
+
3
|
|
147
|
+
];
|
|
148
|
+
case 2:
|
|
149
|
+
err = _state.sent();
|
|
150
|
+
if (!info.fallback) {
|
|
151
|
+
throw err;
|
|
152
|
+
}
|
|
153
|
+
FallbackFunctionComponent = info.fallback;
|
|
154
|
+
FallbackNode = /* @__PURE__ */ _jsx(FallbackFunctionComponent, {
|
|
155
|
+
error: err,
|
|
156
|
+
resetErrorBoundary: function() {
|
|
157
|
+
console.log('SSR mode not support "resetErrorBoundary" !');
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
return [
|
|
161
|
+
2,
|
|
162
|
+
{
|
|
163
|
+
default: function() {
|
|
164
|
+
return FallbackNode;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
];
|
|
168
|
+
case 3:
|
|
169
|
+
return [
|
|
170
|
+
2
|
|
171
|
+
];
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
}));
|
|
175
|
+
return function(props) {
|
|
176
|
+
var key = props.key, args = _object_without_properties(props, [
|
|
177
|
+
"key"
|
|
178
|
+
]);
|
|
175
179
|
return /* @__PURE__ */ _jsx(ErrorBoundary, {
|
|
176
180
|
FallbackComponent: info.fallback,
|
|
177
181
|
children: /* @__PURE__ */ _jsx(React.Suspense, {
|
|
178
182
|
fallback: info.loading,
|
|
179
|
-
children: /* @__PURE__ */ _jsx(LazyComponent, {})
|
|
183
|
+
children: /* @__PURE__ */ _jsx(LazyComponent, _object_spread({}, args))
|
|
180
184
|
})
|
|
181
185
|
});
|
|
182
186
|
};
|
|
@@ -105,54 +105,57 @@ function collectSSRAssets(options) {
|
|
|
105
105
|
];
|
|
106
106
|
}
|
|
107
107
|
function createRemoteSSRComponent(info) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (exportName in m && typeof Com === "function") {
|
|
122
|
-
return {
|
|
123
|
-
default: () => /* @__PURE__ */ _jsxs(_Fragment, {
|
|
124
|
-
children: [
|
|
125
|
-
assets,
|
|
126
|
-
/* @__PURE__ */ _jsx(Com, {
|
|
127
|
-
...props
|
|
128
|
-
})
|
|
129
|
-
]
|
|
130
|
-
})
|
|
131
|
-
};
|
|
132
|
-
} else {
|
|
133
|
-
throw Error(`Make sure that ${moduleId} has the correct export when export is ${String(exportName)}`);
|
|
134
|
-
}
|
|
135
|
-
} catch (err) {
|
|
136
|
-
if (!info.fallback) {
|
|
137
|
-
throw err;
|
|
138
|
-
}
|
|
139
|
-
const FallbackFunctionComponent = info.fallback;
|
|
140
|
-
const FallbackNode = /* @__PURE__ */ _jsx(FallbackFunctionComponent, {
|
|
141
|
-
error: err,
|
|
142
|
-
resetErrorBoundary: () => {
|
|
143
|
-
console.log('SSR mode not support "resetErrorBoundary" !');
|
|
144
|
-
}
|
|
145
|
-
});
|
|
108
|
+
const exportName = (info === null || info === void 0 ? void 0 : info.export) || "default";
|
|
109
|
+
const LazyComponent = /* @__PURE__ */ React.lazy(async () => {
|
|
110
|
+
try {
|
|
111
|
+
const m = await info.loader();
|
|
112
|
+
if (!m) {
|
|
113
|
+
throw new Error("load remote failed");
|
|
114
|
+
}
|
|
115
|
+
const moduleId = m && m[Symbol.for("mf_module_id")];
|
|
116
|
+
const assets = collectSSRAssets({
|
|
117
|
+
id: moduleId
|
|
118
|
+
});
|
|
119
|
+
const Com = m[exportName];
|
|
120
|
+
if (exportName in m && typeof Com === "function") {
|
|
146
121
|
return {
|
|
147
|
-
default: () =>
|
|
122
|
+
default: (props) => /* @__PURE__ */ _jsxs(_Fragment, {
|
|
123
|
+
children: [
|
|
124
|
+
assets,
|
|
125
|
+
/* @__PURE__ */ _jsx(Com, {
|
|
126
|
+
...props
|
|
127
|
+
})
|
|
128
|
+
]
|
|
129
|
+
})
|
|
148
130
|
};
|
|
131
|
+
} else {
|
|
132
|
+
throw Error(`Make sure that ${moduleId} has the correct export when export is ${String(exportName)}`);
|
|
149
133
|
}
|
|
150
|
-
})
|
|
134
|
+
} catch (err) {
|
|
135
|
+
if (!info.fallback) {
|
|
136
|
+
throw err;
|
|
137
|
+
}
|
|
138
|
+
const FallbackFunctionComponent = info.fallback;
|
|
139
|
+
const FallbackNode = /* @__PURE__ */ _jsx(FallbackFunctionComponent, {
|
|
140
|
+
error: err,
|
|
141
|
+
resetErrorBoundary: () => {
|
|
142
|
+
console.log('SSR mode not support "resetErrorBoundary" !');
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
return {
|
|
146
|
+
default: () => FallbackNode
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
return (props) => {
|
|
151
|
+
const { key, ...args } = props;
|
|
151
152
|
return /* @__PURE__ */ _jsx(ErrorBoundary, {
|
|
152
153
|
FallbackComponent: info.fallback,
|
|
153
154
|
children: /* @__PURE__ */ _jsx(React.Suspense, {
|
|
154
155
|
fallback: info.loading,
|
|
155
|
-
children: /* @__PURE__ */ _jsx(LazyComponent, {
|
|
156
|
+
children: /* @__PURE__ */ _jsx(LazyComponent, {
|
|
157
|
+
...args
|
|
158
|
+
})
|
|
156
159
|
})
|
|
157
160
|
});
|
|
158
161
|
};
|
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-20241118092546",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist/",
|
|
6
6
|
"types.d.ts",
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
"hoist-non-react-statics": "3.3.2",
|
|
62
62
|
"node-fetch": "~3.3.0",
|
|
63
63
|
"react-error-boundary": "4.0.13",
|
|
64
|
-
"@module-federation/enhanced": "0.0.0-next-
|
|
65
|
-
"@module-federation/node": "0.0.0-next-
|
|
66
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
64
|
+
"@module-federation/enhanced": "0.0.0-next-20241118092546",
|
|
65
|
+
"@module-federation/node": "0.0.0-next-20241118092546",
|
|
66
|
+
"@module-federation/sdk": "0.0.0-next-20241118092546"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@modern-js/app-tools": "2.60.6",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"@modern-js/runtime": "2.60.6",
|
|
73
73
|
"@modern-js/tsconfig": "2.60.6",
|
|
74
74
|
"@types/hoist-non-react-statics": "3.3.5",
|
|
75
|
-
"@module-federation/manifest": "0.0.0-next-
|
|
75
|
+
"@module-federation/manifest": "0.0.0-next-20241118092546"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"react": ">=17",
|