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

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 (53) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/dist/js/modern/cli/index.js +164 -157
  3. package/dist/js/modern/cli/utils.js +31 -23
  4. package/dist/js/modern/global.d.js +0 -0
  5. package/dist/js/modern/index.js +5 -2
  6. package/dist/js/modern/modern-app.env.d.js +0 -0
  7. package/dist/js/modern/runtime/global.d.js +0 -0
  8. package/dist/js/modern/runtime/index.js +12 -4
  9. package/dist/js/modern/runtime/loadable.js +74 -56
  10. package/dist/js/modern/runtime/plugin.js +114 -79
  11. package/dist/js/modern/runtime/useModuleApps.js +40 -26
  12. package/dist/js/modern/runtime/utils/Context.js +6 -3
  13. package/dist/js/modern/runtime/utils/MApp.js +76 -72
  14. package/dist/js/modern/runtime/utils/apps.js +177 -142
  15. package/dist/js/modern/runtime/utils/setExternal.js +11 -11
  16. package/dist/js/modern/type.d.js +0 -0
  17. package/dist/js/modern/util.js +11 -9
  18. package/dist/js/node/cli/index.js +184 -168
  19. package/dist/js/node/cli/utils.js +45 -30
  20. package/dist/js/node/global.d.js +0 -0
  21. package/dist/js/node/index.js +29 -24
  22. package/dist/js/node/modern-app.env.d.js +0 -0
  23. package/dist/js/node/runtime/global.d.js +0 -0
  24. package/dist/js/node/runtime/index.js +35 -44
  25. package/dist/js/node/runtime/loadable.js +95 -61
  26. package/dist/js/node/runtime/plugin.js +147 -95
  27. package/dist/js/node/runtime/useModuleApps.js +64 -34
  28. package/dist/js/node/runtime/utils/Context.js +30 -10
  29. package/dist/js/node/runtime/utils/MApp.js +107 -84
  30. package/dist/js/node/runtime/utils/apps.js +204 -146
  31. package/dist/js/node/runtime/utils/setExternal.js +35 -18
  32. package/dist/js/node/type.d.js +0 -0
  33. package/dist/js/node/util.js +34 -19
  34. package/dist/js/treeshaking/cli/index.js +402 -284
  35. package/dist/js/treeshaking/cli/utils.js +28 -31
  36. package/dist/js/treeshaking/global.d.js +1 -0
  37. package/dist/js/treeshaking/index.js +3 -2
  38. package/dist/js/treeshaking/modern-app.env.d.js +1 -0
  39. package/dist/js/treeshaking/runtime/global.d.js +1 -0
  40. package/dist/js/treeshaking/runtime/index.js +5 -4
  41. package/dist/js/treeshaking/runtime/loadable.js +230 -109
  42. package/dist/js/treeshaking/runtime/plugin.js +469 -168
  43. package/dist/js/treeshaking/runtime/useModuleApps.js +55 -31
  44. package/dist/js/treeshaking/runtime/utils/Context.js +3 -3
  45. package/dist/js/treeshaking/runtime/utils/MApp.js +348 -180
  46. package/dist/js/treeshaking/runtime/utils/apps.js +536 -230
  47. package/dist/js/treeshaking/runtime/utils/setExternal.js +12 -11
  48. package/dist/js/treeshaking/type.d.js +1 -0
  49. package/dist/js/treeshaking/util.js +7 -9
  50. package/dist/types/cli/index.d.ts +2 -0
  51. package/dist/types/runtime/plugin.d.ts +2 -0
  52. package/dist/types/runtime/utils/setExternal.d.ts +1 -0
  53. package/package.json +10 -10
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,94 @@
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
+ const externals = { "react-dom": "react-dom", react: "react" };
48
+ function getDefaultMicroFrontedConfig(microFrontend) {
13
49
  if (microFrontend === true) {
14
50
  return {
15
51
  enableHtmlEntry: true,
16
52
  externalBasicLibrary: false,
17
- moduleApp: ''
53
+ moduleApp: ""
18
54
  };
19
55
  }
20
- return _objectSpread({
56
+ return __spreadValues({
21
57
  enableHtmlEntry: true,
22
58
  externalBasicLibrary: false
23
59
  }, microFrontend);
24
60
  }
25
- export default (({
26
- pluginName: _pluginName = '@modern-js/plugin-garfish',
27
- runtimePluginName: _runtimePluginName = '@modern-js/runtime/plugins',
28
- mfPackagePath: _mfPackagePath = path.resolve(__dirname, '../../../../')
61
+ var cli_default = ({
62
+ pluginName = "@modern-js/plugin-garfish",
63
+ runtimePluginName = "@modern-js/runtime/plugins",
64
+ mfPackagePath = path.resolve(__dirname, "../../../../")
29
65
  } = {}) => ({
30
- name: '@modern-js/plugin-garfish',
31
- setup: ({
32
- useAppContext,
33
- useResolvedConfigContext,
34
- useConfigContext
35
- }) => {
66
+ name: "@modern-js/plugin-garfish",
67
+ setup: ({ useAppContext, useResolvedConfigContext, useConfigContext }) => {
36
68
  let pluginsExportsUtils;
37
69
  let runtimeExportsUtils;
38
70
  return {
39
71
  validateSchema() {
40
- return PLUGIN_SCHEMAS['@modern-js/plugin-garfish'];
72
+ return PLUGIN_SCHEMAS["@modern-js/plugin-garfish"];
41
73
  },
42
- resolvedConfig: async config => {
43
- const {
44
- resolved
45
- } = config;
46
- const {
47
- masterApp,
48
- router
49
- } = getRuntimeConfig(resolved);
74
+ resolvedConfig: (config) => __async(void 0, null, function* () {
75
+ var _a;
76
+ const { resolved } = config;
77
+ const { masterApp, router } = getRuntimeConfig(resolved);
50
78
  const nConfig = {
51
- resolved: _objectSpread({}, resolved)
79
+ resolved: __spreadValues({}, resolved)
52
80
  };
53
81
  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
- }));
82
+ setRuntimeConfig(
83
+ nConfig.resolved,
84
+ "masterApp",
85
+ Object.assign(
86
+ typeof masterApp === "object" ? __spreadValues({}, masterApp) : {},
87
+ {
88
+ basename: ((_a = router == null ? void 0 : router.historyOptions) == null ? void 0 : _a.basename) || (router == null ? void 0 : router.basename) || "/"
89
+ }
90
+ )
91
+ );
59
92
  }
60
93
  logger(`resolvedConfig`, {
61
94
  output: nConfig.resolved.output,
@@ -64,25 +97,25 @@ export default (({
64
97
  server: nConfig.resolved.server
65
98
  });
66
99
  return nConfig;
67
- },
100
+ }),
68
101
  config() {
69
- var _useConfig$output, _useConfig$deploy;
70
- // eslint-disable-next-line react-hooks/rules-of-hooks
102
+ var _a, _b, _c;
71
103
  const useConfig = useConfigContext();
72
- logger('useConfig', useConfig);
73
-
74
- // eslint-disable-next-line react-hooks/rules-of-hooks
104
+ logger("useConfig", useConfig);
75
105
  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);
106
+ pluginsExportsUtils = createRuntimeExportsUtils(
107
+ config.internalDirectory,
108
+ "plugins"
109
+ );
110
+ runtimeExportsUtils = createRuntimeExportsUtils(
111
+ config.internalDirectory,
112
+ "index"
113
+ );
114
+ let disableCssExtract = ((_a = useConfig.output) == null ? void 0 : _a.disableCssExtract) || false;
115
+ if ((_b = useConfig.deploy) == null ? void 0 : _b.microFrontend) {
116
+ const { enableHtmlEntry } = getDefaultMicroFrontedConfig(
117
+ (_c = useConfig.deploy) == null ? void 0 : _c.microFrontend
118
+ );
86
119
  if (!enableHtmlEntry) {
87
120
  disableCssExtract = true;
88
121
  }
@@ -93,61 +126,54 @@ export default (({
93
126
  },
94
127
  source: {
95
128
  alias: {
96
- '@modern-js/runtime/plugins': pluginsExportsUtils.getPath(),
97
- '@modern-js/runtime/garfish': _mfPackagePath
129
+ "@modern-js/runtime/plugins": pluginsExportsUtils.getPath(),
130
+ "@modern-js/runtime/garfish": mfPackagePath
98
131
  }
99
132
  },
100
133
  tools: {
101
134
  devServer: {
102
135
  headers: {
103
- 'Access-Control-Allow-Origin': '*'
136
+ "Access-Control-Allow-Origin": "*"
104
137
  }
105
138
  },
106
139
  webpackChain: (chain, {
107
140
  webpack,
108
- env: _env = process.env.NODE_ENV || 'development',
141
+ env = process.env.NODE_ENV || "development",
109
142
  CHAIN_ID
110
143
  }) => {
111
- var _resolveOptions$deplo, _resolveWebpackConfig;
112
- // eslint-disable-next-line react-hooks/rules-of-hooks
144
+ var _a2, _b2, _c2, _d;
113
145
  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}/`);
146
+ if ((_a2 = resolveOptions == null ? void 0 : resolveOptions.deploy) == null ? void 0 : _a2.microFrontend) {
147
+ chain.output.libraryTarget("umd");
148
+ if (((_b2 = resolveOptions == null ? void 0 : resolveOptions.server) == null ? void 0 : _b2.port) && env === "development") {
149
+ chain.output.publicPath(
150
+ `//localhost:${resolveOptions.server.port}/`
151
+ );
119
152
  }
120
-
121
- // add comments avoid sourcemap abnormal
122
153
  if (webpack.BannerPlugin) {
123
- chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [{
124
- banner: 'Micro front-end'
125
- }]);
154
+ chain.plugin(CHAIN_ID.PLUGIN.BANNER).use(webpack.BannerPlugin, [{ banner: "Micro front-end" }]);
126
155
  }
127
- const {
128
- enableHtmlEntry,
129
- externalBasicLibrary
130
- } = getDefaultMicroFrontedConfig((_resolveOptions$deplo2 = resolveOptions.deploy) === null || _resolveOptions$deplo2 === void 0 ? void 0 : _resolveOptions$deplo2.microFrontend);
131
- // external
156
+ const { enableHtmlEntry, externalBasicLibrary } = getDefaultMicroFrontedConfig(
157
+ (_c2 = resolveOptions.deploy) == null ? void 0 : _c2.microFrontend
158
+ );
132
159
  if (externalBasicLibrary) {
133
160
  chain.externals(externals);
134
161
  }
135
- // use html mode
136
162
  if (!enableHtmlEntry) {
137
- chain.output.filename('index.js');
163
+ chain.output.filename("index.js");
138
164
  chain.plugins.delete(`${CHAIN_ID.PLUGIN.HTML}-main`);
139
165
  chain.optimization.runtimeChunk(false);
140
166
  chain.optimization.splitChunks({
141
- chunks: 'async'
167
+ chunks: "async"
142
168
  });
143
169
  }
144
170
  }
145
171
  const resolveWebpackConfig = chain.toConfig();
146
- logger('webpackConfig', {
172
+ logger("webpackConfig", {
147
173
  output: resolveWebpackConfig.output,
148
174
  externals: resolveWebpackConfig.externals,
149
- env: _env,
150
- alias: (_resolveWebpackConfig = resolveWebpackConfig.resolve) === null || _resolveWebpackConfig === void 0 ? void 0 : _resolveWebpackConfig.alias,
175
+ env,
176
+ alias: (_d = resolveWebpackConfig.resolve) == null ? void 0 : _d.alias,
151
177
  plugins: resolveWebpackConfig.plugins
152
178
  });
153
179
  }
@@ -155,104 +181,84 @@ export default (({
155
181
  };
156
182
  },
157
183
  addRuntimeExports() {
158
- const addExportStatement = `export { default as garfish, default as masterApp, hoistNonReactStatics } from '${_pluginName}'`;
159
- logger('exportStatement', addExportStatement);
184
+ const addExportStatement = `export { default as garfish, default as masterApp, hoistNonReactStatics } from '${pluginName}'`;
185
+ logger("exportStatement", addExportStatement);
160
186
  pluginsExportsUtils.addExport(addExportStatement);
161
- runtimeExportsUtils.addExport(`export * from '${_mfPackagePath}'`);
187
+ runtimeExportsUtils.addExport(`export * from '${mfPackagePath}'`);
162
188
  },
163
- modifyEntryImports({
164
- entrypoint,
165
- imports
166
- }) {
167
- // eslint-disable-next-line react-hooks/rules-of-hooks
189
+ modifyEntryImports({ entrypoint, imports }) {
168
190
  const config = useResolvedConfigContext();
169
- const {
170
- masterApp
171
- } = getRuntimeConfig(config);
191
+ const { masterApp } = getRuntimeConfig(config);
172
192
  if (masterApp) {
173
193
  imports.push({
174
- value: _runtimePluginName,
175
- specifiers: [{
176
- imported: 'garfish'
177
- }]
194
+ value: runtimePluginName,
195
+ specifiers: [
196
+ {
197
+ imported: "garfish"
198
+ }
199
+ ]
178
200
  });
179
201
  imports.push({
180
- value: _runtimePluginName,
181
- specifiers: [{
182
- imported: 'masterApp'
183
- }]
202
+ value: runtimePluginName,
203
+ specifiers: [
204
+ {
205
+ imported: "masterApp"
206
+ }
207
+ ]
184
208
  });
185
209
  }
186
210
  imports.push({
187
- value: _runtimePluginName,
188
- specifiers: [{
189
- imported: 'hoistNonReactStatics'
190
- }]
211
+ value: runtimePluginName,
212
+ specifiers: [
213
+ {
214
+ imported: "hoistNonReactStatics"
215
+ }
216
+ ]
191
217
  });
192
218
  imports.push({
193
- value: 'react-dom',
194
- specifiers: [{
195
- imported: 'unmountComponentAtNode'
196
- }, {
197
- imported: 'createPortal'
198
- }]
219
+ value: "react-dom",
220
+ specifiers: [
221
+ {
222
+ imported: "unmountComponentAtNode"
223
+ },
224
+ {
225
+ imported: "createPortal"
226
+ }
227
+ ]
199
228
  });
200
- return {
201
- imports,
202
- entrypoint
203
- };
229
+ return { imports, entrypoint };
204
230
  },
205
- modifyEntryRuntimePlugins({
206
- entrypoint,
207
- plugins
208
- }) {
209
- // eslint-disable-next-line react-hooks/rules-of-hooks
231
+ modifyEntryRuntimePlugins({ entrypoint, plugins }) {
210
232
  const config = useResolvedConfigContext();
211
- const {
212
- masterApp
213
- } = getRuntimeConfig(config);
233
+ const { masterApp } = getRuntimeConfig(config);
214
234
  if (masterApp) {
215
- logger('garfishPlugin options', masterApp);
235
+ logger("garfishPlugin options", masterApp);
216
236
  plugins.push({
217
- name: 'garfish',
218
- args: 'masterApp',
237
+ name: "garfish",
238
+ args: "masterApp",
219
239
  options: masterApp === true ? JSON.stringify({}) : JSON.stringify(masterApp)
220
240
  });
221
241
  }
222
- return {
223
- entrypoint,
224
- plugins
225
- };
242
+ return { entrypoint, plugins };
226
243
  },
227
- modifyEntryRenderFunction({
228
- entrypoint,
229
- code
230
- }) {
231
- var _config$deploy;
232
- // eslint-disable-next-line react-hooks/rules-of-hooks
244
+ modifyEntryRenderFunction({ entrypoint, code }) {
245
+ var _a;
233
246
  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
- };
247
+ if (!((_a = config == null ? void 0 : config.deploy) == null ? void 0 : _a.microFrontend)) {
248
+ return { entrypoint, code };
239
249
  }
240
250
  const nCode = makeRenderFunction(code);
241
- logger('makeRenderFunction', nCode);
251
+ logger("makeRenderFunction", nCode);
242
252
  return {
243
253
  entrypoint,
244
254
  code: nCode
245
255
  };
246
256
  },
247
- modifyAsyncEntry({
248
- entrypoint,
249
- code
250
- }) {
251
- var _config$deploy2, _config$source;
252
- // eslint-disable-next-line react-hooks/rules-of-hooks
257
+ modifyAsyncEntry({ entrypoint, code }) {
258
+ var _a, _b;
253
259
  const config = useResolvedConfigContext();
254
260
  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) {
261
+ 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
262
  finalCode = generateAsyncEntry(code);
257
263
  return {
258
264
  entrypoint,
@@ -264,16 +270,12 @@ export default (({
264
270
  code: finalCode
265
271
  };
266
272
  },
267
- modifyEntryExport({
268
- entrypoint,
269
- exportStatement
270
- }) {
271
- var _config$deploy3;
272
- // eslint-disable-next-line react-hooks/rules-of-hooks
273
+ modifyEntryExport({ entrypoint, exportStatement }) {
274
+ var _a;
273
275
  const config = useResolvedConfigContext();
274
- if (config !== null && config !== void 0 && (_config$deploy3 = config.deploy) !== null && _config$deploy3 !== void 0 && _config$deploy3.microFrontend) {
276
+ if ((_a = config == null ? void 0 : config.deploy) == null ? void 0 : _a.microFrontend) {
275
277
  const exportStatementCode = makeProvider();
276
- logger('exportStatement', exportStatementCode);
278
+ logger("exportStatement", exportStatementCode);
277
279
  return {
278
280
  entrypoint,
279
281
  exportStatement: exportStatementCode
@@ -286,4 +288,9 @@ export default (({
286
288
  }
287
289
  };
288
290
  }
289
- }));
291
+ });
292
+ export {
293
+ cli_default as default,
294
+ externals,
295
+ getDefaultMicroFrontedConfig
296
+ };
@@ -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
+ };