@modern-js/plugin-garfish 1.4.12 → 1.5.0

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 CHANGED
@@ -1,5 +1,28 @@
1
1
  # @modern-js/plugin-garfish
2
2
 
3
+ ## 1.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f66fa0e98: feat: support tools.webpackChain config
8
+
9
+ ### Patch Changes
10
+
11
+ - 1dfe08fcd: feat(webpack): add CHAIN_ID constants for webpack chain
12
+ - Updated dependencies [33de0f7ec]
13
+ - @modern-js/utils@1.7.5
14
+ - @modern-js/plugin-router@1.2.14
15
+
16
+ ## 1.4.13
17
+
18
+ ### Patch Changes
19
+
20
+ - a37960018: fix: default config \_SERVER_DATA to insulationVariable and set disableCssExtract to be true
21
+ - Updated dependencies [b8cfc42cd]
22
+ - Updated dependencies [804a5bb8a]
23
+ - @modern-js/utils@1.7.4
24
+ - @modern-js/plugin-router@1.2.14
25
+
3
26
  ## 1.4.11
4
27
 
5
28
  ### 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,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()
@@ -74,10 +112,10 @@ export default (({
74
112
  'Access-Control-Allow-Origin': '*'
75
113
  }
76
114
  },
77
- webpack: (webpackConfig, {
78
- chain,
115
+ webpackChain: (chain, {
79
116
  webpack,
80
- env: _env = process.env.NODE_ENV || 'development'
117
+ env: _env = process.env.NODE_ENV || 'development',
118
+ CHAIN_ID
81
119
  }) => {
82
120
  var _resolveOptions$deplo, _resolveWebpackConfig;
83
121
 
@@ -85,25 +123,25 @@ 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, _resolveOptions$deplo3;
126
+ var _resolveOptions$serve, _resolveOptions$deplo2;
89
127
 
90
128
  chain.output.libraryTarget('umd');
91
129
 
92
- if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$serve = resolveOptions.server) !== null && _resolveOptions$serve !== void 0 && _resolveOptions$serve.port) {
93
- chain.output.publicPath(_env === 'development' ? `//localhost:${resolveOptions.server.port}/` : webpackConfig.output.publicPath);
130
+ if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$serve = resolveOptions.server) !== null && _resolveOptions$serve !== void 0 && _resolveOptions$serve.port && _env === 'development') {
131
+ chain.output.publicPath(`//localhost:${resolveOptions.server.port}/`);
94
132
  } // add comments avoid sourcemap abnormal
95
133
 
96
134
 
97
135
  if (webpack.BannerPlugin) {
98
- chain.plugin('banner').use(webpack.BannerPlugin, [{
136
+ chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [{
99
137
  banner: 'Micro front-end'
100
138
  }]);
101
139
  }
102
140
 
103
141
  const {
104
- enableHtmlEntry = true,
105
- externalBasicLibrary = false
106
- } = 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
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);
@@ -125,7 +163,8 @@ export default (({
125
163
  output: resolveWebpackConfig.output,
126
164
  externals: resolveWebpackConfig.externals,
127
165
  env: _env,
128
- alias: (_resolveWebpackConfig = resolveWebpackConfig.resolve) === null || _resolveWebpackConfig === void 0 ? void 0 : _resolveWebpackConfig.alias
166
+ alias: (_resolveWebpackConfig = resolveWebpackConfig.resolve) === null || _resolveWebpackConfig === void 0 ? void 0 : _resolveWebpackConfig.alias,
167
+ plugins: resolveWebpackConfig.plugins
129
168
  });
130
169
  }
131
170
  }
@@ -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()
@@ -89,10 +129,10 @@ var _default = ({
89
129
  'Access-Control-Allow-Origin': '*'
90
130
  }
91
131
  },
92
- webpack: (webpackConfig, {
93
- chain,
132
+ webpackChain: (chain, {
94
133
  webpack,
95
- env: _env = process.env.NODE_ENV || 'development'
134
+ env: _env = process.env.NODE_ENV || 'development',
135
+ CHAIN_ID
96
136
  }) => {
97
137
  var _resolveOptions$deplo, _resolveWebpackConfig;
98
138
 
@@ -100,25 +140,25 @@ 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, _resolveOptions$deplo3;
143
+ var _resolveOptions$serve, _resolveOptions$deplo2;
104
144
 
105
145
  chain.output.libraryTarget('umd');
106
146
 
107
- if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$serve = resolveOptions.server) !== null && _resolveOptions$serve !== void 0 && _resolveOptions$serve.port) {
108
- chain.output.publicPath(_env === 'development' ? `//localhost:${resolveOptions.server.port}/` : webpackConfig.output.publicPath);
147
+ if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$serve = resolveOptions.server) !== null && _resolveOptions$serve !== void 0 && _resolveOptions$serve.port && _env === 'development') {
148
+ chain.output.publicPath(`//localhost:${resolveOptions.server.port}/`);
109
149
  } // add comments avoid sourcemap abnormal
110
150
 
111
151
 
112
152
  if (webpack.BannerPlugin) {
113
- chain.plugin('banner').use(webpack.BannerPlugin, [{
153
+ chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [{
114
154
  banner: 'Micro front-end'
115
155
  }]);
116
156
  }
117
157
 
118
158
  const {
119
- enableHtmlEntry = true,
120
- externalBasicLibrary = false
121
- } = 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
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);
@@ -140,7 +180,8 @@ var _default = ({
140
180
  output: resolveWebpackConfig.output,
141
181
  externals: resolveWebpackConfig.externals,
142
182
  env: _env,
143
- alias: (_resolveWebpackConfig = resolveWebpackConfig.resolve) === null || _resolveWebpackConfig === void 0 ? void 0 : _resolveWebpackConfig.alias
183
+ alias: (_resolveWebpackConfig = resolveWebpackConfig.resolve) === null || _resolveWebpackConfig === void 0 ? void 0 : _resolveWebpackConfig.alias,
184
+ plugins: resolveWebpackConfig.plugins
144
185
  });
145
186
  }
146
187
  }
