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