@modern-js/plugin-garfish 1.3.1 → 1.4.2
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 +38 -0
- package/dist/js/modern/cli/index.js +91 -93
- package/dist/js/modern/cli/utils.js +84 -25
- package/dist/js/modern/runtime/plugin.js +10 -2
- package/dist/js/modern/runtime/utils/MApp.js +3 -3
- package/dist/js/modern/runtime/utils/apps.js +2 -5
- package/dist/js/node/cli/index.js +97 -91
- package/dist/js/node/cli/utils.js +89 -26
- package/dist/js/node/runtime/plugin.js +10 -2
- package/dist/js/node/runtime/utils/MApp.js +3 -3
- package/dist/js/node/runtime/utils/apps.js +2 -5
- package/dist/js/treeshaking/cli/index.js +235 -216
- package/dist/js/treeshaking/cli/utils.js +32 -3
- package/dist/js/treeshaking/runtime/plugin.js +14 -5
- package/dist/js/treeshaking/runtime/utils/MApp.js +3 -3
- package/dist/js/treeshaking/runtime/utils/apps.js +21 -22
- package/dist/types/cli/index.d.ts +18 -2
- package/dist/types/cli/utils.d.ts +4 -1
- package/package.json +9 -10
- package/tests/cli.test.tsx +215 -23
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = void 0;
|
|
6
|
+
exports.resolvedConfig = exports.initializer = exports.externals = exports.default = void 0;
|
|
7
7
|
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
9
|
|
|
@@ -23,66 +23,57 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
23
23
|
|
|
24
24
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
26
|
+
const externals = {
|
|
27
|
+
'react-dom': 'react-dom',
|
|
28
|
+
react: 'react'
|
|
29
|
+
};
|
|
30
|
+
exports.externals = externals;
|
|
31
|
+
|
|
32
|
+
const resolvedConfig = async config => {
|
|
33
|
+
const {
|
|
34
|
+
resolved
|
|
35
|
+
} = config;
|
|
36
|
+
const {
|
|
37
|
+
masterApp,
|
|
38
|
+
router
|
|
39
|
+
} = (0, _utils2.getRuntimeConfig)(resolved);
|
|
40
|
+
const nConfig = {
|
|
41
|
+
resolved: _objectSpread({}, resolved)
|
|
42
|
+
};
|
|
40
43
|
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
+
if (masterApp) {
|
|
45
|
+
var _router$historyOption;
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
// basename does not exist use router's basename
|
|
48
|
+
(0, _utils2.setRuntimeConfig)(nConfig.resolved, 'masterApp', Object.assign(typeof masterApp === 'object' ? _objectSpread({}, masterApp) : {}, {
|
|
49
|
+
basename: (router === null || router === void 0 ? void 0 : (_router$historyOption = router.historyOptions) === null || _router$historyOption === void 0 ? void 0 : _router$historyOption.basename) || '/'
|
|
50
|
+
}));
|
|
47
51
|
}
|
|
48
|
-
}
|
|
49
52
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
(0, _util.logger)(`resolvedConfig`, {
|
|
54
|
+
runtime: nConfig.resolved.runtime,
|
|
55
|
+
deploy: nConfig.resolved.deploy,
|
|
56
|
+
server: nConfig.resolved.server
|
|
57
|
+
});
|
|
58
|
+
return nConfig;
|
|
53
59
|
};
|
|
54
60
|
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
exports.resolvedConfig = resolvedConfig;
|
|
62
|
+
|
|
63
|
+
const initializer = ( // eslint-disable-next-line @typescript-eslint/no-shadow
|
|
64
|
+
{
|
|
65
|
+
resolvedConfig,
|
|
66
|
+
validateSchema
|
|
67
|
+
}, {
|
|
68
|
+
runtimePluginName: _runtimePluginName = '@modern-js/runtime/plugins',
|
|
69
|
+
defaultEnableHtmlEntry: _defaultEnableHtmlEntry = true,
|
|
70
|
+
defaultExternalBasicLibrary: _defaultExternalBasicLibrary = false
|
|
71
|
+
}) => () => {
|
|
57
72
|
let pluginsExportsUtils;
|
|
58
73
|
let runtimeExportsUtils;
|
|
59
74
|
return {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
resolved
|
|
63
|
-
} = config;
|
|
64
|
-
const {
|
|
65
|
-
masterApp,
|
|
66
|
-
router
|
|
67
|
-
} = getRuntimeConfig(resolved);
|
|
68
|
-
const nConfig = {
|
|
69
|
-
resolved: _objectSpread({}, resolved)
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
if (masterApp) {
|
|
73
|
-
// basename does not exist use router's basename
|
|
74
|
-
setRuntimeConfig(nConfig.resolved, 'masterApp', Object.assign(typeof masterApp === 'object' ? _objectSpread({}, masterApp) : {}, {
|
|
75
|
-
basename: (router === null || router === void 0 ? void 0 : router.basename) || '/'
|
|
76
|
-
}));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
(0, _util.logger)(`resolvedConfig`, {
|
|
80
|
-
runtime: nConfig.resolved.runtime,
|
|
81
|
-
deploy: nConfig.resolved.deploy,
|
|
82
|
-
server: nConfig.resolved.server
|
|
83
|
-
});
|
|
84
|
-
return nConfig;
|
|
85
|
-
},
|
|
75
|
+
validateSchema,
|
|
76
|
+
resolvedConfig,
|
|
86
77
|
|
|
87
78
|
config() {
|
|
88
79
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -98,31 +89,34 @@ var _default = (0, _core.createPlugin)(() => {
|
|
|
98
89
|
tools: {
|
|
99
90
|
webpack: (webpackConfig, {
|
|
100
91
|
chain,
|
|
101
|
-
webpack
|
|
92
|
+
webpack,
|
|
93
|
+
env: _env = process.env.NODE_ENV || 'development'
|
|
102
94
|
}) => {
|
|
103
|
-
var
|
|
104
|
-
|
|
105
|
-
const env = process.env.NODE_ENV; // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
95
|
+
var _resolveOptions$deplo, _resolveWebpackConfig;
|
|
106
96
|
|
|
107
|
-
|
|
97
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
98
|
+
const resolveOptions = (0, _core.useResolvedConfigContext)();
|
|
108
99
|
|
|
109
|
-
if (
|
|
110
|
-
var
|
|
100
|
+
if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$deplo = resolveOptions.deploy) !== null && _resolveOptions$deplo !== void 0 && _resolveOptions$deplo.microFrontend) {
|
|
101
|
+
var _resolveOptions$serve, _resolveOptions$deplo2, _resolveOptions$deplo3;
|
|
111
102
|
|
|
112
103
|
chain.output.libraryTarget('umd');
|
|
113
104
|
|
|
114
|
-
if (
|
|
115
|
-
chain.output.publicPath(
|
|
105
|
+
if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$serve = resolveOptions.server) !== null && _resolveOptions$serve !== void 0 && _resolveOptions$serve.port) {
|
|
106
|
+
chain.output.publicPath(_env === 'development' ? `//localhost:${resolveOptions.server.port}/` : webpackConfig.output.publicPath);
|
|
116
107
|
} // add comments avoid sourcemap abnormal
|
|
117
108
|
|
|
118
109
|
|
|
119
|
-
|
|
120
|
-
banner
|
|
121
|
-
|
|
110
|
+
if (webpack.BannerPlugin) {
|
|
111
|
+
chain.plugin('banner').use(webpack.BannerPlugin, [{
|
|
112
|
+
banner: 'Micro front-end'
|
|
113
|
+
}]);
|
|
114
|
+
}
|
|
115
|
+
|
|
122
116
|
const {
|
|
123
|
-
enableHtmlEntry =
|
|
124
|
-
externalBasicLibrary =
|
|
125
|
-
} = typeof (
|
|
117
|
+
enableHtmlEntry = _defaultEnableHtmlEntry,
|
|
118
|
+
externalBasicLibrary = _defaultExternalBasicLibrary
|
|
119
|
+
} = typeof (resolveOptions === null || resolveOptions === void 0 ? void 0 : (_resolveOptions$deplo2 = resolveOptions.deploy) === null || _resolveOptions$deplo2 === void 0 ? void 0 : _resolveOptions$deplo2.microFrontend) === 'object' ? resolveOptions === null || resolveOptions === void 0 ? void 0 : (_resolveOptions$deplo3 = resolveOptions.deploy) === null || _resolveOptions$deplo3 === void 0 ? void 0 : _resolveOptions$deplo3.microFrontend : {}; // external
|
|
126
120
|
|
|
127
121
|
if (externalBasicLibrary) {
|
|
128
122
|
chain.externals(externals);
|
|
@@ -143,7 +137,7 @@ var _default = (0, _core.createPlugin)(() => {
|
|
|
143
137
|
(0, _util.logger)('webpackConfig', {
|
|
144
138
|
output: resolveWebpackConfig.output,
|
|
145
139
|
externals: resolveWebpackConfig.externals,
|
|
146
|
-
env,
|
|
140
|
+
env: _env,
|
|
147
141
|
alias: (_resolveWebpackConfig = resolveWebpackConfig.resolve) === null || _resolveWebpackConfig === void 0 ? void 0 : _resolveWebpackConfig.alias
|
|
148
142
|
});
|
|
149
143
|
}
|
|
@@ -154,40 +148,35 @@ var _default = (0, _core.createPlugin)(() => {
|
|
|
154
148
|
addRuntimeExports() {
|
|
155
149
|
const mfPackage = _path.default.resolve(__dirname, '../../../../');
|
|
156
150
|
|
|
157
|
-
const addExportStatement = `export { default as garfish } from '${mfPackage}'`;
|
|
151
|
+
const addExportStatement = `export { default as garfish, default as masterApp } from '${mfPackage}'`;
|
|
158
152
|
(0, _util.logger)('exportStatement', addExportStatement);
|
|
159
153
|
pluginsExportsUtils.addExport(addExportStatement);
|
|
160
154
|
runtimeExportsUtils.addExport(`export * from '${mfPackage}'`);
|
|
161
155
|
},
|
|
162
156
|
|
|
163
|
-
validateSchema() {
|
|
164
|
-
return _utils.PLUGIN_SCHEMAS['@modern-js/plugin-garfish'];
|
|
165
|
-
},
|
|
166
|
-
|
|
167
157
|
modifyEntryImports({
|
|
168
158
|
entrypoint,
|
|
169
159
|
imports
|
|
170
160
|
}) {
|
|
171
161
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
172
|
-
const
|
|
173
|
-
|
|
162
|
+
const config = (0, _core.useResolvedConfigContext)();
|
|
174
163
|
const {
|
|
175
164
|
masterApp
|
|
176
|
-
} = getRuntimeConfig(
|
|
165
|
+
} = (0, _utils2.getRuntimeConfig)(config);
|
|
177
166
|
|
|
178
|
-
|
|
179
|
-
packageName
|
|
180
|
-
} = (0, _core.useAppContext)();
|
|
181
|
-
const masterAppConfig = (0, _utils.getEntryOptions)(entrypoint.entryName, masterApp, resolvedConfig.runtimeByEntries, packageName);
|
|
182
|
-
configMap.set(entrypoint.entryName, masterAppConfig);
|
|
183
|
-
|
|
184
|
-
if (masterAppConfig) {
|
|
167
|
+
if (masterApp) {
|
|
185
168
|
imports.push({
|
|
186
|
-
value:
|
|
169
|
+
value: _runtimePluginName,
|
|
187
170
|
specifiers: [{
|
|
188
171
|
imported: 'garfish'
|
|
189
172
|
}]
|
|
190
173
|
});
|
|
174
|
+
imports.push({
|
|
175
|
+
value: _runtimePluginName,
|
|
176
|
+
specifiers: [{
|
|
177
|
+
imported: 'masterApp'
|
|
178
|
+
}]
|
|
179
|
+
});
|
|
191
180
|
}
|
|
192
181
|
|
|
193
182
|
imports.push({
|
|
@@ -208,14 +197,18 @@ var _default = (0, _core.createPlugin)(() => {
|
|
|
208
197
|
entrypoint,
|
|
209
198
|
plugins
|
|
210
199
|
}) {
|
|
211
|
-
|
|
200
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
201
|
+
const config = (0, _core.useResolvedConfigContext)();
|
|
202
|
+
const {
|
|
203
|
+
masterApp
|
|
204
|
+
} = (0, _utils2.getRuntimeConfig)(config);
|
|
212
205
|
|
|
213
|
-
if (
|
|
214
|
-
(0, _util.logger)('garfishPlugin options',
|
|
206
|
+
if (masterApp) {
|
|
207
|
+
(0, _util.logger)('garfishPlugin options', masterApp);
|
|
215
208
|
plugins.push({
|
|
216
209
|
name: 'garfish',
|
|
217
210
|
args: 'masterApp',
|
|
218
|
-
options: JSON.stringify(
|
|
211
|
+
options: masterApp === true ? JSON.stringify({}) : JSON.stringify(masterApp)
|
|
219
212
|
});
|
|
220
213
|
}
|
|
221
214
|
|
|
@@ -253,12 +246,12 @@ var _default = (0, _core.createPlugin)(() => {
|
|
|
253
246
|
entrypoint,
|
|
254
247
|
exportStatement
|
|
255
248
|
}) {
|
|
256
|
-
var
|
|
249
|
+
var _config$deploy2;
|
|
257
250
|
|
|
258
251
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
259
|
-
const
|
|
252
|
+
const config = (0, _core.useResolvedConfigContext)();
|
|
260
253
|
|
|
261
|
-
if (
|
|
254
|
+
if (config !== null && config !== void 0 && (_config$deploy2 = config.deploy) !== null && _config$deploy2 !== void 0 && _config$deploy2.microFrontend) {
|
|
262
255
|
const exportStatementCode = (0, _utils2.makeProvider)();
|
|
263
256
|
(0, _util.logger)('exportStatement', exportStatementCode);
|
|
264
257
|
return {
|
|
@@ -274,7 +267,20 @@ var _default = (0, _core.createPlugin)(() => {
|
|
|
274
267
|
}
|
|
275
268
|
|
|
276
269
|
};
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
exports.initializer = initializer;
|
|
273
|
+
|
|
274
|
+
var _default = (0, _core.createPlugin)(initializer({
|
|
275
|
+
resolvedConfig,
|
|
276
|
+
|
|
277
|
+
validateSchema() {
|
|
278
|
+
return _utils.PLUGIN_SCHEMAS['@modern-js/plugin-garfish'];
|
|
279
|
+
}
|
|
280
|
+
|
|
277
281
|
}, {
|
|
282
|
+
runtimePluginName: '@modern-js/runtime/plugins'
|
|
283
|
+
}), {
|
|
278
284
|
name: '@modern-js/plugin-garfish'
|
|
279
285
|
});
|
|
280
286
|
|
|
@@ -3,41 +3,104 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.getRuntimeConfig = getRuntimeConfig;
|
|
6
7
|
exports.makeRenderFunction = exports.makeProvider = void 0;
|
|
8
|
+
exports.setRuntimeConfig = setRuntimeConfig;
|
|
7
9
|
|
|
8
10
|
const makeProvider = () => `
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (node) {
|
|
21
|
-
unmountComponentAtNode(node);
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
SubModuleComponent: (props) => {
|
|
25
|
-
const SubApp = render(props, basename);
|
|
11
|
+
export const provider = function ({basename, dom, ...props}) {
|
|
12
|
+
return {
|
|
13
|
+
render({basename, dom}) {
|
|
14
|
+
console.log('App.config', App.config);
|
|
15
|
+
const SubApp = render({props, basename});
|
|
16
|
+
const node = dom.querySelector('#' + MOUNT_ID) || dom;
|
|
17
|
+
bootstrap(SubApp, node);
|
|
18
|
+
},
|
|
19
|
+
destroy({ dom }) {
|
|
20
|
+
const node = dom.querySelector('#' + MOUNT_ID) || dom;
|
|
26
21
|
|
|
27
|
-
|
|
22
|
+
if (node) {
|
|
23
|
+
unmountComponentAtNode(node);
|
|
28
24
|
}
|
|
25
|
+
},
|
|
26
|
+
SubModuleComponent: (props) => {
|
|
27
|
+
const SubApp = render({props, basename});
|
|
28
|
+
|
|
29
|
+
return createPortal(<SubApp />, dom.querySelector('#' + MOUNT_ID) || dom);
|
|
30
|
+
},
|
|
31
|
+
jupiter_submodule_app_key: (props) => {
|
|
32
|
+
const SubApp = render({props, basename});
|
|
33
|
+
|
|
34
|
+
return createPortal(<SubApp />, dom.querySelector('#' + MOUNT_ID) || dom);
|
|
29
35
|
}
|
|
30
|
-
};
|
|
31
|
-
if (typeof __GARFISH_EXPORTS__ !== 'undefined') {
|
|
32
|
-
__GARFISH_EXPORTS__.provider = provider;
|
|
33
36
|
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
if (typeof __GARFISH_EXPORTS__ !== 'undefined') {
|
|
40
|
+
__GARFISH_EXPORTS__.provider = provider;
|
|
41
|
+
}
|
|
34
42
|
`;
|
|
35
43
|
|
|
36
44
|
exports.makeProvider = makeProvider;
|
|
37
45
|
|
|
38
|
-
const makeRenderFunction = code =>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
46
|
+
const makeRenderFunction = code => {
|
|
47
|
+
const inGarfishToRender = `
|
|
48
|
+
const { basename, props } = arguments[0] || {};
|
|
49
|
+
let renderByGarfish = false;
|
|
50
|
+
const renderByProvider = !!basename;
|
|
51
|
+
|
|
52
|
+
if (IS_BROWSER && window.Garfish && window.Garfish.activeApps && window.Garfish.activeApps.length !== 0) renderByGarfish = true;
|
|
53
|
+
if (IS_BROWSER && window.Garfish && window.Garfish.apps && Object.keys(window.Garfish.apps).length !== 0) renderByGarfish = true;
|
|
54
|
+
if (typeof __GARFISH_EXPORTS__ !== 'undefined') renderByGarfish = true;
|
|
55
|
+
if (renderByGarfish && !renderByProvider) return null;
|
|
56
|
+
|
|
57
|
+
function RouterPlugin (routerConfig) {
|
|
58
|
+
if (basename) {
|
|
59
|
+
routerConfig.basename = basename;
|
|
60
|
+
if (routerConfig.supportHtml5History !== false) {
|
|
61
|
+
if (!routerConfig.historyOptions) {
|
|
62
|
+
routerConfig.historyOptions = {
|
|
63
|
+
basename: basename
|
|
64
|
+
};
|
|
65
|
+
} else {
|
|
66
|
+
routerConfig.historyOptions.basename = basename;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return router(routerConfig);
|
|
71
|
+
}
|
|
72
|
+
`;
|
|
73
|
+
return inGarfishToRender + code.replace(`router(`, `RouterPlugin(`).replace('IS_BROWSER', `IS_BROWSER && !renderByGarfish`);
|
|
74
|
+
}; // support legacy config
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
exports.makeRenderFunction = makeRenderFunction;
|
|
78
|
+
|
|
79
|
+
function getRuntimeConfig(config) {
|
|
80
|
+
var _config$runtime;
|
|
81
|
+
|
|
82
|
+
if (config !== null && config !== void 0 && (_config$runtime = config.runtime) !== null && _config$runtime !== void 0 && _config$runtime.features) {
|
|
83
|
+
var _config$runtime2;
|
|
84
|
+
|
|
85
|
+
return config === null || config === void 0 ? void 0 : (_config$runtime2 = config.runtime) === null || _config$runtime2 === void 0 ? void 0 : _config$runtime2.features;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return config === null || config === void 0 ? void 0 : config.runtime;
|
|
89
|
+
} // support legacy config
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
function setRuntimeConfig(config, key, value) {
|
|
93
|
+
var _config$runtime3, _config$runtime4;
|
|
94
|
+
|
|
95
|
+
if (config !== null && config !== void 0 && (_config$runtime3 = config.runtime) !== null && _config$runtime3 !== void 0 && _config$runtime3.features && config !== null && config !== void 0 && (_config$runtime4 = config.runtime) !== null && _config$runtime4 !== void 0 && _config$runtime4.features[key]) {
|
|
96
|
+
config.runtime.features[key] = value;
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (config !== null && config !== void 0 && config.runtime && config !== null && config !== void 0 && config.runtime[key]) {
|
|
101
|
+
config.runtime[key] = value;
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
42
104
|
|
|
43
|
-
|
|
105
|
+
return undefined;
|
|
106
|
+
}
|
|
@@ -43,13 +43,21 @@ async function initOptions(manifest = {}, options) {
|
|
|
43
43
|
let apps = options.apps || []; // use manifest modules
|
|
44
44
|
|
|
45
45
|
if (manifest !== null && manifest !== void 0 && manifest.modules) {
|
|
46
|
-
|
|
46
|
+
if ((manifest === null || manifest === void 0 ? void 0 : manifest.modules.length) > 0) {
|
|
47
|
+
apps = manifest === null || manifest === void 0 ? void 0 : manifest.modules;
|
|
48
|
+
}
|
|
49
|
+
|
|
47
50
|
(0, _util.logger)('manifest modules', apps);
|
|
48
51
|
} // get module list
|
|
49
52
|
|
|
50
53
|
|
|
51
54
|
if (manifest !== null && manifest !== void 0 && manifest.getAppList) {
|
|
52
|
-
|
|
55
|
+
const getAppList = await (manifest === null || manifest === void 0 ? void 0 : manifest.getAppList());
|
|
56
|
+
|
|
57
|
+
if (getAppList.length > 0) {
|
|
58
|
+
apps = getAppList;
|
|
59
|
+
}
|
|
60
|
+
|
|
53
61
|
(0, _util.logger)('getAppList modules', apps);
|
|
54
62
|
} // get inject modules list
|
|
55
63
|
|
|
@@ -81,7 +81,7 @@ function generateMApp(options, manifest) {
|
|
|
81
81
|
},
|
|
82
82
|
|
|
83
83
|
errorLoadApp(error, ...args) {
|
|
84
|
-
(0, _util.logger)('MApp errorLoadApp', args);
|
|
84
|
+
(0, _util.logger)('MApp errorLoadApp', error, args);
|
|
85
85
|
setLoadingState({
|
|
86
86
|
error
|
|
87
87
|
});
|
|
@@ -89,7 +89,7 @@ function generateMApp(options, manifest) {
|
|
|
89
89
|
},
|
|
90
90
|
|
|
91
91
|
errorMountApp(error, ...args) {
|
|
92
|
-
(0, _util.logger)('MApp errorMountApp', args);
|
|
92
|
+
(0, _util.logger)('MApp errorMountApp', error, args);
|
|
93
93
|
setLoadingState({
|
|
94
94
|
error
|
|
95
95
|
});
|
|
@@ -97,7 +97,7 @@ function generateMApp(options, manifest) {
|
|
|
97
97
|
},
|
|
98
98
|
|
|
99
99
|
errorUnmountApp(error, ...args) {
|
|
100
|
-
(0, _util.logger)('MApp errorUnmountApp', args);
|
|
100
|
+
(0, _util.logger)('MApp errorUnmountApp', error, args);
|
|
101
101
|
setLoadingState({
|
|
102
102
|
error
|
|
103
103
|
});
|
|
@@ -33,7 +33,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
33
33
|
|
|
34
34
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
35
35
|
|
|
36
|
-
function getAppInstance(appInfo, manifest) {
|
|
36
|
+
function getAppInstance(options, appInfo, manifest) {
|
|
37
37
|
let locationHref = '';
|
|
38
38
|
|
|
39
39
|
class MicroApp extends _react.default.Component {
|
|
@@ -58,9 +58,6 @@ function getAppInstance(appInfo, manifest) {
|
|
|
58
58
|
const {
|
|
59
59
|
domId
|
|
60
60
|
} = this.state;
|
|
61
|
-
const {
|
|
62
|
-
options
|
|
63
|
-
} = _garfish.default;
|
|
64
61
|
|
|
65
62
|
const loadAppOptions = _objectSpread(_objectSpread({}, appInfo), {}, {
|
|
66
63
|
domGetter: `#${domId}`,
|
|
@@ -181,7 +178,7 @@ function generateApps(options, manifest) {
|
|
|
181
178
|
|
|
182
179
|
const apps = {};
|
|
183
180
|
(_options$apps = options.apps) === null || _options$apps === void 0 ? void 0 : _options$apps.forEach(appInfo => {
|
|
184
|
-
const Component = getAppInstance(appInfo, manifest);
|
|
181
|
+
const Component = getAppInstance(options, appInfo, manifest);
|
|
185
182
|
appInfo.Component = Component;
|
|
186
183
|
apps[appInfo.name] = Component;
|
|
187
184
|
});
|