@@ -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()
@@ -87,37 +124,35 @@ export default (function () {
87
124
  'Access-Control-Allow-Origin': '*'
88
125
  }
89
126
  },
90
- webpack: function webpack(webpackConfig, _ref3) {
127
+ webpackChain: function webpackChain(chain, _ref3) {
91
128
  var _resolveOptions$deplo, _resolveWebpackConfig;
92
129
 
93
- var chain = _ref3.chain,
94
- _webpack = _ref3.webpack,
130
+ var webpack = _ref3.webpack,
95
131
  _ref3$env = _ref3.env,
96
- env = _ref3$env === void 0 ? process.env.NODE_ENV || 'development' : _ref3$env;
132
+ env = _ref3$env === void 0 ? process.env.NODE_ENV || 'development' : _ref3$env,
133
+ CHAIN_ID = _ref3.CHAIN_ID;
97
134
  // eslint-disable-next-line react-hooks/rules-of-hooks
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, _resolveOptions$deplo3;
138
+ var _resolveOptions$serve, _resolveOptions$deplo2;
102
139
 
103
140
  chain.output.libraryTarget('umd');
104
141
 
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:".concat(resolveOptions.server.port, "/") : webpackConfig.output.publicPath);
142
+ if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$serve = resolveOptions.server) !== null && _resolveOptions$serve !== void 0 && _resolveOptions$serve.port && env === 'development') {
143
+ chain.output.publicPath("//localhost:".concat(resolveOptions.server.port, "/"));
107
144
  } // add comments avoid sourcemap abnormal
108
145
 
109
146
 
