@modern-js/plugin-garfish 1.4.10 → 1.4.13-alpha.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 +15 -0
- package/dist/js/modern/cli/index.js +50 -9
- package/dist/js/modern/runtime/loadable.js +13 -9
- package/dist/js/modern/runtime/plugin.js +3 -2
- package/dist/js/modern/runtime/utils/MApp.js +9 -6
- package/dist/js/modern/runtime/utils/apps.js +7 -5
- package/dist/js/node/cli/index.js +52 -9
- package/dist/js/node/runtime/loadable.js +13 -9
- package/dist/js/node/runtime/plugin.js +3 -2
- package/dist/js/node/runtime/utils/MApp.js +9 -6
- package/dist/js/node/runtime/utils/apps.js +7 -5
- package/dist/js/treeshaking/cli/index.js +64 -37
- package/dist/js/treeshaking/runtime/loadable.js +19 -40
- package/dist/js/treeshaking/runtime/plugin.js +12 -40
- package/dist/js/treeshaking/runtime/useModuleApps.js +1 -6
- package/dist/js/treeshaking/runtime/utils/MApp.js +17 -37
- package/dist/js/treeshaking/runtime/utils/apps.js +15 -40
- package/dist/types/cli/index.d.ts +8 -1
- package/package.json +36 -13
- package/.eslintrc.js +0 -8
- package/jest.config.js +0 -7
- package/modern.config.js +0 -2
- package/tsconfig.json +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @modern-js/plugin-garfish
|
|
2
2
|
|
|
3
|
+
## 1.4.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- d32f35134: chore: add modern/jest/eslint/ts config files to .npmignore
|
|
8
|
+
- Updated dependencies [d32f35134]
|
|
9
|
+
- Updated dependencies [6ae4a34ae]
|
|
10
|
+
- Updated dependencies [97086dde8]
|
|
11
|
+
- Updated dependencies [97086dde8]
|
|
12
|
+
- Updated dependencies [b80229c79]
|
|
13
|
+
- Updated dependencies [948cc4436]
|
|
14
|
+
- @modern-js/plugin-router@1.2.14
|
|
15
|
+
- @modern-js/runtime-core@1.4.6
|
|
16
|
+
- @modern-js/utils@1.7.3
|
|
17
|
+
|
|
3
18
|
## 1.4.10
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -12,6 +12,20 @@ export const externals = {
|
|
|
12
12
|
'react-dom': 'react-dom',
|
|
13
13
|
react: 'react'
|
|
14
14
|
};
|
|
15
|
+
export function getDefaultMicroFrontedConfig(microFrontend) {
|
|
16
|
+
if (microFrontend === true) {
|
|
17
|
+
return {
|
|
18
|
+
enableHtmlEntry: true,
|
|
19
|
+
externalBasicLibrary: false,
|
|
20
|
+
moduleApp: ''
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return _objectSpread({
|
|
25
|
+
enableHtmlEntry: true,
|
|
26
|
+
externalBasicLibrary: false
|
|
27
|
+
}, microFrontend);
|
|
28
|
+
}
|
|
15
29
|
export default (({
|
|
16
30
|
runtimePluginName: _runtimePluginName = '@modern-js/runtime/plugins',
|
|
17
31
|
mfPackagePath: _mfPackagePath = path.resolve(__dirname, '../../../../')
|
|
@@ -19,7 +33,8 @@ export default (({
|
|
|
19
33
|
name: '@modern-js/plugin-garfish',
|
|
20
34
|
setup: ({
|
|
21
35
|
useAppContext,
|
|
22
|
-
useResolvedConfigContext
|
|
36
|
+
useResolvedConfigContext,
|
|
37
|
+
useConfigContext
|
|
23
38
|
}) => {
|
|
24
39
|
let pluginsExportsUtils;
|
|
25
40
|
let runtimeExportsUtils;
|
|
@@ -50,6 +65,7 @@ export default (({
|
|
|
50
65
|
}
|
|
51
66
|
|
|
52
67
|
logger(`resolvedConfig`, {
|
|
68
|
+
output: nConfig.resolved.output,
|
|
53
69
|
runtime: nConfig.resolved.runtime,
|
|
54
70
|
deploy: nConfig.resolved.deploy,
|
|
55
71
|
server: nConfig.resolved.server
|
|
@@ -58,13 +74,33 @@ export default (({
|
|
|
58
74
|
},
|
|
59
75
|
|
|
60
76
|
config() {
|
|
77
|
+
var _useConfig$output$dis, _useConfig$output, _useConfig$deploy;
|
|
78
|
+
|
|
61
79
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
62
|
-
const
|
|
80
|
+
const useConfig = useConfigContext();
|
|
81
|
+
logger('useConfig', useConfig); // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
63
82
|
|
|
64
|
-
const
|
|
83
|
+
const config = useAppContext();
|
|
65
84
|
pluginsExportsUtils = createRuntimeExportsUtils(config.internalDirectory, 'plugins');
|
|
66
85
|
runtimeExportsUtils = createRuntimeExportsUtils(config.internalDirectory, 'index');
|
|
86
|
+
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; // When the micro-frontend application js entry, there is no need to extract css, close cssExtract
|
|
87
|
+
|
|
88
|
+
if ((_useConfig$deploy = useConfig.deploy) !== null && _useConfig$deploy !== void 0 && _useConfig$deploy.microFrontend) {
|
|
89
|
+
var _useConfig$deploy2;
|
|
90
|
+
|
|
91
|
+
const {
|
|
92
|
+
enableHtmlEntry
|
|
93
|
+
} = getDefaultMicroFrontedConfig((_useConfig$deploy2 = useConfig.deploy) === null || _useConfig$deploy2 === void 0 ? void 0 : _useConfig$deploy2.microFrontend);
|
|
94
|
+
|
|
95
|
+
if (!enableHtmlEntry) {
|
|
96
|
+
disableCssExtract = true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
67
100
|
return {
|
|
101
|
+
output: {
|
|
102
|
+
disableCssExtract
|
|
103
|
+
},
|
|
68
104
|
source: {
|
|
69
105
|
alias: {
|
|
70
106
|
'@modern-js/runtime/plugins': pluginsExportsUtils.getPath()
|
|
@@ -83,8 +119,11 @@ export default (({
|
|
|
83
119
|
}) => {
|
|
84
120
|
var _resolveOptions$deplo, _resolveWebpackConfig;
|
|
85
121
|
|
|
122
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
123
|
+
const resolveOptions = useResolvedConfigContext();
|
|
124
|
+
|
|
86
125
|
if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$deplo = resolveOptions.deploy) !== null && _resolveOptions$deplo !== void 0 && _resolveOptions$deplo.microFrontend) {
|
|
87
|
-
var _resolveOptions$serve, _resolveOptions$deplo2
|
|
126
|
+
var _resolveOptions$serve, _resolveOptions$deplo2;
|
|
88
127
|
|
|
89
128
|
chain.output.libraryTarget('umd');
|
|
90
129
|
|
|
@@ -100,9 +139,9 @@ export default (({
|
|
|
100
139
|
}
|
|
101
140
|
|
|
102
141
|
const {
|
|
103
|
-
enableHtmlEntry
|
|
104
|
-
externalBasicLibrary
|
|
105
|
-
} =
|
|
142
|
+
enableHtmlEntry,
|
|
143
|
+
externalBasicLibrary
|
|
144
|
+
} = getDefaultMicroFrontedConfig((_resolveOptions$deplo2 = resolveOptions.deploy) === null || _resolveOptions$deplo2 === void 0 ? void 0 : _resolveOptions$deplo2.microFrontend); // external
|
|
106
145
|
|
|
107
146
|
if (externalBasicLibrary) {
|
|
108
147
|
chain.externals(externals);
|
|
@@ -111,7 +150,8 @@ export default (({
|
|
|
111
150
|
|
|
112
151
|
if (!enableHtmlEntry) {
|
|
113
152
|
chain.output.filename('index.js');
|
|
114
|
-
chain.plugins.delete('html-main');
|
|
153
|
+
chain.plugins.delete('html-main'); // chain.plugins.delete('mini-css-extract');
|
|
154
|
+
|
|
115
155
|
chain.optimization.runtimeChunk(false);
|
|
116
156
|
chain.optimization.splitChunks({
|
|
117
157
|
chunks: 'async'
|
|
@@ -124,7 +164,8 @@ export default (({
|
|
|
124
164
|
output: resolveWebpackConfig.output,
|
|
125
165
|
externals: resolveWebpackConfig.externals,
|
|
126
166
|
env: _env,
|
|
127
|
-
alias: (_resolveWebpackConfig = resolveWebpackConfig.resolve) === null || _resolveWebpackConfig === void 0 ? void 0 : _resolveWebpackConfig.alias
|
|
167
|
+
alias: (_resolveWebpackConfig = resolveWebpackConfig.resolve) === null || _resolveWebpackConfig === void 0 ? void 0 : _resolveWebpackConfig.alias,
|
|
168
|
+
plugins: resolveWebpackConfig.plugins
|
|
128
169
|
});
|
|
129
170
|
}
|
|
130
171
|
}
|
|
@@ -4,12 +4,12 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
4
4
|
|
|
5
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; }
|
|
6
6
|
|
|
7
|
-
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
7
|
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
8
|
|
|
11
9
|
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
10
|
|
|
11
|
+
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
13
|
// logical reference to https://github.com/jamiebuilds/react-loadable/blob/6201c5837b212d6244c57f3748f2b1375096beeb/src/index.js
|
|
14
14
|
import React from 'react';
|
|
15
15
|
import { logger } from "../util";
|
|
@@ -21,24 +21,28 @@ export function Loadable(WrapComponent) {
|
|
|
21
21
|
return class LoadableComponent extends React.Component {
|
|
22
22
|
constructor(...args) {
|
|
23
23
|
super(...args);
|
|
24
|
-
|
|
24
|
+
|
|
25
|
+
_defineProperty(this, "state", {
|
|
25
26
|
error: null,
|
|
26
27
|
pastDelay: false,
|
|
27
28
|
timedOut: false,
|
|
28
29
|
isLoading: false
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
this
|
|
32
|
-
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
_defineProperty(this, "mounted", false);
|
|
33
|
+
|
|
34
|
+
_defineProperty(this, "delay", void 0);
|
|
33
35
|
|
|
34
|
-
this
|
|
36
|
+
_defineProperty(this, "timeout", void 0);
|
|
37
|
+
|
|
38
|
+
_defineProperty(this, "retry", () => {
|
|
35
39
|
this.setState({
|
|
36
40
|
error: null,
|
|
37
41
|
isLoading: true,
|
|
38
42
|
timedOut: false
|
|
39
43
|
}); // res = loadFn(opts.loader);
|
|
40
44
|
// this._loadModule();
|
|
41
|
-
};
|
|
45
|
+
});
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -76,7 +76,8 @@ export default (config => ({
|
|
|
76
76
|
class GetMicroFrontendApp extends React.Component {
|
|
77
77
|
constructor(props) {
|
|
78
78
|
super(props);
|
|
79
|
-
|
|
79
|
+
|
|
80
|
+
_defineProperty(this, "state", {
|
|
80
81
|
MApp: () => {
|
|
81
82
|
logger('MApp init Component Render');
|
|
82
83
|
return /*#__PURE__*/React.createElement('div');
|
|
@@ -88,7 +89,7 @@ export default (config => ({
|
|
|
88
89
|
|
|
89
90
|
}),
|
|
90
91
|
appInfoList: []
|
|
91
|
-
};
|
|
92
|
+
});
|
|
92
93
|
|
|
93
94
|
const load = async () => {
|
|
94
95
|
const GarfishConfig = await promise;
|
|
@@ -4,12 +4,12 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
4
4
|
|
|
5
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; }
|
|
6
6
|
|
|
7
|
-
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
7
|
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
8
|
|
|
11
9
|
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
10
|
|
|
11
|
+
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
13
|
import React from 'react'; // eslint-disable-next-line import/no-named-as-default
|
|
14
14
|
|
|
15
15
|
import Garfish from 'garfish';
|
|
@@ -20,9 +20,10 @@ export function generateMApp(options, manifest) {
|
|
|
20
20
|
class MApp extends React.Component {
|
|
21
21
|
constructor(...args) {
|
|
22
22
|
super(...args);
|
|
23
|
-
|
|
23
|
+
|
|
24
|
+
_defineProperty(this, "state", {
|
|
24
25
|
domId: generateSubAppContainerKey()
|
|
25
|
-
};
|
|
26
|
+
});
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
componentDidMount() {
|
|
@@ -47,7 +48,7 @@ export function generateMApp(options, manifest) {
|
|
|
47
48
|
listening: true
|
|
48
49
|
});
|
|
49
50
|
|
|
50
|
-
const garfishOptions = _objectSpread({
|
|
51
|
+
const garfishOptions = _objectSpread(_objectSpread({
|
|
51
52
|
domGetter: `#${domId}`,
|
|
52
53
|
|
|
53
54
|
beforeLoad(...args) {
|
|
@@ -91,7 +92,9 @@ export function generateMApp(options, manifest) {
|
|
|
91
92
|
return errorUnmountApp === null || errorUnmountApp === void 0 ? void 0 : errorUnmountApp(error, ...args);
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
}, otherOptions)
|
|
95
|
+
}, otherOptions), {}, {
|
|
96
|
+
insulationVariable: [...(otherOptions.insulationVariable || []), '_SERVER_DATA']
|
|
97
|
+
});
|
|
95
98
|
|
|
96
99
|
logger('MApp componentDidMount', {
|
|
97
100
|
garfishRunning: Garfish.running,
|
|
@@ -4,12 +4,12 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
4
4
|
|
|
5
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; }
|
|
6
6
|
|
|
7
|
-
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
7
|
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
8
|
|
|
11
9
|
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
10
|
|
|
11
|
+
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
13
|
// The loading logic of the current component refers to react-loadable https://github.com/jamiebuilds/react-loadable
|
|
14
14
|
import path from 'path';
|
|
15
15
|
import React from 'react'; // eslint-disable-next-line import/no-named-as-default
|
|
@@ -33,12 +33,13 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
33
33
|
class MicroApp extends React.Component {
|
|
34
34
|
constructor(...args) {
|
|
35
35
|
super(...args);
|
|
36
|
-
|
|
36
|
+
|
|
37
|
+
_defineProperty(this, "state", {
|
|
37
38
|
appInstance: null,
|
|
38
39
|
domId: generateSubAppContainerKey(appInfo)
|
|
39
|
-
};
|
|
40
|
+
});
|
|
40
41
|
|
|
41
|
-
this
|
|
42
|
+
_defineProperty(this, "unregisterHistoryListener", () => {});
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -56,6 +57,7 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
56
57
|
} = this.state;
|
|
57
58
|
|
|
58
59
|
const loadAppOptions = _objectSpread(_objectSpread({}, appInfo), {}, {
|
|
60
|
+
insulationVariable: [...(appInfo.insulationVariable || []), '_SERVER_DATA'],
|
|
59
61
|
domGetter: `#${domId}`,
|
|
60
62
|
basename: path.join((options === null || options === void 0 ? void 0 : options.basename) || '/', (match === null || match === void 0 ? void 0 : match.path) || '/'),
|
|
61
63
|
cache: true,
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.externals = exports.default = void 0;
|
|
7
|
+
exports.getDefaultMicroFrontedConfig = getDefaultMicroFrontedConfig;
|
|
7
8
|
|
|
8
9
|
var _path = _interopRequireDefault(require("path"));
|
|
9
10
|
|
|
@@ -27,6 +28,21 @@ const externals = {
|
|
|
27
28
|
};
|
|
28
29
|
exports.externals = externals;
|
|
29
30
|
|
|
31
|
+
function getDefaultMicroFrontedConfig(microFrontend) {
|
|
32
|
+
if (microFrontend === true) {
|
|
33
|
+
return {
|
|
34
|
+
enableHtmlEntry: true,
|
|
35
|
+
externalBasicLibrary: false,
|
|
36
|
+
moduleApp: ''
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return _objectSpread({
|
|
41
|
+
enableHtmlEntry: true,
|
|
42
|
+
externalBasicLibrary: false
|
|
43
|
+
}, microFrontend);
|
|
44
|
+
}
|
|
45
|
+
|
|
30
46
|
var _default = ({
|
|
31
47
|
runtimePluginName: _runtimePluginName = '@modern-js/runtime/plugins',
|
|
32
48
|
mfPackagePath: _mfPackagePath = _path.default.resolve(__dirname, '../../../../')
|
|
@@ -34,7 +50,8 @@ var _default = ({
|
|
|
34
50
|
name: '@modern-js/plugin-garfish',
|
|
35
51
|
setup: ({
|
|
36
52
|
useAppContext,
|
|
37
|
-
useResolvedConfigContext
|
|
53
|
+
useResolvedConfigContext,
|
|
54
|
+
useConfigContext
|
|
38
55
|
}) => {
|
|
39
56
|
let pluginsExportsUtils;
|
|
40
57
|
let runtimeExportsUtils;
|
|
@@ -65,6 +82,7 @@ var _default = ({
|
|
|
65
82
|
}
|
|
66
83
|
|
|
67
84
|
(0, _util.logger)(`resolvedConfig`, {
|
|
85
|
+
output: nConfig.resolved.output,
|
|
68
86
|
runtime: nConfig.resolved.runtime,
|
|
69
87
|
deploy: nConfig.resolved.deploy,
|
|
70
88
|
server: nConfig.resolved.server
|
|
@@ -73,13 +91,33 @@ var _default = ({
|
|
|
73
91
|
},
|
|
74
92
|
|
|
75
93
|
config() {
|
|
94
|
+
var _useConfig$output$dis, _useConfig$output, _useConfig$deploy;
|
|
95
|
+
|
|
76
96
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
77
|
-
const
|
|
97
|
+
const useConfig = useConfigContext();
|
|
98
|
+
(0, _util.logger)('useConfig', useConfig); // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
78
99
|
|
|
79
|
-
const
|
|
100
|
+
const config = useAppContext();
|
|
80
101
|
pluginsExportsUtils = (0, _utils.createRuntimeExportsUtils)(config.internalDirectory, 'plugins');
|
|
81
102
|
runtimeExportsUtils = (0, _utils.createRuntimeExportsUtils)(config.internalDirectory, 'index');
|
|
103
|
+
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; // When the micro-frontend application js entry, there is no need to extract css, close cssExtract
|
|
104
|
+
|
|
105
|
+
if ((_useConfig$deploy = useConfig.deploy) !== null && _useConfig$deploy !== void 0 && _useConfig$deploy.microFrontend) {
|
|
106
|
+
var _useConfig$deploy2;
|
|
107
|
+
|
|
108
|
+
const {
|
|
109
|
+
enableHtmlEntry
|
|
110
|
+
} = getDefaultMicroFrontedConfig((_useConfig$deploy2 = useConfig.deploy) === null || _useConfig$deploy2 === void 0 ? void 0 : _useConfig$deploy2.microFrontend);
|
|
111
|
+
|
|
112
|
+
if (!enableHtmlEntry) {
|
|
113
|
+
disableCssExtract = true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
82
117
|
return {
|
|
118
|
+
output: {
|
|
119
|
+
disableCssExtract
|
|
120
|
+
},
|
|
83
121
|
source: {
|
|
84
122
|
alias: {
|
|
85
123
|
'@modern-js/runtime/plugins': pluginsExportsUtils.getPath()
|
|
@@ -98,8 +136,11 @@ var _default = ({
|
|
|
98
136
|
}) => {
|
|
99
137
|
var _resolveOptions$deplo, _resolveWebpackConfig;
|
|
100
138
|
|
|
139
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
140
|
+
const resolveOptions = useResolvedConfigContext();
|
|
141
|
+
|
|
101
142
|
if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$deplo = resolveOptions.deploy) !== null && _resolveOptions$deplo !== void 0 && _resolveOptions$deplo.microFrontend) {
|
|
102
|
-
var _resolveOptions$serve, _resolveOptions$deplo2
|
|
143
|
+
var _resolveOptions$serve, _resolveOptions$deplo2;
|
|
103
144
|
|
|
104
145
|
chain.output.libraryTarget('umd');
|
|
105
146
|
|
|
@@ -115,9 +156,9 @@ var _default = ({
|
|
|
115
156
|
}
|
|
116
157
|
|
|
117
158
|
const {
|
|
118
|
-
enableHtmlEntry
|
|
119
|
-
externalBasicLibrary
|
|
120
|
-
} =
|
|
159
|
+
enableHtmlEntry,
|
|
160
|
+
externalBasicLibrary
|
|
161
|
+
} = getDefaultMicroFrontedConfig((_resolveOptions$deplo2 = resolveOptions.deploy) === null || _resolveOptions$deplo2 === void 0 ? void 0 : _resolveOptions$deplo2.microFrontend); // external
|
|
121
162
|
|
|
122
163
|
if (externalBasicLibrary) {
|
|
123
164
|
chain.externals(externals);
|
|
@@ -126,7 +167,8 @@ var _default = ({
|
|
|
126
167
|
|
|
127
168
|
if (!enableHtmlEntry) {
|
|
128
169
|
chain.output.filename('index.js');
|
|
129
|
-
chain.plugins.delete('html-main');
|
|
170
|
+
chain.plugins.delete('html-main'); // chain.plugins.delete('mini-css-extract');
|
|
171
|
+
|
|
130
172
|
chain.optimization.runtimeChunk(false);
|
|
131
173
|
chain.optimization.splitChunks({
|
|
132
174
|
chunks: 'async'
|
|
@@ -139,7 +181,8 @@ var _default = ({
|
|
|
139
181
|
output: resolveWebpackConfig.output,
|
|
140
182
|
externals: resolveWebpackConfig.externals,
|
|
141
183
|
env: _env,
|
|
142
|
-
alias: (_resolveWebpackConfig = resolveWebpackConfig.resolve) === null || _resolveWebpackConfig === void 0 ? void 0 : _resolveWebpackConfig.alias
|
|
184
|
+
alias: (_resolveWebpackConfig = resolveWebpackConfig.resolve) === null || _resolveWebpackConfig === void 0 ? void 0 : _resolveWebpackConfig.alias,
|
|
185
|
+
plugins: resolveWebpackConfig.plugins
|
|
143
186
|
});
|
|
144
187
|
}
|
|
145
188
|
}
|
|
@@ -19,35 +19,39 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
19
19
|
|
|
20
20
|
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; }
|
|
21
21
|
|
|
22
|
-
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; }
|
|
23
|
-
|
|
24
22
|
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; }
|
|
25
23
|
|
|
26
24
|
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; }
|
|
27
25
|
|
|
26
|
+
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; }
|
|
27
|
+
|
|
28
28
|
function Loadable(WrapComponent) {
|
|
29
29
|
return function (defaultLoadable) {
|
|
30
30
|
return class LoadableComponent extends _react.default.Component {
|
|
31
31
|
constructor(...args) {
|
|
32
32
|
super(...args);
|
|
33
|
-
|
|
33
|
+
|
|
34
|
+
_defineProperty(this, "state", {
|
|
34
35
|
error: null,
|
|
35
36
|
pastDelay: false,
|
|
36
37
|
timedOut: false,
|
|
37
38
|
isLoading: false
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
this
|
|
41
|
-
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
_defineProperty(this, "mounted", false);
|
|
42
|
+
|
|
43
|
+
_defineProperty(this, "delay", void 0);
|
|
42
44
|
|
|
43
|
-
this
|
|
45
|
+
_defineProperty(this, "timeout", void 0);
|
|
46
|
+
|
|
47
|
+
_defineProperty(this, "retry", () => {
|
|
44
48
|
this.setState({
|
|
45
49
|
error: null,
|
|
46
50
|
isLoading: true,
|
|
47
51
|
timedOut: false
|
|
48
52
|
}); // res = loadFn(opts.loader);
|
|
49
53
|
// this._loadModule();
|
|
50
|
-
};
|
|
54
|
+
});
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -92,7 +92,8 @@ var _default = config => ({
|
|
|
92
92
|
class GetMicroFrontendApp extends _react.default.Component {
|
|
93
93
|
constructor(props) {
|
|
94
94
|
super(props);
|
|
95
|
-
|
|
95
|
+
|
|
96
|
+
_defineProperty(this, "state", {
|
|
96
97
|
MApp: () => {
|
|
97
98
|
(0, _util.logger)('MApp init Component Render');
|
|
98
99
|
return /*#__PURE__*/_react.default.createElement('div');
|
|
@@ -104,7 +105,7 @@ var _default = config => ({
|
|
|
104
105
|
|
|
105
106
|
}),
|
|
106
107
|
appInfoList: []
|
|
107
|
-
};
|
|
108
|
+
});
|
|
108
109
|
|
|
109
110
|
const load = async () => {
|
|
110
111
|
const GarfishConfig = await promise;
|
|
@@ -23,19 +23,20 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
23
23
|
|
|
24
24
|
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; }
|
|
25
25
|
|
|
26
|
-
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; }
|
|
27
|
-
|
|
28
26
|
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; }
|
|
29
27
|
|
|
30
28
|
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; }
|
|
31
29
|
|
|
30
|
+
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; }
|
|
31
|
+
|
|
32
32
|
function generateMApp(options, manifest) {
|
|
33
33
|
class MApp extends _react.default.Component {
|
|
34
34
|
constructor(...args) {
|
|
35
35
|
super(...args);
|
|
36
|
-
|
|
36
|
+
|
|
37
|
+
_defineProperty(this, "state", {
|
|
37
38
|
domId: (0, _util.generateSubAppContainerKey)()
|
|
38
|
-
};
|
|
39
|
+
});
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
componentDidMount() {
|
|
@@ -60,7 +61,7 @@ function generateMApp(options, manifest) {
|
|
|
60
61
|
listening: true
|
|
61
62
|
});
|
|
62
63
|
|
|
63
|
-
const garfishOptions = _objectSpread({
|
|
64
|
+
const garfishOptions = _objectSpread(_objectSpread({
|
|
64
65
|
domGetter: `#${domId}`,
|
|
65
66
|
|
|
66
67
|
beforeLoad(...args) {
|
|
@@ -104,7 +105,9 @@ function generateMApp(options, manifest) {
|
|
|
104
105
|
return errorUnmountApp === null || errorUnmountApp === void 0 ? void 0 : errorUnmountApp(error, ...args);
|
|
105
106
|
}
|
|
106
107
|
|
|
107
|
-
}, otherOptions)
|
|
108
|
+
}, otherOptions), {}, {
|
|
109
|
+
insulationVariable: [...(otherOptions.insulationVariable || []), '_SERVER_DATA']
|
|
110
|
+
});
|
|
108
111
|
|
|
109
112
|
(0, _util.logger)('MApp componentDidMount', {
|
|
110
113
|
garfishRunning: _garfish.default.running,
|
|
@@ -27,24 +27,25 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
27
27
|
|
|
28
28
|
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; }
|
|
29
29
|
|
|
30
|
-
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; }
|
|
31
|
-
|
|
32
30
|
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; }
|
|
33
31
|
|
|
34
32
|
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
33
|
|
|
34
|
+
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; }
|
|
35
|
+
|
|
36
36
|
function getAppInstance(options, appInfo, manifest) {
|
|
37
37
|
let locationHref = '';
|
|
38
38
|
|
|
39
39
|
class MicroApp extends _react.default.Component {
|
|
40
40
|
constructor(...args) {
|
|
41
41
|
super(...args);
|
|
42
|
-
|
|
42
|
+
|
|
43
|
+
_defineProperty(this, "state", {
|
|
43
44
|
appInstance: null,
|
|
44
45
|
domId: (0, _util.generateSubAppContainerKey)(appInfo)
|
|
45
|
-
};
|
|
46
|
+
});
|
|
46
47
|
|
|
47
|
-
this
|
|
48
|
+
_defineProperty(this, "unregisterHistoryListener", () => {});
|
|
48
49
|
}
|
|
49
50
|
|
|
50
51
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -62,6 +63,7 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
62
63
|
} = this.state;
|
|
63
64
|
|
|
64
65
|
const loadAppOptions = _objectSpread(_objectSpread({}, appInfo), {}, {
|
|
66
|
+
insulationVariable: [...(appInfo.insulationVariable || []), '_SERVER_DATA'],
|
|
65
67
|
domGetter: `#${domId}`,
|
|
66
68
|
basename: _path.default.join((options === null || options === void 0 ? void 0 : options.basename) || '/', (match === null || match === void 0 ? void 0 : match.path) || '/'),
|
|
67
69
|
cache: true,
|