@umijs/preset-umi 4.4.12 → 4.4.13-canary.20250911.3
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/createRouteMiddleware.js +1 -1
- package/dist/commands/dev/dev.js +2 -2
- package/dist/features/aiDev/aiDev.js +1 -1
- package/dist/features/bundler/bundler.js +4 -0
- package/dist/features/esbuildHelperChecker/esbuildHelperChecker.js +1 -1
- package/dist/features/forget/forget.js +5 -0
- package/dist/features/routePreloadOnLoad/routePreloadOnLoad.js +1 -1
- package/dist/features/tmpFiles/tmpFiles.js +3 -3
- package/dist/features/utoopack/utoopack.d.ts +3 -0
- package/dist/features/utoopack/utoopack.js +143 -0
- package/dist/index.js +1 -0
- package/dist/utils/transformIEAR.d.ts +1 -1
- package/dist/utils/transformIEAR.js +12 -1
- package/package.json +16 -15
|
@@ -34,7 +34,7 @@ function createRouteMiddleware(opts) {
|
|
|
34
34
|
onStats == null ? void 0 : onStats(stats);
|
|
35
35
|
});
|
|
36
36
|
async function getStats(api) {
|
|
37
|
-
if (!compiler && api.config.mako) {
|
|
37
|
+
if (!compiler && (api.config.mako || api.config.utoopack)) {
|
|
38
38
|
return {
|
|
39
39
|
compilation: { assets: { "umi.js": "umi.js", "umi.css": "umi.css" } },
|
|
40
40
|
hasErrors: () => false
|
package/dist/commands/dev/dev.js
CHANGED
|
@@ -58,8 +58,8 @@ var dev_default = (api) => {
|
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
api.onStart(() => {
|
|
61
|
-
var _a;
|
|
62
|
-
if ((_a = api.config) == null ? void 0 : _a.mako)
|
|
61
|
+
var _a, _b;
|
|
62
|
+
if (((_a = api.config) == null ? void 0 : _a.mako) || ((_b = api.config) == null ? void 0 : _b.utoopack))
|
|
63
63
|
return;
|
|
64
64
|
if (process.env.BIGFISH_INFO)
|
|
65
65
|
return;
|
|
@@ -35,6 +35,10 @@ var bundler_default = (api) => {
|
|
|
35
35
|
require("@umijs/bundler-webpack/dist/requireHook");
|
|
36
36
|
return require(process.env.OKAM);
|
|
37
37
|
}
|
|
38
|
+
if (bundler === "utoopack") {
|
|
39
|
+
require("@umijs/bundler-webpack/dist/requireHook");
|
|
40
|
+
return require(process.env.UTOOPACK);
|
|
41
|
+
}
|
|
38
42
|
if (bundler === "vite") {
|
|
39
43
|
return bundlerVite;
|
|
40
44
|
}
|
|
@@ -109,7 +109,7 @@ var esbuildHelperChecker_default = (api) => {
|
|
|
109
109
|
}
|
|
110
110
|
});
|
|
111
111
|
api.onBuildComplete(async ({ err }) => {
|
|
112
|
-
if (api.config.vite || api.config.mako)
|
|
112
|
+
if (api.config.vite || api.config.mako || api.config.utoopack)
|
|
113
113
|
return;
|
|
114
114
|
if (err)
|
|
115
115
|
return;
|
|
@@ -47,6 +47,11 @@ var forget_default = (api) => {
|
|
|
47
47
|
`forget is not compatible with mako, please disable mako first.`
|
|
48
48
|
);
|
|
49
49
|
}
|
|
50
|
+
if (api.config.utoopack) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
`forget is not compatible with utoopack, please disable utoopack first.`
|
|
53
|
+
);
|
|
54
|
+
}
|
|
50
55
|
});
|
|
51
56
|
api.onCheck(() => {
|
|
52
57
|
let reactMajorVersion = api.appData.react.version.split(".")[0];
|
|
@@ -64,7 +64,7 @@ async function getRouteChunkFilesMap(chunks, opts) {
|
|
|
64
64
|
if (chunk.entry)
|
|
65
65
|
continue;
|
|
66
66
|
const pickedFiles = pickPreloadFiles(chunk.files);
|
|
67
|
-
const routeOrigins = chunk.origins.filter(
|
|
67
|
+
const routeOrigins = (chunk.origins || []).filter(
|
|
68
68
|
(origin) => {
|
|
69
69
|
var _a2;
|
|
70
70
|
return (_a2 = origin.moduleName) == null ? void 0 : _a2.endsWith(routeModuleName);
|
|
@@ -674,8 +674,8 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
674
674
|
for (const plugin of allPlugins) {
|
|
675
675
|
const file = (0, import_utils.winPath)((0, import_path.join)(api.paths.absTmpPath, plugin, "types.d.ts"));
|
|
676
676
|
if ((0, import_fs.existsSync)(file)) {
|
|
677
|
-
const noSuffixFile = file.replace(/\.ts$/, "");
|
|
678
|
-
beforeExports.push(`export * from '${noSuffixFile}';`);
|
|
677
|
+
const noSuffixFile = file.replace(/\.d\.ts$/, "");
|
|
678
|
+
beforeExports.push(`export type * from '${noSuffixFile}';`);
|
|
679
679
|
}
|
|
680
680
|
}
|
|
681
681
|
let pluginIndex = 0;
|
|
@@ -687,7 +687,7 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
687
687
|
);
|
|
688
688
|
if ((0, import_fs.existsSync)(runtimeConfigFile)) {
|
|
689
689
|
const noSuffixRuntimeConfigFile = runtimeConfigFile.replace(
|
|
690
|
-
/\.ts$/,
|
|
690
|
+
/\.d\.ts$/,
|
|
691
691
|
""
|
|
692
692
|
);
|
|
693
693
|
beforeImport.push(
|
|
@@ -0,0 +1,143 @@
|
|
|
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
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/features/utoopack/utoopack.ts
|
|
30
|
+
var utoopack_exports = {};
|
|
31
|
+
__export(utoopack_exports, {
|
|
32
|
+
default: () => utoopack_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(utoopack_exports);
|
|
35
|
+
var import_bundler_utoopack = require("@umijs/bundler-utoopack");
|
|
36
|
+
var import_path = require("path");
|
|
37
|
+
var import_extractEntryAssets = require("../../utils/extractEntryAssets");
|
|
38
|
+
var utoopack_default = (api) => {
|
|
39
|
+
api.describe({
|
|
40
|
+
key: "utoopack",
|
|
41
|
+
config: {
|
|
42
|
+
schema({ zod }) {
|
|
43
|
+
return zod.object({}).partial();
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
enableBy: api.EnableBy.config
|
|
47
|
+
});
|
|
48
|
+
const assets = {
|
|
49
|
+
// Will contain all js and mjs files
|
|
50
|
+
js: [],
|
|
51
|
+
// Will contain all css files
|
|
52
|
+
css: []
|
|
53
|
+
};
|
|
54
|
+
api.modifyAppData((memo) => {
|
|
55
|
+
memo.bundler = "utoopack";
|
|
56
|
+
return memo;
|
|
57
|
+
});
|
|
58
|
+
api.modifyConfig((memo, args) => {
|
|
59
|
+
const rootDir = memo.rootDir ? (0, import_path.join)(args.paths.cwd, memo.rootDir).replace(/\/$/, "") : (0, import_bundler_utoopack.findRootDir)(args.paths.cwd).replace(/\/$/, "");
|
|
60
|
+
memo.alias = {
|
|
61
|
+
...memo.alias,
|
|
62
|
+
"@/*": `${args.paths.absSrcPath}/*`,
|
|
63
|
+
"@@/*": `${args.paths.absTmpPath}/*`,
|
|
64
|
+
[`${rootDir}/*`]: `${rootDir}/*`
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
...memo,
|
|
68
|
+
mfsu: false,
|
|
69
|
+
hmrGuardian: false,
|
|
70
|
+
utoopack: {
|
|
71
|
+
...memo.utoopack
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
api.onStart(() => {
|
|
76
|
+
process.env.UTOOPACK = process.env.UTOOPACK || require.resolve("@umijs/bundler-utoopack");
|
|
77
|
+
try {
|
|
78
|
+
const pkg = require((0, import_path.join)(
|
|
79
|
+
require.resolve(process.env.UTOOPACK),
|
|
80
|
+
"../../package.json"
|
|
81
|
+
));
|
|
82
|
+
api.logger.info(`Using @utoo/pack@${pkg.dependencies["@utoo/pack"]}`);
|
|
83
|
+
} catch (e) {
|
|
84
|
+
console.error(e);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
api.onDevCompileDone(({ stats }) => {
|
|
88
|
+
var _a, _b, _c;
|
|
89
|
+
const entryPointFiles = /* @__PURE__ */ new Set();
|
|
90
|
+
for (const chunk of ((_b = (_a = stats.entrypoints) == null ? void 0 : _a["umi"]) == null ? void 0 : _b.chunks) || []) {
|
|
91
|
+
const files = ((_c = ((stats == null ? void 0 : stats.chunks) || []).find((c) => (c == null ? void 0 : c.id) === chunk)) == null ? void 0 : _c.files) || [];
|
|
92
|
+
for (const file of files) {
|
|
93
|
+
entryPointFiles.add(file);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const entryAssets = (0, import_extractEntryAssets.extractEntryAssets)(Array.from(entryPointFiles));
|
|
97
|
+
Object.entries(entryAssets).forEach(([ext, files]) => {
|
|
98
|
+
if (!Array.isArray(assets[ext])) {
|
|
99
|
+
assets[ext] = [];
|
|
100
|
+
}
|
|
101
|
+
assets[ext].push(...files);
|
|
102
|
+
});
|
|
103
|
+
const allAssets = (stats.assets || []).map((asset) => asset.name);
|
|
104
|
+
for (const asset of allAssets) {
|
|
105
|
+
if (asset.endsWith(".js") && !assets.js.includes(asset) && !asset.includes("umi.js")) {
|
|
106
|
+
assets.js.push(asset);
|
|
107
|
+
} else if (asset.endsWith(".css") && !assets.css.includes(asset)) {
|
|
108
|
+
assets.css.push(asset);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
api.onBuildComplete(({ stats }) => {
|
|
113
|
+
var _a, _b, _c;
|
|
114
|
+
const entryPointFiles = /* @__PURE__ */ new Set();
|
|
115
|
+
for (const chunk of ((_b = (_a = stats.entrypoints) == null ? void 0 : _a["umi"]) == null ? void 0 : _b.chunks) || []) {
|
|
116
|
+
const files = ((_c = ((stats == null ? void 0 : stats.chunks) || []).find((c) => (c == null ? void 0 : c.id) === chunk)) == null ? void 0 : _c.files) || [];
|
|
117
|
+
for (const file of files) {
|
|
118
|
+
entryPointFiles.add(file);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const entryAssets = (0, import_extractEntryAssets.extractEntryAssets)(Array.from(entryPointFiles));
|
|
122
|
+
Object.entries(entryAssets).forEach(([ext, files]) => {
|
|
123
|
+
if (!Array.isArray(assets[ext])) {
|
|
124
|
+
assets[ext] = [];
|
|
125
|
+
}
|
|
126
|
+
assets[ext].push(...files);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
api.addHTMLStyles(() => {
|
|
130
|
+
const { publicPath } = api.config;
|
|
131
|
+
const displayPublicPath = publicPath === "auto" ? "/" : publicPath;
|
|
132
|
+
return assets.css.map((css) => {
|
|
133
|
+
return `${displayPublicPath}${css}`;
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
api.addHTMLHeadScripts(() => {
|
|
137
|
+
const { publicPath } = api.config;
|
|
138
|
+
const displayPublicPath = publicPath === "auto" ? "/" : publicPath;
|
|
139
|
+
return assets.js.map((js) => {
|
|
140
|
+
return `${displayPublicPath}${js}`;
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -88,6 +88,7 @@ var src_default = () => {
|
|
|
88
88
|
require.resolve("./features/swc/swc"),
|
|
89
89
|
require.resolve("./features/ui/ui"),
|
|
90
90
|
require.resolve("./features/mako/mako"),
|
|
91
|
+
require.resolve("./features/utoopack/utoopack"),
|
|
91
92
|
require.resolve("./features/hmrGuardian/hmrGuardian"),
|
|
92
93
|
require.resolve("./features/routePreloadOnLoad/routePreloadOnLoad"),
|
|
93
94
|
require.resolve("./features/forget/forget"),
|
|
@@ -24,6 +24,7 @@ __export(transformIEAR_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(transformIEAR_exports);
|
|
26
26
|
var import_bundler_utils = require("@umijs/bundler-utils");
|
|
27
|
+
var import_bundler_utoopack = require("@umijs/bundler-utoopack");
|
|
27
28
|
var import_utils = require("@umijs/utils");
|
|
28
29
|
var import_path = require("path");
|
|
29
30
|
var IEAR_REG_EXP = new RegExp(
|
|
@@ -89,7 +90,11 @@ var IEAR_REG_EXP = new RegExp(
|
|
|
89
90
|
// match full-content
|
|
90
91
|
"g"
|
|
91
92
|
);
|
|
92
|
-
function transformIEAR({ content, path }, api) {
|
|
93
|
+
function transformIEAR({ content, path }, api, isUtoopack = false) {
|
|
94
|
+
let rootPath = api.cwd;
|
|
95
|
+
if (isUtoopack) {
|
|
96
|
+
rootPath = (0, import_bundler_utoopack.findRootDir)(api.cwd);
|
|
97
|
+
}
|
|
93
98
|
return content.replace(IEAR_REG_EXP, (_, prefix, quote, absPath) => {
|
|
94
99
|
if (absPath.startsWith(api.paths.absTmpPath)) {
|
|
95
100
|
absPath = (0, import_utils.winPath)((0, import_path.relative)((0, import_path.dirname)(path), absPath)).replace(
|
|
@@ -99,6 +104,12 @@ function transformIEAR({ content, path }, api) {
|
|
|
99
104
|
);
|
|
100
105
|
} else if ((0, import_bundler_utils.isDepPath)(absPath)) {
|
|
101
106
|
absPath = `@fs/${(0, import_utils.winPath)((0, import_path.relative)(api.cwd, absPath))}`;
|
|
107
|
+
} else if (absPath.startsWith(rootPath) && isUtoopack) {
|
|
108
|
+
absPath = (0, import_utils.winPath)((0, import_path.relative)((0, import_path.dirname)(path), absPath)).replace(
|
|
109
|
+
// prepend ./ for same or sub level imports
|
|
110
|
+
/^(?!\.\.\/)/,
|
|
111
|
+
"./"
|
|
112
|
+
);
|
|
102
113
|
}
|
|
103
114
|
return `${prefix}${quote}${absPath}${quote}`;
|
|
104
115
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/preset-umi",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.13-canary.20250911.3",
|
|
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",
|
|
@@ -43,20 +43,21 @@
|
|
|
43
43
|
"react-router": "6.3.0",
|
|
44
44
|
"react-router-dom": "6.3.0",
|
|
45
45
|
"regenerator-runtime": "0.13.11",
|
|
46
|
-
"@umijs/ast": "4.4.
|
|
47
|
-
"@umijs/
|
|
48
|
-
"@umijs/
|
|
49
|
-
"@umijs/bundler-vite": "4.4.
|
|
50
|
-
"@umijs/
|
|
51
|
-
"@umijs/bundler-
|
|
52
|
-
"@umijs/
|
|
53
|
-
"@umijs/
|
|
54
|
-
"@umijs/
|
|
55
|
-
"@umijs/server": "4.4.
|
|
56
|
-
"@umijs/
|
|
57
|
-
"@umijs/
|
|
58
|
-
"@umijs/zod2ts": "4.4.
|
|
59
|
-
"@umijs/
|
|
46
|
+
"@umijs/ast": "4.4.13-canary.20250911.3",
|
|
47
|
+
"@umijs/bundler-utoopack": "4.4.13-canary.20250911.3",
|
|
48
|
+
"@umijs/babel-preset-umi": "4.4.13-canary.20250911.3",
|
|
49
|
+
"@umijs/bundler-vite": "4.4.13-canary.20250911.3",
|
|
50
|
+
"@umijs/mfsu": "4.4.13-canary.20250911.3",
|
|
51
|
+
"@umijs/bundler-utils": "4.4.13-canary.20250911.3",
|
|
52
|
+
"@umijs/bundler-webpack": "4.4.13-canary.20250911.3",
|
|
53
|
+
"@umijs/plugin-run": "4.4.13-canary.20250911.3",
|
|
54
|
+
"@umijs/bundler-esbuild": "4.4.13-canary.20250911.3",
|
|
55
|
+
"@umijs/server": "4.4.13-canary.20250911.3",
|
|
56
|
+
"@umijs/core": "4.4.13-canary.20250911.3",
|
|
57
|
+
"@umijs/renderer-react": "4.4.13-canary.20250911.3",
|
|
58
|
+
"@umijs/zod2ts": "4.4.13-canary.20250911.3",
|
|
59
|
+
"@umijs/utils": "4.4.13-canary.20250911.3",
|
|
60
|
+
"@umijs/ui": "3.0.1"
|
|
60
61
|
},
|
|
61
62
|
"devDependencies": {
|
|
62
63
|
"@manypkg/get-packages": "1.1.3",
|