@module-federation/modern-js 0.8.9 → 0.8.10
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 +63 -65
- package/dist/cjs/cli/index.js +32 -34
- package/dist/cjs/cli/ssrPlugin.js +83 -85
- package/dist/cjs/ssr-runtime/plugin.js +24 -32
- package/dist/esm/cli/configPlugin.js +73 -80
- package/dist/esm/cli/index.js +43 -51
- package/dist/esm/cli/ssrPlugin.js +100 -108
- package/dist/esm/ssr-runtime/plugin.js +55 -67
- package/dist/esm-node/cli/configPlugin.js +63 -65
- package/dist/esm-node/cli/index.js +32 -34
- package/dist/esm-node/cli/ssrPlugin.js +83 -85
- package/dist/esm-node/ssr-runtime/plugin.js +24 -32
- package/dist/types/cli/configPlugin.d.ts +2 -2
- package/dist/types/cli/index.d.ts +2 -2
- package/dist/types/cli/ssrPlugin.d.ts +2 -2
- package/dist/types/ssr-runtime/plugin.d.ts +2 -2
- package/package.json +14 -16
|
@@ -61,80 +61,78 @@ const moduleFederationConfigPlugin = (userConfig) => ({
|
|
|
61
61
|
post: [
|
|
62
62
|
"@modern-js/plugin-module-federation"
|
|
63
63
|
],
|
|
64
|
-
setup: async (
|
|
65
|
-
const modernjsConfig =
|
|
64
|
+
setup: async (api) => {
|
|
65
|
+
const modernjsConfig = api.getConfig();
|
|
66
66
|
const mfConfig = await (0, import_utils.getMFConfig)(userConfig.originPluginOptions);
|
|
67
67
|
const csrConfig = userConfig.csrConfig || JSON.parse(JSON.stringify(mfConfig));
|
|
68
68
|
const ssrConfig = userConfig.ssrConfig || JSON.parse(JSON.stringify(mfConfig));
|
|
69
69
|
userConfig.ssrConfig = ssrConfig;
|
|
70
70
|
userConfig.csrConfig = csrConfig;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
userConfig.remoteIpStrategy = "ipv4";
|
|
82
|
-
}
|
|
71
|
+
api.config(() => {
|
|
72
|
+
var _userConfig_userConfig, _modernjsConfig_server, _modernjsConfig_source, _modernjsConfig_source1, _modernjsConfig_dev;
|
|
73
|
+
const bundlerType = api.getAppContext().bundlerType === "rspack" ? "rspack" : "webpack";
|
|
74
|
+
const ipv4 = (0, import_utils.getIPV4)();
|
|
75
|
+
const enableSSR = ((_userConfig_userConfig = userConfig.userConfig) === null || _userConfig_userConfig === void 0 ? void 0 : _userConfig_userConfig.ssr) === false ? false : Boolean(modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_server = modernjsConfig.server) === null || _modernjsConfig_server === void 0 ? void 0 : _modernjsConfig_server.ssr);
|
|
76
|
+
if (userConfig.remoteIpStrategy === void 0) {
|
|
77
|
+
if (!enableSSR) {
|
|
78
|
+
userConfig.remoteIpStrategy = "inherit";
|
|
79
|
+
} else {
|
|
80
|
+
userConfig.remoteIpStrategy = "ipv4";
|
|
83
81
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
rspack(config, { isServer }) {
|
|
91
|
-
var _config_output;
|
|
92
|
-
modifyBundlerConfig({
|
|
93
|
-
bundlerType,
|
|
94
|
-
mfConfig: isServer ? ssrConfig : csrConfig,
|
|
95
|
-
config,
|
|
96
|
-
isServer,
|
|
97
|
-
modernjsConfig,
|
|
98
|
-
remoteIpStrategy: userConfig.remoteIpStrategy
|
|
99
|
-
});
|
|
100
|
-
userConfig.distOutputDir = ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.path) || import_path.default.resolve(process.cwd(), "dist");
|
|
101
|
-
},
|
|
102
|
-
webpack(config, { isServer }) {
|
|
103
|
-
var _config_output;
|
|
104
|
-
modifyBundlerConfig({
|
|
105
|
-
bundlerType,
|
|
106
|
-
mfConfig: isServer ? ssrConfig : csrConfig,
|
|
107
|
-
config,
|
|
108
|
-
isServer,
|
|
109
|
-
modernjsConfig,
|
|
110
|
-
remoteIpStrategy: userConfig.remoteIpStrategy
|
|
111
|
-
});
|
|
112
|
-
userConfig.distOutputDir = ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.path) || import_path.default.resolve(process.cwd(), "dist");
|
|
113
|
-
},
|
|
114
|
-
devServer: {
|
|
115
|
-
headers: {
|
|
116
|
-
"Access-Control-Allow-Origin": "*",
|
|
117
|
-
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
118
|
-
"Access-Control-Allow-Headers": "*"
|
|
119
|
-
}
|
|
120
|
-
}
|
|
82
|
+
}
|
|
83
|
+
var _modernjsConfig_source_enableAsyncEntry;
|
|
84
|
+
return {
|
|
85
|
+
tools: {
|
|
86
|
+
bundlerChain(chain, { isServer }) {
|
|
87
|
+
(0, import_utils.addMyTypes2Ignored)(chain, isServer ? ssrConfig : csrConfig);
|
|
121
88
|
},
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
89
|
+
rspack(config, { isServer }) {
|
|
90
|
+
var _config_output;
|
|
91
|
+
modifyBundlerConfig({
|
|
92
|
+
bundlerType,
|
|
93
|
+
mfConfig: isServer ? ssrConfig : csrConfig,
|
|
94
|
+
config,
|
|
95
|
+
isServer,
|
|
96
|
+
modernjsConfig,
|
|
97
|
+
remoteIpStrategy: userConfig.remoteIpStrategy
|
|
98
|
+
});
|
|
99
|
+
userConfig.distOutputDir = ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.path) || import_path.default.resolve(process.cwd(), "dist");
|
|
131
100
|
},
|
|
132
|
-
|
|
133
|
-
|
|
101
|
+
webpack(config, { isServer }) {
|
|
102
|
+
var _config_output;
|
|
103
|
+
modifyBundlerConfig({
|
|
104
|
+
bundlerType,
|
|
105
|
+
mfConfig: isServer ? ssrConfig : csrConfig,
|
|
106
|
+
config,
|
|
107
|
+
isServer,
|
|
108
|
+
modernjsConfig,
|
|
109
|
+
remoteIpStrategy: userConfig.remoteIpStrategy
|
|
110
|
+
});
|
|
111
|
+
userConfig.distOutputDir = ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.path) || import_path.default.resolve(process.cwd(), "dist");
|
|
112
|
+
},
|
|
113
|
+
devServer: {
|
|
114
|
+
headers: {
|
|
115
|
+
"Access-Control-Allow-Origin": "*",
|
|
116
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
117
|
+
"Access-Control-Allow-Headers": "*"
|
|
118
|
+
}
|
|
134
119
|
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
120
|
+
},
|
|
121
|
+
source: {
|
|
122
|
+
alias: {
|
|
123
|
+
"@modern-js/runtime/mf": require.resolve("@module-federation/modern-js/runtime")
|
|
124
|
+
},
|
|
125
|
+
define: {
|
|
126
|
+
FEDERATION_IPV4: JSON.stringify(ipv4),
|
|
127
|
+
REMOTE_IP_STRATEGY: JSON.stringify(userConfig.remoteIpStrategy)
|
|
128
|
+
},
|
|
129
|
+
enableAsyncEntry: bundlerType === "rspack" ? (_modernjsConfig_source_enableAsyncEntry = (_modernjsConfig_source = modernjsConfig.source) === null || _modernjsConfig_source === void 0 ? void 0 : _modernjsConfig_source.enableAsyncEntry) !== null && _modernjsConfig_source_enableAsyncEntry !== void 0 ? _modernjsConfig_source_enableAsyncEntry : true : (_modernjsConfig_source1 = modernjsConfig.source) === null || _modernjsConfig_source1 === void 0 ? void 0 : _modernjsConfig_source1.enableAsyncEntry
|
|
130
|
+
},
|
|
131
|
+
dev: {
|
|
132
|
+
assetPrefix: (modernjsConfig === null || modernjsConfig === void 0 ? void 0 : (_modernjsConfig_dev = modernjsConfig.dev) === null || _modernjsConfig_dev === void 0 ? void 0 : _modernjsConfig_dev.assetPrefix) ? modernjsConfig.dev.assetPrefix : true
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
});
|
|
138
136
|
}
|
|
139
137
|
});
|
|
140
138
|
var configPlugin_default = moduleFederationConfigPlugin;
|
package/dist/cjs/cli/index.js
CHANGED
|
@@ -41,42 +41,40 @@ const moduleFederationPlugin = (userConfig = {}) => {
|
|
|
41
41
|
};
|
|
42
42
|
return {
|
|
43
43
|
name: "@modern-js/plugin-module-federation",
|
|
44
|
-
setup: async (
|
|
45
|
-
const modernjsConfig =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
(_config_plugins1 = config.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(new import_enhanced.AsyncBoundaryPlugin(asyncBoundaryPluginOptions));
|
|
74
|
-
}
|
|
44
|
+
setup: async (api) => {
|
|
45
|
+
const modernjsConfig = api.getConfig();
|
|
46
|
+
api.config(() => {
|
|
47
|
+
return {
|
|
48
|
+
tools: {
|
|
49
|
+
rspack(config, { isServer }) {
|
|
50
|
+
const browserPluginOptions = internalModernPluginOptions.csrConfig;
|
|
51
|
+
if (!isServer) {
|
|
52
|
+
var _config_plugins;
|
|
53
|
+
internalModernPluginOptions.browserPlugin = new import_rspack.ModuleFederationPlugin(browserPluginOptions);
|
|
54
|
+
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(internalModernPluginOptions.browserPlugin);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
webpack(config, { isServer }) {
|
|
58
|
+
var _modernjsConfig_source;
|
|
59
|
+
const browserPluginOptions = internalModernPluginOptions.csrConfig;
|
|
60
|
+
if (!isServer) {
|
|
61
|
+
var _config_plugins;
|
|
62
|
+
internalModernPluginOptions.browserPlugin = new import_enhanced.ModuleFederationPlugin(browserPluginOptions);
|
|
63
|
+
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(internalModernPluginOptions.browserPlugin);
|
|
64
|
+
}
|
|
65
|
+
const enableAsyncEntry = (_modernjsConfig_source = modernjsConfig.source) === null || _modernjsConfig_source === void 0 ? void 0 : _modernjsConfig_source.enableAsyncEntry;
|
|
66
|
+
if (!enableAsyncEntry && browserPluginOptions.async !== false) {
|
|
67
|
+
var _config_plugins1;
|
|
68
|
+
const asyncBoundaryPluginOptions = typeof browserPluginOptions.async === "object" ? browserPluginOptions.async : {
|
|
69
|
+
eager: (module2) => module2 && /\.federation/.test((module2 === null || module2 === void 0 ? void 0 : module2.request) || ""),
|
|
70
|
+
excludeChunk: (chunk) => chunk.name === browserPluginOptions.name
|
|
71
|
+
};
|
|
72
|
+
(_config_plugins1 = config.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(new import_enhanced.AsyncBoundaryPlugin(asyncBoundaryPluginOptions));
|
|
75
73
|
}
|
|
76
74
|
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
};
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
});
|
|
80
78
|
},
|
|
81
79
|
usePlugins: [
|
|
82
80
|
(0, import_configPlugin.moduleFederationConfigPlugin)(internalModernPluginOptions),
|
|
@@ -51,110 +51,108 @@ const moduleFederationSSRPlugin = (pluginOptions) => ({
|
|
|
51
51
|
"@modern-js/plugin-module-federation-config",
|
|
52
52
|
"@modern-js/plugin-module-federation"
|
|
53
53
|
],
|
|
54
|
-
setup: async (
|
|
54
|
+
setup: async (api) => {
|
|
55
55
|
var _modernjsConfig_server, _pluginOptions_userConfig;
|
|
56
|
-
const modernjsConfig =
|
|
56
|
+
const modernjsConfig = api.getConfig();
|
|
57
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);
|
|
58
58
|
if (!enableSSR || ((_pluginOptions_userConfig = pluginOptions.userConfig) === null || _pluginOptions_userConfig === void 0 ? void 0 : _pluginOptions_userConfig.ssr) === false) {
|
|
59
59
|
return {};
|
|
60
60
|
}
|
|
61
61
|
setEnv();
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (!import_constant.isDev) {
|
|
65
|
-
return {
|
|
66
|
-
entrypoint,
|
|
67
|
-
plugins
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
plugins.push({
|
|
71
|
-
name: "mfSSR",
|
|
72
|
-
path: "@module-federation/modern-js/ssr-runtime",
|
|
73
|
-
config: {}
|
|
74
|
-
});
|
|
62
|
+
api._internalRuntimePlugins(({ entrypoint, plugins }) => {
|
|
63
|
+
if (!import_constant.isDev) {
|
|
75
64
|
return {
|
|
76
65
|
entrypoint,
|
|
77
66
|
plugins
|
|
78
67
|
};
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
68
|
+
}
|
|
69
|
+
plugins.push({
|
|
70
|
+
name: "mfSSR",
|
|
71
|
+
path: "@module-federation/modern-js/ssr-runtime",
|
|
72
|
+
config: {}
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
entrypoint,
|
|
76
|
+
plugins
|
|
77
|
+
};
|
|
78
|
+
});
|
|
79
|
+
api.config(() => {
|
|
80
|
+
return {
|
|
81
|
+
tools: {
|
|
82
|
+
rspack(config, { isServer }) {
|
|
83
|
+
if (isServer) {
|
|
84
|
+
if (!pluginOptions.nodePlugin) {
|
|
85
|
+
var _config_plugins;
|
|
86
|
+
pluginOptions.nodePlugin = new import_rspack.ModuleFederationPlugin(pluginOptions.ssrConfig);
|
|
87
|
+
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(pluginOptions.nodePlugin);
|
|
93
88
|
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
89
|
+
} else {
|
|
90
|
+
var _config_output;
|
|
91
|
+
pluginOptions.distOutputDir = pluginOptions.distOutputDir || ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.path) || import_path.default.resolve(process.cwd(), "dist");
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
webpack(config, { isServer }) {
|
|
95
|
+
if (isServer) {
|
|
96
|
+
if (!pluginOptions.nodePlugin) {
|
|
97
|
+
var _config_plugins;
|
|
98
|
+
pluginOptions.nodePlugin = new import_webpack.ModuleFederationPlugin(pluginOptions.ssrConfig);
|
|
99
|
+
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(pluginOptions.nodePlugin);
|
|
105
100
|
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
101
|
+
} else {
|
|
102
|
+
var _config_output;
|
|
103
|
+
pluginOptions.distOutputDir = pluginOptions.distOutputDir || ((_config_output = config.output) === null || _config_output === void 0 ? void 0 : _config_output.path) || import_path.default.resolve(process.cwd(), "dist");
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
devServer: {
|
|
107
|
+
before: [
|
|
108
|
+
(req, res, next) => {
|
|
109
|
+
if (!enableSSR) {
|
|
110
|
+
next();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
var _req_url, _req_url1;
|
|
115
|
+
if (((_req_url = req.url) === null || _req_url === void 0 ? void 0 : _req_url.includes(".json")) && !((_req_url1 = req.url) === null || _req_url1 === void 0 ? void 0 : _req_url1.includes("hot-update"))) {
|
|
116
|
+
const filepath = import_path.default.join(process.cwd(), `dist${req.url}`);
|
|
117
|
+
import_utils.fs.statSync(filepath);
|
|
118
|
+
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
119
|
+
res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, PATCH, OPTIONS");
|
|
120
|
+
res.setHeader("Access-Control-Allow-Headers", "*");
|
|
121
|
+
import_utils.fs.createReadStream(filepath).pipe(res);
|
|
122
|
+
} else {
|
|
128
123
|
next();
|
|
129
124
|
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
bundlerChain(chain, { isServer }) {
|
|
134
|
-
if (isServer) {
|
|
135
|
-
chain.target("async-node");
|
|
136
|
-
if (import_constant.isDev) {
|
|
137
|
-
chain.plugin("UniverseEntryChunkTrackerPlugin").use(import_universe_entry_chunk_tracker_plugin.default);
|
|
125
|
+
} catch (err) {
|
|
126
|
+
import_logger.default.debug(err);
|
|
127
|
+
next();
|
|
138
128
|
}
|
|
139
129
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
130
|
+
]
|
|
131
|
+
},
|
|
132
|
+
bundlerChain(chain, { isServer }) {
|
|
133
|
+
if (isServer) {
|
|
134
|
+
chain.target("async-node");
|
|
135
|
+
if (import_constant.isDev) {
|
|
136
|
+
chain.plugin("UniverseEntryChunkTrackerPlugin").use(import_universe_entry_chunk_tracker_plugin.default);
|
|
144
137
|
}
|
|
145
138
|
}
|
|
139
|
+
if (import_constant.isDev && !isServer) {
|
|
140
|
+
chain.externals({
|
|
141
|
+
"@module-federation/node/utils": "NOT_USED_IN_BROWSER"
|
|
142
|
+
});
|
|
143
|
+
}
|
|
146
144
|
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
};
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
});
|
|
148
|
+
api.onAfterBuild(() => {
|
|
149
|
+
const { nodePlugin, browserPlugin, distOutputDir } = pluginOptions;
|
|
150
|
+
(0, import_manifest.updateStatsAndManifest)(nodePlugin, browserPlugin, distOutputDir);
|
|
151
|
+
});
|
|
152
|
+
api.onDevCompileDone(() => {
|
|
153
|
+
const { nodePlugin, browserPlugin, distOutputDir } = pluginOptions;
|
|
154
|
+
(0, import_manifest.updateStatsAndManifest)(nodePlugin, browserPlugin, distOutputDir);
|
|
155
|
+
});
|
|
158
156
|
}
|
|
159
157
|
});
|
|
160
158
|
var ssrPlugin_default = moduleFederationSSRPlugin;
|
|
@@ -32,42 +32,34 @@ __export(plugin_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(plugin_exports);
|
|
34
34
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
-
var import_hoist_non_react_statics = __toESM(require("hoist-non-react-statics"));
|
|
36
35
|
var import_SSRLiveReload = require("./SSRLiveReload");
|
|
37
36
|
const mfSSRPlugin = () => ({
|
|
38
37
|
name: "@module-federation/modern-js",
|
|
39
|
-
setup: () => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return next({
|
|
44
|
-
context
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
globalThis.shouldUpdate = false;
|
|
48
|
-
const nodeUtils = await Promise.resolve().then(() => __toESM(require("@module-federation/node/utils")));
|
|
49
|
-
const shouldUpdate = await nodeUtils.revalidate();
|
|
50
|
-
if (shouldUpdate) {
|
|
51
|
-
console.log("should RELOAD", shouldUpdate);
|
|
52
|
-
await nodeUtils.flushChunks();
|
|
53
|
-
globalThis.shouldUpdate = true;
|
|
54
|
-
}
|
|
55
|
-
return next({
|
|
56
|
-
context
|
|
57
|
-
});
|
|
58
|
-
},
|
|
59
|
-
wrapRoot(App) {
|
|
60
|
-
const AppWrapper = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
61
|
-
children: [
|
|
62
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_SSRLiveReload.SSRLiveReload, {}),
|
|
63
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, {
|
|
64
|
-
...props
|
|
65
|
-
})
|
|
66
|
-
]
|
|
67
|
-
});
|
|
68
|
-
return (0, import_hoist_non_react_statics.default)(AppWrapper, App);
|
|
38
|
+
setup: (api) => {
|
|
39
|
+
api.onBeforeRender(async () => {
|
|
40
|
+
if (typeof window !== "undefined") {
|
|
41
|
+
return;
|
|
69
42
|
}
|
|
70
|
-
|
|
43
|
+
globalThis.shouldUpdate = false;
|
|
44
|
+
const nodeUtils = await Promise.resolve().then(() => __toESM(require("@module-federation/node/utils")));
|
|
45
|
+
const shouldUpdate = await nodeUtils.revalidate();
|
|
46
|
+
if (shouldUpdate) {
|
|
47
|
+
console.log("should RELOAD", shouldUpdate);
|
|
48
|
+
await nodeUtils.flushChunks();
|
|
49
|
+
globalThis.shouldUpdate = true;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
api.wrapRoot((App) => {
|
|
53
|
+
const AppWrapper = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, {
|
|
54
|
+
children: [
|
|
55
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_SSRLiveReload.SSRLiveReload, {}),
|
|
56
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(App, {
|
|
57
|
+
...props
|
|
58
|
+
})
|
|
59
|
+
]
|
|
60
|
+
});
|
|
61
|
+
return AppWrapper;
|
|
62
|
+
});
|
|
71
63
|
}
|
|
72
64
|
});
|
|
73
65
|
// Annotate the CommonJS export names for ESM import in node:
|