@module-federation/modern-js 0.0.0-next-20240912023912 → 0.0.0-next-20240912070754
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/configPlugin.js +3 -0
- package/dist/cjs/cli/dataLoader/plugin.js +8 -8
- package/dist/cjs/cli/ssrPlugin.js +4 -1
- package/dist/cjs/runtime/dataLoader/plugin-inject-assets.js +6 -3
- package/dist/cjs/runtime/dataLoader/plugin.js +2 -3
- package/dist/cjs/ssr-runtime/plugin.js +2 -2
- package/dist/esm/cli/configPlugin.js +3 -0
- package/dist/esm/cli/dataLoader/plugin.js +9 -4
- package/dist/esm/cli/ssrPlugin.js +6 -3
- package/dist/esm/runtime/dataLoader/plugin-inject-assets.js +7 -3
- package/dist/esm/runtime/dataLoader/plugin.js +3 -3
- package/dist/esm/ssr-runtime/plugin.js +3 -2
- package/dist/esm-node/cli/configPlugin.js +3 -0
- package/dist/esm-node/cli/dataLoader/plugin.js +8 -8
- package/dist/esm-node/cli/ssrPlugin.js +5 -2
- package/dist/esm-node/runtime/dataLoader/plugin-inject-assets.js +6 -3
- package/dist/esm-node/runtime/dataLoader/plugin.js +2 -3
- package/dist/esm-node/ssr-runtime/plugin.js +2 -2
- package/dist/types/runtime/dataLoader/plugin-inject-assets.d.ts +3 -1
- package/dist/types/runtime/dataLoader/plugin.d.ts +3 -1
- package/dist/types/ssr-runtime/plugin.d.ts +3 -1
- package/dist/types/types/index.d.ts +1 -1
- package/package.json +5 -5
|
@@ -55,6 +55,9 @@ function modifyBundlerConfig(options) {
|
|
|
55
55
|
}
|
|
56
56
|
const moduleFederationConfigPlugin = (userConfig) => ({
|
|
57
57
|
name: "@modern-js/plugin-module-federation-config",
|
|
58
|
+
pre: [
|
|
59
|
+
"@modern-js/plugin-initialize"
|
|
60
|
+
],
|
|
58
61
|
post: [
|
|
59
62
|
"@modern-js/plugin-module-federation"
|
|
60
63
|
],
|
|
@@ -69,14 +69,10 @@ const moduleFederationDataLoaderPlugin = (enable, internalOptions, userConfig) =
|
|
|
69
69
|
if (!enable) {
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
|
-
const {
|
|
73
|
-
// patchMFConfig,
|
|
74
|
-
metaName = import_constant2.META_NAME,
|
|
75
|
-
serverPlugin = "@module-federation/modern-js/data-loader-server",
|
|
76
|
-
transformRuntimeOptions
|
|
77
|
-
} = userConfig;
|
|
72
|
+
const { serverPlugin = "@module-federation/modern-js/data-loader-server", transformRuntimeOptions } = userConfig;
|
|
78
73
|
const appContext = useAppContext();
|
|
79
74
|
const name = internalOptions.csrConfig.name;
|
|
75
|
+
const { metaName = import_constant2.META_NAME } = internalOptions;
|
|
80
76
|
const internalDirectory = appContext.internalDirectory.replace(import_constant2.META_NAME, metaName || import_constant2.META_NAME);
|
|
81
77
|
const transformRuntimeFn = transformRuntimeOptions || _transformRuntimeOptions;
|
|
82
78
|
const partialSSRRemotes = [];
|
|
@@ -103,12 +99,16 @@ const moduleFederationDataLoaderPlugin = (enable, internalOptions, userConfig) =
|
|
|
103
99
|
plugins.push({
|
|
104
100
|
name: "ssrDataLoader",
|
|
105
101
|
path: "@module-federation/modern-js/data-loader",
|
|
106
|
-
config: {
|
|
102
|
+
config: {
|
|
103
|
+
metaName
|
|
104
|
+
}
|
|
107
105
|
});
|
|
108
106
|
plugins.push({
|
|
109
107
|
name: "ssrDataLoaderInjectAssets",
|
|
110
108
|
path: "@module-federation/modern-js/data-loader-inject-assets",
|
|
111
|
-
config: {
|
|
109
|
+
config: {
|
|
110
|
+
metaName
|
|
111
|
+
}
|
|
112
112
|
});
|
|
113
113
|
return {
|
|
114
114
|
entrypoint,
|
|
@@ -53,6 +53,7 @@ const moduleFederationSSRPlugin = (userConfig) => ({
|
|
|
53
53
|
setup: async ({ useConfigContext, useAppContext }) => {
|
|
54
54
|
var _modernjsConfig_server;
|
|
55
55
|
const modernjsConfig = useConfigContext();
|
|
56
|
+
const { metaName = import_constant.META_NAME } = userConfig;
|
|
56
57
|
const enableSSR = Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
|
|
57
58
|
if (!enableSSR) {
|
|
58
59
|
return {};
|
|
@@ -69,7 +70,9 @@ const moduleFederationSSRPlugin = (userConfig) => ({
|
|
|
69
70
|
plugins.push({
|
|
70
71
|
name: "mfSSR",
|
|
71
72
|
path: "@module-federation/modern-js/ssr-runtime",
|
|
72
|
-
config: {
|
|
73
|
+
config: {
|
|
74
|
+
metaName
|
|
75
|
+
}
|
|
73
76
|
});
|
|
74
77
|
return {
|
|
75
78
|
entrypoint,
|
|
@@ -27,11 +27,11 @@ var import_runtime = require("@module-federation/enhanced/runtime");
|
|
|
27
27
|
var import_createRemoteSSRComponent = require("../createRemoteSSRComponent");
|
|
28
28
|
var import_runtime2 = require("@meta/runtime");
|
|
29
29
|
var import_utils = require("./utils");
|
|
30
|
-
const ssrDataLoaderInjectAssetsPlugin = () => {
|
|
30
|
+
const ssrDataLoaderInjectAssetsPlugin = ({ metaName }) => {
|
|
31
31
|
return {
|
|
32
32
|
name: "@modern-js/plugin-mf-data-loader-inject-assets",
|
|
33
33
|
pre: [
|
|
34
|
-
|
|
34
|
+
`@${metaName}/plugin-router`,
|
|
35
35
|
"@modern-js/plugin-mf-data-loader"
|
|
36
36
|
],
|
|
37
37
|
setup: () => {
|
|
@@ -41,6 +41,7 @@ const ssrDataLoaderInjectAssetsPlugin = () => {
|
|
|
41
41
|
var _context_routerContext;
|
|
42
42
|
const instance = (0, import_runtime.getInstance)();
|
|
43
43
|
if (!instance || !instance.options.remotes.length) {
|
|
44
|
+
console.log("plugin-mf-data-loader-inject-assets no instance!");
|
|
44
45
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, {
|
|
45
46
|
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, {
|
|
46
47
|
...props
|
|
@@ -60,9 +61,11 @@ const ssrDataLoaderInjectAssetsPlugin = () => {
|
|
|
60
61
|
const assets = [];
|
|
61
62
|
remoteIds.forEach((remoteId) => {
|
|
62
63
|
assets.push(...(0, import_createRemoteSSRComponent.collectSSRAssets)({
|
|
63
|
-
id: remoteId
|
|
64
|
+
id: remoteId,
|
|
65
|
+
injectScript: false
|
|
64
66
|
}));
|
|
65
67
|
});
|
|
68
|
+
console.log("plugin-mf-data-loader-inject-assets has assets: ", assets);
|
|
66
69
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
67
70
|
children: [
|
|
68
71
|
assets,
|
|
@@ -24,15 +24,14 @@ module.exports = __toCommonJS(plugin_exports);
|
|
|
24
24
|
var import_runtime = require("@module-federation/enhanced/runtime");
|
|
25
25
|
var import_constant = require("../../constant");
|
|
26
26
|
var import_utils = require("./utils");
|
|
27
|
-
const ssrDataLoaderPlugin = () => {
|
|
27
|
+
const ssrDataLoaderPlugin = ({ metaName }) => {
|
|
28
28
|
return {
|
|
29
29
|
name: "@modern-js/plugin-mf-data-loader",
|
|
30
30
|
post: [
|
|
31
|
-
|
|
31
|
+
`@${metaName}/plugin-router`
|
|
32
32
|
],
|
|
33
33
|
setup: () => {
|
|
34
34
|
const remoteRoutesMap = {};
|
|
35
|
-
const pathRemoteMap = {};
|
|
36
35
|
return {
|
|
37
36
|
async beforeRender() {
|
|
38
37
|
console.log("init");
|
|
@@ -35,10 +35,10 @@ var import_jsx_runtime = require("react/jsx-runtime");
|
|
|
35
35
|
var import_hoist_non_react_statics = __toESM(require("hoist-non-react-statics"));
|
|
36
36
|
var import_SSRLiveReload = require("./SSRLiveReload");
|
|
37
37
|
console.log("mfSSRPlugin trigger");
|
|
38
|
-
const mfSSRPlugin = () => ({
|
|
38
|
+
const mfSSRPlugin = ({ metaName }) => ({
|
|
39
39
|
name: "@module-federation/modern-js",
|
|
40
40
|
pre: [
|
|
41
|
-
|
|
41
|
+
`@${metaName}/plugin-router`
|
|
42
42
|
],
|
|
43
43
|
setup: () => {
|
|
44
44
|
return {
|
|
@@ -22,6 +22,9 @@ function modifyBundlerConfig(options) {
|
|
|
22
22
|
var moduleFederationConfigPlugin = function(userConfig) {
|
|
23
23
|
return {
|
|
24
24
|
name: "@modern-js/plugin-module-federation-config",
|
|
25
|
+
pre: [
|
|
26
|
+
"@modern-js/plugin-initialize"
|
|
27
|
+
],
|
|
25
28
|
post: [
|
|
26
29
|
"@modern-js/plugin-module-federation"
|
|
27
30
|
],
|
|
@@ -37,7 +37,7 @@ var moduleFederationDataLoaderPlugin = function(enable, internalOptions, userCon
|
|
|
37
37
|
],
|
|
38
38
|
setup: function() {
|
|
39
39
|
var _ref = _async_to_generator(function(param) {
|
|
40
|
-
var useAppContext,
|
|
40
|
+
var useAppContext, _userConfig_serverPlugin, serverPlugin, transformRuntimeOptions, appContext, name, _internalOptions_metaName, metaName, internalDirectory, transformRuntimeFn, partialSSRRemotes, entries, remotePathMap, ssrByRouteIdsMap, serverPluginOptions, csrConfig, _ref2, scanEntries, scanRemotePathMap;
|
|
41
41
|
return _ts_generator(this, function(_state) {
|
|
42
42
|
switch (_state.label) {
|
|
43
43
|
case 0:
|
|
@@ -47,9 +47,10 @@ var moduleFederationDataLoaderPlugin = function(enable, internalOptions, userCon
|
|
|
47
47
|
2
|
|
48
48
|
];
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
_userConfig_serverPlugin = userConfig.serverPlugin, serverPlugin = _userConfig_serverPlugin === void 0 ? "@module-federation/modern-js/data-loader-server" : _userConfig_serverPlugin, transformRuntimeOptions = userConfig.transformRuntimeOptions;
|
|
51
51
|
appContext = useAppContext();
|
|
52
52
|
name = internalOptions.csrConfig.name;
|
|
53
|
+
_internalOptions_metaName = internalOptions.metaName, metaName = _internalOptions_metaName === void 0 ? META_NAME : _internalOptions_metaName;
|
|
53
54
|
internalDirectory = appContext.internalDirectory.replace(META_NAME, metaName || META_NAME);
|
|
54
55
|
transformRuntimeFn = transformRuntimeOptions || _transformRuntimeOptions;
|
|
55
56
|
partialSSRRemotes = [];
|
|
@@ -95,12 +96,16 @@ var moduleFederationDataLoaderPlugin = function(enable, internalOptions, userCon
|
|
|
95
96
|
plugins.push({
|
|
96
97
|
name: "ssrDataLoader",
|
|
97
98
|
path: "@module-federation/modern-js/data-loader",
|
|
98
|
-
config: {
|
|
99
|
+
config: {
|
|
100
|
+
metaName
|
|
101
|
+
}
|
|
99
102
|
});
|
|
100
103
|
plugins.push({
|
|
101
104
|
name: "ssrDataLoaderInjectAssets",
|
|
102
105
|
path: "@module-federation/modern-js/data-loader-inject-assets",
|
|
103
|
-
config: {
|
|
106
|
+
config: {
|
|
107
|
+
metaName
|
|
108
|
+
}
|
|
104
109
|
});
|
|
105
110
|
return {
|
|
106
111
|
entrypoint,
|
|
@@ -6,7 +6,7 @@ import { ModuleFederationPlugin } from "@module-federation/enhanced/webpack";
|
|
|
6
6
|
import { ModuleFederationPlugin as RspackModuleFederationPlugin } from "@module-federation/enhanced/rspack";
|
|
7
7
|
import UniverseEntryChunkTrackerPlugin from "@module-federation/node/universe-entry-chunk-tracker-plugin";
|
|
8
8
|
import { updateStatsAndManifest } from "./manifest";
|
|
9
|
-
import { isDev } from "../constant";
|
|
9
|
+
import { isDev, META_NAME } from "../constant";
|
|
10
10
|
function setEnv() {
|
|
11
11
|
process.env["MF_DISABLE_EMIT_STATS"] = "true";
|
|
12
12
|
process.env["MF_SSR_PRJ"] = "true";
|
|
@@ -20,10 +20,11 @@ var moduleFederationSSRPlugin = function(userConfig) {
|
|
|
20
20
|
],
|
|
21
21
|
setup: function() {
|
|
22
22
|
var _ref = _async_to_generator(function(param) {
|
|
23
|
-
var useConfigContext, useAppContext, _modernjsConfig_server, modernjsConfig, enableSSR;
|
|
23
|
+
var useConfigContext, useAppContext, _modernjsConfig_server, modernjsConfig, _userConfig_metaName, metaName, enableSSR;
|
|
24
24
|
return _ts_generator(this, function(_state) {
|
|
25
25
|
useConfigContext = param.useConfigContext, useAppContext = param.useAppContext;
|
|
26
26
|
modernjsConfig = useConfigContext();
|
|
27
|
+
_userConfig_metaName = userConfig.metaName, metaName = _userConfig_metaName === void 0 ? META_NAME : _userConfig_metaName;
|
|
27
28
|
enableSSR = Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
|
|
28
29
|
if (!enableSSR) {
|
|
29
30
|
return [
|
|
@@ -46,7 +47,9 @@ var moduleFederationSSRPlugin = function(userConfig) {
|
|
|
46
47
|
plugins.push({
|
|
47
48
|
name: "mfSSR",
|
|
48
49
|
path: "@module-federation/modern-js/ssr-runtime",
|
|
49
|
-
config: {
|
|
50
|
+
config: {
|
|
51
|
+
metaName
|
|
52
|
+
}
|
|
50
53
|
});
|
|
51
54
|
return {
|
|
52
55
|
entrypoint,
|
|
@@ -6,11 +6,12 @@ import { getInstance } from "@module-federation/enhanced/runtime";
|
|
|
6
6
|
import { collectSSRAssets } from "../createRemoteSSRComponent";
|
|
7
7
|
import { RuntimeReactContext } from "@meta/runtime";
|
|
8
8
|
import { decodeId, getRemoteId } from "./utils";
|
|
9
|
-
var ssrDataLoaderInjectAssetsPlugin = function() {
|
|
9
|
+
var ssrDataLoaderInjectAssetsPlugin = function(param) {
|
|
10
|
+
var metaName = param.metaName;
|
|
10
11
|
return {
|
|
11
12
|
name: "@modern-js/plugin-mf-data-loader-inject-assets",
|
|
12
13
|
pre: [
|
|
13
|
-
"@
|
|
14
|
+
"@".concat(metaName, "/plugin-router"),
|
|
14
15
|
"@modern-js/plugin-mf-data-loader"
|
|
15
16
|
],
|
|
16
17
|
setup: function() {
|
|
@@ -20,6 +21,7 @@ var ssrDataLoaderInjectAssetsPlugin = function() {
|
|
|
20
21
|
var _context_routerContext;
|
|
21
22
|
var instance = getInstance();
|
|
22
23
|
if (!instance || !instance.options.remotes.length) {
|
|
24
|
+
console.log("plugin-mf-data-loader-inject-assets no instance!");
|
|
23
25
|
return /* @__PURE__ */ _jsx(_Fragment, {
|
|
24
26
|
children: /* @__PURE__ */ _jsx(App, _object_spread({}, props))
|
|
25
27
|
});
|
|
@@ -42,9 +44,11 @@ var ssrDataLoaderInjectAssetsPlugin = function() {
|
|
|
42
44
|
remoteIds.forEach(function(remoteId) {
|
|
43
45
|
var _assets;
|
|
44
46
|
(_assets = assets).push.apply(_assets, _to_consumable_array(collectSSRAssets({
|
|
45
|
-
id: remoteId
|
|
47
|
+
id: remoteId,
|
|
48
|
+
injectScript: false
|
|
46
49
|
})));
|
|
47
50
|
});
|
|
51
|
+
console.log("plugin-mf-data-loader-inject-assets has assets: ", assets);
|
|
48
52
|
return /* @__PURE__ */ _jsxs(_Fragment, {
|
|
49
53
|
children: [
|
|
50
54
|
assets,
|
|
@@ -3,15 +3,15 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
|
3
3
|
import { getInstance } from "@module-federation/enhanced/runtime";
|
|
4
4
|
import { MF_ROUTES, DEFAULT_ENTRY } from "../../constant";
|
|
5
5
|
import { injectRemoteRoutes } from "./utils";
|
|
6
|
-
var ssrDataLoaderPlugin = function() {
|
|
6
|
+
var ssrDataLoaderPlugin = function(param) {
|
|
7
|
+
var metaName = param.metaName;
|
|
7
8
|
return {
|
|
8
9
|
name: "@modern-js/plugin-mf-data-loader",
|
|
9
10
|
post: [
|
|
10
|
-
"@
|
|
11
|
+
"@".concat(metaName, "/plugin-router")
|
|
11
12
|
],
|
|
12
13
|
setup: function() {
|
|
13
14
|
var remoteRoutesMap = {};
|
|
14
|
-
var pathRemoteMap = {};
|
|
15
15
|
return {
|
|
16
16
|
beforeRender: function beforeRender() {
|
|
17
17
|
return _async_to_generator(function() {
|
|
@@ -5,11 +5,12 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
5
5
|
import hoistNonReactStatics from "hoist-non-react-statics";
|
|
6
6
|
import { SSRLiveReload } from "./SSRLiveReload";
|
|
7
7
|
console.log("mfSSRPlugin trigger");
|
|
8
|
-
var mfSSRPlugin = function() {
|
|
8
|
+
var mfSSRPlugin = function(param) {
|
|
9
|
+
var metaName = param.metaName;
|
|
9
10
|
return {
|
|
10
11
|
name: "@module-federation/modern-js",
|
|
11
12
|
pre: [
|
|
12
|
-
"@
|
|
13
|
+
"@".concat(metaName, "/plugin-router")
|
|
13
14
|
],
|
|
14
15
|
setup: function() {
|
|
15
16
|
return {
|
|
@@ -19,6 +19,9 @@ function modifyBundlerConfig(options) {
|
|
|
19
19
|
}
|
|
20
20
|
const moduleFederationConfigPlugin = (userConfig) => ({
|
|
21
21
|
name: "@modern-js/plugin-module-federation-config",
|
|
22
|
+
pre: [
|
|
23
|
+
"@modern-js/plugin-initialize"
|
|
24
|
+
],
|
|
22
25
|
post: [
|
|
23
26
|
"@modern-js/plugin-module-federation"
|
|
24
27
|
],
|
|
@@ -34,14 +34,10 @@ const moduleFederationDataLoaderPlugin = (enable, internalOptions, userConfig) =
|
|
|
34
34
|
if (!enable) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
const {
|
|
38
|
-
// patchMFConfig,
|
|
39
|
-
metaName = META_NAME,
|
|
40
|
-
serverPlugin = "@module-federation/modern-js/data-loader-server",
|
|
41
|
-
transformRuntimeOptions
|
|
42
|
-
} = userConfig;
|
|
37
|
+
const { serverPlugin = "@module-federation/modern-js/data-loader-server", transformRuntimeOptions } = userConfig;
|
|
43
38
|
const appContext = useAppContext();
|
|
44
39
|
const name = internalOptions.csrConfig.name;
|
|
40
|
+
const { metaName = META_NAME } = internalOptions;
|
|
45
41
|
const internalDirectory = appContext.internalDirectory.replace(META_NAME, metaName || META_NAME);
|
|
46
42
|
const transformRuntimeFn = transformRuntimeOptions || _transformRuntimeOptions;
|
|
47
43
|
const partialSSRRemotes = [];
|
|
@@ -68,12 +64,16 @@ const moduleFederationDataLoaderPlugin = (enable, internalOptions, userConfig) =
|
|
|
68
64
|
plugins.push({
|
|
69
65
|
name: "ssrDataLoader",
|
|
70
66
|
path: "@module-federation/modern-js/data-loader",
|
|
71
|
-
config: {
|
|
67
|
+
config: {
|
|
68
|
+
metaName
|
|
69
|
+
}
|
|
72
70
|
});
|
|
73
71
|
plugins.push({
|
|
74
72
|
name: "ssrDataLoaderInjectAssets",
|
|
75
73
|
path: "@module-federation/modern-js/data-loader-inject-assets",
|
|
76
|
-
config: {
|
|
74
|
+
config: {
|
|
75
|
+
metaName
|
|
76
|
+
}
|
|
77
77
|
});
|
|
78
78
|
return {
|
|
79
79
|
entrypoint,
|
|
@@ -4,7 +4,7 @@ import { ModuleFederationPlugin } from "@module-federation/enhanced/webpack";
|
|
|
4
4
|
import { ModuleFederationPlugin as RspackModuleFederationPlugin } from "@module-federation/enhanced/rspack";
|
|
5
5
|
import UniverseEntryChunkTrackerPlugin from "@module-federation/node/universe-entry-chunk-tracker-plugin";
|
|
6
6
|
import { updateStatsAndManifest } from "./manifest";
|
|
7
|
-
import { isDev } from "../constant";
|
|
7
|
+
import { isDev, META_NAME } from "../constant";
|
|
8
8
|
function setEnv() {
|
|
9
9
|
process.env["MF_DISABLE_EMIT_STATS"] = "true";
|
|
10
10
|
process.env["MF_SSR_PRJ"] = "true";
|
|
@@ -18,6 +18,7 @@ const moduleFederationSSRPlugin = (userConfig) => ({
|
|
|
18
18
|
setup: async ({ useConfigContext, useAppContext }) => {
|
|
19
19
|
var _modernjsConfig_server;
|
|
20
20
|
const modernjsConfig = useConfigContext();
|
|
21
|
+
const { metaName = META_NAME } = userConfig;
|
|
21
22
|
const enableSSR = Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
|
|
22
23
|
if (!enableSSR) {
|
|
23
24
|
return {};
|
|
@@ -34,7 +35,9 @@ const moduleFederationSSRPlugin = (userConfig) => ({
|
|
|
34
35
|
plugins.push({
|
|
35
36
|
name: "mfSSR",
|
|
36
37
|
path: "@module-federation/modern-js/ssr-runtime",
|
|
37
|
-
config: {
|
|
38
|
+
config: {
|
|
39
|
+
metaName
|
|
40
|
+
}
|
|
38
41
|
});
|
|
39
42
|
return {
|
|
40
43
|
entrypoint,
|
|
@@ -4,11 +4,11 @@ import { getInstance } from "@module-federation/enhanced/runtime";
|
|
|
4
4
|
import { collectSSRAssets } from "../createRemoteSSRComponent";
|
|
5
5
|
import { RuntimeReactContext } from "@meta/runtime";
|
|
6
6
|
import { decodeId, getRemoteId } from "./utils";
|
|
7
|
-
const ssrDataLoaderInjectAssetsPlugin = () => {
|
|
7
|
+
const ssrDataLoaderInjectAssetsPlugin = ({ metaName }) => {
|
|
8
8
|
return {
|
|
9
9
|
name: "@modern-js/plugin-mf-data-loader-inject-assets",
|
|
10
10
|
pre: [
|
|
11
|
-
|
|
11
|
+
`@${metaName}/plugin-router`,
|
|
12
12
|
"@modern-js/plugin-mf-data-loader"
|
|
13
13
|
],
|
|
14
14
|
setup: () => {
|
|
@@ -18,6 +18,7 @@ const ssrDataLoaderInjectAssetsPlugin = () => {
|
|
|
18
18
|
var _context_routerContext;
|
|
19
19
|
const instance = getInstance();
|
|
20
20
|
if (!instance || !instance.options.remotes.length) {
|
|
21
|
+
console.log("plugin-mf-data-loader-inject-assets no instance!");
|
|
21
22
|
return /* @__PURE__ */ _jsx(_Fragment, {
|
|
22
23
|
children: /* @__PURE__ */ _jsx(App, {
|
|
23
24
|
...props
|
|
@@ -37,9 +38,11 @@ const ssrDataLoaderInjectAssetsPlugin = () => {
|
|
|
37
38
|
const assets = [];
|
|
38
39
|
remoteIds.forEach((remoteId) => {
|
|
39
40
|
assets.push(...collectSSRAssets({
|
|
40
|
-
id: remoteId
|
|
41
|
+
id: remoteId,
|
|
42
|
+
injectScript: false
|
|
41
43
|
}));
|
|
42
44
|
});
|
|
45
|
+
console.log("plugin-mf-data-loader-inject-assets has assets: ", assets);
|
|
43
46
|
return /* @__PURE__ */ _jsxs(_Fragment, {
|
|
44
47
|
children: [
|
|
45
48
|
assets,
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { getInstance } from "@module-federation/enhanced/runtime";
|
|
2
2
|
import { MF_ROUTES, DEFAULT_ENTRY } from "../../constant";
|
|
3
3
|
import { injectRemoteRoutes } from "./utils";
|
|
4
|
-
const ssrDataLoaderPlugin = () => {
|
|
4
|
+
const ssrDataLoaderPlugin = ({ metaName }) => {
|
|
5
5
|
return {
|
|
6
6
|
name: "@modern-js/plugin-mf-data-loader",
|
|
7
7
|
post: [
|
|
8
|
-
|
|
8
|
+
`@${metaName}/plugin-router`
|
|
9
9
|
],
|
|
10
10
|
setup: () => {
|
|
11
11
|
const remoteRoutesMap = {};
|
|
12
|
-
const pathRemoteMap = {};
|
|
13
12
|
return {
|
|
14
13
|
async beforeRender() {
|
|
15
14
|
console.log("init");
|
|
@@ -2,10 +2,10 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import hoistNonReactStatics from "hoist-non-react-statics";
|
|
3
3
|
import { SSRLiveReload } from "./SSRLiveReload";
|
|
4
4
|
console.log("mfSSRPlugin trigger");
|
|
5
|
-
const mfSSRPlugin = () => ({
|
|
5
|
+
const mfSSRPlugin = ({ metaName }) => ({
|
|
6
6
|
name: "@module-federation/modern-js",
|
|
7
7
|
pre: [
|
|
8
|
-
|
|
8
|
+
`@${metaName}/plugin-router`
|
|
9
9
|
],
|
|
10
10
|
setup: () => {
|
|
11
11
|
return {
|
|
@@ -9,6 +9,7 @@ export interface PluginOptions {
|
|
|
9
9
|
dataLoader?: boolean | DataLoaderOptions;
|
|
10
10
|
}
|
|
11
11
|
export interface InternalModernPluginOptions {
|
|
12
|
+
metaName?: string;
|
|
12
13
|
csrConfig?: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
13
14
|
ssrConfig?: moduleFederationPlugin.ModuleFederationPluginOptions;
|
|
14
15
|
distOutputDir: string;
|
|
@@ -21,7 +22,6 @@ export type BundlerPlugin = WebpackModuleFederationPlugin | RspackModuleFederati
|
|
|
21
22
|
export type TransformRuntimeOptions = (mfConfig: moduleFederationPlugin.ModuleFederationPluginOptions) => Parameters<typeof init>[0];
|
|
22
23
|
export type DataLoaderOptions = {
|
|
23
24
|
partialSSRRemotes?: string[];
|
|
24
|
-
metaName?: string;
|
|
25
25
|
serverPlugin?: string;
|
|
26
26
|
transformRuntimeOptions?: TransformRuntimeOptions;
|
|
27
27
|
};
|
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-20240912070754",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist/",
|
|
6
6
|
"types.d.ts",
|
|
@@ -94,9 +94,9 @@
|
|
|
94
94
|
"@babel/parser": "7.25.3",
|
|
95
95
|
"@babel/traverse": "7.25.3",
|
|
96
96
|
"@babel/types": "7.25.2",
|
|
97
|
-
"@module-federation/sdk": "0.0.0-next-
|
|
98
|
-
"@module-federation/enhanced": "0.0.0-next-
|
|
99
|
-
"@module-federation/node": "0.0.0-next-
|
|
97
|
+
"@module-federation/sdk": "0.0.0-next-20240912070754",
|
|
98
|
+
"@module-federation/enhanced": "0.0.0-next-20240912070754",
|
|
99
|
+
"@module-federation/node": "0.0.0-next-20240912070754"
|
|
100
100
|
},
|
|
101
101
|
"devDependencies": {
|
|
102
102
|
"@types/babel__traverse": "7.20.6",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"@modern-js/runtime": "^2.59.0",
|
|
109
109
|
"@modern-js/module-tools": "^2.59.0",
|
|
110
110
|
"@modern-js/tsconfig": "^2.59.0",
|
|
111
|
-
"@module-federation/manifest": "0.0.0-next-
|
|
111
|
+
"@module-federation/manifest": "0.0.0-next-20240912070754"
|
|
112
112
|
},
|
|
113
113
|
"peerDependencies": {
|
|
114
114
|
"@modern-js/runtime": "^2.59.0",
|