@umijs/plugins 4.0.0-canary.20220323.1 → 4.0.0-rc.10

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.
@@ -30,7 +30,7 @@ exports.default = (api) => {
30
30
  import React from 'react';
31
31
  import { useModel } from '@@/plugin-model';
32
32
  ${loading
33
- ? `import Loading from ${loading}`
33
+ ? `import Loading from '${loading}'`
34
34
  : `function Loading() { return <div>loading</div>; }`}
35
35
  export default function InitialStateProvider(props: any) {
36
36
  const appLoaded = React.useRef(false);
@@ -91,7 +91,6 @@ export const setMasterOptions = (newOpts) => options = ({ ...options, ...newOpts
91
91
  path: file.replace(/\.tpl$/, ''),
92
92
  tpl: getFileContent(file),
93
93
  context: {
94
- runtimeHistory: api.config.runtimeHistory,
95
94
  dynamicRoot: false,
96
95
  hasModelPlugin: api.isPluginEnable('model'),
97
96
  // dynamicRoot:
@@ -35,15 +35,14 @@ exports.default = (api) => {
35
35
  },
36
36
  });
37
37
  api.modifyDefaultConfig((memo) => {
38
- var _a, _b, _c;
38
+ var _a, _b, _c, _d;
39
39
  const initialSlaveOptions = Object.assign(Object.assign({ devSourceMap: true }, JSON.parse(process.env.INITIAL_QIANKUN_SLAVE_OPTIONS || '{}')), (memo.qiankun || {}).slave);
40
40
  const modifiedDefaultConfig = Object.assign(Object.assign({}, memo), {
41
41
  // 默认开启 runtimePublicPath,避免出现 dynamic import 场景子应用资源地址出问题
42
- runtimePublicPath: true,
43
- // TODO: runtimeHistory
44
- runtimeHistory: {}, qiankun: Object.assign(Object.assign({}, memo.qiankun), { slave: initialSlaveOptions }) });
42
+ runtimePublicPath: true, qiankun: Object.assign(Object.assign({}, memo.qiankun), { slave: initialSlaveOptions }) });
45
43
  const shouldNotModifyDefaultBase = (_c = (_b = (_a = api.userConfig.qiankun) === null || _a === void 0 ? void 0 : _a.slave) === null || _b === void 0 ? void 0 : _b.shouldNotModifyDefaultBase) !== null && _c !== void 0 ? _c : initialSlaveOptions.shouldNotModifyDefaultBase;
46
- if (!shouldNotModifyDefaultBase) {
44
+ const historyType = ((_d = api.userConfig.history) === null || _d === void 0 ? void 0 : _d.type) || 'browser';
45
+ if (!shouldNotModifyDefaultBase && historyType !== 'hash') {
47
46
  // @ts-ignore
48
47
  modifiedDefaultConfig.base = `/${api.pkg.name}`;
49
48
  }
@@ -58,17 +57,15 @@ exports.default = (api) => {
58
57
  }
59
58
  return config;
60
59
  });
61
- // api.modifyPublicPathStr((publicPathStr) => {
62
- // const { runtimePublicPath } = api.config;
63
- // const { shouldNotModifyRuntimePublicPath } = (api.config.qiankun || {})
64
- // .slave!;
65
- // if (runtimePublicPath === true && !shouldNotModifyRuntimePublicPath) {
66
- // return `window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__ || "${
67
- // api.config.publicPath || '/'
68
- // }"`;
69
- // }
70
- // return publicPathStr;
71
- // });
60
+ api.addHTMLHeadScripts(() => {
61
+ var _a;
62
+ const dontModify = (_a = api.config.qiankun) === null || _a === void 0 ? void 0 : _a.shouldNotModifyRuntimePublicPath;
63
+ return dontModify
64
+ ? []
65
+ : [
66
+ `window.publicPath = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__ || "${api.config.publicPath || '/'}";`,
67
+ ];
68
+ });
72
69
  api.chainWebpack((config) => {
73
70
  (0, assert_1.default)(api.pkg.name, 'You should have name in package.json.');
74
71
  const { shouldNotAddLibraryChunkName } = (api.config.qiankun || {}).slave;
@@ -1,8 +1,5 @@
1
1
  import React from 'react';
2
2
  import { MicroApp } from './MicroApp';
3
- {{#runtimeHistory}}
4
- import { getCreateHistoryOptions } from 'umi';
5
- {{/runtimeHistory}}
6
3
  import { useLocation } from 'umi';
7
4
 
8
5
  export function getMicroAppRouteComponent(opts: {
@@ -18,12 +15,6 @@ export function getMicroAppRouteComponent(opts: {
18
15
  // 默认取静态配置的 base
19
16
  let umiConfigBase = base === '/' ? '' : base;
20
17
 
21
- {{#runtimeHistory}}
22
- // 存在 getCreateHistoryOptions 说明当前应用开启了 runtimeHistory,此时取运行时的 history 配置的 basename
23
- const { basename = '/' } = getCreateHistoryOptions();
24
- umiConfigBase = basename === '/' ? '' : basename;
25
- {{/runtimeHistory}}
26
-
27
18
  let runtimeMatchedBase =
28
19
  umiConfigBase + (url.endsWith('/') ? url.substr(0, url.length - 1) : url);
29
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/plugins",
3
- "version": "4.0.0-canary.20220323.1",
3
+ "version": "4.0.0-rc.10",
4
4
  "description": "@umijs/plugins",
5
5
  "homepage": "https://github.com/umijs/umi-next/tree/master/packages/plugins#readme",
6
6
  "bugs": "https://github.com/umijs/umi-next/issues",
@@ -25,7 +25,7 @@
25
25
  "@ahooksjs/use-request": "^2.0.0",
26
26
  "@ant-design/icons": "^4.7.0",
27
27
  "@ant-design/pro-layout": "^6.34.6",
28
- "@umijs/bundler-utils": "4.0.0-canary.20220323.1",
28
+ "@umijs/bundler-utils": "4.0.0-rc.10",
29
29
  "antd-dayjs-webpack-plugin": "^1.0.6",
30
30
  "axios": "^0.26.1",
31
31
  "babel-plugin-import": "^1.13.3",
@@ -44,7 +44,7 @@
44
44
  "warning": "^4.0.3"
45
45
  },
46
46
  "devDependencies": {
47
- "umi": "4.0.0-canary.20220323.1"
47
+ "umi": "4.0.0-rc.10"
48
48
  },
49
49
  "publishConfig": {
50
50
  "access": "public"