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

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,97 @@
1
1
  # @modern-js/plugin-garfish
2
2
 
3
+ ## 2.0.0-beta.7
4
+
5
+ ### Major Changes
6
+
7
+ - dda38c9c3e: chore: v2
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [c9e800d39a]
12
+ - Updated dependencies [edd1cfb1af]
13
+ - Updated dependencies [6bda14ed71]
14
+ - Updated dependencies [dda38c9c3e]
15
+ - Updated dependencies [8b8e1bb571]
16
+ - Updated dependencies [bbe4c4ab64]
17
+ - @modern-js/runtime@2.0.0-beta.7
18
+ - @modern-js/utils@2.0.0-beta.7
19
+
20
+ ## 2.0.0-beta.6
21
+
22
+ ### Major Changes
23
+
24
+ - dda38c9c3e: chore: v2
25
+
26
+ ### Minor Changes
27
+
28
+ - df7ee2d: feat: runtime user config types extends
29
+ feat: runtime 用户配置类型扩展
30
+
31
+ ### Patch Changes
32
+
33
+ - 6604f1b8b3: feat: support router basename
34
+ feat: router 插件支持设置 basename
35
+ - 21d2ddb59c: feat: support async export provider for module federation
36
+ 支持模块联邦场景异步导出 provider
37
+ - cce8ecee2d: fix: handle some `TODO` & `FIXME`, change some tests
38
+ fix: 处理一些 `TODO` 和 `FIXME`, 修改了一些 tests
39
+ - 2344eb26ed: fix: loadApp when dom is mount
40
+ 修复 dom 未渲染时挂载子应用行为
41
+ - Updated dependencies [2344eb26ed]
42
+ - Updated dependencies [a11fcf8b50]
43
+ - Updated dependencies [a93159440e]
44
+ - Updated dependencies [e7ce0636d1]
45
+ - Updated dependencies [b18fa8f3ed]
46
+ - Updated dependencies [7879e8f711]
47
+ - Updated dependencies [50d4675e5b]
48
+ - Updated dependencies [c9e800d39a]
49
+ - Updated dependencies [6604f1b8b3]
50
+ - Updated dependencies [6aca875011]
51
+ - Updated dependencies [fda836fe8a]
52
+ - Updated dependencies [d6bc321747]
53
+ - Updated dependencies [3e57f2bd58]
54
+ - Updated dependencies [2e6031955e]
55
+ - Updated dependencies [c5798d284f]
56
+ - Updated dependencies [fbf5eed5aa]
57
+ - Updated dependencies [a2509bfbdb]
58
+ - Updated dependencies [a7c68832b3]
59
+ - Updated dependencies [425e57092d]
60
+ - Updated dependencies [e4357f1856]
61
+ - Updated dependencies [7b7d12cf8f]
62
+ - Updated dependencies [4369648ae2]
63
+ - Updated dependencies [7efeed4]
64
+ - Updated dependencies [92f0eade39]
65
+ - Updated dependencies [df7ee2d]
66
+ - Updated dependencies [92c0994468]
67
+ - Updated dependencies [2cc2eb35ba]
68
+ - Updated dependencies [edd1cfb1af]
69
+ - Updated dependencies [cc971eabfc]
70
+ - Updated dependencies [5b9049f2e9]
71
+ - Updated dependencies [6bda14ed71]
72
+ - Updated dependencies [92004d1906]
73
+ - Updated dependencies [b8bbe036c7]
74
+ - Updated dependencies [40ed5874c6]
75
+ - Updated dependencies [60d5378632]
76
+ - Updated dependencies [d5a31df781]
77
+ - Updated dependencies [dda38c9c3e]
78
+ - Updated dependencies [8b8e1bb571]
79
+ - Updated dependencies [3bbea92b2a]
80
+ - Updated dependencies [21d7521]
81
+ - Updated dependencies [9144c21d27]
82
+ - Updated dependencies [b710adb843]
83
+ - Updated dependencies [18aaf42249]
84
+ - Updated dependencies [34702d5d47]
85
+ - Updated dependencies [fcace5b5b9]
86
+ - Updated dependencies [ea7cf06257]
87
+ - Updated dependencies [bbe4c4ab64]
88
+ - Updated dependencies [e4558a0bc4]
89
+ - Updated dependencies [abf3421a75]
90
+ - Updated dependencies [543be9558e]
91
+ - Updated dependencies [14b712da84]
92
+ - @modern-js/runtime@2.0.0-beta.6
93
+ - @modern-js/utils@2.0.0-beta.6
94
+
3
95
  ## 2.0.0-beta.4
