@umijs/plugins 4.0.5 → 4.0.8
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/dist/access.js +70 -54
- package/dist/analytics.js +62 -41
- package/dist/antd.js +139 -123
- package/dist/dva.js +133 -142
- package/dist/icons.js +28 -4
- package/dist/initial-state.js +71 -54
- package/dist/layout.js +199 -207
- package/dist/locale.js +214 -192
- package/dist/model.js +79 -78
- package/dist/moment2dayjs.js +102 -81
- package/dist/qiankun/constants.js +41 -8
- package/dist/qiankun/master.js +147 -121
- package/dist/qiankun/slave.js +160 -150
- package/dist/qiankun.js +46 -19
- package/dist/request.js +84 -53
- package/dist/tailwindcss.js +70 -49
- package/dist/unocss.js +56 -36
- package/dist/utils/astUtils.js +38 -34
- package/dist/utils/localeUtils.js +125 -120
- package/dist/utils/modelUtils.js +216 -237
- package/dist/utils/resolveProjectDep.js +36 -13
- package/dist/utils/withTmpPath.js +31 -9
- package/libs/locale/SelectLang.tpl +1 -1
- package/libs/qiankun/master/MicroApp.tsx +9 -10
- package/libs/qiankun/slave/lifecycles.ts +6 -0
- package/package.json +5 -5
package/dist/moment2dayjs.js
CHANGED
|
@@ -1,73 +1,92 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// moment2dayjs.ts
|
|
23
|
+
var moment2dayjs_exports = {};
|
|
24
|
+
__export(moment2dayjs_exports, {
|
|
25
|
+
default: () => moment2dayjs_default
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(moment2dayjs_exports);
|
|
28
|
+
var import_path = require("path");
|
|
29
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
30
|
+
var moment2dayjs_default = (api) => {
|
|
31
|
+
api.describe({
|
|
32
|
+
key: "moment2dayjs",
|
|
33
|
+
config: {
|
|
34
|
+
schema(joi) {
|
|
35
|
+
return joi.object({
|
|
36
|
+
preset: joi.string(),
|
|
37
|
+
plugins: joi.array()
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
enableBy: api.EnableBy.config
|
|
42
|
+
});
|
|
43
|
+
const presets = {
|
|
44
|
+
antd: [
|
|
45
|
+
"isSameOrBefore",
|
|
46
|
+
"isSameOrAfter",
|
|
47
|
+
"advancedFormat",
|
|
48
|
+
"customParseFormat",
|
|
49
|
+
"weekday",
|
|
50
|
+
"weekYear",
|
|
51
|
+
"weekOfYear",
|
|
52
|
+
"isMoment",
|
|
53
|
+
"localeData",
|
|
54
|
+
"localizedFormat"
|
|
55
|
+
],
|
|
56
|
+
antdv3: [
|
|
57
|
+
"isSameOrBefore",
|
|
58
|
+
"isSameOrAfter",
|
|
59
|
+
"advancedFormat",
|
|
60
|
+
"customParseFormat",
|
|
61
|
+
"weekday",
|
|
62
|
+
"weekYear",
|
|
63
|
+
"weekOfYear",
|
|
64
|
+
"isMoment",
|
|
65
|
+
"localeData",
|
|
66
|
+
"localizedFormat",
|
|
67
|
+
"badMutable"
|
|
68
|
+
]
|
|
69
|
+
};
|
|
70
|
+
const getDayjsPlugins = (api2) => {
|
|
71
|
+
let { preset = "antd", plugins = [] } = api2.config.moment2dayjs || {};
|
|
72
|
+
switch (preset) {
|
|
73
|
+
case "antd":
|
|
74
|
+
return Array.from(new Set(presets["antd"].concat(plugins)));
|
|
75
|
+
case "antdv3":
|
|
76
|
+
return Array.from(new Set(presets["antdv3"].concat(plugins)));
|
|
77
|
+
case "none":
|
|
78
|
+
return [].concat(plugins);
|
|
79
|
+
default:
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
api.modifyConfig((memo) => {
|
|
84
|
+
memo.alias.moment = (0, import_path.dirname)(require.resolve("dayjs/package.json"));
|
|
85
|
+
return memo;
|
|
86
|
+
});
|
|
87
|
+
api.onGenerateFiles(() => {
|
|
88
|
+
const plugins = getDayjsPlugins(api);
|
|
89
|
+
const runtimeTpl = `
|
|
71
90
|
import dayjs from '{{{dayjsPath}}}';
|
|
72
91
|
import antdPlugin from '{{{dayjsAntdPluginPath}}}';
|
|
73
92
|
|
|
@@ -81,16 +100,18 @@ dayjs.extend({{.}});
|
|
|
81
100
|
|
|
82
101
|
dayjs.extend(antdPlugin);
|
|
83
102
|
`;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
});
|
|
103
|
+
const dayjsAntdPluginPath = (0, import_plugin_utils.winPath)(require.resolve("antd-dayjs-webpack-plugin/src/antd-plugin"));
|
|
104
|
+
const dayjsPath = (0, import_plugin_utils.winPath)((0, import_path.dirname)(require.resolve("dayjs/package.json")));
|
|
105
|
+
api.writeTmpFile({
|
|
106
|
+
path: "runtime.tsx",
|
|
107
|
+
content: import_plugin_utils.Mustache.render(runtimeTpl, {
|
|
108
|
+
plugins,
|
|
109
|
+
dayjsPath,
|
|
110
|
+
dayjsAntdPluginPath
|
|
111
|
+
})
|
|
94
112
|
});
|
|
95
|
-
|
|
113
|
+
});
|
|
114
|
+
api.addEntryCodeAhead(() => [`import './plugin-moment2dayjs/runtime.tsx'`]);
|
|
96
115
|
};
|
|
116
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
117
|
+
0 && (module.exports = {});
|
|
@@ -1,8 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// constants.ts
|
|
20
|
+
var constants_exports = {};
|
|
21
|
+
__export(constants_exports, {
|
|
22
|
+
MODEL_EXPORT_NAME: () => MODEL_EXPORT_NAME,
|
|
23
|
+
defaultHistoryType: () => defaultHistoryType,
|
|
24
|
+
defaultMasterRootId: () => defaultMasterRootId,
|
|
25
|
+
qiankunStateForSlaveModelNamespace: () => qiankunStateForSlaveModelNamespace,
|
|
26
|
+
qiankunStateFromMasterModelNamespace: () => qiankunStateFromMasterModelNamespace
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(constants_exports);
|
|
29
|
+
var defaultMasterRootId = "root-master";
|
|
30
|
+
var defaultHistoryType = "browser";
|
|
31
|
+
var qiankunStateForSlaveModelNamespace = "@@qiankunStateForSlave";
|
|
32
|
+
var qiankunStateFromMasterModelNamespace = "@@qiankunStateFromMaster";
|
|
33
|
+
var MODEL_EXPORT_NAME = "useQiankunStateForSlave";
|
|
34
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
35
|
+
0 && (module.exports = {
|
|
36
|
+
MODEL_EXPORT_NAME,
|
|
37
|
+
defaultHistoryType,
|
|
38
|
+
defaultMasterRootId,
|
|
39
|
+
qiankunStateForSlaveModelNamespace,
|
|
40
|
+
qiankunStateFromMasterModelNamespace
|
|
41
|
+
});
|
package/dist/qiankun/master.js
CHANGED
|
@@ -1,137 +1,163 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
20
|
}
|
|
15
|
-
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
37
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
38
|
+
|
|
39
|
+
// master.ts
|
|
40
|
+
var master_exports = {};
|
|
41
|
+
__export(master_exports, {
|
|
42
|
+
default: () => master_default,
|
|
43
|
+
isMasterEnable: () => isMasterEnable
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(master_exports);
|
|
46
|
+
var import_fs = require("fs");
|
|
47
|
+
var import_path = require("path");
|
|
48
|
+
var import_plugin_utils = require("umi/plugin-utils");
|
|
49
|
+
var import_withTmpPath = require("../utils/withTmpPath");
|
|
50
|
+
var import_constants = require("./constants");
|
|
51
|
+
function isMasterEnable(opts) {
|
|
52
|
+
var _a;
|
|
53
|
+
const masterCfg = (_a = opts.userConfig.qiankun) == null ? void 0 : _a.master;
|
|
54
|
+
if (masterCfg) {
|
|
55
|
+
return masterCfg.enable !== false;
|
|
56
|
+
}
|
|
57
|
+
return !!process.env.INITIAL_QIANKUN_MASTER_OPTIONS;
|
|
16
58
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const appName = route.microApp;
|
|
43
|
-
const base = api.config.base || '/';
|
|
44
|
-
const masterHistoryType = ((_a = api.config.history) === null || _a === void 0 ? void 0 : _a.type) || 'browser';
|
|
45
|
-
const routeProps = route.microAppProps || {};
|
|
46
|
-
const normalizedRouteProps = JSON.stringify(routeProps).replace(/"/g, "'");
|
|
47
|
-
route.file = `(async () => {
|
|
59
|
+
var master_default = (api) => {
|
|
60
|
+
api.describe({
|
|
61
|
+
key: "qiankun-master",
|
|
62
|
+
enableBy: isMasterEnable
|
|
63
|
+
});
|
|
64
|
+
api.addRuntimePlugin(() => {
|
|
65
|
+
return [(0, import_withTmpPath.withTmpPath)({ api, path: "masterRuntimePlugin.tsx" })];
|
|
66
|
+
});
|
|
67
|
+
api.modifyDefaultConfig((config) => __spreadProps(__spreadValues({}, config), {
|
|
68
|
+
mountElementId: import_constants.defaultMasterRootId,
|
|
69
|
+
qiankun: __spreadProps(__spreadValues({}, config.qiankun), {
|
|
70
|
+
master: __spreadValues(__spreadValues({}, JSON.parse(process.env.INITIAL_QIANKUN_MASTER_OPTIONS || "{}")), (config.qiankun || {}).master)
|
|
71
|
+
})
|
|
72
|
+
}));
|
|
73
|
+
api.modifyRoutes((memo) => {
|
|
74
|
+
Object.keys(memo).forEach((id) => {
|
|
75
|
+
var _a;
|
|
76
|
+
const route = memo[id];
|
|
77
|
+
if (route.microApp) {
|
|
78
|
+
const appName = route.microApp;
|
|
79
|
+
const base = api.config.base || "/";
|
|
80
|
+
const masterHistoryType = ((_a = api.config.history) == null ? void 0 : _a.type) || "browser";
|
|
81
|
+
const routeProps = route.microAppProps || {};
|
|
82
|
+
const normalizedRouteProps = JSON.stringify(routeProps).replace(/"/g, "'");
|
|
83
|
+
route.file = `(async () => {
|
|
48
84
|
const { getMicroAppRouteComponent } = await import('@@/plugin-qiankun-master/getMicroAppRouteComponent');
|
|
49
85
|
return getMicroAppRouteComponent({ appName: '${appName}', base: '${base}', routePath: '${route.path}', masterHistoryType: '${masterHistoryType}', routeProps: ${normalizedRouteProps} })
|
|
50
86
|
})()`;
|
|
51
|
-
|
|
52
|
-
});
|
|
53
|
-
return memo;
|
|
54
|
-
});
|
|
55
|
-
// state model for slave app
|
|
56
|
-
api.addRuntimePluginKey(() => [constants_1.MODEL_EXPORT_NAME]);
|
|
57
|
-
api.register({
|
|
58
|
-
key: 'addExtraModels',
|
|
59
|
-
fn() {
|
|
60
|
-
const { path, exports } = api.appData.appJS || {};
|
|
61
|
-
return path && exports.includes(constants_1.MODEL_EXPORT_NAME)
|
|
62
|
-
? [
|
|
63
|
-
`${path}#{"namespace":"${constants_1.qiankunStateForSlaveModelNamespace}","exportName":"${constants_1.MODEL_EXPORT_NAME}"}`,
|
|
64
|
-
]
|
|
65
|
-
: [];
|
|
66
|
-
},
|
|
87
|
+
}
|
|
67
88
|
});
|
|
68
|
-
|
|
69
|
-
|
|
89
|
+
return memo;
|
|
90
|
+
});
|
|
91
|
+
api.addRuntimePluginKey(() => [import_constants.MODEL_EXPORT_NAME]);
|
|
92
|
+
api.register({
|
|
93
|
+
key: "addExtraModels",
|
|
94
|
+
fn() {
|
|
95
|
+
const { path, exports } = api.appData.appJS || {};
|
|
96
|
+
return path && exports.includes(import_constants.MODEL_EXPORT_NAME) ? [
|
|
97
|
+
`${path}#{"namespace":"${import_constants.qiankunStateForSlaveModelNamespace}","exportName":"${import_constants.MODEL_EXPORT_NAME}"}`
|
|
98
|
+
] : [];
|
|
70
99
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
100
|
+
});
|
|
101
|
+
function getFileContent(file) {
|
|
102
|
+
return (0, import_fs.readFileSync)((0, import_path.join)(__dirname, "../../libs/qiankun/master", file), "utf-8");
|
|
103
|
+
}
|
|
104
|
+
api.onGenerateFiles(() => {
|
|
105
|
+
var _a;
|
|
106
|
+
api.writeTmpFile({
|
|
107
|
+
path: "masterOptions.ts",
|
|
108
|
+
content: `
|
|
109
|
+
let options = ${JSON.stringify(__spreadValues({
|
|
110
|
+
masterHistoryType: ((_a = api.config.history) == null ? void 0 : _a.type) || import_constants.defaultHistoryType,
|
|
111
|
+
base: api.config.base || "/"
|
|
112
|
+
}, api.config.qiankun.master))};
|
|
81
113
|
export const getMasterOptions = () => options;
|
|
82
114
|
export const setMasterOptions = (newOpts) => options = ({ ...options, ...newOpts });
|
|
83
|
-
|
|
84
|
-
|
|
115
|
+
`
|
|
116
|
+
});
|
|
117
|
+
api.writeTmpFile({
|
|
118
|
+
path: "MicroAppLoader.tsx",
|
|
119
|
+
content: api.isPluginEnable("antd") ? getFileContent("AntdLoader.tsx") : `export default function Loader() { console.warn(\`[plugins/qiankun]: Seems like you'r not using @umijs/plugin-antd, you need to provide a custom loader or set autoSetLoading false to shut down this warning!\`); return null; }`
|
|
120
|
+
});
|
|
121
|
+
[
|
|
122
|
+
"common.ts",
|
|
123
|
+
"constants.ts",
|
|
124
|
+
"types.ts",
|
|
125
|
+
"masterRuntimePlugin.tsx",
|
|
126
|
+
"getMicroAppRouteComponent.tsx.tpl",
|
|
127
|
+
"ErrorBoundary.tsx",
|
|
128
|
+
"MicroApp.tsx",
|
|
129
|
+
"MicroAppWithMemoHistory.tsx"
|
|
130
|
+
].forEach((file) => {
|
|
131
|
+
if (file.endsWith(".tpl")) {
|
|
85
132
|
api.writeTmpFile({
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
[
|
|
93
|
-
'common.ts',
|
|
94
|
-
'constants.ts',
|
|
95
|
-
'types.ts',
|
|
96
|
-
'masterRuntimePlugin.tsx',
|
|
97
|
-
'getMicroAppRouteComponent.tsx.tpl',
|
|
98
|
-
'ErrorBoundary.tsx',
|
|
99
|
-
'MicroApp.tsx',
|
|
100
|
-
'MicroAppWithMemoHistory.tsx',
|
|
101
|
-
].forEach((file) => {
|
|
102
|
-
if (file.endsWith('.tpl')) {
|
|
103
|
-
api.writeTmpFile({
|
|
104
|
-
path: file.replace(/\.tpl$/, ''),
|
|
105
|
-
tpl: getFileContent(file),
|
|
106
|
-
context: {
|
|
107
|
-
dynamicRoot: false,
|
|
108
|
-
hasModelPlugin: api.isPluginEnable('model'),
|
|
109
|
-
// dynamicRoot:
|
|
110
|
-
// api.config.exportStatic && api.config.exportStatic.dynamicRoot,
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
let content = getFileContent(file);
|
|
116
|
-
if (!api.config.qiankun.externalQiankun) {
|
|
117
|
-
content = content.replace(/from 'qiankun'/g, `from '${(0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('qiankun/package')))}'`);
|
|
118
|
-
}
|
|
119
|
-
api.writeTmpFile({
|
|
120
|
-
path: file.replace(/\.tpl$/, ''),
|
|
121
|
-
content: content
|
|
122
|
-
.replace('__USE_MODEL__', api.isPluginEnable('model')
|
|
123
|
-
? `import { useModel } from '@@/plugin-model'`
|
|
124
|
-
: `const useModel = null;`)
|
|
125
|
-
.replace(/from 'lodash\//g, `from '${(0, plugin_utils_1.winPath)((0, path_1.dirname)(require.resolve('lodash/package')))}/`),
|
|
126
|
-
});
|
|
127
|
-
}
|
|
133
|
+
path: file.replace(/\.tpl$/, ""),
|
|
134
|
+
tpl: getFileContent(file),
|
|
135
|
+
context: {
|
|
136
|
+
dynamicRoot: false,
|
|
137
|
+
hasModelPlugin: api.isPluginEnable("model")
|
|
138
|
+
}
|
|
128
139
|
});
|
|
140
|
+
} else {
|
|
141
|
+
let content = getFileContent(file);
|
|
142
|
+
if (!api.config.qiankun.externalQiankun) {
|
|
143
|
+
content = content.replace(/from 'qiankun'/g, `from '${(0, import_plugin_utils.winPath)((0, import_path.dirname)(require.resolve("qiankun/package")))}'`);
|
|
144
|
+
}
|
|
129
145
|
api.writeTmpFile({
|
|
130
|
-
|
|
131
|
-
|
|
146
|
+
path: file.replace(/\.tpl$/, ""),
|
|
147
|
+
content: content.replace("__USE_MODEL__", api.isPluginEnable("model") ? `import { useModel } from '@@/plugin-model'` : `const useModel = null;`).replace(/from 'lodash\//g, `from '${(0, import_plugin_utils.winPath)((0, import_path.dirname)(require.resolve("lodash/package")))}/`)
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
api.writeTmpFile({
|
|
152
|
+
path: "index.ts",
|
|
153
|
+
content: `
|
|
132
154
|
export { MicroApp } from './MicroApp';
|
|
133
155
|
export { MicroAppWithMemoHistory } from './MicroAppWithMemoHistory';
|
|
134
|
-
|
|
135
|
-
});
|
|
156
|
+
`
|
|
136
157
|
});
|
|
158
|
+
});
|
|
137
159
|
};
|
|
160
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
161
|
+
0 && (module.exports = {
|
|
162
|
+
isMasterEnable
|
|
163
|
+
});
|