@umijs/preset-umi 4.0.46 → 4.0.48
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/commands/dev/depBuildWorker/depBuildWorker.js +1 -0
- package/dist/commands/generators/tailwindcss.js +6 -5
- package/dist/features/appData/appData.js +11 -5
- package/dist/features/exportStatic/exportStatic.js +15 -10
- package/dist/features/icons/{esbuildPlugins/esbuildCollectIconPlugin.d.ts → esbuildIconPlugin.d.ts} +1 -1
- package/dist/features/icons/{esbuildPlugins/esbuildCollectIconPlugin.js → esbuildIconPlugin.js} +12 -9
- package/dist/features/icons/icons.js +55 -63
- package/dist/features/mpa/extractExports.js +2 -1
- package/dist/features/mpa/mpa.js +3 -4
- package/dist/features/phantomDependency/phantomDependency.js +61 -21
- package/dist/features/polyfill/polyfill.js +6 -2
- package/dist/features/prepare/build.d.ts +15 -0
- package/dist/features/{icons → prepare}/build.js +9 -14
- package/dist/features/{icons → prepare}/esbuildPlugins/esbuildAliasPlugin.d.ts +0 -0
- package/dist/features/{icons → prepare}/esbuildPlugins/esbuildAliasPlugin.js +13 -12
- package/dist/features/{icons → prepare}/esbuildPlugins/esbuildExternalPlugin.d.ts +0 -0
- package/dist/features/{icons → prepare}/esbuildPlugins/esbuildExternalPlugin.js +16 -2
- package/dist/features/prepare/prepare.d.ts +3 -0
- package/dist/features/prepare/prepare.js +86 -0
- package/dist/index.js +1 -0
- package/dist/registerMethods.js +6 -2
- package/dist/types.d.ts +7 -1
- package/package.json +12 -12
- package/dist/features/icons/build.d.ts +0 -13
|
@@ -49,17 +49,18 @@ var tailwindcss_default = (api) => {
|
|
|
49
49
|
h.setUmirc("tailwindcss", {});
|
|
50
50
|
h.appendInternalPlugin("@umijs/plugins/dist/tailwindcss");
|
|
51
51
|
import_utils.logger.info("Update .umirc.ts");
|
|
52
|
+
const srcPrefix = api.appData.hasSrcDir ? "src/" : "";
|
|
52
53
|
(0, import_fs.writeFileSync)(
|
|
53
54
|
(0, import_path.join)(api.cwd, "tailwind.config.js"),
|
|
54
55
|
`
|
|
55
56
|
module.exports = {
|
|
56
57
|
content: [
|
|
57
|
-
'
|
|
58
|
-
'
|
|
59
|
-
'
|
|
58
|
+
'./${srcPrefix}pages/**/*.tsx',
|
|
59
|
+
'./${srcPrefix}components/**.tsx',
|
|
60
|
+
'./${srcPrefix}layouts/**.tsx',
|
|
60
61
|
],
|
|
61
62
|
}
|
|
62
|
-
`.
|
|
63
|
+
`.trimStart()
|
|
63
64
|
);
|
|
64
65
|
import_utils.logger.info("Write tailwind.config.js");
|
|
65
66
|
(0, import_fs.writeFileSync)(
|
|
@@ -68,7 +69,7 @@ module.exports = {
|
|
|
68
69
|
@tailwind base;
|
|
69
70
|
@tailwind components;
|
|
70
71
|
@tailwind utilities;
|
|
71
|
-
`.
|
|
72
|
+
`.trimStart()
|
|
72
73
|
);
|
|
73
74
|
import_utils.logger.info("Write tailwind.css");
|
|
74
75
|
h.installDeps();
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
17
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
24
|
|
|
19
25
|
// src/features/appData/appData.ts
|
|
@@ -22,14 +28,12 @@ __export(appData_exports, {
|
|
|
22
28
|
default: () => appData_default
|
|
23
29
|
});
|
|
24
30
|
module.exports = __toCommonJS(appData_exports);
|
|
25
|
-
var import_bundler_utils = require("@umijs/bundler-utils");
|
|
26
31
|
var import_utils = require("@umijs/utils");
|
|
27
32
|
var import_fs = require("fs");
|
|
28
33
|
var import_path = require("path");
|
|
29
34
|
var import_ini = require("../../../compiled/ini");
|
|
30
35
|
var import_os_locale = require("../../../compiled/os-locale");
|
|
31
36
|
var import_watch = require("../../commands/dev/watch");
|
|
32
|
-
var import_scan = require("../../libs/scan");
|
|
33
37
|
var import_overrides = require("../overrides/overrides");
|
|
34
38
|
var import_routes = require("../tmpFiles/routes");
|
|
35
39
|
var appData_default = (api) => {
|
|
@@ -112,10 +116,11 @@ var appData_default = (api) => {
|
|
|
112
116
|
api.register({
|
|
113
117
|
key: "updateAppDataDeps",
|
|
114
118
|
async fn() {
|
|
115
|
-
const
|
|
119
|
+
const { createResolver, scan } = await import("../../libs/scan.js");
|
|
120
|
+
const resolver = createResolver({
|
|
116
121
|
alias: api.config.alias
|
|
117
122
|
});
|
|
118
|
-
api.appData.deps = await
|
|
123
|
+
api.appData.deps = await scan({
|
|
119
124
|
entry: (0, import_path.join)(api.paths.absTmpPath, "umi.ts"),
|
|
120
125
|
externals: api.config.externals,
|
|
121
126
|
resolver
|
|
@@ -133,7 +138,8 @@ var appData_default = (api) => {
|
|
|
133
138
|
async function getAppJsInfo() {
|
|
134
139
|
for (const path of (0, import_watch.expandJSPaths)((0, import_path.join)(api.paths.absSrcPath, "app"))) {
|
|
135
140
|
if ((0, import_fs.existsSync)(path)) {
|
|
136
|
-
const
|
|
141
|
+
const { parseModule } = (0, import_utils.importLazy)(require.resolve("@umijs/bundler-utils"));
|
|
142
|
+
const [_, exports] = await parseModule({
|
|
137
143
|
path,
|
|
138
144
|
content: (0, import_fs.readFileSync)(path, "utf-8")
|
|
139
145
|
});
|
|
@@ -28,10 +28,10 @@ __export(exportStatic_exports, {
|
|
|
28
28
|
default: () => exportStatic_default
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(exportStatic_exports);
|
|
31
|
-
var import_path = require("path");
|
|
32
31
|
var import_server = require("@umijs/server");
|
|
33
32
|
var import_utils = require("@umijs/utils");
|
|
34
33
|
var import_assert = __toESM(require("assert"));
|
|
34
|
+
var import_path = require("path");
|
|
35
35
|
var import_utils2 = require("../ssr/utils");
|
|
36
36
|
var markupRender;
|
|
37
37
|
var IS_WIN = process.platform === "win32";
|
|
@@ -46,6 +46,7 @@ function getExportHtmlData(routes) {
|
|
|
46
46
|
path: is404 ? "/404" : route.absPath,
|
|
47
47
|
redirect: route.redirect
|
|
48
48
|
},
|
|
49
|
+
prerender: route.prerender !== false,
|
|
49
50
|
file
|
|
50
51
|
});
|
|
51
52
|
}
|
|
@@ -75,13 +76,17 @@ async function getPreRenderedHTML(api, htmlTpl, path) {
|
|
|
75
76
|
var exportStatic_default = (api) => {
|
|
76
77
|
async function getRoutesFromUserExtraPaths(routePaths) {
|
|
77
78
|
const paths = typeof routePaths === "function" ? await routePaths() : routePaths;
|
|
78
|
-
return paths.reduce(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
return paths.reduce((acc, item) => {
|
|
80
|
+
const routePath = typeof item === "string" ? item : item.path;
|
|
81
|
+
acc[routePath] = {
|
|
82
|
+
id: routePath,
|
|
83
|
+
absPath: routePath,
|
|
84
|
+
path: routePath.slice(1),
|
|
85
|
+
file: "",
|
|
86
|
+
...typeof item === "object" && item.prerender === false ? { prerender: false } : {}
|
|
87
|
+
};
|
|
88
|
+
return acc;
|
|
89
|
+
}, {});
|
|
85
90
|
}
|
|
86
91
|
api.describe({
|
|
87
92
|
config: {
|
|
@@ -109,7 +114,7 @@ var exportStatic_default = (api) => {
|
|
|
109
114
|
extraHtmlData
|
|
110
115
|
);
|
|
111
116
|
const htmlFiles = [];
|
|
112
|
-
for (const { file, route } of htmlData) {
|
|
117
|
+
for (const { file, route, prerender } of htmlData) {
|
|
113
118
|
let { markupArgs } = opts;
|
|
114
119
|
if (publicPath.startsWith(".")) {
|
|
115
120
|
(0, import_assert.default)(
|
|
@@ -156,7 +161,7 @@ var exportStatic_default = (api) => {
|
|
|
156
161
|
const htmlContent = await (0, import_server.getMarkup)(markupArgs);
|
|
157
162
|
htmlFiles.push({
|
|
158
163
|
path: file,
|
|
159
|
-
content: api.config.ssr ? await getPreRenderedHTML(api, htmlContent, route.path) : htmlContent
|
|
164
|
+
content: api.config.ssr && prerender ? await getPreRenderedHTML(api, htmlContent, route.path) : htmlContent
|
|
160
165
|
});
|
|
161
166
|
}
|
|
162
167
|
return htmlFiles;
|
package/dist/features/icons/{esbuildPlugins/esbuildCollectIconPlugin.js → esbuildIconPlugin.js}
RENAMED
|
@@ -22,15 +22,16 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
));
|
|
23
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
24
|
|
|
25
|
-
// src/features/icons/
|
|
26
|
-
var
|
|
27
|
-
__export(
|
|
28
|
-
|
|
25
|
+
// src/features/icons/esbuildIconPlugin.ts
|
|
26
|
+
var esbuildIconPlugin_exports = {};
|
|
27
|
+
__export(esbuildIconPlugin_exports, {
|
|
28
|
+
esbuildIconPlugin: () => esbuildIconPlugin
|
|
29
29
|
});
|
|
30
|
-
module.exports = __toCommonJS(
|
|
30
|
+
module.exports = __toCommonJS(esbuildIconPlugin_exports);
|
|
31
|
+
var import_utils = require("@umijs/utils");
|
|
31
32
|
var import_fs = __toESM(require("fs"));
|
|
32
|
-
var import_extract = require("
|
|
33
|
-
function
|
|
33
|
+
var import_extract = require("./extract");
|
|
34
|
+
function esbuildIconPlugin(opts) {
|
|
34
35
|
return {
|
|
35
36
|
name: "esbuildCollectIconPlugin",
|
|
36
37
|
setup(build) {
|
|
@@ -39,7 +40,9 @@ function esbuildCollectIconPlugin(opts) {
|
|
|
39
40
|
const filter = new RegExp(`\\.(${loader})$`);
|
|
40
41
|
build.onLoad({ filter }, (args) => {
|
|
41
42
|
const contents = import_fs.default.readFileSync(args.path, "utf-8");
|
|
42
|
-
(0, import_extract.extractIcons)(contents)
|
|
43
|
+
const icons = (0, import_extract.extractIcons)(contents);
|
|
44
|
+
import_utils.logger.debug(`[icons] ${args.path} > ${icons}`);
|
|
45
|
+
icons.forEach((icon) => {
|
|
43
46
|
opts.icons.add(opts.alias[icon] || icon);
|
|
44
47
|
});
|
|
45
48
|
return {
|
|
@@ -53,5 +56,5 @@ function esbuildCollectIconPlugin(opts) {
|
|
|
53
56
|
}
|
|
54
57
|
// Annotate the CommonJS export names for ESM import in node:
|
|
55
58
|
0 && (module.exports = {
|
|
56
|
-
|
|
59
|
+
esbuildIconPlugin
|
|
57
60
|
});
|
|
@@ -28,10 +28,8 @@ __export(icons_exports, {
|
|
|
28
28
|
default: () => icons_default
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(icons_exports);
|
|
31
|
-
var import_path = __toESM(require("path"));
|
|
32
|
-
var import_build = require("./build");
|
|
33
31
|
var import_utils = require("@umijs/utils");
|
|
34
|
-
var
|
|
32
|
+
var import_path = __toESM(require("path"));
|
|
35
33
|
var icons_default = (api) => {
|
|
36
34
|
api.describe({
|
|
37
35
|
config: {
|
|
@@ -52,66 +50,58 @@ var icons_default = (api) => {
|
|
|
52
50
|
);
|
|
53
51
|
}
|
|
54
52
|
});
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
53
|
+
const EMPTY_ICONS_FILE = `export const __no_icons = true;`;
|
|
54
|
+
const icons = /* @__PURE__ */ new Set();
|
|
55
|
+
api.addPrepareBuildPlugins(() => {
|
|
56
|
+
const { esbuildIconPlugin } = (0, import_utils.importLazy)(require.resolve("./esbuildIconPlugin"));
|
|
57
|
+
return [
|
|
58
|
+
esbuildIconPlugin({
|
|
59
|
+
icons,
|
|
60
|
+
alias: api.config.icons.alias || {}
|
|
61
|
+
})
|
|
62
|
+
];
|
|
63
|
+
});
|
|
64
|
+
api.onPrepareBuildSuccess(async () => {
|
|
65
|
+
if (!icons.size) {
|
|
66
|
+
import_utils.logger.info(`[icons] no icons was found`);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
import_utils.logger.info(`[icons] generate icons ${Array.from(icons).join(", ")}`);
|
|
70
|
+
const code = [];
|
|
71
|
+
const { generateIconName, generateSvgr } = await import("./svgr.js");
|
|
72
|
+
for (const iconStr of icons) {
|
|
73
|
+
const [collect, icon] = iconStr.split(":");
|
|
74
|
+
const iconName = generateIconName({ collect, icon });
|
|
75
|
+
const svgr = await generateSvgr({
|
|
76
|
+
collect,
|
|
77
|
+
icon,
|
|
78
|
+
iconifyOptions: { autoInstall: api.config.icons.autoInstall },
|
|
79
|
+
localIconDir: import_path.default.join(api.paths.absSrcPath, "icons")
|
|
78
80
|
});
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
iconifyOptions: { autoInstall: api.config.icons.autoInstall },
|
|
89
|
-
localIconDir: import_path.default.join(api.paths.absSrcPath, "icons")
|
|
90
|
-
});
|
|
91
|
-
if (svgr) {
|
|
92
|
-
code.push(svgr);
|
|
93
|
-
code.push(`export { ${iconName} };`);
|
|
94
|
-
} else {
|
|
95
|
-
if (api.env === "development") {
|
|
96
|
-
iconsSet.delete(iconStr);
|
|
97
|
-
import_utils.logger.error(`[icons] Icon ${iconStr} not found`);
|
|
98
|
-
} else {
|
|
99
|
-
throw new Error(`[icons] Icon ${iconStr} not found`);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
81
|
+
if (svgr) {
|
|
82
|
+
code.push(svgr);
|
|
83
|
+
code.push(`export { ${iconName} };`);
|
|
84
|
+
} else {
|
|
85
|
+
if (api.env === "development") {
|
|
86
|
+
icons.delete(iconStr);
|
|
87
|
+
import_utils.logger.error(`[icons] Icon ${iconStr} not found`);
|
|
88
|
+
} else {
|
|
89
|
+
throw new Error(`[icons] Icon ${iconStr} not found`);
|
|
102
90
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
import_utils.logger.error(e);
|
|
110
|
-
});
|
|
111
|
-
},
|
|
112
|
-
stage: Infinity
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
api.writeTmpFile({
|
|
94
|
+
path: "icons.tsx",
|
|
95
|
+
content: code.join("\n") || EMPTY_ICONS_FILE
|
|
96
|
+
});
|
|
113
97
|
});
|
|
114
|
-
api.onGenerateFiles(() => {
|
|
98
|
+
api.onGenerateFiles(({ isFirstTime }) => {
|
|
99
|
+
if (isFirstTime) {
|
|
100
|
+
api.writeTmpFile({
|
|
101
|
+
path: "icons.tsx",
|
|
102
|
+
content: EMPTY_ICONS_FILE
|
|
103
|
+
});
|
|
104
|
+
}
|
|
115
105
|
api.writeTmpFile({
|
|
116
106
|
path: "index.tsx",
|
|
117
107
|
content: `
|
|
@@ -122,9 +112,9 @@ import './index.css';
|
|
|
122
112
|
const alias = ${JSON.stringify(api.config.icons.alias || {})};
|
|
123
113
|
type AliasKeys = keyof typeof alias;
|
|
124
114
|
|
|
125
|
-
|
|
115
|
+
interface IUmiIconProps extends React.SVGAttributes<SVGElement> {
|
|
126
116
|
icon: AliasKeys | string;
|
|
127
|
-
hover
|
|
117
|
+
hover?: AliasKeys | string;
|
|
128
118
|
className?: string;
|
|
129
119
|
viewBox?: string;
|
|
130
120
|
width?: string;
|
|
@@ -133,7 +123,9 @@ export const Icon = React.forwardRef((props: {
|
|
|
133
123
|
spin?: boolean;
|
|
134
124
|
rotate?: number | string;
|
|
135
125
|
flip?: 'vertical' | 'horizontal' | 'horizontal,vertical' | 'vertical,horizontal';
|
|
136
|
-
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export const Icon = React.forwardRef((props: IUmiIconProps, ref) => {
|
|
137
129
|
const { icon, hover, style, className, rotate, flip, ...extraProps } = props;
|
|
138
130
|
const iconName = normalizeIconName(alias[icon] || icon);
|
|
139
131
|
const Component = iconsMap[iconName];
|
|
@@ -29,6 +29,7 @@ __export(extractExports_exports, {
|
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(extractExports_exports);
|
|
31
31
|
var import_esbuild = __toESM(require("@umijs/bundler-utils/compiled/esbuild"));
|
|
32
|
+
var import_utils = require("@umijs/utils");
|
|
32
33
|
async function extractExports(opts) {
|
|
33
34
|
const res = await import_esbuild.default.build({
|
|
34
35
|
format: "cjs",
|
|
@@ -94,7 +95,7 @@ async function extractExports(opts) {
|
|
|
94
95
|
build.onLoad({ filter: /.*/, namespace: "entry" }, (args) => {
|
|
95
96
|
return {
|
|
96
97
|
contents: `
|
|
97
|
-
import * as x from "${args.path}";
|
|
98
|
+
import * as x from "${(0, import_utils.winPath)(args.path)}";
|
|
98
99
|
ret = x.${opts.exportName} || {};
|
|
99
100
|
`,
|
|
100
101
|
loader: "ts"
|
package/dist/features/mpa/mpa.js
CHANGED
|
@@ -31,9 +31,7 @@ module.exports = __toCommonJS(mpa_exports);
|
|
|
31
31
|
var import_utils = require("@umijs/utils");
|
|
32
32
|
var import_assert = __toESM(require("assert"));
|
|
33
33
|
var import_fs = require("fs");
|
|
34
|
-
var import_html_webpack_plugin = __toESM(require("html-webpack-plugin"));
|
|
35
34
|
var import_path = require("path");
|
|
36
|
-
var import_extractExports = require("./extractExports");
|
|
37
35
|
var mpa_default = (api) => {
|
|
38
36
|
api.describe({
|
|
39
37
|
key: "mpa",
|
|
@@ -112,7 +110,7 @@ ${renderer}
|
|
|
112
110
|
});
|
|
113
111
|
api.chainWebpack((memo) => {
|
|
114
112
|
api.appData.mpa.entry.forEach((entry) => {
|
|
115
|
-
memo.plugin(`html-${entry.name}`).use(
|
|
113
|
+
memo.plugin(`html-${entry.name}`).use(require("html-webpack-plugin"), [
|
|
116
114
|
{
|
|
117
115
|
filename: `${entry.name}.html`,
|
|
118
116
|
minify: false,
|
|
@@ -183,7 +181,8 @@ async function getConfig(indexFile) {
|
|
|
183
181
|
}
|
|
184
182
|
}
|
|
185
183
|
async function getConfigFromEntryFile(indexFile) {
|
|
186
|
-
const
|
|
184
|
+
const { extractExports } = await import("./extractExports.js");
|
|
185
|
+
const config = await extractExports({
|
|
187
186
|
entry: indexFile,
|
|
188
187
|
exportName: "config"
|
|
189
188
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
17
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
24
|
|
|
19
25
|
// src/features/phantomDependency/phantomDependency.ts
|
|
@@ -22,6 +28,8 @@ __export(phantomDependency_exports, {
|
|
|
22
28
|
default: () => phantomDependency_default
|
|
23
29
|
});
|
|
24
30
|
module.exports = __toCommonJS(phantomDependency_exports);
|
|
31
|
+
var import_utils = require("@umijs/utils");
|
|
32
|
+
var import_path = __toESM(require("path"));
|
|
25
33
|
var phantomDependency_default = (api) => {
|
|
26
34
|
api.describe({
|
|
27
35
|
key: "phantomDependency",
|
|
@@ -39,38 +47,70 @@ var phantomDependency_default = (api) => {
|
|
|
39
47
|
api.logger.warn("Phantom dependencies check is not needed in pnpm.");
|
|
40
48
|
}
|
|
41
49
|
});
|
|
42
|
-
api.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
api.onPrepareBuildSuccess(({ result }) => {
|
|
51
|
+
var _a, _b, _c, _d;
|
|
52
|
+
const files = Object.keys(result.metafile.inputs);
|
|
53
|
+
const importsBySource = /* @__PURE__ */ new Map();
|
|
54
|
+
for (const file of files) {
|
|
55
|
+
const winP = (0, import_utils.winPath)(file);
|
|
56
|
+
if (winP.includes(".umi/"))
|
|
57
|
+
continue;
|
|
58
|
+
if (winP.includes("/node_modules/"))
|
|
59
|
+
continue;
|
|
60
|
+
if (winP.startsWith("../"))
|
|
61
|
+
continue;
|
|
62
|
+
if (import_path.default.isAbsolute(file))
|
|
63
|
+
continue;
|
|
64
|
+
const { imports } = result.metafile.inputs[file];
|
|
65
|
+
for (const imp of imports) {
|
|
66
|
+
if (imp.kind === "import-statement" && imp.external) {
|
|
67
|
+
if (!importsBySource.has(imp.path)) {
|
|
68
|
+
importsBySource.set(imp.path, []);
|
|
69
|
+
}
|
|
70
|
+
importsBySource.get(imp.path).push({ file });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const phantomDeps = [];
|
|
75
|
+
for (const [source, files2] of importsBySource) {
|
|
76
|
+
if (source.startsWith("<"))
|
|
77
|
+
continue;
|
|
50
78
|
if (source.startsWith("."))
|
|
51
|
-
|
|
79
|
+
continue;
|
|
52
80
|
if (source.startsWith("/"))
|
|
53
|
-
|
|
81
|
+
continue;
|
|
54
82
|
if (source.startsWith("@/") || source.startsWith("@@/"))
|
|
55
|
-
|
|
83
|
+
continue;
|
|
56
84
|
const pkgName = getPkgName(source);
|
|
57
85
|
if ((_a = api.config.phantomDependency.exclude) == null ? void 0 : _a.includes(pkgName))
|
|
58
|
-
|
|
86
|
+
continue;
|
|
59
87
|
if ((_b = api.pkg.dependencies) == null ? void 0 : _b[pkgName])
|
|
60
|
-
|
|
88
|
+
continue;
|
|
61
89
|
if ((_c = api.pkg.devDependencies) == null ? void 0 : _c[pkgName])
|
|
62
|
-
|
|
90
|
+
continue;
|
|
63
91
|
if ((_d = api.pkg.clientDependencies) == null ? void 0 : _d[pkgName])
|
|
64
|
-
|
|
92
|
+
continue;
|
|
65
93
|
if (matchAlias(source, api.config.alias || {}))
|
|
66
|
-
|
|
94
|
+
continue;
|
|
67
95
|
if (matchExternals(source, api.config.externals || {}))
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
96
|
+
continue;
|
|
97
|
+
phantomDeps.push(source);
|
|
98
|
+
import_utils.logger.error(
|
|
99
|
+
`[phantomDependency] ${import_utils.chalk.red(
|
|
100
|
+
`${source} is a phantom dependency, please specify it in package.json.`
|
|
101
|
+
)}`
|
|
102
|
+
);
|
|
103
|
+
for (const file of files2) {
|
|
104
|
+
import_utils.logger.error(`[phantomDependency] ${file.file} imports ${source}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (phantomDeps.length && api.name !== "dev") {
|
|
108
|
+
throw new Error(
|
|
109
|
+
`[phantomDependency] has phantom dependencies ${phantomDeps.join(
|
|
110
|
+
", "
|
|
111
|
+
)}, exit.`
|
|
72
112
|
);
|
|
73
|
-
}
|
|
113
|
+
}
|
|
74
114
|
});
|
|
75
115
|
function getPkgName(source) {
|
|
76
116
|
const arr = source.split("/");
|
|
@@ -28,7 +28,6 @@ __export(polyfill_exports, {
|
|
|
28
28
|
default: () => polyfill_default
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(polyfill_exports);
|
|
31
|
-
var import_core = require("@umijs/bundler-utils/compiled/babel/core");
|
|
32
31
|
var import_constants = require("@umijs/bundler-webpack/dist/constants");
|
|
33
32
|
var import_utils = require("@umijs/utils");
|
|
34
33
|
var import_path = require("path");
|
|
@@ -49,7 +48,12 @@ var polyfill_default = (api) => {
|
|
|
49
48
|
api.onGenerateFiles(() => {
|
|
50
49
|
var _a, _b;
|
|
51
50
|
const coreJsImports = ((_a = api.config.polyfill) == null ? void 0 : _a.imports) ? (_b = api.config.polyfill) == null ? void 0 : _b.imports.map((item) => `import '${item}';`).join("\n") : `import 'core-js';`;
|
|
52
|
-
const {
|
|
51
|
+
const {
|
|
52
|
+
transform
|
|
53
|
+
} = (0, import_utils.importLazy)(
|
|
54
|
+
require.resolve("@umijs/bundler-utils/compiled/babel/core")
|
|
55
|
+
);
|
|
56
|
+
const { code } = transform(
|
|
53
57
|
`
|
|
54
58
|
${coreJsImports}
|
|
55
59
|
import '${(0, import_utils.winPath)(require.resolve("regenerator-runtime/runtime"))}';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import esbuild from '@umijs/bundler-utils/compiled/esbuild';
|
|
2
|
+
export declare function build(opts: {
|
|
3
|
+
entryPoints: string[];
|
|
4
|
+
watch?: {
|
|
5
|
+
onRebuildSuccess({ result }: {
|
|
6
|
+
result: esbuild.BuildResult;
|
|
7
|
+
}): void;
|
|
8
|
+
} | false;
|
|
9
|
+
config?: {
|
|
10
|
+
alias?: any;
|
|
11
|
+
};
|
|
12
|
+
plugins?: esbuild.Plugin[];
|
|
13
|
+
}): Promise<esbuild.BuildResult & {
|
|
14
|
+
outputFiles: esbuild.OutputFile[];
|
|
15
|
+
}>;
|
|
@@ -22,7 +22,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
));
|
|
23
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
24
|
|
|
25
|
-
// src/features/
|
|
25
|
+
// src/features/prepare/build.ts
|
|
26
26
|
var build_exports = {};
|
|
27
27
|
__export(build_exports, {
|
|
28
28
|
build: () => build
|
|
@@ -32,28 +32,26 @@ var import_esbuild = __toESM(require("@umijs/bundler-utils/compiled/esbuild"));
|
|
|
32
32
|
var import_utils = require("@umijs/utils");
|
|
33
33
|
var import_path = __toESM(require("path"));
|
|
34
34
|
var import_esbuildAliasPlugin = require("./esbuildPlugins/esbuildAliasPlugin");
|
|
35
|
-
var import_esbuildCollectIconPlugin = require("./esbuildPlugins/esbuildCollectIconPlugin");
|
|
36
35
|
var import_esbuildExternalPlugin = require("./esbuildPlugins/esbuildExternalPlugin");
|
|
37
36
|
async function build(opts) {
|
|
38
|
-
var _a
|
|
39
|
-
|
|
40
|
-
await import_esbuild.default.build({
|
|
37
|
+
var _a;
|
|
38
|
+
return await import_esbuild.default.build({
|
|
41
39
|
format: "esm",
|
|
42
40
|
platform: "browser",
|
|
43
41
|
target: "esnext",
|
|
44
42
|
loader: {
|
|
45
|
-
".js": "
|
|
46
|
-
".jsx": "
|
|
43
|
+
".js": "tsx",
|
|
44
|
+
".jsx": "tsx",
|
|
47
45
|
".ts": "ts",
|
|
48
46
|
".tsx": "tsx"
|
|
49
47
|
},
|
|
50
48
|
watch: !!opts.watch && {
|
|
51
|
-
onRebuild(err) {
|
|
49
|
+
onRebuild(err, result) {
|
|
52
50
|
if (err) {
|
|
53
51
|
import_utils.logger.error(`[icons] build failed: ${err}`);
|
|
54
52
|
} else {
|
|
55
53
|
if (opts.watch) {
|
|
56
|
-
opts.watch.onRebuildSuccess();
|
|
54
|
+
opts.watch.onRebuildSuccess({ result });
|
|
57
55
|
}
|
|
58
56
|
}
|
|
59
57
|
}
|
|
@@ -63,16 +61,13 @@ async function build(opts) {
|
|
|
63
61
|
entryPoints: opts.entryPoints,
|
|
64
62
|
write: false,
|
|
65
63
|
outdir: import_path.default.join(import_path.default.dirname(opts.entryPoints[0]), "out"),
|
|
64
|
+
metafile: true,
|
|
66
65
|
plugins: [
|
|
67
66
|
(0, import_esbuildExternalPlugin.esbuildExternalPlugin)(),
|
|
68
67
|
(0, import_esbuildAliasPlugin.esbuildAliasPlugin)({ alias: ((_a = opts.config) == null ? void 0 : _a.alias) || {} }),
|
|
69
|
-
|
|
70
|
-
icons,
|
|
71
|
-
alias: ((_b = opts.options) == null ? void 0 : _b.alias) || {}
|
|
72
|
-
})
|
|
68
|
+
...opts.plugins || []
|
|
73
69
|
]
|
|
74
70
|
});
|
|
75
|
-
return icons;
|
|
76
71
|
}
|
|
77
72
|
// Annotate the CommonJS export names for ESM import in node:
|
|
78
73
|
0 && (module.exports = {
|
|
File without changes
|
|
@@ -22,24 +22,25 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
));
|
|
23
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
24
|
|
|
25
|
-
// src/features/
|
|
25
|
+
// src/features/prepare/esbuildPlugins/esbuildAliasPlugin.ts
|
|
26
26
|
var esbuildAliasPlugin_exports = {};
|
|
27
27
|
__export(esbuildAliasPlugin_exports, {
|
|
28
28
|
esbuildAliasPlugin: () => esbuildAliasPlugin
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(esbuildAliasPlugin_exports);
|
|
31
|
-
var import_fs = require("fs");
|
|
32
31
|
var import_enhanced_resolve = __toESM(require("enhanced-resolve"));
|
|
32
|
+
var import_fs = __toESM(require("fs"));
|
|
33
|
+
var import_path = __toESM(require("path"));
|
|
33
34
|
var resolver = import_enhanced_resolve.default.create({
|
|
34
35
|
mainFields: ["module", "browser", "main"],
|
|
35
36
|
extensions: [".json", ".js", ".jsx", ".ts", ".tsx", ".cjs", ".mjs"],
|
|
36
37
|
exportsFields: []
|
|
37
38
|
});
|
|
38
|
-
async function resolve(context,
|
|
39
|
+
async function resolve(context, path2) {
|
|
39
40
|
return new Promise((resolve2, reject) => {
|
|
40
41
|
resolver(
|
|
41
42
|
context,
|
|
42
|
-
|
|
43
|
+
path2,
|
|
43
44
|
(err, result) => err ? reject(err) : resolve2(result)
|
|
44
45
|
);
|
|
45
46
|
});
|
|
@@ -61,31 +62,31 @@ function addSlashAffix(key) {
|
|
|
61
62
|
}
|
|
62
63
|
function esbuildAliasPlugin(opts) {
|
|
63
64
|
return {
|
|
64
|
-
name: "
|
|
65
|
+
name: "esbuildAliasPlugin",
|
|
65
66
|
setup(build) {
|
|
66
67
|
sortByAffix({ keys: Object.keys(opts.alias), affix: "$" }).filter((key) => {
|
|
67
|
-
return opts.alias[key]
|
|
68
|
+
return import_path.default.isAbsolute(opts.alias[key]) && !opts.alias[key].includes("node_modules");
|
|
68
69
|
}).forEach((key) => {
|
|
69
70
|
const value = opts.alias[key];
|
|
70
|
-
const filter = key.endsWith("$") ? new RegExp(key) : new RegExp(
|
|
71
|
+
const filter = key.endsWith("$") ? new RegExp(`^${key}`) : new RegExp(`^${key}$`);
|
|
71
72
|
build.onResolve({ filter }, async (args) => {
|
|
72
|
-
const
|
|
73
|
+
const path2 = await resolve(
|
|
73
74
|
args.importer,
|
|
74
75
|
args.path.replace(filter, value)
|
|
75
76
|
);
|
|
76
77
|
return {
|
|
77
|
-
path
|
|
78
|
+
path: path2
|
|
78
79
|
};
|
|
79
80
|
});
|
|
80
|
-
if (!key.endsWith("/") &&
|
|
81
|
+
if (!key.endsWith("/") && import_fs.default.existsSync(value) && import_fs.default.statSync(value).isDirectory()) {
|
|
81
82
|
const filter2 = new RegExp(`^${addSlashAffix(key)}`);
|
|
82
83
|
build.onResolve({ filter: filter2 }, async (args) => {
|
|
83
|
-
const
|
|
84
|
+
const path2 = await resolve(
|
|
84
85
|
args.importer,
|
|
85
86
|
args.path.replace(filter2, addSlashAffix(value))
|
|
86
87
|
);
|
|
87
88
|
return {
|
|
88
|
-
path
|
|
89
|
+
path: path2
|
|
89
90
|
};
|
|
90
91
|
});
|
|
91
92
|
}
|
|
File without changes
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,14 +16,20 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
17
23
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
24
|
|
|
19
|
-
// src/features/
|
|
25
|
+
// src/features/prepare/esbuildPlugins/esbuildExternalPlugin.ts
|
|
20
26
|
var esbuildExternalPlugin_exports = {};
|
|
21
27
|
__export(esbuildExternalPlugin_exports, {
|
|
22
28
|
esbuildExternalPlugin: () => esbuildExternalPlugin
|
|
23
29
|
});
|
|
24
30
|
module.exports = __toCommonJS(esbuildExternalPlugin_exports);
|
|
31
|
+
var import_utils = require("@umijs/utils");
|
|
32
|
+
var import_path = __toESM(require("path"));
|
|
25
33
|
function esbuildExternalPlugin() {
|
|
26
34
|
return {
|
|
27
35
|
name: "esbuildExternalPlugin",
|
|
@@ -41,7 +49,13 @@ function esbuildExternalPlugin() {
|
|
|
41
49
|
if (args.kind === "entry-point") {
|
|
42
50
|
return null;
|
|
43
51
|
}
|
|
44
|
-
|
|
52
|
+
const winP = (0, import_utils.winPath)(args.path);
|
|
53
|
+
const isAliasImport = winP.startsWith("@/") || winP.startsWith("@@/");
|
|
54
|
+
if (isAliasImport) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
const isNodeModuleImport = args.path.includes("node_modules");
|
|
58
|
+
if (import_path.default.isAbsolute(args.path) && !isNodeModuleImport) {
|
|
45
59
|
return null;
|
|
46
60
|
}
|
|
47
61
|
return {
|
|
@@ -0,0 +1,86 @@
|
|
|
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(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
|
|
25
|
+
// src/features/prepare/prepare.ts
|
|
26
|
+
var prepare_exports = {};
|
|
27
|
+
__export(prepare_exports, {
|
|
28
|
+
default: () => prepare_default
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(prepare_exports);
|
|
31
|
+
var import_utils = require("@umijs/utils");
|
|
32
|
+
var import_path = __toESM(require("path"));
|
|
33
|
+
var import_watch = require("../../commands/dev/watch");
|
|
34
|
+
var prepare_default = (api) => {
|
|
35
|
+
api.register({
|
|
36
|
+
key: "onGenerateFiles",
|
|
37
|
+
async fn({ isFirstTime }) {
|
|
38
|
+
if (api.appData.framework === "vue") {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (!isFirstTime)
|
|
42
|
+
return;
|
|
43
|
+
import_utils.logger.info("Preparing...");
|
|
44
|
+
const entryFile = import_path.default.join(api.paths.absTmpPath, "umi.ts");
|
|
45
|
+
const { build } = await import("./build.js");
|
|
46
|
+
const watch = api.name === "dev";
|
|
47
|
+
const plugins = await api.applyPlugins({
|
|
48
|
+
key: "addPrepareBuildPlugins",
|
|
49
|
+
initialValue: []
|
|
50
|
+
});
|
|
51
|
+
const buildResult = await build({
|
|
52
|
+
entryPoints: [entryFile],
|
|
53
|
+
watch: watch && {
|
|
54
|
+
onRebuildSuccess({ result }) {
|
|
55
|
+
api.applyPlugins({
|
|
56
|
+
key: "onPrepareBuildSuccess",
|
|
57
|
+
args: {
|
|
58
|
+
isWatch: true,
|
|
59
|
+
result
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
config: {
|
|
65
|
+
alias: api.config.alias
|
|
66
|
+
},
|
|
67
|
+
plugins
|
|
68
|
+
});
|
|
69
|
+
if (watch) {
|
|
70
|
+
(0, import_watch.addUnWatch)(() => {
|
|
71
|
+
var _a;
|
|
72
|
+
(_a = buildResult.stop) == null ? void 0 : _a.call(buildResult);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
await api.applyPlugins({
|
|
76
|
+
key: "onPrepareBuildSuccess",
|
|
77
|
+
args: {
|
|
78
|
+
result: buildResult
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
stage: Infinity
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
+
0 && (module.exports = {});
|
package/dist/index.js
CHANGED
|
@@ -53,6 +53,7 @@ var src_default = () => {
|
|
|
53
53
|
require.resolve("./features/phantomDependency/phantomDependency"),
|
|
54
54
|
require.resolve("./features/polyfill/polyfill"),
|
|
55
55
|
require.resolve("./features/polyfill/publicPathPolyfill"),
|
|
56
|
+
require.resolve("./features/prepare/prepare"),
|
|
56
57
|
require.resolve("./features/routePrefetch/routePrefetch"),
|
|
57
58
|
require.resolve("./features/ssr/ssr"),
|
|
58
59
|
require.resolve("./features/terminal/terminal"),
|
package/dist/registerMethods.js
CHANGED
|
@@ -34,7 +34,6 @@ var import_assert = __toESM(require("assert"));
|
|
|
34
34
|
var import_fs = require("fs");
|
|
35
35
|
var import_path = require("path");
|
|
36
36
|
var import_isTypeScriptFile = require("./utils/isTypeScriptFile");
|
|
37
|
-
var import_transformIEAR = __toESM(require("./utils/transformIEAR"));
|
|
38
37
|
var registerMethods_default = (api) => {
|
|
39
38
|
[
|
|
40
39
|
"onGenerateFiles",
|
|
@@ -43,6 +42,7 @@ var registerMethods_default = (api) => {
|
|
|
43
42
|
"onBuildHtmlComplete",
|
|
44
43
|
"onPatchRoute",
|
|
45
44
|
"onPkgJSONChanged",
|
|
45
|
+
"onPrepareBuildSuccess",
|
|
46
46
|
"onDevCompileDone",
|
|
47
47
|
"onCheckPkgJSON",
|
|
48
48
|
"onCheckCode",
|
|
@@ -55,6 +55,7 @@ var registerMethods_default = (api) => {
|
|
|
55
55
|
"addRuntimePlugin",
|
|
56
56
|
"addRuntimePluginKey",
|
|
57
57
|
"addPolyfillImports",
|
|
58
|
+
"addPrepareBuildPlugins",
|
|
58
59
|
"addEntryImportsAhead",
|
|
59
60
|
"addEntryImports",
|
|
60
61
|
"addEntryCodeAhead",
|
|
@@ -122,7 +123,10 @@ var registerMethods_default = (api) => {
|
|
|
122
123
|
""
|
|
123
124
|
].filter((text) => text !== false).join("\n");
|
|
124
125
|
if (api.appData.vite && isJsFile) {
|
|
125
|
-
|
|
126
|
+
const { default: transformIEAR } = (0, import_utils.importLazy)(
|
|
127
|
+
require.resolve("./utils/transformIEAR")
|
|
128
|
+
);
|
|
129
|
+
content = transformIEAR({ content, path: absPath }, api);
|
|
126
130
|
}
|
|
127
131
|
if (!(0, import_fs.existsSync)(absPath)) {
|
|
128
132
|
(0, import_fs.writeFileSync)(absPath, content, "utf-8");
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ImportDeclaration } from '@umijs/bundler-utils/compiled/@babel/types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { BuildResult as ESBuildBuildResult, Plugin as ESBuildPlugin } from '@umijs/bundler-utils/compiled/esbuild';
|
|
3
|
+
import type { Express, RequestHandler, webpack } from '@umijs/bundler-webpack';
|
|
3
4
|
import type WebpackChain from '@umijs/bundler-webpack/compiled/webpack-5-chain';
|
|
4
5
|
import type { IConfig } from '@umijs/bundler-webpack/dist/types';
|
|
5
6
|
import type { IAdd, IEvent, IModify, IRoute as ICoreRoute, IServicePluginAPI, PluginAPI } from '@umijs/core';
|
|
@@ -92,6 +93,7 @@ export declare type IApi = PluginAPI & IServicePluginAPI & {
|
|
|
92
93
|
source: string;
|
|
93
94
|
specifier?: string;
|
|
94
95
|
}>;
|
|
96
|
+
addPrepareBuildPlugins: IAdd<null, ESBuildPlugin>;
|
|
95
97
|
addRuntimePlugin: IAdd<null, string>;
|
|
96
98
|
addRuntimePluginKey: IAdd<null, string>;
|
|
97
99
|
addTmpGenerateWatcherPaths: IAdd<null, string>;
|
|
@@ -180,6 +182,10 @@ export declare type IApi = PluginAPI & IServicePluginAPI & {
|
|
|
180
182
|
current: Record<string, any>;
|
|
181
183
|
origin: Record<string, any>;
|
|
182
184
|
}>;
|
|
185
|
+
onPrepareBuildSuccess: IEvent<{
|
|
186
|
+
isWatch: boolean;
|
|
187
|
+
result: ESBuildBuildResult;
|
|
188
|
+
}>;
|
|
183
189
|
restartServer: () => void;
|
|
184
190
|
writeTmpFile: (opts: {
|
|
185
191
|
content?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/preset-umi",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.48",
|
|
4
4
|
"description": "@umijs/preset-umi",
|
|
5
5
|
"homepage": "https://github.com/umijs/umi/tree/master/packages/preset-umi#readme",
|
|
6
6
|
"bugs": "https://github.com/umijs/umi/issues",
|
|
@@ -27,19 +27,19 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@iconify/utils": "2.0.9",
|
|
29
29
|
"@svgr/core": "6.2.1",
|
|
30
|
-
"@umijs/ast": "4.0.
|
|
31
|
-
"@umijs/babel-preset-umi": "4.0.
|
|
32
|
-
"@umijs/bundler-utils": "4.0.
|
|
33
|
-
"@umijs/bundler-vite": "4.0.
|
|
34
|
-
"@umijs/bundler-webpack": "4.0.
|
|
35
|
-
"@umijs/core": "4.0.
|
|
30
|
+
"@umijs/ast": "4.0.48",
|
|
31
|
+
"@umijs/babel-preset-umi": "4.0.48",
|
|
32
|
+
"@umijs/bundler-utils": "4.0.48",
|
|
33
|
+
"@umijs/bundler-vite": "4.0.48",
|
|
34
|
+
"@umijs/bundler-webpack": "4.0.48",
|
|
35
|
+
"@umijs/core": "4.0.48",
|
|
36
36
|
"@umijs/did-you-know": "^1.0.0",
|
|
37
37
|
"@umijs/history": "5.3.1",
|
|
38
|
-
"@umijs/mfsu": "4.0.
|
|
39
|
-
"@umijs/plugin-run": "4.0.
|
|
40
|
-
"@umijs/renderer-react": "4.0.
|
|
41
|
-
"@umijs/server": "4.0.
|
|
42
|
-
"@umijs/utils": "4.0.
|
|
38
|
+
"@umijs/mfsu": "4.0.48",
|
|
39
|
+
"@umijs/plugin-run": "4.0.48",
|
|
40
|
+
"@umijs/renderer-react": "4.0.48",
|
|
41
|
+
"@umijs/server": "4.0.48",
|
|
42
|
+
"@umijs/utils": "4.0.48",
|
|
43
43
|
"babel-plugin-dynamic-import-node": "2.3.3",
|
|
44
44
|
"click-to-react-component": "^1.0.8",
|
|
45
45
|
"core-js": "3.27.1",
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare function build(opts: {
|
|
2
|
-
entryPoints: string[];
|
|
3
|
-
watch?: {
|
|
4
|
-
onRebuildSuccess(): void;
|
|
5
|
-
} | false;
|
|
6
|
-
config?: {
|
|
7
|
-
alias?: any;
|
|
8
|
-
};
|
|
9
|
-
options?: {
|
|
10
|
-
alias?: Record<string, string>;
|
|
11
|
-
};
|
|
12
|
-
icons?: Set<string>;
|
|
13
|
-
}): Promise<Set<string>>;
|