4
96
 
5
97
  ### Major Changes
@@ -34,7 +34,6 @@ var __async = (__this, __arguments, generator) => {
34
34
  step((generator = generator.apply(__this, __arguments)).next());
35
35
  });
36
36
  };
37
- import path from "path";
38
37
  import { createRuntimeExportsUtils, PLUGIN_SCHEMAS } from "@modern-js/utils";
39
38
  import { logger } from "../util";
40
39
  import {
@@ -44,7 +43,6 @@ import {
44
43
  setRuntimeConfig,
45
44
  generateAsyncEntry
46
45
  } from "./utils";
47
- import "./types";
48
46
  const externals = { "react-dom": "react-dom", react: "react" };
49
47
  function getDefaultMicroFrontedConfig(microFrontend) {
50
48
  if (microFrontend === true) {
@@ -61,13 +59,11 @@ function getDefaultMicroFrontedConfig(microFrontend) {
61
59
  }
62
60
  var cli_default = ({
63
61
  pluginName = "@modern-js/plugin-garfish",
64
- runtimePluginName = "@modern-js/runtime/plugins",
65
- mfPackagePath = path.resolve(__dirname, "../../../../")
62
+ runtimePluginName = "@modern-js/runtime/plugins"
66
63
  } = {}) => ({
67
64
  name: "@modern-js/plugin-garfish",
68
65
  setup: ({ useAppContext, useResolvedConfigContext, useConfigContext }) => {
69
66
  let pluginsExportsUtils;
70
- let runtimeExportsUtils;
71
67
  return {
72
68
  validateSchema() {
73
69
  return PLUGIN_SCHEMAS["@modern-js/plugin-garfish"];
@@ -108,10 +104,6 @@ var cli_default = ({
108
104
  config.internalDirectory,
109
105
  "plugins"
110
106
  );
111
- runtimeExportsUtils = createRuntimeExportsUtils(
112
- config.internalDirectory,
113
- "index"
114
- );
115
107
  let disableCssExtract = ((_a = useConfig.output) == null ? void 0 : _a.disableCssExtract) || false;
116
108
  if ((_b = useConfig.deploy) == null ? void 0 : _b.microFrontend) {
117
109
  const { enableHtmlEntry } = getDefaultMicroFrontedConfig(
@@ -128,7 +120,7 @@ var cli_default = ({
128
120
  source: {
129
121
  alias: {
130
122
  "@modern-js/runtime/plugins": pluginsExportsUtils.getPath(),
131
- "@modern-js/runtime/garfish": mfPackagePath
123
+ "@modern-js/runtime/garfish": "@modern-js/plugin-garfish/runtime"
132
124
  }
133
125
  },
134
126
  tools: {
@@ -185,9 +177,6 @@ var cli_default = ({
185
177
  const addExportStatement = `export { default as garfish, default as masterApp, hoistNonReactStatics } from '${pluginName}/runtime'`;
186
178
  logger("exportStatement", addExportStatement);
187
179
  pluginsExportsUtils.addExport(addExportStatement);
188
- runtimeExportsUtils.addExport(
189
- `export * from '${mfPackagePath}/runtime'`
190
- );
191
180
  },
192
181
  modifyEntryImports({ entrypoint, imports }) {
193
182
  const config = useResolvedConfigContext();
@@ -64,7 +64,7 @@ function pathJoin(...args) {
64
64
  if (nPath[0] !== "/") {
65
65
  nPath = `/${nPath}`;
66
66
  }
67
- const lastIndex = path.length - 1;
67
+ const lastIndex = nPath.length - 1;
68
68
  if (nPath[lastIndex] === "/") {
69
69
  nPath = nPath.substring(0, lastIndex);
70
70
  }
@@ -90,7 +90,7 @@ function getAppInstance(options, appInfo, manifest) {
90
90
  basename = pathJoin(basename, (match == null ? void 0 : match.path) || "/");
91
91
  }
92
92
  useEffect(() => {
93
- if (location && locationHref !== location.pathname) {
93
+ if (location && locationHref !== location.pathname && !Garfish.running) {
94
94
  locationHref = location.pathname;
95
95
  const popStateEvent = new PopStateEvent("popstate");
96
96
  popStateEvent.garfish = true;
@@ -1,9 +1,7 @@
1
- var __create = Object.create;
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
4
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
7
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -30,10 +28,6 @@ var __copyProps = (to, from, except, desc) => {
30
28
  }
31
29
  return to;
32
30
  };
33
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
34
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
- mod
36
- ));
37
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
32
  var __async = (__this, __arguments, generator) => {
39
33
  return new Promise((resolve, reject) => {
@@ -62,11 +56,9 @@ __export(cli_exports, {
62
56
  getDefaultMicroFrontedConfig: () => getDefaultMicroFrontedConfig
63
57
  });
64
58
  module.exports = __toCommonJS(cli_exports);
65
- var import_path = __toESM(require("path"));
66
59
  var import_utils = require("@modern-js/utils");
67
60
  var import_util = require("../util");
68
61
  var import_utils2 = require("./utils");
69
- var import_types = require("./types");
70
62
  const externals = { "react-dom": "react-dom", react: "react" };
71
63
  function getDefaultMicroFrontedConfig(microFrontend) {
72
64
  if (microFrontend === true) {
@@ -83,13 +75,11 @@ function getDefaultMicroFrontedConfig(microFrontend) {
83
75
  }
84
76
  var cli_default = ({
85
77
  pluginName = "@modern-js/plugin-garfish",
86
- runtimePluginName = "@modern-js/runtime/plugins",
87
- mfPackagePath = import_path.default.resolve(__dirname, "../../../../")
78
+ runtimePluginName = "@modern-js/runtime/plugins"
88
79
  } = {}) => ({
89
80
  name: "@modern-js/plugin-garfish",
90
81
  setup: ({ useAppContext, useResolvedConfigContext, useConfigContext }) => {
91
82
  let pluginsExportsUtils;
92
- let runtimeExportsUtils;
93
83
  return {
94
84
  validateSchema() {
95
85
  return import_utils.PLUGIN_SCHEMAS["@modern-js/plugin-garfish"];
@@ -130,10 +120,6 @@ var cli_default = ({
130
120
  config.internalDirectory,
131
121
  "plugins"
132
122
  );
133
- runtimeExportsUtils = (0, import_utils.createRuntimeExportsUtils)(
134
- config.internalDirectory,
135
- "index"
136
- );
137
123
  let disableCssExtract = ((_a = useConfig.output) == null ? void 0 : _a.disableCssExtract) || false;
138
124
  if ((_b = useConfig.deploy) == null ? void 0 : _b.microFrontend) {
139
125
  const { enableHtmlEntry } = getDefaultMicroFrontedConfig(
@@ -150,7 +136,7 @@ var cli_default = ({
150
136
  source: {
151
137
  alias: {
152
138
  "@modern-js/runtime/plugins": pluginsExportsUtils.getPath(),
153
- "@modern-js/runtime/garfish": mfPackagePath
139
+ "@modern-js/runtime/garfish": "@modern-js/plugin-garfish/runtime"
154
140
  }
155
141
  },
156
142
  tools: {
@@ -207,9 +193,6 @@ var cli_default = ({
207
193
  const addExportStatement = `export { default as garfish, default as masterApp, hoistNonReactStatics } from '${pluginName}/runtime'`;
208
194
  (0, import_util.logger)("exportStatement", addExportStatement);
209
195
  pluginsExportsUtils.addExport(addExportStatement);
210
- runtimeExportsUtils.addExport(
211
- `export * from '${mfPackagePath}/runtime'`
212
- );
213
196
  },
214
197
  modifyEntryImports({ entrypoint, imports }) {
215
198
  const config = useResolvedConfigContext();
@@ -91,7 +91,7 @@ function pathJoin(...args) {
91
91
  if (nPath[0] !== "/") {
92
92
  nPath = `/${nPath}`;
93
93
  }
94
- const lastIndex = path.length - 1;
94
+ const lastIndex = nPath.length - 1;
95
95
  if (nPath[lastIndex] === "/") {
96
96
  nPath = nPath.substring(0, lastIndex);
97
97
  }
@@ -117,7 +117,7 @@ function getAppInstance(options, appInfo, manifest) {
117
117
  basename = pathJoin(basename, (match == null ? void 0 : match.path) || "/");
118
118
  }
119
119
  (0, import_react.useEffect)(() => {
120
- if (location && locationHref !== location.pathname) {
120
+ if (location && locationHref !== location.pathname && !import_garfish.default.running) {
121
121
  locationHref = location.pathname;
122
122
  const popStateEvent = new PopStateEvent("popstate");
123
123
  popStateEvent.garfish = true;
@@ -150,11 +150,9 @@ var __generator = this && this.__generator || function(thisArg, body) {
150
150
  };
151
151
  }
152
152
  };
153
- import path from "path";
154
153
  import { createRuntimeExportsUtils, PLUGIN_SCHEMAS } from "@modern-js/utils";
155
154
  import { logger } from "../util";
156
155
  import { getRuntimeConfig, makeProvider, makeRenderFunction, setRuntimeConfig, generateAsyncEntry } from "./utils";
157
- import "./types";
158
156
  var externals = {
159
157
  "react-dom": "react-dom",
160
158
  react: "react"
@@ -173,13 +171,12 @@ function getDefaultMicroFrontedConfig(microFrontend) {
173
171
  }, microFrontend);
174
172
  }
175
173
  var cli_default = function() {
176
- var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _pluginName = ref.pluginName, pluginName = _pluginName === void 0 ? "@modern-js/plugin-garfish" : _pluginName, _runtimePluginName = ref.runtimePluginName, runtimePluginName = _runtimePluginName === void 0 ? "@modern-js/runtime/plugins" : _runtimePluginName, _mfPackagePath = ref.mfPackagePath, mfPackagePath = _mfPackagePath === void 0 ? path.resolve(__dirname, "../../../../") : _mfPackagePath;
174
+ var ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _pluginName = ref.pluginName, pluginName = _pluginName === void 0 ? "@modern-js/plugin-garfish" : _pluginName, _runtimePluginName = ref.runtimePluginName, runtimePluginName = _runtimePluginName === void 0 ? "@modern-js/runtime/plugins" : _runtimePluginName;
177
175
  return {
178
176
  name: "@modern-js/plugin-garfish",
179
177
  setup: function(param) {
180
178
  var useAppContext = param.useAppContext, useResolvedConfigContext = param.useResolvedConfigContext, useConfigContext = param.useConfigContext;
181
179
  var pluginsExportsUtils;
182
- var runtimeExportsUtils;
183
180
  return {
184
181
  validateSchema: function validateSchema() {
185
182
  return PLUGIN_SCHEMAS["@modern-js/plugin-garfish"];
@@ -221,7 +218,6 @@ var cli_default = function() {
221
218
  logger("useConfig", useConfig);
222
219
  var config = useAppContext();
223
220
  pluginsExportsUtils = createRuntimeExportsUtils(config.internalDirectory, "plugins");
224
- runtimeExportsUtils = createRuntimeExportsUtils(config.internalDirectory, "index");
225
221
  var disableCssExtract = ((ref = useConfig.output) === null || ref === void 0 ? void 0 : ref.disableCssExtract) || false;
226
222
  if ((ref1 = useConfig.deploy) === null || ref1 === void 0 ? void 0 : ref1.microFrontend) {
227
223
  var ref2;
@@ -237,7 +233,7 @@ var cli_default = function() {
237
233
  source: {
238
234
  alias: {
239
235
  "@modern-js/runtime/plugins": pluginsExportsUtils.getPath(),
240
- "@modern-js/runtime/garfish": mfPackagePath
236
+ "@modern-js/runtime/garfish": "@modern-js/plugin-garfish/runtime"
241
237
  }
242
238
  },
243
239
  tools: {
@@ -292,7 +288,6 @@ var cli_default = function() {
292
288
  var addExportStatement = "export { default as garfish, default as masterApp, hoistNonReactStatics } from '".concat(pluginName, "/runtime'");
293
289
  logger("exportStatement", addExportStatement);
294
290
  pluginsExportsUtils.addExport(addExportStatement);
295
- runtimeExportsUtils.addExport("export * from '".concat(mfPackagePath, "/runtime'"));
296
291
  },
297
292
  modifyEntryImports: function modifyEntryImports(param) {
298
293
  var entrypoint = param.entrypoint, imports = param.imports;
@@ -277,7 +277,7 @@ function pathJoin() {
277
277
  if (nPath[0] !== "/") {
278
278
  nPath = "/".concat(nPath);
279
279
  }
280
- var lastIndex = path.length - 1;
280
+ var lastIndex = nPath.length - 1;
281
281
  if (nPath[lastIndex] === "/") {
282
282
  nPath = nPath.substring(0, lastIndex);
283
283
  }
@@ -302,7 +302,7 @@ function getAppInstance(options, appInfo, manifest) {
302
302
  basename = pathJoin(basename, (match === null || match === void 0 ? void 0 : match.path) || "/");
303
303
  }
304
304
  useEffect(function() {
305
- if (location && locationHref !== location.pathname) {
305
+ if (location && locationHref !== location.pathname && !Garfish.running) {
306
306
  locationHref = location.pathname;
307
307
  var popStateEvent = new PopStateEvent("popstate");
308
308
  popStateEvent.garfish = true;
@@ -1,6 +1,5 @@
1
1
  import type { CliHookCallbacks, useConfigContext } from '@modern-js/core';
2
2
  import type { CliPlugin, AppTools } from '@modern-js/app-tools';
3
- import './types';
4
3
  export declare type UseConfig = ReturnType<typeof useConfigContext>;
5
4
  export declare const externals: {
6
5
  'react-dom': string;
@@ -12,12 +11,10 @@ export declare function getDefaultMicroFrontedConfig(microFrontend: NonInValidAb
12
11
 
13
12
  declare const _default: ({
14
13
  pluginName,
15
- runtimePluginName,
16
- mfPackagePath
14
+ runtimePluginName
17
15
  }?: {
18
16
  pluginName?: string | undefined;
19
17
  runtimePluginName?: string | undefined;
20
- mfPackagePath?: string | undefined;
21
18
  }) => CliPlugin<AppTools>;
22
19
 
23
20
  export default _default;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.0.0-beta.5",
14
+ "version": "2.0.0-beta.7",
15
15
  "jsnext:source": "./src/cli/index.ts",
16
16
  "types": "./dist/types/cli/index.d.ts",
17
17
  "typesVersions": {
@@ -54,16 +54,16 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@babel/runtime": "^7.18.0",
57
- "@modern-js/utils": "2.0.0-beta.4",
58
57
  "@types/debug": "^4.1.7",
59
58
  "@types/react-loadable": "^5.5.6",
60
59
  "debug": "^4.3.2",
61
60
  "garfish": "^1.8.1",
62
61
  "hoist-non-react-statics": "^3.3.2",
63
- "react-loadable": "^5.5.0"
62
+ "react-loadable": "^5.5.0",
63
+ "@modern-js/utils": "2.0.0-beta.7"
64
64
  },
65
65
  "peerDependencies": {
66
- "@modern-js/runtime": "^2.0.0-beta.4"
66
+ "@modern-js/runtime": "^2.0.0-beta.7"
67
67
  },
68
68
  "peerDependenciesMeta": {
69
69
  "@modern-js/runtime": {
@@ -71,13 +71,6 @@
71
71
  }
72
72
  },
73
73
  "devDependencies": {
74
- "@modern-js/core": "2.0.0-beta.4",
75
- "@modern-js/runtime": "2.0.0-beta.5",
76
- "@modern-js/plugin-router-v5": "2.0.0-beta.5",
77
- "@modern-js/types": "2.0.0-beta.4",
78
- "@scripts/build": "2.0.0-beta.4",
79
- "@modern-js/app-tools": "2.0.0-beta.4",
80
- "@scripts/jest-config": "2.0.0-beta.4",
81
74
  "@testing-library/jest-dom": "^5.16.1",
82
75
  "@testing-library/react": "^13.4.0",
83
76
  "@testing-library/react-hooks": "^8.0.1",
@@ -89,9 +82,16 @@
89
82
  "jest-fetch-mock": "^3.0.3",
90
83
  "react": "^18",
91
84
  "react-dom": "^18",
92
- "react-router-dom": "^6.4.4",
85
+ "react-router-dom": "^6.6.0",
93
86
  "typescript": "^4",
94
- "webpack-chain": "^6.5.1"
87
+ "webpack-chain": "^6.5.1",
88
+ "@modern-js/app-tools": "2.0.0-beta.7",
89
+ "@modern-js/core": "2.0.0-beta.7",
90
+ "@modern-js/runtime": "2.0.0-beta.7",
91
+ "@modern-js/plugin-router-v5": "2.0.0-beta.7",
92
+ "@modern-js/types": "2.0.0-beta.7",
93
+ "@scripts/build": "2.0.0-beta.7",
94
+ "@scripts/jest-config": "2.0.0-beta.7"
95
95
  },
96
96
  "sideEffects": false,
97
97
  "modernConfig": {},
package/type.d.ts CHANGED
@@ -10,3 +10,8 @@ declare module '@modern-js/runtime' {
10
10
  masterApp?: Config;
11
11
  }
12
12
  }
13
+ declare module '@modern-js/app-tools' {
14
+ interface RuntimeUserConfig {
15
+ masterApp?: Config;
16
+ }
17
+ }
File without changes
File without changes
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,6 +0,0 @@
1
- import { Config as MasterAppConfig } from '../runtime/useModuleApps';
2
- declare module '@modern-js/app-tools' {
3
- interface RuntimeUserConfig {
4
- masterApp?: MasterAppConfig;
5
- }
6
- }