@modern-js/plugin-garfish 1.21.5 → 2.0.0-beta.1
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 +63 -19
- package/dist/js/modern/cli/index.js +10 -44
- package/dist/js/modern/cli/utils.js +4 -8
- package/dist/js/modern/runtime/loadable.js +3 -17
- package/dist/js/modern/runtime/plugin.js +11 -33
- package/dist/js/modern/runtime/useModuleApps.js +0 -5
- package/dist/js/modern/runtime/utils/MApp.js +9 -42
- package/dist/js/modern/runtime/utils/apps.js +12 -41
- package/dist/js/node/cli/index.js +10 -53
- package/dist/js/node/cli/utils.js +4 -14
- package/dist/js/node/index.js +0 -4
- package/dist/js/node/runtime/index.js +0 -5
- package/dist/js/node/runtime/loadable.js +3 -22
- package/dist/js/node/runtime/plugin.js +11 -47
- package/dist/js/node/runtime/useModuleApps.js +0 -12
- package/dist/js/node/runtime/utils/Context.js +0 -4
- package/dist/js/node/runtime/utils/MApp.js +7 -49
- package/dist/js/node/runtime/utils/apps.js +10 -48
- package/dist/js/node/runtime/utils/setExternal.js +0 -9
- package/dist/js/node/util.js +1 -4
- package/dist/js/treeshaking/cli/index.js +29 -59
- package/dist/js/treeshaking/cli/utils.js +4 -8
- package/dist/js/treeshaking/runtime/loadable.js +29 -39
- package/dist/js/treeshaking/runtime/plugin.js +9 -42
- package/dist/js/treeshaking/runtime/useModuleApps.js +4 -7
- package/dist/js/treeshaking/runtime/utils/MApp.js +13 -46
- package/dist/js/treeshaking/runtime/utils/apps.js +9 -49
- package/dist/types/cli/index.d.ts +0 -2
- package/dist/types/runtime/loadable.d.ts +2 -1
- package/dist/types/runtime/plugin.d.ts +0 -2
- package/dist/types/runtime/utils/MApp.d.ts +1 -0
- package/dist/types/runtime/utils/setExternal.d.ts +0 -1
- package/package.json +16 -39
- package/type.d.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,29 +1,73 @@
|
|
|
1
1
|
# @modern-js/plugin-garfish
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 2.0.0-beta.1
|
|
4
4
|
|
|
5
|
-
###
|
|
6
|
-
|
|
7
|
-
- 6d8475f: fix: loadApp when dom is mount
|
|
8
|
-
修复 dom 未渲染时挂载子应用行为
|
|
9
|
-
- Updated dependencies [a150632]
|
|
10
|
-
- Updated dependencies [29576fc]
|
|
11
|
-
- @modern-js/runtime@1.21.5
|
|
12
|
-
- @modern-js/utils@1.21.5
|
|
13
|
-
|
|
14
|
-
## 1.21.4
|
|
5
|
+
### Major Changes
|
|
15
6
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
- @modern-js/runtime@1.21.4
|
|
19
|
-
- @modern-js/utils@1.21.4
|
|
20
|
-
|
|
21
|
-
## 1.21.3
|
|
7
|
+
- dda38c9: chore: v2
|
|
22
8
|
|
|
23
9
|
### Patch Changes
|
|
24
10
|
|
|
25
|
-
-
|
|
26
|
-
|
|
11
|
+
- 2344eb2: fix: loadApp when dom is mount
|
|
12
|
+
修复 dom 未渲染时挂载子应用行为
|
|
13
|
+
- Updated dependencies [2344eb2]
|
|
14
|
+
- Updated dependencies [a11fcf8]
|
|
15
|
+
- Updated dependencies [b18fa8f]
|
|
16
|
+
- Updated dependencies [c9e800d39a]
|
|
17
|
+
- Updated dependencies [3e57f2b]
|
|
18
|
+
- Updated dependencies [fbf5eed]
|
|
19
|
+
- Updated dependencies [a2509bfbdb]
|
|
20
|
+
- Updated dependencies [4369648ae2]
|
|
21
|
+
- Updated dependencies [92f0ead]
|
|
22
|
+
- Updated dependencies [92c0994]
|
|
23
|
+
- Updated dependencies [edd1cfb1af]
|
|
24
|
+
- Updated dependencies [cc971eabfc]
|
|
25
|
+
- Updated dependencies [5b9049f]
|
|
26
|
+
- Updated dependencies [6bda14ed71]
|
|
27
|
+
- Updated dependencies [92004d1]
|
|
28
|
+
- Updated dependencies [b8bbe036c7]
|
|
29
|
+
- Updated dependencies [40ed587]
|
|
30
|
+
- Updated dependencies [60d5378632]
|
|
31
|
+
- Updated dependencies [d5a31df781]
|
|
32
|
+
- Updated dependencies [dda38c9]
|
|
33
|
+
- Updated dependencies [8b8e1bb571]
|
|
34
|
+
- Updated dependencies [3bbea92b2a]
|
|
35
|
+
- Updated dependencies [18aaf42]
|
|
36
|
+
- Updated dependencies [fcace5b5b9]
|
|
37
|
+
- Updated dependencies [abf3421]
|
|
38
|
+
- Updated dependencies [543be9558e]
|
|
39
|
+
- Updated dependencies [14b712d]
|
|
40
|
+
- @modern-js/runtime@2.0.0-beta.1
|
|
41
|
+
- @modern-js/utils@2.0.0-beta.1
|
|
42
|
+
|
|
43
|
+
## 2.0.0-beta.0
|
|
44
|
+
|
|
45
|
+
### Major Changes
|
|
46
|
+
|
|
47
|
+
- dda38c9: chore: v2
|
|
48
|
+
|
|
49
|
+
### Patch Changes
|
|
50
|
+
|
|
51
|
+
- Updated dependencies [b18fa8f]
|
|
52
|
+
- Updated dependencies [c9e800d39]
|
|
53
|
+
- Updated dependencies [a2509bf]
|
|
54
|
+
- Updated dependencies [4369648ae]
|
|
55
|
+
- Updated dependencies [edd1cfb1a]
|
|
56
|
+
- Updated dependencies [cc971eabf]
|
|
57
|
+
- Updated dependencies [5b9049f]
|
|
58
|
+
- Updated dependencies [6bda14ed7]
|
|
59
|
+
- Updated dependencies [b8bbe036c]
|
|
60
|
+
- Updated dependencies [60d5378]
|
|
61
|
+
- Updated dependencies [d5a31df78]
|
|
62
|
+
- Updated dependencies [dda38c9]
|
|
63
|
+
- Updated dependencies [8b8e1bb57]
|
|
64
|
+
- Updated dependencies [3bbea92b2]
|
|
65
|
+
- Updated dependencies [fcace5b5b]
|
|
66
|
+
- Updated dependencies [abf3421]
|
|
67
|
+
- Updated dependencies [543be95]
|
|
68
|
+
- Updated dependencies [14b712d]
|
|
69
|
+
- @modern-js/runtime@2.0.0-beta.0
|
|
70
|
+
- @modern-js/utils@2.0.0-beta.0
|
|
27
71
|
|
|
28
72
|
## 1.21.2
|
|
29
73
|
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
2
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
3
|
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; }
|
|
6
|
-
|
|
7
4
|
import path from 'path';
|
|
8
5
|
import { createRuntimeExportsUtils, PLUGIN_SCHEMAS } from '@modern-js/utils';
|
|
9
6
|
import { logger } from "../util";
|
|
@@ -20,7 +17,6 @@ export function getDefaultMicroFrontedConfig(microFrontend) {
|
|
|
20
17
|
moduleApp: ''
|
|
21
18
|
};
|
|
22
19
|
}
|
|
23
|
-
|
|
24
20
|
return _objectSpread({
|
|
25
21
|
enableHtmlEntry: true,
|
|
26
22
|
externalBasicLibrary: false
|
|
@@ -43,7 +39,6 @@ export default (({
|
|
|
43
39
|
validateSchema() {
|
|
44
40
|
return PLUGIN_SCHEMAS['@modern-js/plugin-garfish'];
|
|
45
41
|
},
|
|
46
|
-
|
|
47
42
|
resolvedConfig: async config => {
|
|
48
43
|
const {
|
|
49
44
|
resolved
|
|
@@ -55,16 +50,13 @@ export default (({
|
|
|
55
50
|
const nConfig = {
|
|
56
51
|
resolved: _objectSpread({}, resolved)
|
|
57
52
|
};
|
|
58
|
-
|
|
59
53
|
if (masterApp) {
|
|
60
54
|
var _router$historyOption;
|
|
61
|
-
|
|
62
55
|
// basename does not exist use router's basename
|
|
63
56
|
setRuntimeConfig(nConfig.resolved, 'masterApp', Object.assign(typeof masterApp === 'object' ? _objectSpread({}, masterApp) : {}, {
|
|
64
57
|
basename: (router === null || router === void 0 ? void 0 : (_router$historyOption = router.historyOptions) === null || _router$historyOption === void 0 ? void 0 : _router$historyOption.basename) || (router === null || router === void 0 ? void 0 : router.basename) || '/'
|
|
65
58
|
}));
|
|
66
59
|
}
|
|
67
|
-
|
|
68
60
|
logger(`resolvedConfig`, {
|
|
69
61
|
output: nConfig.resolved.output,
|
|
70
62
|
runtime: nConfig.resolved.runtime,
|
|
@@ -73,31 +65,28 @@ export default (({
|
|
|
73
65
|
});
|
|
74
66
|
return nConfig;
|
|
75
67
|
},
|
|
76
|
-
|
|
77
68
|
config() {
|
|
78
69
|
var _useConfig$output$dis, _useConfig$output, _useConfig$deploy;
|
|
79
|
-
|
|
80
70
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
81
71
|
const useConfig = useConfigContext();
|
|
82
|
-
logger('useConfig', useConfig);
|
|
72
|
+
logger('useConfig', useConfig);
|
|
83
73
|
|
|
74
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
84
75
|
const config = useAppContext();
|
|
85
76
|
pluginsExportsUtils = createRuntimeExportsUtils(config.internalDirectory, 'plugins');
|
|
86
77
|
runtimeExportsUtils = createRuntimeExportsUtils(config.internalDirectory, 'index');
|
|
87
|
-
let disableCssExtract = (_useConfig$output$dis = (_useConfig$output = useConfig.output) === null || _useConfig$output === void 0 ? void 0 : _useConfig$output.disableCssExtract) !== null && _useConfig$output$dis !== void 0 ? _useConfig$output$dis : false;
|
|
78
|
+
let disableCssExtract = (_useConfig$output$dis = (_useConfig$output = useConfig.output) === null || _useConfig$output === void 0 ? void 0 : _useConfig$output.disableCssExtract) !== null && _useConfig$output$dis !== void 0 ? _useConfig$output$dis : false;
|
|
88
79
|
|
|
80
|
+
// When the micro-frontend application js entry, there is no need to extract css, close cssExtract
|
|
89
81
|
if ((_useConfig$deploy = useConfig.deploy) !== null && _useConfig$deploy !== void 0 && _useConfig$deploy.microFrontend) {
|
|
90
82
|
var _useConfig$deploy2;
|
|
91
|
-
|
|
92
83
|
const {
|
|
93
84
|
enableHtmlEntry
|
|
94
85
|
} = getDefaultMicroFrontedConfig((_useConfig$deploy2 = useConfig.deploy) === null || _useConfig$deploy2 === void 0 ? void 0 : _useConfig$deploy2.microFrontend);
|
|
95
|
-
|
|
96
86
|
if (!enableHtmlEntry) {
|
|
97
87
|
disableCssExtract = true;
|
|
98
88
|
}
|
|
99
89
|
}
|
|
100
|
-
|
|
101
90
|
return {
|
|
102
91
|
output: {
|
|
103
92
|
disableCssExtract
|
|
@@ -120,36 +109,30 @@ export default (({
|
|
|
120
109
|
CHAIN_ID
|
|
121
110
|
}) => {
|
|
122
111
|
var _resolveOptions$deplo, _resolveWebpackConfig;
|
|
123
|
-
|
|
124
112
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
125
113
|
const resolveOptions = useResolvedConfigContext();
|
|
126
|
-
|
|
127
114
|
if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$deplo = resolveOptions.deploy) !== null && _resolveOptions$deplo !== void 0 && _resolveOptions$deplo.microFrontend) {
|
|
128
115
|
var _resolveOptions$serve, _resolveOptions$deplo2;
|
|
129
|
-
|
|
130
116
|
chain.output.libraryTarget('umd');
|
|
131
|
-
|
|
132
117
|
if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$serve = resolveOptions.server) !== null && _resolveOptions$serve !== void 0 && _resolveOptions$serve.port && _env === 'development') {
|
|
133
118
|
chain.output.publicPath(`//localhost:${resolveOptions.server.port}/`);
|
|
134
|
-
}
|
|
135
|
-
|
|
119
|
+
}
|
|
136
120
|
|
|
121
|
+
// add comments avoid sourcemap abnormal
|
|
137
122
|
if (webpack.BannerPlugin) {
|
|
138
123
|
chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [{
|
|
139
124
|
banner: 'Micro front-end'
|
|
140
125
|
}]);
|
|
141
126
|
}
|
|
142
|
-
|
|
143
127
|
const {
|
|
144
128
|
enableHtmlEntry,
|
|
145
129
|
externalBasicLibrary
|
|
146
|
-
} = getDefaultMicroFrontedConfig((_resolveOptions$deplo2 = resolveOptions.deploy) === null || _resolveOptions$deplo2 === void 0 ? void 0 : _resolveOptions$deplo2.microFrontend);
|
|
147
|
-
|
|
130
|
+
} = getDefaultMicroFrontedConfig((_resolveOptions$deplo2 = resolveOptions.deploy) === null || _resolveOptions$deplo2 === void 0 ? void 0 : _resolveOptions$deplo2.microFrontend);
|
|
131
|
+
// external
|
|
148
132
|
if (externalBasicLibrary) {
|
|
149
133
|
chain.externals(externals);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
|
134
|
+
}
|
|
135
|
+
// use html mode
|
|
153
136
|
if (!enableHtmlEntry) {
|
|
154
137
|
chain.output.filename('index.js');
|
|
155
138
|
chain.plugins.delete(`${CHAIN_ID.PLUGIN.HTML}-main`);
|
|
@@ -159,7 +142,6 @@ export default (({
|
|
|
159
142
|
});
|
|
160
143
|
}
|
|
161
144
|
}
|
|
162
|
-
|
|
163
145
|
const resolveWebpackConfig = chain.toConfig();
|
|
164
146
|
logger('webpackConfig', {
|
|
165
147
|
output: resolveWebpackConfig.output,
|
|
@@ -172,14 +154,12 @@ export default (({
|
|
|
172
154
|
}
|
|
173
155
|
};
|
|
174
156
|
},
|
|
175
|
-
|
|
176
157
|
addRuntimeExports() {
|
|
177
158
|
const addExportStatement = `export { default as garfish, default as masterApp, hoistNonReactStatics } from '${_pluginName}'`;
|
|
178
159
|
logger('exportStatement', addExportStatement);
|
|
179
160
|
pluginsExportsUtils.addExport(addExportStatement);
|
|
180
161
|
runtimeExportsUtils.addExport(`export * from '${_mfPackagePath}'`);
|
|
181
162
|
},
|
|
182
|
-
|
|
183
163
|
modifyEntryImports({
|
|
184
164
|
entrypoint,
|
|
185
165
|
imports
|
|
@@ -189,7 +169,6 @@ export default (({
|
|
|
189
169
|
const {
|
|
190
170
|
masterApp
|
|
191
171
|
} = getRuntimeConfig(config);
|
|
192
|
-
|
|
193
172
|
if (masterApp) {
|
|
194
173
|
imports.push({
|
|
195
174
|
value: _runtimePluginName,
|
|
@@ -204,7 +183,6 @@ export default (({
|
|
|
204
183
|
}]
|
|
205
184
|
});
|
|
206
185
|
}
|
|
207
|
-
|
|
208
186
|
imports.push({
|
|
209
187
|
value: _runtimePluginName,
|
|
210
188
|
specifiers: [{
|
|
@@ -224,7 +202,6 @@ export default (({
|
|
|
224
202
|
entrypoint
|
|
225
203
|
};
|
|
226
204
|
},
|
|
227
|
-
|
|
228
205
|
modifyEntryRuntimePlugins({
|
|
229
206
|
entrypoint,
|
|
230
207
|
plugins
|
|
@@ -234,7 +211,6 @@ export default (({
|
|
|
234
211
|
const {
|
|
235
212
|
masterApp
|
|
236
213
|
} = getRuntimeConfig(config);
|
|
237
|
-
|
|
238
214
|
if (masterApp) {
|
|
239
215
|
logger('garfishPlugin options', masterApp);
|
|
240
216
|
plugins.push({
|
|
@@ -243,29 +219,24 @@ export default (({
|
|
|
243
219
|
options: masterApp === true ? JSON.stringify({}) : JSON.stringify(masterApp)
|
|
244
220
|
});
|
|
245
221
|
}
|
|
246
|
-
|
|
247
222
|
return {
|
|
248
223
|
entrypoint,
|
|
249
224
|
plugins
|
|
250
225
|
};
|
|
251
226
|
},
|
|
252
|
-
|
|
253
227
|
modifyEntryRenderFunction({
|
|
254
228
|
entrypoint,
|
|
255
229
|
code
|
|
256
230
|
}) {
|
|
257
231
|
var _config$deploy;
|
|
258
|
-
|
|
259
232
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
260
233
|
const config = useResolvedConfigContext();
|
|
261
|
-
|
|
262
234
|
if (!(config !== null && config !== void 0 && (_config$deploy = config.deploy) !== null && _config$deploy !== void 0 && _config$deploy.microFrontend)) {
|
|
263
235
|
return {
|
|
264
236
|
entrypoint,
|
|
265
237
|
code
|
|
266
238
|
};
|
|
267
239
|
}
|
|
268
|
-
|
|
269
240
|
const nCode = makeRenderFunction(code);
|
|
270
241
|
logger('makeRenderFunction', nCode);
|
|
271
242
|
return {
|
|
@@ -273,16 +244,13 @@ export default (({
|
|
|
273
244
|
code: nCode
|
|
274
245
|
};
|
|
275
246
|
},
|
|
276
|
-
|
|
277
247
|
modifyEntryExport({
|
|
278
248
|
entrypoint,
|
|
279
249
|
exportStatement
|
|
280
250
|
}) {
|
|
281
251
|
var _config$deploy2;
|
|
282
|
-
|
|
283
252
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
284
253
|
const config = useResolvedConfigContext();
|
|
285
|
-
|
|
286
254
|
if (config !== null && config !== void 0 && (_config$deploy2 = config.deploy) !== null && _config$deploy2 !== void 0 && _config$deploy2.microFrontend) {
|
|
287
255
|
const exportStatementCode = makeProvider();
|
|
288
256
|
logger('exportStatement', exportStatementCode);
|
|
@@ -291,13 +259,11 @@ export default (({
|
|
|
291
259
|
exportStatement: exportStatementCode
|
|
292
260
|
};
|
|
293
261
|
}
|
|
294
|
-
|
|
295
262
|
return {
|
|
296
263
|
entrypoint,
|
|
297
264
|
exportStatement
|
|
298
265
|
};
|
|
299
266
|
}
|
|
300
|
-
|
|
301
267
|
};
|
|
302
268
|
}
|
|
303
269
|
}));
|
|
@@ -86,32 +86,28 @@ export const makeRenderFunction = code => {
|
|
|
86
86
|
let { AppWrapper, mountNode } = generateAppWrapperAndRootDom({App, props, dom});
|
|
87
87
|
`;
|
|
88
88
|
return inGarfishToRender + code.replace(`router(`, `generateRouterPlugin(basename,`).replace('(App)', `(AppWrapper)`).replace(/MOUNT_ID/g, 'mountNode').replace(`bootstrap(AppWrapper, mountNode, root`, 'bootstrap(AppWrapper, mountNode, root = IS_REACT18 ? ReactDOM.createRoot(mountNode) : null');
|
|
89
|
-
};
|
|
89
|
+
};
|
|
90
90
|
|
|
91
|
+
// support legacy config
|
|
91
92
|
export function getRuntimeConfig(config) {
|
|
92
93
|
var _config$runtime;
|
|
93
|
-
|
|
94
94
|
if (config !== null && config !== void 0 && (_config$runtime = config.runtime) !== null && _config$runtime !== void 0 && _config$runtime.features) {
|
|
95
95
|
var _config$runtime2;
|
|
96
|
-
|
|
97
96
|
return config === null || config === void 0 ? void 0 : (_config$runtime2 = config.runtime) === null || _config$runtime2 === void 0 ? void 0 : _config$runtime2.features;
|
|
98
97
|
}
|
|
99
|
-
|
|
100
98
|
return (config === null || config === void 0 ? void 0 : config.runtime) || {};
|
|
101
|
-
}
|
|
99
|
+
}
|
|
102
100
|
|
|
101
|
+
// support legacy config
|
|
103
102
|
export function setRuntimeConfig(config, key, value) {
|
|
104
103
|
var _config$runtime3, _config$runtime4;
|
|
105
|
-
|
|
106
104
|
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]) {
|
|
107
105
|
config.runtime.features[key] = value;
|
|
108
106
|
return undefined;
|
|
109
107
|
}
|
|
110
|
-
|
|
111
108
|
if (config !== null && config !== void 0 && config.runtime && config !== null && config !== void 0 && config.runtime[key]) {
|
|
112
109
|
config.runtime[key] = value;
|
|
113
110
|
return undefined;
|
|
114
111
|
}
|
|
115
|
-
|
|
116
112
|
return undefined;
|
|
117
113
|
}
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
const _excluded = ["loadable"];
|
|
2
|
-
|
|
3
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
|
-
|
|
5
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
-
|
|
7
4
|
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; }
|
|
8
|
-
|
|
9
5
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
10
|
-
|
|
11
6
|
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; }
|
|
12
|
-
|
|
13
7
|
// logical reference to https://github.com/jamiebuilds/react-loadable/blob/6201c5837b212d6244c57f3748f2b1375096beeb/src/index.js
|
|
14
8
|
import { useState, useEffect, useCallback } from 'react';
|
|
15
9
|
import { logger } from "../util";
|
|
@@ -25,12 +19,10 @@ export function Loadable(WrapComponent) {
|
|
|
25
19
|
return function (defaultLoadable) {
|
|
26
20
|
return function Lodable(props) {
|
|
27
21
|
var _props$loadable;
|
|
28
|
-
|
|
29
22
|
const {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
loadable = defaultLoadable !== null && defaultLoadable !== void 0 ? defaultLoadable : DEFAULT_LOADABLE
|
|
24
|
+
} = props,
|
|
25
|
+
otherProps = _objectWithoutProperties(props, _excluded);
|
|
34
26
|
let delayTimer = null;
|
|
35
27
|
let timeoutTimer = null;
|
|
36
28
|
const [state, setState] = useState(() => {
|
|
@@ -44,7 +36,6 @@ export function Loadable(WrapComponent) {
|
|
|
44
36
|
timedOut: false,
|
|
45
37
|
isLoading: false
|
|
46
38
|
};
|
|
47
|
-
|
|
48
39
|
if (typeof delay === 'number') {
|
|
49
40
|
if (delay === 0) {
|
|
50
41
|
initState.pastDelay = true;
|
|
@@ -56,7 +47,6 @@ export function Loadable(WrapComponent) {
|
|
|
56
47
|
}, delay);
|
|
57
48
|
}
|
|
58
49
|
}
|
|
59
|
-
|
|
60
50
|
if (typeof timeout === 'number') {
|
|
61
51
|
timeoutTimer = setTimeout(() => {
|
|
62
52
|
setStateWithMountCheck({
|
|
@@ -64,7 +54,6 @@ export function Loadable(WrapComponent) {
|
|
|
64
54
|
});
|
|
65
55
|
}, timeout);
|
|
66
56
|
}
|
|
67
|
-
|
|
68
57
|
return initState;
|
|
69
58
|
});
|
|
70
59
|
const LoadingComponent = (_props$loadable = props.loadable) === null || _props$loadable === void 0 ? void 0 : _props$loadable.loading;
|
|
@@ -80,12 +69,10 @@ export function Loadable(WrapComponent) {
|
|
|
80
69
|
isLoading: false,
|
|
81
70
|
error: null
|
|
82
71
|
});
|
|
83
|
-
|
|
84
72
|
if (delayTimer) {
|
|
85
73
|
clearTimeout(delayTimer);
|
|
86
74
|
delayTimer = null;
|
|
87
75
|
}
|
|
88
|
-
|
|
89
76
|
if (timeoutTimer) {
|
|
90
77
|
clearTimeout(timeoutTimer);
|
|
91
78
|
timeoutTimer = null;
|
|
@@ -119,7 +106,6 @@ export function Loadable(WrapComponent) {
|
|
|
119
106
|
if (props.error && !LoadingComponent) {
|
|
120
107
|
throw props.error;
|
|
121
108
|
}
|
|
122
|
-
|
|
123
109
|
setStateWithMountCheck(props);
|
|
124
110
|
}
|
|
125
111
|
}, otherProps))]
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
const _excluded = ["manifest"];
|
|
2
|
-
|
|
3
2
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
4
|
-
|
|
5
3
|
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; }
|
|
6
|
-
|
|
7
4
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
|
-
|
|
9
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
|
-
|
|
11
6
|
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; }
|
|
12
|
-
|
|
13
7
|
import GarfishInstance from 'garfish';
|
|
14
8
|
import React from 'react';
|
|
15
9
|
import hoistNonReactStatics from 'hoist-non-react-statics';
|
|
@@ -19,55 +13,47 @@ import setExternal from "./utils/setExternal";
|
|
|
19
13
|
import { generateMApp } from "./utils/MApp";
|
|
20
14
|
import { generateApps } from "./utils/apps";
|
|
21
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
-
|
|
23
16
|
async function initOptions(manifest = {}, options) {
|
|
24
17
|
var _window, _window$modern_manife, _window2, _window2$modern_manif;
|
|
18
|
+
let apps = options.apps || [];
|
|
25
19
|
|
|
26
|
-
|
|
27
|
-
|
|
20
|
+
// use manifest modules
|
|
28
21
|
if (manifest !== null && manifest !== void 0 && manifest.modules) {
|
|
29
22
|
if ((manifest === null || manifest === void 0 ? void 0 : manifest.modules.length) > 0) {
|
|
30
23
|
apps = manifest === null || manifest === void 0 ? void 0 : manifest.modules;
|
|
31
24
|
}
|
|
32
|
-
|
|
33
25
|
logger('manifest modules', apps);
|
|
34
|
-
}
|
|
35
|
-
|
|
26
|
+
}
|
|
36
27
|
|
|
28
|
+
// get module list
|
|
37
29
|
if (manifest !== null && manifest !== void 0 && manifest.getAppList) {
|
|
38
30
|
const getAppList = await (manifest === null || manifest === void 0 ? void 0 : manifest.getAppList(manifest));
|
|
39
|
-
|
|
40
31
|
if (getAppList.length > 0) {
|
|
41
32
|
apps = getAppList;
|
|
42
33
|
}
|
|
43
|
-
|
|
44
34
|
logger('getAppList modules', apps);
|
|
45
|
-
}
|
|
46
|
-
|
|
35
|
+
}
|
|
47
36
|
|
|
37
|
+
// get inject modules list
|
|
48
38
|
if ((_window = window) !== null && _window !== void 0 && (_window$modern_manife = _window.modern_manifest) !== null && _window$modern_manife !== void 0 && _window$modern_manife.modules && ((_window2 = window) === null || _window2 === void 0 ? void 0 : (_window2$modern_manif = _window2.modern_manifest) === null || _window2$modern_manif === void 0 ? void 0 : _window2$modern_manif.modules.length) > 0) {
|
|
49
39
|
var _window3, _window3$modern_manif;
|
|
50
|
-
|
|
51
40
|
apps = (_window3 = window) === null || _window3 === void 0 ? void 0 : (_window3$modern_manif = _window3.modern_manifest) === null || _window3$modern_manif === void 0 ? void 0 : _window3$modern_manif.modules;
|
|
52
41
|
logger('modern_manifest', apps);
|
|
53
42
|
}
|
|
54
|
-
|
|
55
43
|
return _objectSpread(_objectSpread({}, options), {}, {
|
|
56
44
|
apps
|
|
57
45
|
});
|
|
58
|
-
}
|
|
59
|
-
|
|
46
|
+
}
|
|
60
47
|
|
|
48
|
+
// export default GarfishPlugin;
|
|
61
49
|
export default (config => ({
|
|
62
50
|
name: '@modern-js/garfish-plugin',
|
|
63
51
|
setup: () => {
|
|
64
52
|
setExternal();
|
|
65
|
-
|
|
66
53
|
const {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
54
|
+
manifest
|
|
55
|
+
} = config,
|
|
56
|
+
options = _objectWithoutProperties(config, _excluded);
|
|
71
57
|
logger('createPlugin', config);
|
|
72
58
|
const promise = initOptions(manifest, options);
|
|
73
59
|
return {
|
|
@@ -77,7 +63,6 @@ export default (config => ({
|
|
|
77
63
|
class GetMicroFrontendApp extends React.Component {
|
|
78
64
|
constructor(props) {
|
|
79
65
|
super(props);
|
|
80
|
-
|
|
81
66
|
_defineProperty(this, "state", {
|
|
82
67
|
MApp: () => {
|
|
83
68
|
logger('MApp init Component Render');
|
|
@@ -87,11 +72,9 @@ export default (config => ({
|
|
|
87
72
|
get() {
|
|
88
73
|
return () => /*#__PURE__*/React.createElement('div');
|
|
89
74
|
}
|
|
90
|
-
|
|
91
75
|
}),
|
|
92
76
|
appInfoList: []
|
|
93
77
|
});
|
|
94
|
-
|
|
95
78
|
const load = async () => {
|
|
96
79
|
GarfishInstance.setOptions(_objectSpread(_objectSpread({}, options), {}, {
|
|
97
80
|
insulationVariable: [...(options.insulationVariable || []), '_SERVER_DATA'],
|
|
@@ -119,10 +102,8 @@ export default (config => ({
|
|
|
119
102
|
appInfoList
|
|
120
103
|
});
|
|
121
104
|
};
|
|
122
|
-
|
|
123
105
|
load();
|
|
124
106
|
}
|
|
125
|
-
|
|
126
107
|
render() {
|
|
127
108
|
logger('GarfishProvider state', this.state);
|
|
128
109
|
return /*#__PURE__*/_jsx(GarfishProvider, {
|
|
@@ -130,14 +111,11 @@ export default (config => ({
|
|
|
130
111
|
children: /*#__PURE__*/_jsx(App, _objectSpread(_objectSpread({}, this.props), this.state))
|
|
131
112
|
});
|
|
132
113
|
}
|
|
133
|
-
|
|
134
114
|
}
|
|
135
|
-
|
|
136
115
|
return next({
|
|
137
116
|
App: hoistNonReactStatics(GetMicroFrontendApp, App)
|
|
138
117
|
});
|
|
139
118
|
}
|
|
140
|
-
|
|
141
119
|
};
|
|
142
120
|
}
|
|
143
121
|
}));
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
2
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
3
|
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; }
|
|
6
|
-
|
|
7
4
|
import React, { useContext } from 'react';
|
|
8
5
|
import { logger } from "../util";
|
|
9
6
|
import { GarfishContext } from "./utils/Context";
|
|
@@ -25,10 +22,8 @@ export function useModuleApps() {
|
|
|
25
22
|
if (typeof p === 'string' && p in target) {
|
|
26
23
|
return Reflect.get(target, p, receiver);
|
|
27
24
|
}
|
|
28
|
-
|
|
29
25
|
return () => /*#__PURE__*/React.createElement('div');
|
|
30
26
|
}
|
|
31
|
-
|
|
32
27
|
});
|
|
33
28
|
return Info;
|
|
34
29
|
}
|