@modern-js/plugin-garfish 1.4.12 → 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/dist/js/modern/cli/index.js +47 -7
- package/dist/js/modern/runtime/utils/MApp.js +4 -2
- package/dist/js/modern/runtime/utils/apps.js +1 -0
- package/dist/js/node/cli/index.js +49 -7
- package/dist/js/node/runtime/utils/MApp.js +4 -2
- package/dist/js/node/runtime/utils/apps.js +1 -0
- package/dist/js/treeshaking/cli/index.js +60 -23
- package/dist/js/treeshaking/runtime/utils/MApp.js +5 -2
- package/dist/js/treeshaking/runtime/utils/apps.js +2 -0
- package/dist/types/cli/index.d.ts +8 -1
- package/package.json +4 -3
|
@@ -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,11 +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
|
|
80
|
+
const useConfig = useConfigContext();
|
|
81
|
+
logger('useConfig', useConfig); // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
82
|
+
|
|
62
83
|
const config = useAppContext();
|
|
63
84
|
pluginsExportsUtils = createRuntimeExportsUtils(config.internalDirectory, 'plugins');
|
|
64
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
|
+
|
|
65
100
|
return {
|
|
101
|
+
output: {
|
|
102
|
+
disableCssExtract
|
|
103
|
+
},
|
|
66
104
|
source: {
|
|
67
105
|
alias: {
|
|
68
106
|
'@modern-js/runtime/plugins': pluginsExportsUtils.getPath()
|
|
@@ -85,7 +123,7 @@ export default (({
|
|
|
85
123
|
const resolveOptions = useResolvedConfigContext();
|
|
86
124
|
|
|
87
125
|
if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$deplo = resolveOptions.deploy) !== null && _resolveOptions$deplo !== void 0 && _resolveOptions$deplo.microFrontend) {
|
|
88
|
-
var _resolveOptions$serve, _resolveOptions$deplo2
|
|
126
|
+
var _resolveOptions$serve, _resolveOptions$deplo2;
|
|
89
127
|
|
|
90
128
|
chain.output.libraryTarget('umd');
|
|
91
129
|
|
|
@@ -101,9 +139,9 @@ export default (({
|
|
|
101
139
|
}
|
|
102
140
|
|
|
103
141
|
const {
|
|
104
|
-
enableHtmlEntry
|
|
105
|
-
externalBasicLibrary
|
|
106
|
-
} =
|
|
142
|
+
enableHtmlEntry,
|
|
143
|
+
externalBasicLibrary
|
|
144
|
+
} = getDefaultMicroFrontedConfig((_resolveOptions$deplo2 = resolveOptions.deploy) === null || _resolveOptions$deplo2 === void 0 ? void 0 : _resolveOptions$deplo2.microFrontend); // external
|
|
107
145
|
|
|
108
146
|
if (externalBasicLibrary) {
|
|
109
147
|
chain.externals(externals);
|
|
@@ -112,7 +150,8 @@ export default (({
|
|
|
112
150
|
|
|
113
151
|
if (!enableHtmlEntry) {
|
|
114
152
|
chain.output.filename('index.js');
|
|
115
|
-
chain.plugins.delete('html-main');
|
|
153
|
+
chain.plugins.delete('html-main'); // chain.plugins.delete('mini-css-extract');
|
|
154
|
+
|
|
116
155
|
chain.optimization.runtimeChunk(false);
|
|
117
156
|
chain.optimization.splitChunks({
|
|
118
157
|
chunks: 'async'
|
|
@@ -125,7 +164,8 @@ export default (({
|
|
|
125
164
|
output: resolveWebpackConfig.output,
|
|
126
165
|
externals: resolveWebpackConfig.externals,
|
|
127
166
|
env: _env,
|
|
128
|
-
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
|
|
129
169
|
});
|
|
130
170
|
}
|
|
131
171
|
}
|
|
@@ -48,7 +48,7 @@ export function generateMApp(options, manifest) {
|
|
|
48
48
|
listening: true
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
const garfishOptions = _objectSpread({
|
|
51
|
+
const garfishOptions = _objectSpread(_objectSpread({
|
|
52
52
|
domGetter: `#${domId}`,
|
|
53
53
|
|
|
54
54
|
beforeLoad(...args) {
|
|
@@ -92,7 +92,9 @@ export function generateMApp(options, manifest) {
|
|
|
92
92
|
return errorUnmountApp === null || errorUnmountApp === void 0 ? void 0 : errorUnmountApp(error, ...args);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
}, otherOptions)
|
|
95
|
+
}, otherOptions), {}, {
|
|
96
|
+
insulationVariable: [...(otherOptions.insulationVariable || []), '_SERVER_DATA']
|
|
97
|
+
});
|
|
96
98
|
|
|
97
99
|
logger('MApp componentDidMount', {
|
|
98
100
|
garfishRunning: Garfish.running,
|
|
@@ -57,6 +57,7 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
57
57
|
} = this.state;
|
|
58
58
|
|
|
59
59
|
const loadAppOptions = _objectSpread(_objectSpread({}, appInfo), {}, {
|
|
60
|
+
insulationVariable: [...(appInfo.insulationVariable || []), '_SERVER_DATA'],
|
|
60
61
|
domGetter: `#${domId}`,
|
|
61
62
|
basename: path.join((options === null || options === void 0 ? void 0 : options.basename) || '/', (match === null || match === void 0 ? void 0 : match.path) || '/'),
|
|
62
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,11 +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
|
|
97
|
+
const useConfig = useConfigContext();
|
|
98
|
+
(0, _util.logger)('useConfig', useConfig); // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
99
|
+
|
|
77
100
|
const config = useAppContext();
|
|
78
101
|
pluginsExportsUtils = (0, _utils.createRuntimeExportsUtils)(config.internalDirectory, 'plugins');
|
|
79
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
|
+
|
|
80
117
|
return {
|
|
118
|
+
output: {
|
|
119
|
+
disableCssExtract
|
|
120
|
+
},
|
|
81
121
|
source: {
|
|
82
122
|
alias: {
|
|
83
123
|
'@modern-js/runtime/plugins': pluginsExportsUtils.getPath()
|
|
@@ -100,7 +140,7 @@ var _default = ({
|
|
|
100
140
|
const resolveOptions = useResolvedConfigContext();
|
|
101
141
|
|
|
102
142
|
if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$deplo = resolveOptions.deploy) !== null && _resolveOptions$deplo !== void 0 && _resolveOptions$deplo.microFrontend) {
|
|
103
|
-
var _resolveOptions$serve, _resolveOptions$deplo2
|
|
143
|
+
var _resolveOptions$serve, _resolveOptions$deplo2;
|
|
104
144
|
|
|
105
145
|
chain.output.libraryTarget('umd');
|
|
106
146
|
|
|
@@ -116,9 +156,9 @@ var _default = ({
|
|
|
116
156
|
}
|
|
117
157
|
|
|
118
158
|
const {
|
|
119
|
-
enableHtmlEntry
|
|
120
|
-
externalBasicLibrary
|
|
121
|
-
} =
|
|
159
|
+
enableHtmlEntry,
|
|
160
|
+
externalBasicLibrary
|
|
161
|
+
} = getDefaultMicroFrontedConfig((_resolveOptions$deplo2 = resolveOptions.deploy) === null || _resolveOptions$deplo2 === void 0 ? void 0 : _resolveOptions$deplo2.microFrontend); // external
|
|
122
162
|
|
|
123
163
|
if (externalBasicLibrary) {
|
|
124
164
|
chain.externals(externals);
|
|
@@ -127,7 +167,8 @@ var _default = ({
|
|
|
127
167
|
|
|
128
168
|
if (!enableHtmlEntry) {
|
|
129
169
|
chain.output.filename('index.js');
|
|
130
|
-
chain.plugins.delete('html-main');
|
|
170
|
+
chain.plugins.delete('html-main'); // chain.plugins.delete('mini-css-extract');
|
|
171
|
+
|
|
131
172
|
chain.optimization.runtimeChunk(false);
|
|
132
173
|
chain.optimization.splitChunks({
|
|
133
174
|
chunks: 'async'
|
|
@@ -140,7 +181,8 @@ var _default = ({
|
|
|
140
181
|
output: resolveWebpackConfig.output,
|
|
141
182
|
externals: resolveWebpackConfig.externals,
|
|
142
183
|
env: _env,
|
|
143
|
-
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
|
|
144
186
|
});
|
|
145
187
|
}
|
|
146
188
|
}
|
|
@@ -61,7 +61,7 @@ function generateMApp(options, manifest) {
|
|
|
61
61
|
listening: true
|
|
62
62
|
});
|
|
63
63
|
|
|
64
|
-
const garfishOptions = _objectSpread({
|
|
64
|
+
const garfishOptions = _objectSpread(_objectSpread({
|
|
65
65
|
domGetter: `#${domId}`,
|
|
66
66
|
|
|
67
67
|
beforeLoad(...args) {
|
|
@@ -105,7 +105,9 @@ function generateMApp(options, manifest) {
|
|
|
105
105
|
return errorUnmountApp === null || errorUnmountApp === void 0 ? void 0 : errorUnmountApp(error, ...args);
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
}, otherOptions)
|
|
108
|
+
}, otherOptions), {}, {
|
|
109
|
+
insulationVariable: [...(otherOptions.insulationVariable || []), '_SERVER_DATA']
|
|
110
|
+
});
|
|
109
111
|
|
|
110
112
|
(0, _util.logger)('MApp componentDidMount', {
|
|
111
113
|
garfishRunning: _garfish.default.running,
|
|
@@ -63,6 +63,7 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
63
63
|
} = this.state;
|
|
64
64
|
|
|
65
65
|
const loadAppOptions = _objectSpread(_objectSpread({}, appInfo), {}, {
|
|
66
|
+
insulationVariable: [...(appInfo.insulationVariable || []), '_SERVER_DATA'],
|
|
66
67
|
domGetter: `#${domId}`,
|
|
67
68
|
basename: _path.default.join((options === null || options === void 0 ? void 0 : options.basename) || '/', (match === null || match === void 0 ? void 0 : match.path) || '/'),
|
|
68
69
|
cache: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
2
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
4
4
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { createRuntimeExportsUtils, PLUGIN_SCHEMAS } from '@modern-js/utils';
|
|
@@ -10,6 +10,20 @@ export var externals = {
|
|
|
10
10
|
'react-dom': 'react-dom',
|
|
11
11
|
react: 'react'
|
|
12
12
|
};
|
|
13
|
+
export function getDefaultMicroFrontedConfig(microFrontend) {
|
|
14
|
+
if (microFrontend === true) {
|
|
15
|
+
return {
|
|
16
|
+
enableHtmlEntry: true,
|
|
17
|
+
externalBasicLibrary: false,
|
|
18
|
+
moduleApp: ''
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return _objectSpread({
|
|
23
|
+
enableHtmlEntry: true,
|
|
24
|
+
externalBasicLibrary: false
|
|
25
|
+
}, microFrontend);
|
|
26
|
+
}
|
|
13
27
|
export default (function () {
|
|
14
28
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
15
29
|
_ref$runtimePluginNam = _ref.runtimePluginName,
|
|
@@ -21,7 +35,8 @@ export default (function () {
|
|
|
21
35
|
name: '@modern-js/plugin-garfish',
|
|
22
36
|
setup: function setup(_ref2) {
|
|
23
37
|
var useAppContext = _ref2.useAppContext,
|
|
24
|
-
useResolvedConfigContext = _ref2.useResolvedConfigContext
|
|
38
|
+
useResolvedConfigContext = _ref2.useResolvedConfigContext,
|
|
39
|
+
useConfigContext = _ref2.useConfigContext;
|
|
25
40
|
var pluginsExportsUtils;
|
|
26
41
|
var runtimeExportsUtils;
|
|
27
42
|
return {
|
|
@@ -50,6 +65,7 @@ export default (function () {
|
|
|
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
|
|
@@ -71,11 +87,32 @@ export default (function () {
|
|
|
71
87
|
return resolvedConfig;
|
|
72
88
|
}(),
|
|
73
89
|
config: function config() {
|
|
90
|
+
var _useConfig$output$dis, _useConfig$output, _useConfig$deploy;
|
|
91
|
+
|
|
74
92
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
93
|
+
var useConfig = useConfigContext();
|
|
94
|
+
logger('useConfig', useConfig); // eslint-disable-next-line react-hooks/rules-of-hooks
|
|
95
|
+
|
|
75
96
|
var config = useAppContext();
|
|
76
97
|
pluginsExportsUtils = createRuntimeExportsUtils(config.internalDirectory, 'plugins');
|
|
77
98
|
runtimeExportsUtils = createRuntimeExportsUtils(config.internalDirectory, 'index');
|
|
99
|
+
var 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
|
|
100
|
+
|
|
101
|
+
if ((_useConfig$deploy = useConfig.deploy) !== null && _useConfig$deploy !== void 0 && _useConfig$deploy.microFrontend) {
|
|
102
|
+
var _useConfig$deploy2;
|
|
103
|
+
|
|
104
|
+
var _getDefaultMicroFront = getDefaultMicroFrontedConfig((_useConfig$deploy2 = useConfig.deploy) === null || _useConfig$deploy2 === void 0 ? void 0 : _useConfig$deploy2.microFrontend),
|
|
105
|
+
enableHtmlEntry = _getDefaultMicroFront.enableHtmlEntry;
|
|
106
|
+
|
|
107
|
+
if (!enableHtmlEntry) {
|
|
108
|
+
disableCssExtract = true;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
78
112
|
return {
|
|
113
|
+
output: {
|
|
114
|
+
disableCssExtract: disableCssExtract
|
|
115
|
+
},
|
|
79
116
|
source: {
|
|
80
117
|
alias: {
|
|
81
118
|
'@modern-js/runtime/plugins': pluginsExportsUtils.getPath()
|
|
@@ -98,7 +135,7 @@ export default (function () {
|
|
|
98
135
|
var resolveOptions = useResolvedConfigContext();
|
|
99
136
|
|
|
100
137
|
if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$deplo = resolveOptions.deploy) !== null && _resolveOptions$deplo !== void 0 && _resolveOptions$deplo.microFrontend) {
|
|
101
|
-
var _resolveOptions$serve, _resolveOptions$deplo2
|
|
138
|
+
var _resolveOptions$serve, _resolveOptions$deplo2;
|
|
102
139
|
|
|
103
140
|
chain.output.libraryTarget('umd');
|
|
104
141
|
|
|
@@ -113,11 +150,9 @@ export default (function () {
|
|
|
113
150
|
}]);
|
|
114
151
|
}
|
|
115
152
|
|
|
116
|
-
var
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
_ref4$externalBasicLi = _ref4.externalBasicLibrary,
|
|
120
|
-
externalBasicLibrary = _ref4$externalBasicLi === void 0 ? false : _ref4$externalBasicLi; // external
|
|
153
|
+
var _getDefaultMicroFront2 = getDefaultMicroFrontedConfig((_resolveOptions$deplo2 = resolveOptions.deploy) === null || _resolveOptions$deplo2 === void 0 ? void 0 : _resolveOptions$deplo2.microFrontend),
|
|
154
|
+
_enableHtmlEntry = _getDefaultMicroFront2.enableHtmlEntry,
|
|
155
|
+
externalBasicLibrary = _getDefaultMicroFront2.externalBasicLibrary; // external
|
|
121
156
|
|
|
122
157
|
|
|
123
158
|
if (externalBasicLibrary) {
|
|
@@ -125,9 +160,10 @@ export default (function () {
|
|
|
125
160
|
} // use html mode
|
|
126
161
|
|
|
127
162
|
|
|
128
|
-
if (!
|
|
163
|
+
if (!_enableHtmlEntry) {
|
|
129
164
|
chain.output.filename('index.js');
|
|
130
|
-
chain.plugins["delete"]('html-main');
|
|
165
|
+
chain.plugins["delete"]('html-main'); // chain.plugins.delete('mini-css-extract');
|
|
166
|
+
|
|
131
167
|
chain.optimization.runtimeChunk(false);
|
|
132
168
|
chain.optimization.splitChunks({
|
|
133
169
|
chunks: 'async'
|
|
@@ -140,7 +176,8 @@ export default (function () {
|
|
|
140
176
|
output: resolveWebpackConfig.output,
|
|
141
177
|
externals: resolveWebpackConfig.externals,
|
|
142
178
|
env: env,
|
|
143
|
-
alias: (_resolveWebpackConfig = resolveWebpackConfig.resolve) === null || _resolveWebpackConfig === void 0 ? void 0 : _resolveWebpackConfig.alias
|
|
179
|
+
alias: (_resolveWebpackConfig = resolveWebpackConfig.resolve) === null || _resolveWebpackConfig === void 0 ? void 0 : _resolveWebpackConfig.alias,
|
|
180
|
+
plugins: resolveWebpackConfig.plugins
|
|
144
181
|
});
|
|
145
182
|
}
|
|
146
183
|
}
|
|
@@ -152,9 +189,9 @@ export default (function () {
|
|
|
152
189
|
pluginsExportsUtils.addExport(addExportStatement);
|
|
153
190
|
runtimeExportsUtils.addExport("export * from '".concat(mfPackagePath, "'"));
|
|
154
191
|
},
|
|
155
|
-
modifyEntryImports: function modifyEntryImports(
|
|
156
|
-
var entrypoint =
|
|
157
|
-
imports =
|
|
192
|
+
modifyEntryImports: function modifyEntryImports(_ref4) {
|
|
193
|
+
var entrypoint = _ref4.entrypoint,
|
|
194
|
+
imports = _ref4.imports;
|
|
158
195
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
159
196
|
var config = useResolvedConfigContext();
|
|
160
197
|
|
|
@@ -189,9 +226,9 @@ export default (function () {
|
|
|
189
226
|
entrypoint: entrypoint
|
|
190
227
|
};
|
|
191
228
|
},
|
|
192
|
-
modifyEntryRuntimePlugins: function modifyEntryRuntimePlugins(
|
|
193
|
-
var entrypoint =
|
|
194
|
-
plugins =
|
|
229
|
+
modifyEntryRuntimePlugins: function modifyEntryRuntimePlugins(_ref5) {
|
|
230
|
+
var entrypoint = _ref5.entrypoint,
|
|
231
|
+
plugins = _ref5.plugins;
|
|
195
232
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
196
233
|
var config = useResolvedConfigContext();
|
|
197
234
|
|
|
@@ -212,11 +249,11 @@ export default (function () {
|
|
|
212
249
|
plugins: plugins
|
|
213
250
|
};
|
|
214
251
|
},
|
|
215
|
-
modifyEntryRenderFunction: function modifyEntryRenderFunction(
|
|
252
|
+
modifyEntryRenderFunction: function modifyEntryRenderFunction(_ref6) {
|
|
216
253
|
var _config$deploy;
|
|
217
254
|
|
|
218
|
-
var entrypoint =
|
|
219
|
-
code =
|
|
255
|
+
var entrypoint = _ref6.entrypoint,
|
|
256
|
+
code = _ref6.code;
|
|
220
257
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
221
258
|
var config = useResolvedConfigContext();
|
|
222
259
|
|
|
@@ -234,11 +271,11 @@ export default (function () {
|
|
|
234
271
|
code: nCode
|
|
235
272
|
};
|
|
236
273
|
},
|
|
237
|
-
modifyEntryExport: function modifyEntryExport(
|
|
274
|
+
modifyEntryExport: function modifyEntryExport(_ref7) {
|
|
238
275
|
var _config$deploy2;
|
|
239
276
|
|
|
240
|
-
var entrypoint =
|
|
241
|
-
exportStatement =
|
|
277
|
+
var entrypoint = _ref7.entrypoint,
|
|
278
|
+
exportStatement = _ref7.exportStatement;
|
|
242
279
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
243
280
|
var config = useResolvedConfigContext();
|
|
244
281
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
1
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
4
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
@@ -55,7 +56,7 @@ export function generateMApp(options, manifest) {
|
|
|
55
56
|
listening: true
|
|
56
57
|
});
|
|
57
58
|
|
|
58
|
-
var garfishOptions = _objectSpread({
|
|
59
|
+
var garfishOptions = _objectSpread(_objectSpread({
|
|
59
60
|
domGetter: "#".concat(domId),
|
|
60
61
|
beforeLoad: function beforeLoad() {
|
|
61
62
|
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
@@ -113,7 +114,9 @@ export function generateMApp(options, manifest) {
|
|
|
113
114
|
});
|
|
114
115
|
return _errorUnmountApp === null || _errorUnmountApp === void 0 ? void 0 : _errorUnmountApp.apply(void 0, [error].concat(args));
|
|
115
116
|
}
|
|
116
|
-
}, otherOptions)
|
|
117
|
+
}, otherOptions), {}, {
|
|
118
|
+
insulationVariable: [].concat(_toConsumableArray(otherOptions.insulationVariable || []), ['_SERVER_DATA'])
|
|
119
|
+
});
|
|
117
120
|
|
|
118
121
|
logger('MApp componentDidMount', {
|
|
119
122
|
garfishRunning: Garfish.running,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
1
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
4
|
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
@@ -69,6 +70,7 @@ function getAppInstance(options, appInfo, manifest) {
|
|
|
69
70
|
_this$props = this.props, match = _this$props.match, history = _this$props.history, setLoadingState = _this$props.setLoadingState, userProps = _objectWithoutProperties(_this$props, _excluded);
|
|
70
71
|
domId = this.state.domId;
|
|
71
72
|
loadAppOptions = _objectSpread(_objectSpread({}, appInfo), {}, {
|
|
73
|
+
insulationVariable: [].concat(_toConsumableArray(appInfo.insulationVariable || []), ['_SERVER_DATA']),
|
|
72
74
|
domGetter: "#".concat(domId),
|
|
73
75
|
basename: path.join((options === null || options === void 0 ? void 0 : options.basename) || '/', (match === null || match === void 0 ? void 0 : match.path) || '/'),
|
|
74
76
|
cache: true,
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import type { CliHookCallbacks, CliPlugin } from '@modern-js/core';
|
|
1
|
+
import type { CliHookCallbacks, CliPlugin, useConfigContext } from '@modern-js/core';
|
|
2
|
+
export declare type UseConfig = ReturnType<typeof useConfigContext>;
|
|
2
3
|
export declare const externals: {
|
|
3
4
|
'react-dom': string;
|
|
4
5
|
react: string;
|
|
5
6
|
};
|
|
6
7
|
export declare type LifeCycle = CliHookCallbacks;
|
|
8
|
+
declare type NonInValidAble<T> = T extends null | undefined | false ? never : T;
|
|
9
|
+
export declare function getDefaultMicroFrontedConfig(microFrontend: NonInValidAble<NonNullable<UseConfig['deploy']>['microFrontend']>): {
|
|
10
|
+
enableHtmlEntry: boolean;
|
|
11
|
+
externalBasicLibrary: boolean;
|
|
12
|
+
moduleApp?: string | undefined;
|
|
13
|
+
};
|
|
7
14
|
|
|
8
15
|
declare const _default: ({
|
|
9
16
|
runtimePluginName,
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.4.
|
|
14
|
+
"version": "1.4.13-alpha.1",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/runtime/index.d.ts",
|
|
17
17
|
"typesVersions": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@types/debug": "^4.1.7",
|
|
55
55
|
"@types/react-loadable": "^5.5.6",
|
|
56
56
|
"debug": "^4.3.2",
|
|
57
|
-
"garfish": "^1.
|
|
57
|
+
"garfish": "^1.5.5",
|
|
58
58
|
"hoist-non-react-statics": "^3.3.2",
|
|
59
59
|
"react-loadable": "^5.5.0"
|
|
60
60
|
},
|
|
@@ -91,7 +91,8 @@
|
|
|
91
91
|
"modernConfig": {},
|
|
92
92
|
"publishConfig": {
|
|
93
93
|
"registry": "https://registry.npmjs.org/",
|
|
94
|
-
"access": "public"
|
|
94
|
+
"access": "public",
|
|
95
|
+
"types": "./dist/types/runtime/index.d.ts"
|
|
95
96
|
},
|
|
96
97
|
"wireit": {
|
|
97
98
|
"build": {
|