110
- if (_webpack.BannerPlugin) {
111
- chain.plugin('banner').use(_webpack.BannerPlugin, [{
147
+ if (webpack.BannerPlugin) {
148
+ chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [{
112
149
  banner: 'Micro front-end'
113
150
  }]);
114
151
  }
115
152
 
116
- var _ref4 = _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 : {},
117
- _ref4$enableHtmlEntry = _ref4.enableHtmlEntry,
118
- enableHtmlEntry = _ref4$enableHtmlEntry === void 0 ? true : _ref4$enableHtmlEntry,
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,7 +160,7 @@ export default (function () {
125
160
  } // use html mode
126
161
 
127
162
 
128
- if (!enableHtmlEntry) {
163
+ if (!_enableHtmlEntry) {
129
164
  chain.output.filename('index.js');
130
165
  chain.plugins["delete"]('html-main');
131
166
  chain.optimization.runtimeChunk(false);
@@ -140,7 +175,8 @@ export default (function () {
140
175
  output: resolveWebpackConfig.output,
141
176
  externals: resolveWebpackConfig.externals,
142
177
  env: env,
143
- alias: (_resolveWebpackConfig = resolveWebpackConfig.resolve) === null || _resolveWebpackConfig === void 0 ? void 0 : _resolveWebpackConfig.alias
178
+ alias: (_resolveWebpackConfig = resolveWebpackConfig.resolve) === null || _resolveWebpackConfig === void 0 ? void 0 : _resolveWebpackConfig.alias,
179
+ plugins: resolveWebpackConfig.plugins
144
180
  });
145
181
  }
146
182
  }
@@ -152,9 +188,9 @@ export default (function () {
152
188
  pluginsExportsUtils.addExport(addExportStatement);
153
189
  runtimeExportsUtils.addExport("export * from '".concat(mfPackagePath, "'"));
154
190
  },
155
- modifyEntryImports: function modifyEntryImports(_ref5) {
156
- var entrypoint = _ref5.entrypoint,
157
- imports = _ref5.imports;
191
+ modifyEntryImports: function modifyEntryImports(_ref4) {
192
+ var entrypoint = _ref4.entrypoint,
193
+ imports = _ref4.imports;
158
194
  // eslint-disable-next-line react-hooks/rules-of-hooks
159
195
  var config = useResolvedConfigContext();
160
196
 
@@ -189,9 +225,9 @@ export default (function () {
189
225
  entrypoint: entrypoint
190
226
  };
191
227
  },
192
- modifyEntryRuntimePlugins: function modifyEntryRuntimePlugins(_ref6) {
193
- var entrypoint = _ref6.entrypoint,
194
- plugins = _ref6.plugins;
228
+ modifyEntryRuntimePlugins: function modifyEntryRuntimePlugins(_ref5) {
229
+ var entrypoint = _ref5.entrypoint,
230
+ plugins = _ref5.plugins;
195
231
  // eslint-disable-next-line react-hooks/rules-of-hooks
196
232
  var config = useResolvedConfigContext();
197
233
 
@@ -212,11 +248,11 @@ export default (function () {
212
248
  plugins: plugins
213
249
  };
214
250
  },
215
- modifyEntryRenderFunction: function modifyEntryRenderFunction(_ref7) {
251
+ modifyEntryRenderFunction: function modifyEntryRenderFunction(_ref6) {
216
252
  var _config$deploy;
217
253
 
218
- var entrypoint = _ref7.entrypoint,
219
- code = _ref7.code;
254
+ var entrypoint = _ref6.entrypoint,
255
+ code = _ref6.code;
220
256
  // eslint-disable-next-line react-hooks/rules-of-hooks
221
257
  var config = useResolvedConfigContext();
222
258
 
@@ -234,11 +270,11 @@ export default (function () {
234
270
  code: nCode
235
271
  };
236
272
  },
237
- modifyEntryExport: function modifyEntryExport(_ref8) {
273
+ modifyEntryExport: function modifyEntryExport(_ref7) {
238
274
  var _config$deploy2;
239
275
 
240
- var entrypoint = _ref8.entrypoint,
241
- exportStatement = _ref8.exportStatement;
276
+ var entrypoint = _ref7.entrypoint,
277
+ exportStatement = _ref7.exportStatement;
242
278
  // eslint-disable-next-line react-hooks/rules-of-hooks
243
279
  var config = useResolvedConfigContext();
244
280
 
@@ -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,
@@ -3,6 +3,7 @@ import React from 'react';
3
3
  export declare type Options = typeof garfish.options;
4
4
  export declare type ModuleInfo = GarfishInterfaces.AppInfo & {
5
5
  Component?: React.ComponentType | React.ElementType;
6
+ path?: string;
6
7
  originInfo?: Record<string, unknown>;
7
8
  };
8
9
  export declare type ModulesInfo = Array<ModuleInfo>;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.4.12",
14
+ "version": "1.5.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/runtime/index.d.ts",
17
17
  "typesVersions": {
@@ -50,16 +50,16 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@babel/runtime": "^7",
53
- "@modern-js/utils": "^1.7.3",
53
+ "@modern-js/utils": "^1.7.5",
54
54
  "@types/debug": "^4.1.7",
55
55
  "@types/react-loadable": "^5.5.6",
56
56
  "debug": "^4.3.2",
57
- "garfish": "^1.3.3",
57
+ "garfish": "^1.5.5",
58
58
  "hoist-non-react-statics": "^3.3.2",
59
59
  "react-loadable": "^5.5.0"
60
60
  },
61
61
  "devDependencies": {
62
- "@modern-js/core": "1.10.2",
62
+ "@modern-js/core": "1.11.0",
63
63
  "@modern-js/plugin-router": "1.2.14",
64
64
  "@modern-js/runtime-core": "1.4.6",
65
65
  "@modern-js/types": "1.5.3",
@@ -110,7 +110,8 @@
110
110
  "files": [
111
111
  "src/**/*",
112
112
  "tsconfig.json",
113
- "package.json"
113
+ "package.json",
114
+ "tests/**/*"
114
115
  ],
115
116
  "output": []
116
117
  }