@modern-js/plugin-garfish 2.0.0-beta.3 → 2.0.0-beta.5
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 +67 -0
- package/dist/js/modern/cli/index.js +167 -157
- package/dist/js/modern/cli/types.js +0 -0
- package/dist/js/modern/cli/utils.js +31 -23
- package/dist/js/modern/global.d.js +0 -0
- package/dist/js/modern/index.js +5 -2
- package/dist/js/modern/modern-app.env.d.js +0 -0
- package/dist/js/modern/runtime/global.d.js +0 -0
- package/dist/js/modern/runtime/index.js +12 -4
- package/dist/js/modern/runtime/loadable.js +74 -56
- package/dist/js/modern/runtime/plugin.js +114 -79
- package/dist/js/modern/runtime/useModuleApps.js +40 -26
- package/dist/js/modern/runtime/utils/Context.js +6 -3
- package/dist/js/modern/runtime/utils/MApp.js +76 -72
- package/dist/js/modern/runtime/utils/apps.js +181 -132
- package/dist/js/modern/runtime/utils/setExternal.js +11 -11
- package/dist/js/modern/util.js +11 -9
- package/dist/js/node/cli/index.js +191 -169
- package/dist/js/node/cli/types.js +0 -0
- package/dist/js/node/cli/utils.js +53 -30
- package/dist/js/node/global.d.js +0 -0
- package/dist/js/node/index.js +31 -24
- package/dist/js/node/modern-app.env.d.js +0 -0
- package/dist/js/node/runtime/global.d.js +0 -0
- package/dist/js/node/runtime/index.js +42 -43
- package/dist/js/node/runtime/loadable.js +97 -61
- package/dist/js/node/runtime/plugin.js +147 -95
- package/dist/js/node/runtime/useModuleApps.js +67 -34
- package/dist/js/node/runtime/utils/Context.js +35 -10
- package/dist/js/node/runtime/utils/MApp.js +109 -84
- package/dist/js/node/runtime/utils/apps.js +210 -135
- package/dist/js/node/runtime/utils/setExternal.js +37 -18
- package/dist/js/node/util.js +40 -19
- package/dist/js/treeshaking/cli/index.js +403 -284
- package/dist/js/treeshaking/cli/types.js +1 -0
- package/dist/js/treeshaking/cli/utils.js +28 -31
- package/dist/js/treeshaking/global.d.js +1 -0
- package/dist/js/treeshaking/index.js +3 -2
- package/dist/js/treeshaking/modern-app.env.d.js +1 -0
- package/dist/js/treeshaking/runtime/global.d.js +1 -0
- package/dist/js/treeshaking/runtime/index.js +5 -4
- package/dist/js/treeshaking/runtime/loadable.js +230 -109
- package/dist/js/treeshaking/runtime/plugin.js +469 -168
- package/dist/js/treeshaking/runtime/useModuleApps.js +55 -31
- package/dist/js/treeshaking/runtime/utils/Context.js +3 -3
- package/dist/js/treeshaking/runtime/utils/MApp.js +348 -180
- package/dist/js/treeshaking/runtime/utils/apps.js +472 -224
- package/dist/js/treeshaking/runtime/utils/setExternal.js +12 -11
- package/dist/js/treeshaking/util.js +7 -9
- package/dist/types/cli/index.d.ts +3 -0
- package/dist/types/cli/types.d.ts +6 -0
- package/dist/types/runtime/index.d.ts +1 -1
- package/dist/types/runtime/loadable.d.ts +1 -2
- package/dist/types/runtime/plugin.d.ts +2 -0
- package/dist/types/runtime/utils/apps.d.ts +1 -0
- package/dist/types/runtime/utils/setExternal.d.ts +1 -0
- package/package.json +25 -20
- package/type.d.ts +5 -6
|
@@ -1,97 +1,144 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __export = (target, all) => {
|
|
22
|
+
for (var name in all)
|
|
23
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
24
|
+
};
|
|
25
|
+
var __copyProps = (to, from, except, desc) => {
|
|
26
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
27
|
+
for (let key of __getOwnPropNames(from))
|
|
28
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
29
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
30
|
+
}
|
|
31
|
+
return to;
|
|
19
32
|
};
|
|
20
|
-
|
|
33
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
34
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
|
+
mod
|
|
36
|
+
));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
var __async = (__this, __arguments, generator) => {
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
var fulfilled = (value) => {
|
|
41
|
+
try {
|
|
42
|
+
step(generator.next(value));
|
|
43
|
+
} catch (e) {
|
|
44
|
+
reject(e);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var rejected = (value) => {
|
|
48
|
+
try {
|
|
49
|
+
step(generator.throw(value));
|
|
50
|
+
} catch (e) {
|
|
51
|
+
reject(e);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
55
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
var cli_exports = {};
|
|
59
|
+
__export(cli_exports, {
|
|
60
|
+
default: () => cli_default,
|
|
61
|
+
externals: () => externals,
|
|
62
|
+
getDefaultMicroFrontedConfig: () => getDefaultMicroFrontedConfig
|
|
63
|
+
});
|
|
64
|
+
module.exports = __toCommonJS(cli_exports);
|
|
65
|
+
var import_path = __toESM(require("path"));
|
|
66
|
+
var import_utils = require("@modern-js/utils");
|
|
67
|
+
var import_util = require("../util");
|
|
68
|
+
var import_utils2 = require("./utils");
|
|
69
|
+
var import_types = require("./types");
|
|
70
|
+
const externals = { "react-dom": "react-dom", react: "react" };
|
|
21
71
|
function getDefaultMicroFrontedConfig(microFrontend) {
|
|
22
72
|
if (microFrontend === true) {
|
|
23
73
|
return {
|
|
24
74
|
enableHtmlEntry: true,
|
|
25
75
|
externalBasicLibrary: false,
|
|
26
|
-
moduleApp:
|
|
76
|
+
moduleApp: ""
|
|
27
77
|
};
|
|
28
78
|
}
|
|
29
|
-
return
|
|
79
|
+
return __spreadValues({
|
|
30
80
|
enableHtmlEntry: true,
|
|
31
81
|
externalBasicLibrary: false
|
|
32
82
|
}, microFrontend);
|
|
33
83
|
}
|
|
34
|
-
var
|
|
35
|
-
pluginName
|
|
36
|
-
runtimePluginName
|
|
37
|
-
mfPackagePath
|
|
84
|
+
var cli_default = ({
|
|
85
|
+
pluginName = "@modern-js/plugin-garfish",
|
|
86
|
+
runtimePluginName = "@modern-js/runtime/plugins",
|
|
87
|
+
mfPackagePath = import_path.default.resolve(__dirname, "../../../../")
|
|
38
88
|
} = {}) => ({
|
|
39
|
-
name:
|
|
40
|
-
setup: ({
|
|
41
|
-
useAppContext,
|
|
42
|
-
useResolvedConfigContext,
|
|
43
|
-
useConfigContext
|
|
44
|
-
}) => {
|
|
89
|
+
name: "@modern-js/plugin-garfish",
|
|
90
|
+
setup: ({ useAppContext, useResolvedConfigContext, useConfigContext }) => {
|
|
45
91
|
let pluginsExportsUtils;
|
|
46
92
|
let runtimeExportsUtils;
|
|
47
93
|
return {
|
|
48
94
|
validateSchema() {
|
|
49
|
-
return
|
|
95
|
+
return import_utils.PLUGIN_SCHEMAS["@modern-js/plugin-garfish"];
|
|
50
96
|
},
|
|
51
|
-
resolvedConfig:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
} =
|
|
55
|
-
const {
|
|
56
|
-
masterApp,
|
|
57
|
-
router
|
|
58
|
-
} = (0, _utils2.getRuntimeConfig)(resolved);
|
|
97
|
+
resolvedConfig: (config) => __async(void 0, null, function* () {
|
|
98
|
+
var _a;
|
|
99
|
+
const { resolved } = config;
|
|
100
|
+
const { masterApp, router } = (0, import_utils2.getRuntimeConfig)(resolved);
|
|
59
101
|
const nConfig = {
|
|
60
|
-
resolved:
|
|
102
|
+
resolved: __spreadValues({}, resolved)
|
|
61
103
|
};
|
|
62
104
|
if (masterApp) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
105
|
+
(0, import_utils2.setRuntimeConfig)(
|
|
106
|
+
nConfig.resolved,
|
|
107
|
+
"masterApp",
|
|
108
|
+
Object.assign(
|
|
109
|
+
typeof masterApp === "object" ? __spreadValues({}, masterApp) : {},
|
|
110
|
+
{
|
|
111
|
+
basename: ((_a = router == null ? void 0 : router.historyOptions) == null ? void 0 : _a.basename) || (router == null ? void 0 : router.basename) || "/"
|
|
112
|
+
}
|
|
113
|
+
)
|
|
114
|
+
);
|
|
68
115
|
}
|
|
69
|
-
(0,
|
|
116
|
+
(0, import_util.logger)(`resolvedConfig`, {
|
|
70
117
|
output: nConfig.resolved.output,
|
|
71
118
|
runtime: nConfig.resolved.runtime,
|
|
72
119
|
deploy: nConfig.resolved.deploy,
|
|
73
120
|
server: nConfig.resolved.server
|
|
74
121
|
});
|
|
75
122
|
return nConfig;
|
|
76
|
-
},
|
|
123
|
+
}),
|
|
77
124
|
config() {
|
|
78
|
-
var
|
|
79
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
125
|
+
var _a, _b, _c;
|
|
80
126
|
const useConfig = useConfigContext();
|
|
81
|
-
(0,
|
|
82
|
-
|
|
83
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
127
|
+
(0, import_util.logger)("useConfig", useConfig);
|
|
84
128
|
const config = useAppContext();
|
|
85
|
-
pluginsExportsUtils = (0,
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
129
|
+
pluginsExportsUtils = (0, import_utils.createRuntimeExportsUtils)(
|
|
130
|
+
config.internalDirectory,
|
|
131
|
+
"plugins"
|
|
132
|
+
);
|
|
133
|
+
runtimeExportsUtils = (0, import_utils.createRuntimeExportsUtils)(
|
|
134
|
+
config.internalDirectory,
|
|
135
|
+
"index"
|
|
136
|
+
);
|
|
137
|
+
let disableCssExtract = ((_a = useConfig.output) == null ? void 0 : _a.disableCssExtract) || false;
|
|
138
|
+
if ((_b = useConfig.deploy) == null ? void 0 : _b.microFrontend) {
|
|
139
|
+
const { enableHtmlEntry } = getDefaultMicroFrontedConfig(
|
|
140
|
+
(_c = useConfig.deploy) == null ? void 0 : _c.microFrontend
|
|
141
|
+
);
|
|
95
142
|
if (!enableHtmlEntry) {
|
|
96
143
|
disableCssExtract = true;
|
|
97
144
|
}
|
|
@@ -102,61 +149,54 @@ var _default = ({
|
|
|
102
149
|
},
|
|
103
150
|
source: {
|
|
104
151
|
alias: {
|
|
105
|
-
|
|
106
|
-
|
|
152
|
+
"@modern-js/runtime/plugins": pluginsExportsUtils.getPath(),
|
|
153
|
+
"@modern-js/runtime/garfish": mfPackagePath
|
|
107
154
|
}
|
|
108
155
|
},
|
|
109
156
|
tools: {
|
|
110
157
|
devServer: {
|
|
111
158
|
headers: {
|
|
112
|
-
|
|
159
|
+
"Access-Control-Allow-Origin": "*"
|
|
113
160
|
}
|
|
114
161
|
},
|
|
115
162
|
webpackChain: (chain, {
|
|
116
163
|
webpack,
|
|
117
|
-
env
|
|
164
|
+
env = process.env.NODE_ENV || "development",
|
|
118
165
|
CHAIN_ID
|
|
119
166
|
}) => {
|
|
120
|
-
var
|
|
121
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
167
|
+
var _a2, _b2, _c2, _d;
|
|
122
168
|
const resolveOptions = useResolvedConfigContext();
|
|
123
|
-
if (resolveOptions
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
169
|
+
if ((_a2 = resolveOptions == null ? void 0 : resolveOptions.deploy) == null ? void 0 : _a2.microFrontend) {
|
|
170
|
+
chain.output.libraryTarget("umd");
|
|
171
|
+
if (((_b2 = resolveOptions == null ? void 0 : resolveOptions.server) == null ? void 0 : _b2.port) && env === "development") {
|
|
172
|
+
chain.output.publicPath(
|
|
173
|
+
`//localhost:${resolveOptions.server.port}/`
|
|
174
|
+
);
|
|
128
175
|
}
|
|
129
|
-
|
|
130
|
-
// add comments avoid sourcemap abnormal
|
|
131
176
|
if (webpack.BannerPlugin) {
|
|
132
|
-
chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [{
|
|
133
|
-
banner: 'Micro front-end'
|
|
134
|
-
}]);
|
|
177
|
+
chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [{ banner: "Micro front-end" }]);
|
|
135
178
|
}
|
|
136
|
-
const {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
} = getDefaultMicroFrontedConfig((_resolveOptions$deplo2 = resolveOptions.deploy) === null || _resolveOptions$deplo2 === void 0 ? void 0 : _resolveOptions$deplo2.microFrontend);
|
|
140
|
-
// external
|
|
179
|
+
const { enableHtmlEntry, externalBasicLibrary } = getDefaultMicroFrontedConfig(
|
|
180
|
+
(_c2 = resolveOptions.deploy) == null ? void 0 : _c2.microFrontend
|
|
181
|
+
);
|
|
141
182
|
if (externalBasicLibrary) {
|
|
142
183
|
chain.externals(externals);
|
|
143
184
|
}
|
|
144
|
-
// use html mode
|
|
145
185
|
if (!enableHtmlEntry) {
|
|
146
|
-
chain.output.filename(
|
|
186
|
+
chain.output.filename("index.js");
|
|
147
187
|
chain.plugins.delete(`${CHAIN_ID.PLUGIN.HTML}-main`);
|
|
148
188
|
chain.optimization.runtimeChunk(false);
|
|
149
189
|
chain.optimization.splitChunks({
|
|
150
|
-
chunks:
|
|
190
|
+
chunks: "async"
|
|
151
191
|
});
|
|
152
192
|
}
|
|
153
193
|
}
|
|
154
194
|
const resolveWebpackConfig = chain.toConfig();
|
|
155
|
-
(0,
|
|
195
|
+
(0, import_util.logger)("webpackConfig", {
|
|
156
196
|
output: resolveWebpackConfig.output,
|
|
157
197
|
externals: resolveWebpackConfig.externals,
|
|
158
|
-
env
|
|
159
|
-
alias: (
|
|
198
|
+
env,
|
|
199
|
+
alias: (_d = resolveWebpackConfig.resolve) == null ? void 0 : _d.alias,
|
|
160
200
|
plugins: resolveWebpackConfig.plugins
|
|
161
201
|
});
|
|
162
202
|
}
|
|
@@ -164,105 +204,87 @@ var _default = ({
|
|
|
164
204
|
};
|
|
165
205
|
},
|
|
166
206
|
addRuntimeExports() {
|
|
167
|
-
const addExportStatement = `export { default as garfish, default as masterApp, hoistNonReactStatics } from '${
|
|
168
|
-
(0,
|
|
207
|
+
const addExportStatement = `export { default as garfish, default as masterApp, hoistNonReactStatics } from '${pluginName}/runtime'`;
|
|
208
|
+
(0, import_util.logger)("exportStatement", addExportStatement);
|
|
169
209
|
pluginsExportsUtils.addExport(addExportStatement);
|
|
170
|
-
runtimeExportsUtils.addExport(
|
|
210
|
+
runtimeExportsUtils.addExport(
|
|
211
|
+
`export * from '${mfPackagePath}/runtime'`
|
|
212
|
+
);
|
|
171
213
|
},
|
|
172
|
-
modifyEntryImports({
|
|
173
|
-
entrypoint,
|
|
174
|
-
imports
|
|
175
|
-
}) {
|
|
176
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
214
|
+
modifyEntryImports({ entrypoint, imports }) {
|
|
177
215
|
const config = useResolvedConfigContext();
|
|
178
|
-
const {
|
|
179
|
-
masterApp
|
|
180
|
-
} = (0, _utils2.getRuntimeConfig)(config);
|
|
216
|
+
const { masterApp } = (0, import_utils2.getRuntimeConfig)(config);
|
|
181
217
|
if (masterApp) {
|
|
182
218
|
imports.push({
|
|
183
|
-
value:
|
|
184
|
-
specifiers: [
|
|
185
|
-
|
|
186
|
-
|
|
219
|
+
value: runtimePluginName,
|
|
220
|
+
specifiers: [
|
|
221
|
+
{
|
|
222
|
+
imported: "garfish"
|
|
223
|
+
}
|
|
224
|
+
]
|
|
187
225
|
});
|
|
188
226
|
imports.push({
|
|
189
|
-
value:
|
|
190
|
-
specifiers: [
|
|
191
|
-
|
|
192
|
-
|
|
227
|
+
value: runtimePluginName,
|
|
228
|
+
specifiers: [
|
|
229
|
+
{
|
|
230
|
+
imported: "masterApp"
|
|
231
|
+
}
|
|
232
|
+
]
|
|
193
233
|
});
|
|
194
234
|
}
|
|
195
235
|
imports.push({
|
|
196
|
-
value:
|
|
197
|
-
specifiers: [
|
|
198
|
-
|
|
199
|
-
|
|
236
|
+
value: runtimePluginName,
|
|
237
|
+
specifiers: [
|
|
238
|
+
{
|
|
239
|
+
imported: "hoistNonReactStatics"
|
|
240
|
+
}
|
|
241
|
+
]
|
|
200
242
|
});
|
|
201
243
|
imports.push({
|
|
202
|
-
value:
|
|
203
|
-
specifiers: [
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
244
|
+
value: "react-dom",
|
|
245
|
+
specifiers: [
|
|
246
|
+
{
|
|
247
|
+
imported: "unmountComponentAtNode"
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
imported: "createPortal"
|
|
251
|
+
}
|
|
252
|
+
]
|
|
208
253
|
});
|
|
209
|
-
return {
|
|
210
|
-
imports,
|
|
211
|
-
entrypoint
|
|
212
|
-
};
|
|
254
|
+
return { imports, entrypoint };
|
|
213
255
|
},
|
|
214
|
-
modifyEntryRuntimePlugins({
|
|
215
|
-
entrypoint,
|
|
216
|
-
plugins
|
|
217
|
-
}) {
|
|
218
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
256
|
+
modifyEntryRuntimePlugins({ entrypoint, plugins }) {
|
|
219
257
|
const config = useResolvedConfigContext();
|
|
220
|
-
const {
|
|
221
|
-
masterApp
|
|
222
|
-
} = (0, _utils2.getRuntimeConfig)(config);
|
|
258
|
+
const { masterApp } = (0, import_utils2.getRuntimeConfig)(config);
|
|
223
259
|
if (masterApp) {
|
|
224
|
-
(0,
|
|
260
|
+
(0, import_util.logger)("garfishPlugin options", masterApp);
|
|
225
261
|
plugins.push({
|
|
226
|
-
name:
|
|
227
|
-
args:
|
|
262
|
+
name: "garfish",
|
|
263
|
+
args: "masterApp",
|
|
228
264
|
options: masterApp === true ? JSON.stringify({}) : JSON.stringify(masterApp)
|
|
229
265
|
});
|
|
230
266
|
}
|
|
231
|
-
return {
|
|
232
|
-
entrypoint,
|
|
233
|
-
plugins
|
|
234
|
-
};
|
|
267
|
+
return { entrypoint, plugins };
|
|
235
268
|
},
|
|
236
|
-
modifyEntryRenderFunction({
|
|
237
|
-
|
|
238
|
-
code
|
|
239
|
-
}) {
|
|
240
|
-
var _config$deploy;
|
|
241
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
269
|
+
modifyEntryRenderFunction({ entrypoint, code }) {
|
|
270
|
+
var _a;
|
|
242
271
|
const config = useResolvedConfigContext();
|
|
243
|
-
if (!(config
|
|
244
|
-
return {
|
|
245
|
-
entrypoint,
|
|
246
|
-
code
|
|
247
|
-
};
|
|
272
|
+
if (!((_a = config == null ? void 0 : config.deploy) == null ? void 0 : _a.microFrontend)) {
|
|
273
|
+
return { entrypoint, code };
|
|
248
274
|
}
|
|
249
|
-
const nCode = (0,
|
|
250
|
-
(0,
|
|
275
|
+
const nCode = (0, import_utils2.makeRenderFunction)(code);
|
|
276
|
+
(0, import_util.logger)("makeRenderFunction", nCode);
|
|
251
277
|
return {
|
|
252
278
|
entrypoint,
|
|
253
279
|
code: nCode
|
|
254
280
|
};
|
|
255
281
|
},
|
|
256
|
-
modifyAsyncEntry({
|
|
257
|
-
|
|
258
|
-
code
|
|
259
|
-
}) {
|
|
260
|
-
var _config$deploy2, _config$source;
|
|
261
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
282
|
+
modifyAsyncEntry({ entrypoint, code }) {
|
|
283
|
+
var _a, _b;
|
|
262
284
|
const config = useResolvedConfigContext();
|
|
263
285
|
let finalCode = code;
|
|
264
|
-
if (config
|
|
265
|
-
finalCode = (0,
|
|
286
|
+
if (((_a = config == null ? void 0 : config.deploy) == null ? void 0 : _a.microFrontend) && ((_b = config == null ? void 0 : config.source) == null ? void 0 : _b.enableAsyncEntry)) {
|
|
287
|
+
finalCode = (0, import_utils2.generateAsyncEntry)(code);
|
|
266
288
|
return {
|
|
267
289
|
entrypoint,
|
|
268
290
|
code: `${finalCode}`
|
|
@@ -273,16 +295,12 @@ var _default = ({
|
|
|
273
295
|
code: finalCode
|
|
274
296
|
};
|
|
275
297
|
},
|
|
276
|
-
modifyEntryExport({
|
|
277
|
-
|
|
278
|
-
exportStatement
|
|
279
|
-
}) {
|
|
280
|
-
var _config$deploy3;
|
|
281
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
298
|
+
modifyEntryExport({ entrypoint, exportStatement }) {
|
|
299
|
+
var _a;
|
|
282
300
|
const config = useResolvedConfigContext();
|
|
283
|
-
if (config
|
|
284
|
-
const exportStatementCode = (0,
|
|
285
|
-
(0,
|
|
301
|
+
if ((_a = config == null ? void 0 : config.deploy) == null ? void 0 : _a.microFrontend) {
|
|
302
|
+
const exportStatementCode = (0, import_utils2.makeProvider)();
|
|
303
|
+
(0, import_util.logger)("exportStatement", exportStatementCode);
|
|
286
304
|
return {
|
|
287
305
|
entrypoint,
|
|
288
306
|
exportStatement: exportStatementCode
|
|
@@ -296,4 +314,8 @@ var _default = ({
|
|
|
296
314
|
};
|
|
297
315
|
}
|
|
298
316
|
});
|
|
299
|
-
|
|
317
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
318
|
+
0 && (module.exports = {
|
|
319
|
+
externals,
|
|
320
|
+
getDefaultMicroFrontedConfig
|
|
321
|
+
});
|
|
File without changes
|
|
@@ -1,12 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var utils_exports = {};
|
|
19
|
+
__export(utils_exports, {
|
|
20
|
+
generateAsyncEntry: () => generateAsyncEntry,
|
|
21
|
+
getRuntimeConfig: () => getRuntimeConfig,
|
|
22
|
+
makeProvider: () => makeProvider,
|
|
23
|
+
makeRenderFunction: () => makeRenderFunction,
|
|
24
|
+
setRuntimeConfig: () => setRuntimeConfig
|
|
5
25
|
});
|
|
6
|
-
exports
|
|
7
|
-
exports.getRuntimeConfig = getRuntimeConfig;
|
|
8
|
-
exports.makeRenderFunction = exports.makeProvider = void 0;
|
|
9
|
-
exports.setRuntimeConfig = setRuntimeConfig;
|
|
26
|
+
module.exports = __toCommonJS(utils_exports);
|
|
10
27
|
const makeProvider = () => `
|
|
11
28
|
export const provider = function ({basename, dom}) {
|
|
12
29
|
return {
|
|
@@ -88,42 +105,41 @@ function generateAppWrapperAndRootDom ({ App, props, dom }) {
|
|
|
88
105
|
return { AppWrapper, mountNode }
|
|
89
106
|
}
|
|
90
107
|
`;
|
|
91
|
-
|
|
92
|
-
const makeRenderFunction = code => {
|
|
108
|
+
const makeRenderFunction = (code) => {
|
|
93
109
|
const inGarfishToRender = `
|
|
94
110
|
const { basename, props, dom, appName } = typeof arguments[0] === 'object' && arguments[0] || {};
|
|
95
111
|
if (!canContinueRender({ dom, appName })) return null;
|
|
96
112
|
let { AppWrapper, mountNode } = generateAppWrapperAndRootDom({App, props, dom});
|
|
97
113
|
`;
|
|
98
|
-
return inGarfishToRender + code.replace(`router(`, `generateRouterPlugin(basename,`).replace(
|
|
114
|
+
return inGarfishToRender + code.replace(`router(`, `generateRouterPlugin(basename,`).replace("(App)", `(AppWrapper)`).replace(/MOUNT_ID/g, "mountNode").replace(
|
|
115
|
+
`bootstrap(AppWrapper, mountNode, root`,
|
|
116
|
+
"bootstrap(AppWrapper, mountNode, root = IS_REACT18 ? ReactDOM.createRoot(mountNode) : null"
|
|
117
|
+
);
|
|
99
118
|
};
|
|
100
|
-
|
|
101
|
-
// support legacy config
|
|
102
|
-
exports.makeRenderFunction = makeRenderFunction;
|
|
103
119
|
function getRuntimeConfig(config) {
|
|
104
|
-
var
|
|
105
|
-
if (config
|
|
106
|
-
|
|
107
|
-
return config === null || config === void 0 ? void 0 : (_config$runtime2 = config.runtime) === null || _config$runtime2 === void 0 ? void 0 : _config$runtime2.features;
|
|
120
|
+
var _a, _b;
|
|
121
|
+
if ((_a = config == null ? void 0 : config.runtime) == null ? void 0 : _a.features) {
|
|
122
|
+
return (_b = config == null ? void 0 : config.runtime) == null ? void 0 : _b.features;
|
|
108
123
|
}
|
|
109
|
-
return (config
|
|
124
|
+
return (config == null ? void 0 : config.runtime) || {};
|
|
110
125
|
}
|
|
111
|
-
|
|
112
|
-
// support legacy config
|
|
113
126
|
function setRuntimeConfig(config, key, value) {
|
|
114
|
-
var
|
|
115
|
-
if (config
|
|
127
|
+
var _a, _b;
|
|
128
|
+
if (((_a = config == null ? void 0 : config.runtime) == null ? void 0 : _a.features) && ((_b = config == null ? void 0 : config.runtime) == null ? void 0 : _b.features[key])) {
|
|
116
129
|
config.runtime.features[key] = value;
|
|
117
|
-
return
|
|
130
|
+
return void 0;
|
|
118
131
|
}
|
|
119
|
-
if (config
|
|
132
|
+
if ((config == null ? void 0 : config.runtime) && (config == null ? void 0 : config.runtime[key])) {
|
|
120
133
|
config.runtime[key] = value;
|
|
121
|
-
return
|
|
134
|
+
return void 0;
|
|
122
135
|
}
|
|
123
|
-
return
|
|
136
|
+
return void 0;
|
|
124
137
|
}
|
|
125
|
-
const generateAsyncEntry = code => {
|
|
126
|
-
const transformCode = code.replace(
|
|
138
|
+
const generateAsyncEntry = (code) => {
|
|
139
|
+
const transformCode = code.replace(
|
|
140
|
+
`import('./bootstrap.js');`,
|
|
141
|
+
`if (!window.__GARFISH__) { import('./bootstrap.js'); }`
|
|
142
|
+
);
|
|
127
143
|
return `
|
|
128
144
|
export const provider = async (...args) => {
|
|
129
145
|
const exports = await import('./bootstrap');
|
|
@@ -132,4 +148,11 @@ const generateAsyncEntry = code => {
|
|
|
132
148
|
${transformCode}
|
|
133
149
|
`;
|
|
134
150
|
};
|
|
135
|
-
|
|
151
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
152
|
+
0 && (module.exports = {
|
|
153
|
+
generateAsyncEntry,
|
|
154
|
+
getRuntimeConfig,
|
|
155
|
+
makeProvider,
|
|
156
|
+
makeRenderFunction,
|
|
157
|
+
setRuntimeConfig
|
|
158
|
+
});
|
|
File without changes
|