@modern-js/plugin-garfish 2.0.0-beta.3 → 2.0.0-beta.5

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.
Files changed (58) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/dist/js/modern/cli/index.js +167 -157
  3. package/dist/js/modern/cli/types.js +0 -0
  4. package/dist/js/modern/cli/utils.js +31 -23
  5. package/dist/js/modern/global.d.js +0 -0
  6. package/dist/js/modern/index.js +5 -2
  7. package/dist/js/modern/modern-app.env.d.js +0 -0
  8. package/dist/js/modern/runtime/global.d.js +0 -0
  9. package/dist/js/modern/runtime/index.js +12 -4
  10. package/dist/js/modern/runtime/loadable.js +74 -56
  11. package/dist/js/modern/runtime/plugin.js +114 -79
  12. package/dist/js/modern/runtime/useModuleApps.js +40 -26
  13. package/dist/js/modern/runtime/utils/Context.js +6 -3
  14. package/dist/js/modern/runtime/utils/MApp.js +76 -72
  15. package/dist/js/modern/runtime/utils/apps.js +181 -132
  16. package/dist/js/modern/runtime/utils/setExternal.js +11 -11
  17. package/dist/js/modern/util.js +11 -9
  18. package/dist/js/node/cli/index.js +191 -169
  19. package/dist/js/node/cli/types.js +0 -0
  20. package/dist/js/node/cli/utils.js +53 -30
  21. package/dist/js/node/global.d.js +0 -0
  22. package/dist/js/node/index.js +31 -24
  23. package/dist/js/node/modern-app.env.d.js +0 -0
  24. package/dist/js/node/runtime/global.d.js +0 -0
  25. package/dist/js/node/runtime/index.js +42 -43
  26. package/dist/js/node/runtime/loadable.js +97 -61
  27. package/dist/js/node/runtime/plugin.js +147 -95
  28. package/dist/js/node/runtime/useModuleApps.js +67 -34
  29. package/dist/js/node/runtime/utils/Context.js +35 -10
  30. package/dist/js/node/runtime/utils/MApp.js +109 -84
  31. package/dist/js/node/runtime/utils/apps.js +210 -135
  32. package/dist/js/node/runtime/utils/setExternal.js +37 -18
  33. package/dist/js/node/util.js +40 -19
  34. package/dist/js/treeshaking/cli/index.js +403 -284
  35. package/dist/js/treeshaking/cli/types.js +1 -0
  36. package/dist/js/treeshaking/cli/utils.js +28 -31
  37. package/dist/js/treeshaking/global.d.js +1 -0
  38. package/dist/js/treeshaking/index.js +3 -2
  39. package/dist/js/treeshaking/modern-app.env.d.js +1 -0
  40. package/dist/js/treeshaking/runtime/global.d.js +1 -0
  41. package/dist/js/treeshaking/runtime/index.js +5 -4
  42. package/dist/js/treeshaking/runtime/loadable.js +230 -109
  43. package/dist/js/treeshaking/runtime/plugin.js +469 -168
  44. package/dist/js/treeshaking/runtime/useModuleApps.js +55 -31
  45. package/dist/js/treeshaking/runtime/utils/Context.js +3 -3
  46. package/dist/js/treeshaking/runtime/utils/MApp.js +348 -180
  47. package/dist/js/treeshaking/runtime/utils/apps.js +472 -224
  48. package/dist/js/treeshaking/runtime/utils/setExternal.js +12 -11
  49. package/dist/js/treeshaking/util.js +7 -9
  50. package/dist/types/cli/index.d.ts +3 -0
  51. package/dist/types/cli/types.d.ts +6 -0
  52. package/dist/types/runtime/index.d.ts +1 -1
  53. package/dist/types/runtime/loadable.d.ts +1 -2
  54. package/dist/types/runtime/plugin.d.ts +2 -0
  55. package/dist/types/runtime/utils/apps.d.ts +1 -0
  56. package/dist/types/runtime/utils/setExternal.d.ts +1 -0
  57. package/package.json +25 -20
  58. package/type.d.ts +5 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,72 @@
