@modern-js/plugin-garfish 2.27.0 → 2.28.0
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/CHANGELOG.md +8 -0
- package/dist/cjs/cli/index.js +241 -243
- package/dist/cjs/cli/utils.js +8 -8
- package/dist/cjs/runtime/loadable.js +2 -2
- package/dist/cjs/runtime/plugin.js +12 -9
- package/dist/cjs/runtime/utils/MApp.js +18 -9
- package/dist/cjs/runtime/utils/apps.js +19 -12
- package/dist/cjs/util.js +2 -1
- package/dist/esm/cli/index.js +15 -15
- package/dist/esm/cli/utils.js +8 -8
- package/dist/esm/runtime/loadable.js +2 -2
- package/dist/esm/runtime/plugin.js +10 -8
- package/dist/esm/runtime/utils/MApp.js +18 -9
- package/dist/esm/runtime/utils/apps.js +18 -13
- package/dist/esm/util.js +2 -1
- package/dist/esm-node/cli/index.js +241 -243
- package/dist/esm-node/cli/utils.js +8 -8
- package/dist/esm-node/runtime/loadable.js +2 -2
- package/dist/esm-node/runtime/plugin.js +12 -9
- package/dist/esm-node/runtime/utils/MApp.js +18 -9
- package/dist/esm-node/runtime/utils/apps.js +19 -12
- package/dist/esm-node/util.js +2 -1
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
package/dist/cjs/cli/index.js
CHANGED
|
@@ -44,286 +44,284 @@ function getDefaultMicroFrontedConfig(microFrontend) {
|
|
|
44
44
|
...microFrontend
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
|
-
const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtimePluginName = "@modern-js/runtime/plugins" } = {}) => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
]
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
target: "dev.withMasterApp",
|
|
66
|
-
schema: {
|
|
67
|
-
type: [
|
|
68
|
-
"object"
|
|
69
|
-
]
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
target: "deploy.microFrontend",
|
|
74
|
-
schema: {
|
|
75
|
-
type: [
|
|
76
|
-
"boolean",
|
|
77
|
-
"object"
|
|
78
|
-
]
|
|
79
|
-
}
|
|
47
|
+
const garfishPlugin = ({ pluginName = "@modern-js/plugin-garfish", runtimePluginName = "@modern-js/runtime/plugins" } = {}) => ({
|
|
48
|
+
name: "@modern-js/plugin-garfish",
|
|
49
|
+
setup: ({ useAppContext, useResolvedConfigContext, useConfigContext }) => {
|
|
50
|
+
let pluginsExportsUtils;
|
|
51
|
+
return {
|
|
52
|
+
validateSchema() {
|
|
53
|
+
return [
|
|
54
|
+
{
|
|
55
|
+
target: "runtime.masterApp",
|
|
56
|
+
schema: {
|
|
57
|
+
type: [
|
|
58
|
+
"boolean",
|
|
59
|
+
"object"
|
|
60
|
+
]
|
|
80
61
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
...resolved
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
target: "dev.withMasterApp",
|
|
65
|
+
schema: {
|
|
66
|
+
type: [
|
|
67
|
+
"object"
|
|
68
|
+
]
|
|
89
69
|
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
target: "deploy.microFrontend",
|
|
73
|
+
schema: {
|
|
74
|
+
type: [
|
|
75
|
+
"boolean",
|
|
76
|
+
"object"
|
|
77
|
+
]
|
|
97
78
|
}
|
|
98
|
-
(0, _utils1.setRuntimeConfig)(nConfig.resolved, "masterApp", Object.assign(typeof masterApp === "object" ? {
|
|
99
|
-
...masterApp
|
|
100
|
-
} : {}, {
|
|
101
|
-
basename: baseUrl || (router === null || router === void 0 ? void 0 : (_router_historyOptions = router.historyOptions) === null || _router_historyOptions === void 0 ? void 0 : _router_historyOptions.basename) || (router === null || router === void 0 ? void 0 : router.basename) || "/"
|
|
102
|
-
}));
|
|
103
79
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
80
|
+
];
|
|
81
|
+
},
|
|
82
|
+
resolvedConfig: async (config) => {
|
|
83
|
+
const { resolved } = config;
|
|
84
|
+
const { masterApp, router } = (0, _utils1.getRuntimeConfig)(resolved);
|
|
85
|
+
const nConfig = {
|
|
86
|
+
resolved: {
|
|
87
|
+
...resolved
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
if (masterApp) {
|
|
91
|
+
var _useConfig_server, _useConfig, _router_historyOptions, _router, _router1;
|
|
114
92
|
const useConfig = useConfigContext();
|
|
115
|
-
(0
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
let disableCssExtract = ((_useConfig_output = useConfig.output) === null || _useConfig_output === void 0 ? void 0 : _useConfig_output.disableCssExtract) || false;
|
|
119
|
-
if ((_useConfig_deploy = useConfig.deploy) === null || _useConfig_deploy === void 0 ? void 0 : _useConfig_deploy.microFrontend) {
|
|
120
|
-
var _useConfig_deploy1;
|
|
121
|
-
const { enableHtmlEntry } = getDefaultMicroFrontedConfig((_useConfig_deploy1 = useConfig.deploy) === null || _useConfig_deploy1 === void 0 ? void 0 : _useConfig_deploy1.microFrontend);
|
|
122
|
-
if (!enableHtmlEntry) {
|
|
123
|
-
disableCssExtract = true;
|
|
124
|
-
}
|
|
93
|
+
const baseUrl = (_useConfig = useConfig) === null || _useConfig === void 0 ? void 0 : (_useConfig_server = _useConfig.server) === null || _useConfig_server === void 0 ? void 0 : _useConfig_server.baseUrl;
|
|
94
|
+
if (Array.isArray(baseUrl)) {
|
|
95
|
+
throw new Error("Now Micro-Front-End mode dose not support multiple baseUrl, you can set it as a string");
|
|
125
96
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
97
|
+
(0, _utils1.setRuntimeConfig)(nConfig.resolved, "masterApp", Object.assign(typeof masterApp === "object" ? {
|
|
98
|
+
...masterApp
|
|
99
|
+
} : {}, {
|
|
100
|
+
basename: baseUrl || ((_router = router) === null || _router === void 0 ? void 0 : (_router_historyOptions = _router.historyOptions) === null || _router_historyOptions === void 0 ? void 0 : _router_historyOptions.basename) || ((_router1 = router) === null || _router1 === void 0 ? void 0 : _router1.basename) || "/"
|
|
101
|
+
}));
|
|
102
|
+
}
|
|
103
|
+
(0, _util.logger)(`resolvedConfig`, {
|
|
104
|
+
output: nConfig.resolved.output,
|
|
105
|
+
runtime: nConfig.resolved.runtime,
|
|
106
|
+
deploy: nConfig.resolved.deploy,
|
|
107
|
+
server: nConfig.resolved.server
|
|
108
|
+
});
|
|
109
|
+
return nConfig;
|
|
110
|
+
},
|
|
111
|
+
config() {
|
|
112
|
+
var _useConfig_output, _useConfig_deploy;
|
|
113
|
+
const useConfig = useConfigContext();
|
|
114
|
+
(0, _util.logger)("useConfig", useConfig);
|
|
115
|
+
const config = useAppContext();
|
|
116
|
+
pluginsExportsUtils = (0, _utils.createRuntimeExportsUtils)(config.internalDirectory, "plugins");
|
|
117
|
+
let disableCssExtract = ((_useConfig_output = useConfig.output) === null || _useConfig_output === void 0 ? void 0 : _useConfig_output.disableCssExtract) || false;
|
|
118
|
+
if ((_useConfig_deploy = useConfig.deploy) === null || _useConfig_deploy === void 0 ? void 0 : _useConfig_deploy.microFrontend) {
|
|
119
|
+
var _useConfig_deploy1;
|
|
120
|
+
const { enableHtmlEntry } = getDefaultMicroFrontedConfig((_useConfig_deploy1 = useConfig.deploy) === null || _useConfig_deploy1 === void 0 ? void 0 : _useConfig_deploy1.microFrontend);
|
|
121
|
+
if (!enableHtmlEntry) {
|
|
122
|
+
disableCssExtract = true;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
output: {
|
|
127
|
+
disableCssExtract
|
|
128
|
+
},
|
|
129
|
+
source: {
|
|
130
|
+
alias: {
|
|
131
|
+
"@modern-js/runtime/plugins": pluginsExportsUtils.getPath(),
|
|
132
|
+
"@modern-js/runtime/garfish": "@modern-js/plugin-garfish/runtime"
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
tools: {
|
|
136
|
+
devServer: {
|
|
137
|
+
headers: {
|
|
138
|
+
"Access-Control-Allow-Origin": "*"
|
|
134
139
|
}
|
|
135
140
|
},
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
"Access-Control-Allow-Origin": "*"
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
webpackChain: (chain, { webpack, CHAIN_ID }) => {
|
|
143
|
-
if (webpack.BannerPlugin) {
|
|
144
|
-
chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [
|
|
145
|
-
{
|
|
146
|
-
banner: "Micro front-end"
|
|
147
|
-
}
|
|
148
|
-
]);
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
rspack: (config2) => {
|
|
152
|
-
var _resolveOptions_deploy;
|
|
153
|
-
var _config;
|
|
154
|
-
var _builtins;
|
|
155
|
-
(_builtins = (_config = config2).builtins) !== null && _builtins !== void 0 ? _builtins : _config.builtins = {};
|
|
156
|
-
const resolveOptions = useResolvedConfigContext();
|
|
157
|
-
if ((resolveOptions === null || resolveOptions === void 0 ? void 0 : (_resolveOptions_deploy = resolveOptions.deploy) === null || _resolveOptions_deploy === void 0 ? void 0 : _resolveOptions_deploy.microFrontend) && !config2.externalsType) {
|
|
158
|
-
config2.externalsType = "commonjs";
|
|
159
|
-
}
|
|
160
|
-
const banner = config2.builtins.banner || [];
|
|
161
|
-
config2.builtins.banner = [
|
|
162
|
-
...Array.isArray(banner) ? banner : [
|
|
163
|
-
banner
|
|
164
|
-
],
|
|
141
|
+
webpackChain: (chain, { webpack, CHAIN_ID }) => {
|
|
142
|
+
if (webpack.BannerPlugin) {
|
|
143
|
+
chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [
|
|
165
144
|
{
|
|
166
145
|
banner: "Micro front-end"
|
|
167
146
|
}
|
|
168
|
-
];
|
|
169
|
-
},
|
|
170
|
-
bundlerChain: (chain, { env, CHAIN_ID }) => {
|
|
171
|
-
var _resolveOptions_deploy, _resolveConfig_resolve;
|
|
172
|
-
const resolveOptions = useResolvedConfigContext();
|
|
173
|
-
if (resolveOptions === null || resolveOptions === void 0 ? void 0 : (_resolveOptions_deploy = resolveOptions.deploy) === null || _resolveOptions_deploy === void 0 ? void 0 : _resolveOptions_deploy.microFrontend) {
|
|
174
|
-
var _useConfig_dev, _resolveOptions_server, _resolveOptions_deploy1;
|
|
175
|
-
chain.output.libraryTarget("umd");
|
|
176
|
-
if (!((_useConfig_dev = useConfig.dev) === null || _useConfig_dev === void 0 ? void 0 : _useConfig_dev.assetPrefix) && (resolveOptions === null || resolveOptions === void 0 ? void 0 : (_resolveOptions_server = resolveOptions.server) === null || _resolveOptions_server === void 0 ? void 0 : _resolveOptions_server.port) && env === "development") {
|
|
177
|
-
chain.output.publicPath(`//localhost:${resolveOptions.server.port}/`);
|
|
178
|
-
}
|
|
179
|
-
const { enableHtmlEntry, externalBasicLibrary } = getDefaultMicroFrontedConfig((_resolveOptions_deploy1 = resolveOptions.deploy) === null || _resolveOptions_deploy1 === void 0 ? void 0 : _resolveOptions_deploy1.microFrontend);
|
|
180
|
-
if (externalBasicLibrary) {
|
|
181
|
-
chain.externals(externals);
|
|
182
|
-
}
|
|
183
|
-
if (!enableHtmlEntry) {
|
|
184
|
-
chain.output.filename("index.js");
|
|
185
|
-
chain.plugins.delete(`${CHAIN_ID.PLUGIN.HTML}-main`);
|
|
186
|
-
chain.optimization.runtimeChunk(false);
|
|
187
|
-
chain.optimization.splitChunks({
|
|
188
|
-
chunks: "async"
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
const resolveConfig = chain.toConfig();
|
|
193
|
-
(0, _util.logger)("bundlerConfig", {
|
|
194
|
-
output: resolveConfig.output,
|
|
195
|
-
externals: resolveConfig.externals,
|
|
196
|
-
env,
|
|
197
|
-
alias: (_resolveConfig_resolve = resolveConfig.resolve) === null || _resolveConfig_resolve === void 0 ? void 0 : _resolveConfig_resolve.alias,
|
|
198
|
-
plugins: resolveConfig.plugins
|
|
199
|
-
});
|
|
147
|
+
]);
|
|
200
148
|
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
modifyEntryImports({ entrypoint, imports }) {
|
|
217
|
-
const config = useResolvedConfigContext();
|
|
218
|
-
const { masterApp } = (0, _utils1.getRuntimeConfig)(config);
|
|
219
|
-
if (masterApp) {
|
|
220
|
-
imports.push({
|
|
221
|
-
value: runtimePluginName,
|
|
222
|
-
specifiers: [
|
|
149
|
+
},
|
|
150
|
+
rspack: (config2) => {
|
|
151
|
+
var _resolveOptions_deploy, _resolveOptions;
|
|
152
|
+
var _config;
|
|
153
|
+
var _builtins;
|
|
154
|
+
(_builtins = (_config = config2).builtins) !== null && _builtins !== void 0 ? _builtins : _config.builtins = {};
|
|
155
|
+
const resolveOptions = useResolvedConfigContext();
|
|
156
|
+
if (((_resolveOptions = resolveOptions) === null || _resolveOptions === void 0 ? void 0 : (_resolveOptions_deploy = _resolveOptions.deploy) === null || _resolveOptions_deploy === void 0 ? void 0 : _resolveOptions_deploy.microFrontend) && !config2.externalsType) {
|
|
157
|
+
config2.externalsType = "commonjs";
|
|
158
|
+
}
|
|
159
|
+
const banner = config2.builtins.banner || [];
|
|
160
|
+
config2.builtins.banner = [
|
|
161
|
+
...Array.isArray(banner) ? banner : [
|
|
162
|
+
banner
|
|
163
|
+
],
|
|
223
164
|
{
|
|
224
|
-
|
|
165
|
+
banner: "Micro front-end"
|
|
225
166
|
}
|
|
226
|
-
]
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
167
|
+
];
|
|
168
|
+
},
|
|
169
|
+
bundlerChain: (chain, { env, CHAIN_ID }) => {
|
|
170
|
+
var _resolveOptions_deploy, _resolveOptions, _resolveConfig_resolve;
|
|
171
|
+
const resolveOptions = useResolvedConfigContext();
|
|
172
|
+
if ((_resolveOptions = resolveOptions) === null || _resolveOptions === void 0 ? void 0 : (_resolveOptions_deploy = _resolveOptions.deploy) === null || _resolveOptions_deploy === void 0 ? void 0 : _resolveOptions_deploy.microFrontend) {
|
|
173
|
+
var _useConfig_dev, _resolveOptions_server, _resolveOptions1, _resolveOptions_deploy1;
|
|
174
|
+
chain.output.libraryTarget("umd");
|
|
175
|
+
if (!((_useConfig_dev = useConfig.dev) === null || _useConfig_dev === void 0 ? void 0 : _useConfig_dev.assetPrefix) && ((_resolveOptions1 = resolveOptions) === null || _resolveOptions1 === void 0 ? void 0 : (_resolveOptions_server = _resolveOptions1.server) === null || _resolveOptions_server === void 0 ? void 0 : _resolveOptions_server.port) && env === "development") {
|
|
176
|
+
chain.output.publicPath(`//localhost:${resolveOptions.server.port}/`);
|
|
233
177
|
}
|
|
234
|
-
|
|
235
|
-
|
|
178
|
+
const { enableHtmlEntry, externalBasicLibrary } = getDefaultMicroFrontedConfig((_resolveOptions_deploy1 = resolveOptions.deploy) === null || _resolveOptions_deploy1 === void 0 ? void 0 : _resolveOptions_deploy1.microFrontend);
|
|
179
|
+
if (externalBasicLibrary) {
|
|
180
|
+
chain.externals(externals);
|
|
181
|
+
}
|
|
182
|
+
if (!enableHtmlEntry) {
|
|
183
|
+
chain.output.filename("index.js");
|
|
184
|
+
chain.plugins.delete(`${CHAIN_ID.PLUGIN.HTML}-main`);
|
|
185
|
+
chain.optimization.runtimeChunk(false);
|
|
186
|
+
chain.optimization.splitChunks({
|
|
187
|
+
chunks: "async"
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
const resolveConfig = chain.toConfig();
|
|
192
|
+
(0, _util.logger)("bundlerConfig", {
|
|
193
|
+
output: resolveConfig.output,
|
|
194
|
+
externals: resolveConfig.externals,
|
|
195
|
+
env,
|
|
196
|
+
alias: (_resolveConfig_resolve = resolveConfig.resolve) === null || _resolveConfig_resolve === void 0 ? void 0 : _resolveConfig_resolve.alias,
|
|
197
|
+
plugins: resolveConfig.plugins
|
|
198
|
+
});
|
|
199
|
+
}
|
|
236
200
|
}
|
|
201
|
+
};
|
|
202
|
+
},
|
|
203
|
+
addRuntimeExports() {
|
|
204
|
+
const config = useResolvedConfigContext();
|
|
205
|
+
const { masterApp } = (0, _utils1.getRuntimeConfig)(config);
|
|
206
|
+
if (masterApp) {
|
|
207
|
+
const addExportStatement = `export { default as garfish, default as masterApp } from '${pluginName}/runtime'`;
|
|
208
|
+
(0, _util.logger)("exportStatement", addExportStatement);
|
|
209
|
+
pluginsExportsUtils.addExport(addExportStatement);
|
|
210
|
+
}
|
|
211
|
+
const otherExportStatement = `export { hoistNonReactStatics } from '${pluginName}/deps'`;
|
|
212
|
+
(0, _util.logger)("otherExportStatement", otherExportStatement);
|
|
213
|
+
pluginsExportsUtils.addExport(otherExportStatement);
|
|
214
|
+
},
|
|
215
|
+
modifyEntryImports({ entrypoint, imports }) {
|
|
216
|
+
const config = useResolvedConfigContext();
|
|
217
|
+
const { masterApp } = (0, _utils1.getRuntimeConfig)(config);
|
|
218
|
+
if (masterApp) {
|
|
237
219
|
imports.push({
|
|
238
220
|
value: runtimePluginName,
|
|
239
221
|
specifiers: [
|
|
240
222
|
{
|
|
241
|
-
imported: "
|
|
223
|
+
imported: "garfish"
|
|
242
224
|
}
|
|
243
225
|
]
|
|
244
226
|
});
|
|
245
227
|
imports.push({
|
|
246
|
-
value:
|
|
228
|
+
value: runtimePluginName,
|
|
247
229
|
specifiers: [
|
|
248
230
|
{
|
|
249
|
-
imported: "
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
imported: "createPortal"
|
|
231
|
+
imported: "masterApp"
|
|
253
232
|
}
|
|
254
233
|
]
|
|
255
234
|
});
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
235
|
+
}
|
|
236
|
+
imports.push({
|
|
237
|
+
value: runtimePluginName,
|
|
238
|
+
specifiers: [
|
|
239
|
+
{
|
|
240
|
+
imported: "hoistNonReactStatics"
|
|
241
|
+
}
|
|
242
|
+
]
|
|
243
|
+
});
|
|
244
|
+
imports.push({
|
|
245
|
+
value: "react-dom",
|
|
246
|
+
specifiers: [
|
|
247
|
+
{
|
|
248
|
+
imported: "unmountComponentAtNode"
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
imported: "createPortal"
|
|
252
|
+
}
|
|
253
|
+
]
|
|
254
|
+
});
|
|
255
|
+
return {
|
|
256
|
+
imports,
|
|
257
|
+
entrypoint
|
|
258
|
+
};
|
|
259
|
+
},
|
|
260
|
+
modifyEntryRuntimePlugins({ entrypoint, plugins }) {
|
|
261
|
+
const config = useResolvedConfigContext();
|
|
262
|
+
const { masterApp } = (0, _utils1.getRuntimeConfig)(config);
|
|
263
|
+
if (masterApp) {
|
|
264
|
+
(0, _util.logger)("garfishPlugin options", masterApp);
|
|
265
|
+
plugins.push({
|
|
266
|
+
name: "garfish",
|
|
267
|
+
args: "masterApp",
|
|
268
|
+
options: masterApp === true ? JSON.stringify({}) : JSON.stringify(masterApp)
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
return {
|
|
272
|
+
entrypoint,
|
|
273
|
+
plugins
|
|
274
|
+
};
|
|
275
|
+
},
|
|
276
|
+
modifyEntryRenderFunction({ entrypoint, code }) {
|
|
277
|
+
var _config_deploy, _config;
|
|
278
|
+
const config = useResolvedConfigContext();
|
|
279
|
+
if (!((_config = config) === null || _config === void 0 ? void 0 : (_config_deploy = _config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend)) {
|
|
288
280
|
return {
|
|
289
281
|
entrypoint,
|
|
290
|
-
code
|
|
282
|
+
code
|
|
291
283
|
};
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
284
|
+
}
|
|
285
|
+
const nCode = (0, _utils1.makeRenderFunction)(code);
|
|
286
|
+
(0, _util.logger)("makeRenderFunction", nCode);
|
|
287
|
+
return {
|
|
288
|
+
entrypoint,
|
|
289
|
+
code: nCode
|
|
290
|
+
};
|
|
291
|
+
},
|
|
292
|
+
modifyAsyncEntry({ entrypoint, code }) {
|
|
293
|
+
var _config_deploy, _config, _config_source, _config1;
|
|
294
|
+
const config = useResolvedConfigContext();
|
|
295
|
+
let finalCode = code;
|
|
296
|
+
if (((_config = config) === null || _config === void 0 ? void 0 : (_config_deploy = _config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend) && ((_config1 = config) === null || _config1 === void 0 ? void 0 : (_config_source = _config1.source) === null || _config_source === void 0 ? void 0 : _config_source.enableAsyncEntry)) {
|
|
297
|
+
finalCode = (0, _utils1.generateAsyncEntry)(code);
|
|
304
298
|
return {
|
|
305
299
|
entrypoint,
|
|
306
|
-
code: finalCode
|
|
300
|
+
code: `${finalCode}`
|
|
307
301
|
};
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
302
|
+
}
|
|
303
|
+
return {
|
|
304
|
+
entrypoint,
|
|
305
|
+
code: finalCode
|
|
306
|
+
};
|
|
307
|
+
},
|
|
308
|
+
modifyEntryExport({ entrypoint, exportStatement }) {
|
|
309
|
+
var _config_deploy, _config;
|
|
310
|
+
const config = useResolvedConfigContext();
|
|
311
|
+
if ((_config = config) === null || _config === void 0 ? void 0 : (_config_deploy = _config.deploy) === null || _config_deploy === void 0 ? void 0 : _config_deploy.microFrontend) {
|
|
312
|
+
const exportStatementCode = (0, _utils1.makeProvider)();
|
|
313
|
+
(0, _util.logger)("exportStatement", exportStatementCode);
|
|
320
314
|
return {
|
|
321
315
|
entrypoint,
|
|
322
|
-
exportStatement
|
|
316
|
+
exportStatement: exportStatementCode
|
|
323
317
|
};
|
|
324
318
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
};
|
|
319
|
+
return {
|
|
320
|
+
entrypoint,
|
|
321
|
+
exportStatement
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
});
|
|
329
327
|
const _default = garfishPlugin;
|
package/dist/cjs/cli/utils.js
CHANGED
|
@@ -115,20 +115,20 @@ const makeRenderFunction = (code) => {
|
|
|
115
115
|
return inGarfishToRender + code.replace(`router(`, `generateRouterPlugin(basename,`).replace(/MOUNT_ID/g, "mountNode").replace(`createApp({`, "createApp({ props,").replace(`bootstrap(AppWrapper, mountNode, root`, "bootstrap(AppWrapper, mountNode, root = IS_REACT18 ? ReactDOM.createRoot(mountNode) : null").replace(`customBootstrap(AppWrapper`, "customBootstrap(AppWrapper, mountNode");
|
|
116
116
|
};
|
|
117
117
|
function getRuntimeConfig(config) {
|
|
118
|
-
var _config_runtime;
|
|
119
|
-
if (config === null ||
|
|
120
|
-
var _config_runtime1;
|
|
121
|
-
return config === null ||
|
|
118
|
+
var _config_runtime, _config, _config1;
|
|
119
|
+
if ((_config = config) === null || _config === void 0 ? void 0 : (_config_runtime = _config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.features) {
|
|
120
|
+
var _config_runtime1, _config2;
|
|
121
|
+
return (_config2 = config) === null || _config2 === void 0 ? void 0 : (_config_runtime1 = _config2.runtime) === null || _config_runtime1 === void 0 ? void 0 : _config_runtime1.features;
|
|
122
122
|
}
|
|
123
|
-
return (config === null ||
|
|
123
|
+
return ((_config1 = config) === null || _config1 === void 0 ? void 0 : _config1.runtime) || {};
|
|
124
124
|
}
|
|
125
125
|
function setRuntimeConfig(config, key, value) {
|
|
126
|
-
var _config_runtime, _config_runtime1;
|
|
127
|
-
if ((config === null ||
|
|
126
|
+
var _config_runtime, _config, _config_runtime1, _config1, _config2, _config3;
|
|
127
|
+
if (((_config = config) === null || _config === void 0 ? void 0 : (_config_runtime = _config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.features) && ((_config1 = config) === null || _config1 === void 0 ? void 0 : (_config_runtime1 = _config1.runtime) === null || _config_runtime1 === void 0 ? void 0 : _config_runtime1.features[key])) {
|
|
128
128
|
config.runtime.features[key] = value;
|
|
129
129
|
return void 0;
|
|
130
130
|
}
|
|
131
|
-
if ((config === null ||
|
|
131
|
+
if (((_config2 = config) === null || _config2 === void 0 ? void 0 : _config2.runtime) && ((_config3 = config) === null || _config3 === void 0 ? void 0 : _config3.runtime[key])) {
|
|
132
132
|
config.runtime[key] = value;
|
|
133
133
|
return void 0;
|
|
134
134
|
}
|
|
@@ -19,7 +19,7 @@ const DEFAULT_LOADABLE = {
|
|
|
19
19
|
function Loadable(WrapComponent) {
|
|
20
20
|
return function(defaultLoadable) {
|
|
21
21
|
return function Lodable(props) {
|
|
22
|
-
var _props_loadable;
|
|
22
|
+
var _props_loadable, _state;
|
|
23
23
|
const { loadable = defaultLoadable !== null && defaultLoadable !== void 0 ? defaultLoadable : DEFAULT_LOADABLE, ...otherProps } = props;
|
|
24
24
|
let delayTimer = null;
|
|
25
25
|
let timeoutTimer = null;
|
|
@@ -99,7 +99,7 @@ function Loadable(WrapComponent) {
|
|
|
99
99
|
isLoading: state.isLoading,
|
|
100
100
|
pastDelay: state.pastDelay,
|
|
101
101
|
timedOut: state.timedOut,
|
|
102
|
-
error: state === null ||
|
|
102
|
+
error: (_state = state) === null || _state === void 0 ? void 0 : _state.error,
|
|
103
103
|
retry
|
|
104
104
|
}),
|
|
105
105
|
/* @__PURE__ */ (0, _jsxruntime.jsx)(WrapComponent, {
|
|
@@ -25,24 +25,27 @@ const _setExternal = /* @__PURE__ */ _interop_require_default._(require("./utils
|
|
|
25
25
|
const _MApp = require("./utils/MApp");
|
|
26
26
|
const _apps = require("./utils/apps");
|
|
27
27
|
async function initOptions(manifest = {}, options) {
|
|
28
|
-
var _window_modern_manifest, _window_modern_manifest1;
|
|
28
|
+
var _manifest, _manifest1, _window_modern_manifest, _window, _window_modern_manifest1, _window1;
|
|
29
29
|
let apps = options.apps || [];
|
|
30
|
-
if (manifest === null ||
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
if ((_manifest = manifest) === null || _manifest === void 0 ? void 0 : _manifest.modules) {
|
|
31
|
+
var _manifest2;
|
|
32
|
+
if (((_manifest2 = manifest) === null || _manifest2 === void 0 ? void 0 : _manifest2.modules.length) > 0) {
|
|
33
|
+
var _manifest3;
|
|
34
|
+
apps = (_manifest3 = manifest) === null || _manifest3 === void 0 ? void 0 : _manifest3.modules;
|
|
33
35
|
}
|
|
34
36
|
(0, _util.logger)("manifest modules", apps);
|
|
35
37
|
}
|
|
36
|
-
if (manifest === null ||
|
|
37
|
-
|
|
38
|
+
if ((_manifest1 = manifest) === null || _manifest1 === void 0 ? void 0 : _manifest1.getAppList) {
|
|
39
|
+
var _manifest4;
|
|
40
|
+
const getAppList = await ((_manifest4 = manifest) === null || _manifest4 === void 0 ? void 0 : _manifest4.getAppList(manifest));
|
|
38
41
|
if (getAppList.length > 0) {
|
|
39
42
|
apps = getAppList;
|
|
40
43
|
}
|
|
41
44
|
(0, _util.logger)("getAppList modules", apps);
|
|
42
45
|
}
|
|
43
|
-
if ((window === null ||
|
|
44
|
-
var _window_modern_manifest2;
|
|
45
|
-
apps = window === null ||
|
|
46
|
+
if (((_window = window) === null || _window === void 0 ? void 0 : (_window_modern_manifest = _window.modern_manifest) === null || _window_modern_manifest === void 0 ? void 0 : _window_modern_manifest.modules) && ((_window1 = window) === null || _window1 === void 0 ? void 0 : (_window_modern_manifest1 = _window1.modern_manifest) === null || _window_modern_manifest1 === void 0 ? void 0 : _window_modern_manifest1.modules.length) > 0) {
|
|
47
|
+
var _window_modern_manifest2, _window2;
|
|
48
|
+
apps = (_window2 = window) === null || _window2 === void 0 ? void 0 : (_window_modern_manifest2 = _window2.modern_manifest) === null || _window_modern_manifest2 === void 0 ? void 0 : _window_modern_manifest2.modules;
|
|
46
49
|
(0, _util.logger)("modern_manifest", apps);
|
|
47
50
|
}
|
|
48
51
|
return {
|