1
1
  # @modern-js/plugin-garfish
2
2
 
3
+ ## 2.0.0-beta.4
4
+
5
+ ### Major Changes
6
+
7
+ - dda38c9c3e: chore: v2
8
+
9
+ ### Patch Changes
10
+
11
+ - 6604f1b: feat: support router basename
12
+ feat: router 插件支持设置 basename
13
+ - 21d2ddb59c: feat: support async export provider for module federation
14
+ 支持模块联邦场景异步导出 provider
15
+ - cce8ecee2d: fix: handle some `TODO` & `FIXME`, change some tests
16
+ fix: 处理一些 `TODO` 和 `FIXME`, 修改了一些 tests
17
+ - 2344eb26ed: fix: loadApp when dom is mount
18
+ 修复 dom 未渲染时挂载子应用行为
19
+ - Updated dependencies [2344eb26ed]
20
+ - Updated dependencies [a11fcf8b50]
21
+ - Updated dependencies [a931594]
22
+ - Updated dependencies [e7ce063]
23
+ - Updated dependencies [b18fa8f3ed]
24
+ - Updated dependencies [7879e8f]
25
+ - Updated dependencies [50d4675]
26
+ - Updated dependencies [c9e800d39a]
27
+ - Updated dependencies [6604f1b]
28
+ - Updated dependencies [6aca875]
29
+ - Updated dependencies [fda836f]
30
+ - Updated dependencies [d6bc321]
31
+ - Updated dependencies [3e57f2bd58]
32
+ - Updated dependencies [2e6031955e]
33
+ - Updated dependencies [c5798d2]
34
+ - Updated dependencies [fbf5eed5aa]
35
+ - Updated dependencies [a2509bfbdb]
36
+ - Updated dependencies [a7c6883]
37
+ - Updated dependencies [425e57092d]
38
+ - Updated dependencies [e4357f1856]
39
+ - Updated dependencies [7b7d12c]
40
+ - Updated dependencies [4369648ae2]
41
+ - Updated dependencies [92f0eade39]
42
+ - Updated dependencies [92c0994468]
43
+ - Updated dependencies [2cc2eb3]
44
+ - Updated dependencies [edd1cfb1af]
45
+ - Updated dependencies [cc971eabfc]
46
+ - Updated dependencies [5b9049f2e9]
47
+ - Updated dependencies [6bda14ed71]
48
+ - Updated dependencies [92004d1906]
49
+ - Updated dependencies [b8bbe036c7]
50
+ - Updated dependencies [40ed5874c6]
51
+ - Updated dependencies [60d5378632]
52
+ - Updated dependencies [d5a31df781]
53
+ - Updated dependencies [dda38c9c3e]
54
+ - Updated dependencies [8b8e1bb571]
55
+ - Updated dependencies [3bbea92b2a]
56
+ - Updated dependencies [9144c21]
57
+ - Updated dependencies [b710adb843]
58
+ - Updated dependencies [18aaf42249]
59
+ - Updated dependencies [34702d5]
60
+ - Updated dependencies [fcace5b5b9]
61
+ - Updated dependencies [ea7cf06]
62
+ - Updated dependencies [bbe4c4a]
63
+ - Updated dependencies [e4558a0]
64
+ - Updated dependencies [abf3421a75]
65
+ - Updated dependencies [543be9558e]
66
+ - Updated dependencies [14b712da84]
67
+ - @modern-js/runtime@2.0.0-beta.4
68
+ - @modern-js/utils@2.0.0-beta.4
69
+
3
70
  ## 2.0.0-beta.3
4
71
 
5
72
  ### Major Changes
@@ -1,61 +1,95 @@
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
- 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; }
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; }
4
- import path from 'path';
5
- import { createRuntimeExportsUtils, PLUGIN_SCHEMAS } from '@modern-js/utils';
6
- import { logger } from "../util";
7
- import { getRuntimeConfig, makeProvider, makeRenderFunction, setRuntimeConfig, generateAsyncEntry } from "./utils";
8
- export const externals = {
9
- 'react-dom': 'react-dom',
10
- react: 'react'
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
4
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __spreadValues = (a, b) => {
7
+ for (var prop in b || (b = {}))
8
+ if (__hasOwnProp.call(b, prop))
9
+ __defNormalProp(a, prop, b[prop]);
10
+ if (__getOwnPropSymbols)
11
+ for (var prop of __getOwnPropSymbols(b)) {
12
+ if (__propIsEnum.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ }
15
+ return a;
16
+ };
17
+ var __async = (__this, __arguments, generator) => {
18
+ return new Promise((resolve, reject) => {
19
+ var fulfilled = (value) => {
20
+ try {
21
+ step(generator.next(value));
22
+ } catch (e) {
23
+ reject(e);
24
+ }
25
+ };
26
+ var rejected = (value) => {
27
+ try {
28
+ step(generator.throw(value));
29
+ } catch (e) {
30
+ reject(e);
31
+ }
32
+ };
33
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
34
+ step((generator = generator.apply(__this, __arguments)).next());
35
+ });
11
36
  };
12
- export function getDefaultMicroFrontedConfig(microFrontend) {
37
+ import path from "path";
38
+ import { createRuntimeExportsUtils, PLUGIN_SCHEMAS } from "@modern-js/utils";
39
+ import { logger } from "../util";
40
+ import {
41
+ getRuntimeConfig,
42
+ makeProvider,
43
+ makeRenderFunction,
44
+ setRuntimeConfig,
45
+ generateAsyncEntry
46
+ } from "./utils";
47
+ import "./types";
48
+ const externals = { "react-dom": "react-dom", react: "react" };
49
+ function getDefaultMicroFrontedConfig(microFrontend) {
13
50
  if (microFrontend === true) {
14
51
  return {
15
52
  enableHtmlEntry: true,
16
53
  externalBasicLibrary: false,
17
- moduleApp: ''
54
+ moduleApp: ""
18
55
  };
19
56
  }
20
- return _objectSpread({
57
+ return __spreadValues({
21
58
  enableHtmlEntry: true,
22
59
  externalBasicLibrary: false
23
60
  }, microFrontend);
24
61
  }
25
- export default (({
26
- pluginName: _pluginName = '@modern-js/plugin-garfish',
27
- runtimePluginName: _runtimePluginName = '@modern-js/runtime/plugins',
28
- mfPackagePath: _mfPackagePath = path.resolve(__dirname, '../../../../')
62
+ var cli_default = ({
63
+ pluginName = "@modern-js/plugin-garfish",
64
+ runtimePluginName = "@modern-js/runtime/plugins",
65
+ mfPackagePath = path.resolve(__dirname, "../../../../")
29
66
  } = {}) => ({
30
- name: '@modern-js/plugin-garfish',
31
- setup: ({
32
- useAppContext,
33
- useResolvedConfigContext,
34
- useConfigContext
35
- }) => {
67
+ name: "@modern-js/plugin-garfish",
68
+ setup: ({ useAppContext, useResolvedConfigContext, useConfigContext }) => {
36
69
  let pluginsExportsUtils;
37
70
  let runtimeExportsUtils;
38
71
  return {
39
72
  validateSchema() {
40
- return PLUGIN_SCHEMAS['@modern-js/plugin-garfish'];
73
+ return PLUGIN_SCHEMAS["@modern-js/plugin-garfish"];
41
74
  },
42
- resolvedConfig: async config => {
43
- const {
44
- resolved
45
- } = config;
46
- const {
47
- masterApp,
48
- router
49
- } = getRuntimeConfig(resolved);
75
+ resolvedConfig: (config) => __async(void 0, null, function* () {
76
+ var _a;
77
+ const { resolved } = config;
78
+ const { masterApp, router } = getRuntimeConfig(resolved);
50
79
  const nConfig = {
51
- resolved: _objectSpread({}, resolved)
80
+ resolved: __spreadValues({}, resolved)
52
81
  };
53
82
  if (masterApp) {
54
- var _router$historyOption;
55
- // basename does not exist use router's basename
56
- setRuntimeConfig(nConfig.resolved, 'masterApp', Object.assign(typeof masterApp === 'object' ? _objectSpread({}, masterApp) : {}, {
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) || '/'
58
- }));
83
+ setRuntimeConfig(
84
+ nConfig.resolved,
85
+ "masterApp",
86
+ Object.assign(
87
+ typeof masterApp === "object" ? __spreadValues({}, masterApp) : {},
88
+ {
89
+ basename: ((_a = router == null ? void 0 : router.historyOptions) == null ? void 0 : _a.basename) || (router == null ? void 0 : router.basename) || "/"
90
+ }
91
+ )
92
+ );
59
93
  }
60
94
  logger(`resolvedConfig`, {
61
95
  output: nConfig.resolved.output,
@@ -64,25 +98,25 @@ export default (({
64
98
  server: nConfig.resolved.server
65
99
  });
66
100
  return nConfig;
67
- },
101
+ }),
68
102
  config() {
69
- var _useConfig$output, _useConfig$deploy;
70
- // eslint-disable-next-line react-hooks/rules-of-hooks
103
+ var _a, _b, _c;
71
104
  const useConfig = useConfigContext();
72
- logger('useConfig', useConfig);
73
-
74
- // eslint-disable-next-line react-hooks/rules-of-hooks
105
+ logger("useConfig", useConfig);
75
106
  const config = useAppContext();
76
- pluginsExportsUtils = createRuntimeExportsUtils(config.internalDirectory, 'plugins');
77
- runtimeExportsUtils = createRuntimeExportsUtils(config.internalDirectory, 'index');
78
- let disableCssExtract = ((_useConfig$output = useConfig.output) === null || _useConfig$output === void 0 ? void 0 : _useConfig$output.disableCssExtract) || false;
79
-
80
- // When the micro-frontend application js entry, there is no need to extract css, close cssExtract
81
- if ((_useConfig$deploy = useConfig.deploy) !== null && _useConfig$deploy !== void 0 && _useConfig$deploy.microFrontend) {
82
- var _useConfig$deploy2;
83
- const {
84
- enableHtmlEntry
85
- } = getDefaultMicroFrontedConfig((_useConfig$deploy2 = useConfig.deploy) === null || _useConfig$deploy2 === void 0 ? void 0 : _useConfig$deploy2.microFrontend);
107
+ pluginsExportsUtils = createRuntimeExportsUtils(
108
+ config.internalDirectory,
109
+ "plugins"
110
+ );
111
+ runtimeExportsUtils = createRuntimeExportsUtils(
112
+ config.internalDirectory,
113
+ "index"
114
+ );
115
+ let disableCssExtract = ((_a = useConfig.output) == null ? void 0 : _a.disableCssExtract) || false;
116
+ if ((_b = useConfig.deploy) == null ? void 0 : _b.microFrontend) {
117
+ const { enableHtmlEntry } = getDefaultMicroFrontedConfig(
118
+ (_c = useConfig.deploy) == null ? void 0 : _c.microFrontend
119
+ );
86
120
  if (!enableHtmlEntry) {
87
121
  disableCssExtract = true;
88
122
  }
@@ -93,61 +127,54 @@ export default (({
93
127
  },
94
128
  source: {
95
129
  alias: {
96
- '@modern-js/runtime/plugins': pluginsExportsUtils.getPath(),
97
- '@modern-js/runtime/garfish': _mfPackagePath
130
+ "@modern-js/runtime/plugins": pluginsExportsUtils.getPath(),
131
+ "@modern-js/runtime/garfish": mfPackagePath
98
132
  }
99
133
  },
100
134
  tools: {
101
135
  devServer: {
102
136
  headers: {
103
- 'Access-Control-Allow-Origin': '*'
137
+ "Access-Control-Allow-Origin": "*"
104
138
  }
105
139
  },
106
140
  webpackChain: (chain, {
107
141
  webpack,
108
- env: _env = process.env.NODE_ENV || 'development',
142
+ env = process.env.NODE_ENV || "development",
109
143
  CHAIN_ID
110
144
  }) => {
111
- var _resolveOptions$deplo, _resolveWebpackConfig;
112
- // eslint-disable-next-line react-hooks/rules-of-hooks
145
+ var _a2, _b2, _c2, _d;
113
146
  const resolveOptions = useResolvedConfigContext();
114
- if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$deplo = resolveOptions.deploy) !== null && _resolveOptions$deplo !== void 0 && _resolveOptions$deplo.microFrontend) {
115
- var _resolveOptions$serve, _resolveOptions$deplo2;
116
- chain.output.libraryTarget('umd');
117
- if (resolveOptions !== null && resolveOptions !== void 0 && (_resolveOptions$serve = resolveOptions.server) !== null && _resolveOptions$serve !== void 0 && _resolveOptions$serve.port && _env === 'development') {
118
- chain.output.publicPath(`//localhost:${resolveOptions.server.port}/`);
147
+ if ((_a2 = resolveOptions == null ? void 0 : resolveOptions.deploy) == null ? void 0 : _a2.microFrontend) {
148
+ chain.output.libraryTarget("umd");
149
+ if (((_b2 = resolveOptions == null ? void 0 : resolveOptions.server) == null ? void 0 : _b2.port) && env === "development") {
150
+ chain.output.publicPath(
151
+ `//localhost:${resolveOptions.server.port}/`
152
+ );
119
153
  }
120
-
121
- // add comments avoid sourcemap abnormal
122
154
  if (webpack.BannerPlugin) {
123
- chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [{
124
- banner: 'Micro front-end'
125
- }]);
155
+ chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [{ banner: "Micro front-end" }]);
126
156
  }
127
- const {
128
- enableHtmlEntry,
129
- externalBasicLibrary
130
- } = getDefaultMicroFrontedConfig((_resolveOptions$deplo2 = resolveOptions.deploy) === null || _resolveOptions$deplo2 === void 0 ? void 0 : _resolveOptions$deplo2.microFrontend);
131
- // external
157
+ const { enableHtmlEntry, externalBasicLibrary } = getDefaultMicroFrontedConfig(
158
+ (_c2 = resolveOptions.deploy) == null ? void 0 : _c2.microFrontend
159
+ );
132
160
  if (externalBasicLibrary) {
133
161
  chain.externals(externals);
134
162
  }
135
- // use html mode
136
163
  if (!enableHtmlEntry) {
137
- chain.output.filename('index.js');
164
+ chain.output.filename("index.js");
138
165
  chain.plugins.delete(`${CHAIN_ID.PLUGIN.HTML}-main`);
139
166
  chain.optimization.runtimeChunk(false);
140
167
  chain.optimization.splitChunks({
141
- chunks: 'async'
168
+ chunks: "async"
142
169
  });
143
170
  }
144
171
  }
145
172
  const resolveWebpackConfig = chain.toConfig();
146
- logger('webpackConfig', {
173
+ logger("webpackConfig", {
147
174
  output: resolveWebpackConfig.output,
148
175
  externals: resolveWebpackConfig.externals,
149
- env: _env,
150
- alias: (_resolveWebpackConfig = resolveWebpackConfig.resolve) === null || _resolveWebpackConfig === void 0 ? void 0 : _resolveWebpackConfig.alias,
176
+ env,
177
+ alias: (_d = resolveWebpackConfig.resolve) == null ? void 0 : _d.alias,
151
178
  plugins: resolveWebpackConfig.plugins
152
179
  });
153
180
  }
@@ -155,104 +182,86 @@ export default (({
155
182
  };
156
183
  },
157
184
  addRuntimeExports() {
158
- const addExportStatement = `export { default as garfish, default as masterApp, hoistNonReactStatics } from '${_pluginName}'`;
159
- logger('exportStatement', addExportStatement);
185
+ const addExportStatement = `export { default as garfish, default as masterApp, hoistNonReactStatics } from '${pluginName}/runtime'`;
186
+ logger("exportStatement", addExportStatement);
160
187
  pluginsExportsUtils.addExport(addExportStatement);
161
- runtimeExportsUtils.addExport(`export * from '${_mfPackagePath}'`);
188
+ runtimeExportsUtils.addExport(
189
+ `export * from '${mfPackagePath}/runtime'`
190
+ );
162
191
  },
163
- modifyEntryImports({
164
- entrypoint,
165
- imports
166
- }) {
167
- // eslint-disable-next-line react-hooks/rules-of-hooks
192
+ modifyEntryImports({ entrypoint, imports }) {
168
193
  const config = useResolvedConfigContext();
169
- const {
170
- masterApp
171
- } = getRuntimeConfig(config);
194
+ const { masterApp } = getRuntimeConfig(config);
172
195
  if (masterApp) {
173
196
  imports.push({
174
- value: _runtimePluginName,
175
- specifiers: [{
176
- imported: 'garfish'
177
- }]
197
+ value: runtimePluginName,
198
+ specifiers: [
199
+ {
200
+ imported: "garfish"
201
+ }
202
+ ]
178
203
  });
179
204
  imports.push({
180
- value: _runtimePluginName,
181
- specifiers: [{
182
- imported: 'masterApp'
183
- }]
205
+ value: runtimePluginName,
206
+ specifiers: [
207
+ {
208
+ imported: "masterApp"
209
+ }
210
+ ]
184
211
  });
185
212
  }
186
213
  imports.push({
187
- value: _runtimePluginName,
188
- specifiers: [{
189
- imported: 'hoistNonReactStatics'
190
- }]
214
+ value: runtimePluginName,
215
+ specifiers: [
216
+ {
217
+ imported: "hoistNonReactStatics"
218
+ }
219
+ ]
191
220
  });
192
221
  imports.push({
193
- value: 'react-dom',
194
- specifiers: [{
195
- imported: 'unmountComponentAtNode'
196
- }, {
197
- imported: 'createPortal'
198
- }]
222
+ value: "react-dom",
223
+ specifiers: [
224
+ {
225
+ imported: "unmountComponentAtNode"
226
+ },
227
+ {
228
+ imported: "createPortal"
229
+ }
230
+ ]
199
231
  });
200
- return {
201
- imports,
202
- entrypoint
203
- };
232
+ return { imports, entrypoint };
204
233
  },
205
- modifyEntryRuntimePlugins({
206
- entrypoint,
207
- plugins
208
- }) {
209
- // eslint-disable-next-line react-hooks/rules-of-hooks
234
+ modifyEntryRuntimePlugins({ entrypoint, plugins }) {
210
235
  const config = useResolvedConfigContext();
211
- const {
212
- masterApp
213
- } = getRuntimeConfig(config);
236
+ const { masterApp } = getRuntimeConfig(config);
214
237
  if (masterApp) {
215
- logger('garfishPlugin options', masterApp);
238
+ logger("garfishPlugin options", masterApp);
216
239
  plugins.push({
217
- name: 'garfish',
218
- args: 'masterApp',
240
+ name: "garfish",
241
+ args: "masterApp",
219
242
  options: masterApp === true ? JSON.stringify({}) : JSON.stringify(masterApp)
220
243
  });
221
244
  }
222
- return {
223
- entrypoint,
224
- plugins
225
- };
245
+ return { entrypoint, plugins };
226
246
  },
227
- modifyEntryRenderFunction({
228
- entrypoint,
229
- code
230
- }) {
231
- var _config$deploy;
232
- // eslint-disable-next-line react-hooks/rules-of-hooks
247
+ modifyEntryRenderFunction({ entrypoint, code }) {
248
+ var _a;
233
249
  const config = useResolvedConfigContext();
234
- if (!(config !== null && config !== void 0 && (_config$deploy = config.deploy) !== null && _config$deploy !== void 0 && _config$deploy.microFrontend)) {
235
- return {
236
- entrypoint,
237
- code
238
- };
250
+ if (!((_a = config == null ? void 0 : config.deploy) == null ? void 0 : _a.microFrontend)) {
251
+ return { entrypoint, code };
239
252
  }
240
253
  const nCode = makeRenderFunction(code);
241
- logger('makeRenderFunction', nCode);
254
+ logger("makeRenderFunction", nCode);
242
255
  return {
243
256
  entrypoint,
244
257
  code: nCode
245
258
  };
246
259
  },
247
- modifyAsyncEntry({
248
- entrypoint,
249
- code
250
- }) {
251
- var _config$deploy2, _config$source;
252
- // eslint-disable-next-line react-hooks/rules-of-hooks
260
+ modifyAsyncEntry({ entrypoint, code }) {
261
+ var _a, _b;
253
262
  const config = useResolvedConfigContext();
254
263
  let finalCode = code;
255
- if (config !== null && config !== void 0 && (_config$deploy2 = config.deploy) !== null && _config$deploy2 !== void 0 && _config$deploy2.microFrontend && config !== null && config !== void 0 && (_config$source = config.source) !== null && _config$source !== void 0 && _config$source.enableAsyncEntry) {
264
+ if (((_a = config == null ? void 0 : config.deploy) == null ? void 0 : _a.microFrontend) && ((_b = config == null ? void 0 : config.source) == null ? void 0 : _b.enableAsyncEntry)) {
256
265
  finalCode = generateAsyncEntry(code);
257
266
  return {
258
267
  entrypoint,
@@ -264,16 +273,12 @@ export default (({
264
273
  code: finalCode
265
274
  };
266
275
  },
267
- modifyEntryExport({
268
- entrypoint,
269
- exportStatement
270
- }) {
271
- var _config$deploy3;
272
- // eslint-disable-next-line react-hooks/rules-of-hooks
276
+ modifyEntryExport({ entrypoint, exportStatement }) {
277
+ var _a;
273
278
  const config = useResolvedConfigContext();
274
- if (config !== null && config !== void 0 && (_config$deploy3 = config.deploy) !== null && _config$deploy3 !== void 0 && _config$deploy3.microFrontend) {
279
+ if ((_a = config == null ? void 0 : config.deploy) == null ? void 0 : _a.microFrontend) {
275
280
  const exportStatementCode = makeProvider();
276
- logger('exportStatement', exportStatementCode);
281
+ logger("exportStatement", exportStatementCode);
277
282
  return {
278
283
  entrypoint,
279
284
  exportStatement: exportStatementCode
@@ -286,4 +291,9 @@ export default (({
286
291
  }
287
292
  };
288
293
  }
289
- }));
294
+ });
295
+ export {
296
+ cli_default as default,
297
+ externals,
298
+ getDefaultMicroFrontedConfig
299
+ };
File without changes
@@ -1,4 +1,4 @@
1
- export const makeProvider = () => `
1
+ const makeProvider = () => `
2
2
  export const provider = function ({basename, dom}) {
3
3
  return {
4
4
  render({basename, dom, props, appName}) {
@@ -79,40 +79,41 @@ function generateAppWrapperAndRootDom ({ App, props, dom }) {
79
79
  return { AppWrapper, mountNode }
80
80
  }
81
81
  `;
82
- export const makeRenderFunction = code => {
82
+ const makeRenderFunction = (code) => {
83
83
  const inGarfishToRender = `
84
84
  const { basename, props, dom, appName } = typeof arguments[0] === 'object' && arguments[0] || {};
85
85
  if (!canContinueRender({ dom, appName })) return null;
86
86
  let { AppWrapper, mountNode } = generateAppWrapperAndRootDom({App, props, dom});
87
87
  `;
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');
88
+ return inGarfishToRender + code.replace(`router(`, `generateRouterPlugin(basename,`).replace("(App)", `(AppWrapper)`).replace(/MOUNT_ID/g, "mountNode").replace(
89
+ `bootstrap(AppWrapper, mountNode, root`,
90
+ "bootstrap(AppWrapper, mountNode, root = IS_REACT18 ? ReactDOM.createRoot(mountNode) : null"
91
+ );
89
92
  };
90
-
91
- // support legacy config
92
- export function getRuntimeConfig(config) {
93
- var _config$runtime;
94
- if (config !== null && config !== void 0 && (_config$runtime = config.runtime) !== null && _config$runtime !== void 0 && _config$runtime.features) {
95
- var _config$runtime2;
96
- return config === null || config === void 0 ? void 0 : (_config$runtime2 = config.runtime) === null || _config$runtime2 === void 0 ? void 0 : _config$runtime2.features;
93
+ function getRuntimeConfig(config) {
94
+ var _a, _b;
95
+ if ((_a = config == null ? void 0 : config.runtime) == null ? void 0 : _a.features) {
96
+ return (_b = config == null ? void 0 : config.runtime) == null ? void 0 : _b.features;
97
97
  }
98
- return (config === null || config === void 0 ? void 0 : config.runtime) || {};
98
+ return (config == null ? void 0 : config.runtime) || {};
99
99
  }
100
-
101
- // support legacy config
102
- export function setRuntimeConfig(config, key, value) {
103
- var _config$runtime3, _config$runtime4;
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]) {
100
+ function setRuntimeConfig(config, key, value) {
101
+ var _a, _b;
102
+ if (((_a = config == null ? void 0 : config.runtime) == null ? void 0 : _a.features) && ((_b = config == null ? void 0 : config.runtime) == null ? void 0 : _b.features[key])) {
105
103
  config.runtime.features[key] = value;
106
- return undefined;
104
+ return void 0;
107
105
  }
108
- if (config !== null && config !== void 0 && config.runtime && config !== null && config !== void 0 && config.runtime[key]) {
106
+ if ((config == null ? void 0 : config.runtime) && (config == null ? void 0 : config.runtime[key])) {
109
107
  config.runtime[key] = value;
110
- return undefined;
108
+ return void 0;
111
109
  }
112
- return undefined;
110
+ return void 0;
113
111
  }
114
- export const generateAsyncEntry = code => {
115
- const transformCode = code.replace(`import('./bootstrap.js');`, `if (!window.__GARFISH__) { import('./bootstrap.js'); }`);
112
+ const generateAsyncEntry = (code) => {
113
+ const transformCode = code.replace(
114
+ `import('./bootstrap.js');`,
115
+ `if (!window.__GARFISH__) { import('./bootstrap.js'); }`
116
+ );
116
117
  return `
117
118
  export const provider = async (...args) => {
118
119
  const exports = await import('./bootstrap');
@@ -120,4 +121,11 @@ export const generateAsyncEntry = code => {
120
121
  };
121
122
  ${transformCode}
122
123
  `;
123
- };
124
+ };
125
+ export {
126
+ generateAsyncEntry,
127
+ getRuntimeConfig,
128
+ makeProvider,
129
+ makeRenderFunction,
130
+ setRuntimeConfig
131
+ };
File without changes
@@ -1,2 +1,5 @@
1
- export { default } from "./runtime";
2
- export * from "./runtime";
1
+ import { default as default2 } from "./runtime";
2
+ export * from "./runtime";
3
+ export {
4
+ default2 as default
5
+ };
File without changes
File without changes
@@ -1,4 +1,12 @@
1
- export { default } from "./plugin";
2
- export { useModuleApps, useModuleApp } from "./useModuleApps";
3
- export { default as Garfish, default as garfish } from 'garfish';
4
- export { default as hoistNonReactStatics } from 'hoist-non-react-statics';
1
+ import { default as default2 } from "./plugin";
2
+ import { useModuleApps, useModuleApp } from "./useModuleApps";
3
+ import { default as default3, default as default4 } from "garfish";
4
+ import { default as default5 } from "hoist-non-react-statics";
5
+ export {
6
+ default3 as Garfish,
7
+ default2 as default,
8
+ default4 as garfish,
9
+ default5 as hoistNonReactStatics,
10
+ useModuleApp,
11
+ useModuleApps
12
+ };