@umijs/preset-umi 4.0.69 → 4.0.70
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/dev-config.js +1 -1
- package/dist/commands/lint.js +1 -0
- package/dist/features/apiRoute/dev-server/esbuild.js +16 -12
- package/dist/features/hmrGuardian/babelPlugin.d.ts +7 -0
- package/dist/features/hmrGuardian/babelPlugin.js +83 -0
- package/dist/features/hmrGuardian/hmrGuardian.d.ts +2 -0
- package/dist/features/hmrGuardian/hmrGuardian.js +58 -0
- package/dist/features/prepare/build.d.ts +2 -4
- package/dist/features/prepare/build.js +23 -13
- package/dist/features/prepare/prepare.js +2 -3
- package/dist/features/ssr/builder/builder.js +20 -12
- package/dist/features/ssr/builder/less-loader.js +1 -1
- package/dist/features/tmpFiles/tmpFiles.js +1 -5
- package/dist/index.js +1 -0
- package/dist/utils/routeExportExtractor.d.ts +1 -1
- package/dist/utils/routeExportExtractor.js +13 -7
- package/package.json +15 -14
package/dist/commands/lint.js
CHANGED
|
@@ -32,6 +32,7 @@ __export(esbuild_exports, {
|
|
|
32
32
|
default: () => esbuild_default
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(esbuild_exports);
|
|
35
|
+
var import_watchRebuild = require("@umijs/bundler-esbuild/dist/plugins/watchRebuild");
|
|
35
36
|
var import_esbuild = __toESM(require("@umijs/bundler-utils/compiled/esbuild"));
|
|
36
37
|
var import_utils = require("@umijs/utils");
|
|
37
38
|
var import_path = require("path");
|
|
@@ -41,7 +42,7 @@ async function esbuild_default(api, apiRoutes) {
|
|
|
41
42
|
const apiRoutePaths = apiRoutes.map(
|
|
42
43
|
(r) => (0, import_path.join)(api.paths.absTmpPath, "api", r.file)
|
|
43
44
|
);
|
|
44
|
-
await import_esbuild.default.
|
|
45
|
+
const ctx = await import_esbuild.default.context({
|
|
45
46
|
format: "cjs",
|
|
46
47
|
platform: "node",
|
|
47
48
|
bundle: true,
|
|
@@ -50,18 +51,21 @@ async function esbuild_default(api, apiRoutes) {
|
|
|
50
51
|
(0, import_path.resolve)(api.paths.absTmpPath, "api/_middlewares.ts")
|
|
51
52
|
],
|
|
52
53
|
outdir: (0, import_path.resolve)(api.paths.cwd, import_constants.OUTPUT_PATH),
|
|
53
|
-
plugins: [
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
54
|
+
plugins: [
|
|
55
|
+
(0, import_utils2.esbuildIgnorePathPrefixPlugin)(),
|
|
56
|
+
(0, import_watchRebuild.esbuildWatchRebuildPlugin)({
|
|
57
|
+
onRebuild(error) {
|
|
58
|
+
if (error)
|
|
59
|
+
import_utils.logger.error("Compile api routes failed: ", error);
|
|
60
|
+
Object.keys(require.cache).forEach((modulePath) => {
|
|
61
|
+
if (modulePath.startsWith((0, import_path.join)(api.paths.cwd, import_constants.OUTPUT_PATH)))
|
|
62
|
+
delete require.cache[modulePath];
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
]
|
|
64
67
|
});
|
|
68
|
+
await ctx.watch();
|
|
65
69
|
}
|
|
66
70
|
// Annotate the CommonJS export names for ESM import in node:
|
|
67
71
|
0 && (module.exports = {});
|
|
@@ -0,0 +1,83 @@
|
|
|
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/hmrGuardian/babelPlugin.ts
|
|
30
|
+
var babelPlugin_exports = {};
|
|
31
|
+
__export(babelPlugin_exports, {
|
|
32
|
+
defaultRenameVisitor: () => defaultRenameVisitor
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(babelPlugin_exports);
|
|
35
|
+
var t = __toESM(require("@umijs/bundler-utils/compiled/babel/types"));
|
|
36
|
+
var import_utils = require("@umijs/utils");
|
|
37
|
+
var import_path = require("path");
|
|
38
|
+
function defaultRenameVisitor() {
|
|
39
|
+
return {
|
|
40
|
+
visitor: {
|
|
41
|
+
// @ts-ignore
|
|
42
|
+
ExportDefaultDeclaration: {
|
|
43
|
+
enter(path, state) {
|
|
44
|
+
const def = path.node.declaration;
|
|
45
|
+
const { cwd, filename } = state.file.opts;
|
|
46
|
+
const relativePath = (0, import_path.relative)(cwd, filename);
|
|
47
|
+
if (/^\.(tsx|jsx)$/.test((0, import_path.extname)(relativePath)) && // hidden relativePath
|
|
48
|
+
!/(^|\/)\.[^\/.]/g.test(relativePath) && !relativePath.includes("node_modules")) {
|
|
49
|
+
let componentName = path2Component(relativePath);
|
|
50
|
+
if (!componentName) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const identifiers = Object.keys(path.scope.bindings || {});
|
|
54
|
+
let idx = 0;
|
|
55
|
+
while (identifiers.includes(componentName)) {
|
|
56
|
+
componentName = `${componentName}${idx}`;
|
|
57
|
+
idx += 1;
|
|
58
|
+
}
|
|
59
|
+
const named = t.identifier(componentName);
|
|
60
|
+
if (t.isArrowFunctionExpression(def)) {
|
|
61
|
+
const varDec = t.variableDeclaration("const", [
|
|
62
|
+
t.variableDeclarator(named, def)
|
|
63
|
+
]);
|
|
64
|
+
const [varDeclPath] = path.insertBefore(varDec);
|
|
65
|
+
path.scope.registerDeclaration(varDeclPath);
|
|
66
|
+
path.replaceWith(t.exportDefaultDeclaration(named));
|
|
67
|
+
} else if (t.isFunctionDeclaration(def) && !def.id) {
|
|
68
|
+
def.id = named;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function path2Component(filePath) {
|
|
77
|
+
const { ext } = (0, import_path.parse)(filePath);
|
|
78
|
+
return filePath.replace(ext, "").split(import_path.sep).map((item) => import_utils.lodash.upperFirst(item.replace(/\W/g, ""))).join("");
|
|
79
|
+
}
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
defaultRenameVisitor
|
|
83
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
// src/features/hmrGuardian/hmrGuardian.ts
|
|
20
|
+
var hmrGuardian_exports = {};
|
|
21
|
+
__export(hmrGuardian_exports, {
|
|
22
|
+
default: () => hmrGuardian_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(hmrGuardian_exports);
|
|
25
|
+
var import_babelPlugin = require("./babelPlugin");
|
|
26
|
+
function hmrGuardian_default(api) {
|
|
27
|
+
api.describe({
|
|
28
|
+
key: "hmrGuardian",
|
|
29
|
+
config: {
|
|
30
|
+
schema: ({ zod }) => zod.boolean()
|
|
31
|
+
},
|
|
32
|
+
enableBy: ({ env }) => {
|
|
33
|
+
if (env === "production" || process.env.HMR === "none" || process.env.IS_UMI_BUILD_WORKER) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return api.config.hmrGuardian;
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
api.onCheckConfig(({ userConfig }) => {
|
|
40
|
+
var _a;
|
|
41
|
+
(_a = userConfig.headScripts) == null ? void 0 : _a.some((script) => {
|
|
42
|
+
const url = typeof script === "string" ? script : script.src;
|
|
43
|
+
if (url == null ? void 0 : url.includes("react.production")) {
|
|
44
|
+
api.logger.warn(
|
|
45
|
+
"Using react/react-dom production scripts, HMR will not work."
|
|
46
|
+
);
|
|
47
|
+
api.logger.warn(
|
|
48
|
+
"Use ternary expression to use development scripts in dev environment"
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
api.addBeforeBabelPlugins(() => {
|
|
54
|
+
return [(0, import_babelPlugin.defaultRenameVisitor)()];
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import esbuild from '@umijs/bundler-utils/compiled/esbuild';
|
|
1
|
+
import esbuild, { BuildContext, BuildResult } from '@umijs/bundler-utils/compiled/esbuild';
|
|
2
2
|
export declare function build(opts: {
|
|
3
3
|
entryPoints: string[];
|
|
4
4
|
watch?: {
|
|
@@ -12,6 +12,4 @@ export declare function build(opts: {
|
|
|
12
12
|
};
|
|
13
13
|
plugins?: esbuild.Plugin[];
|
|
14
14
|
write?: boolean;
|
|
15
|
-
}): Promise<
|
|
16
|
-
metafile: esbuild.Metafile;
|
|
17
|
-
}>;
|
|
15
|
+
}): Promise<[BuildResult, BuildContext | undefined]>;
|
|
@@ -32,6 +32,7 @@ __export(build_exports, {
|
|
|
32
32
|
build: () => build
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(build_exports);
|
|
35
|
+
var import_watchRebuild = require("@umijs/bundler-esbuild/dist/plugins/watchRebuild");
|
|
35
36
|
var import_esbuild = __toESM(require("@umijs/bundler-utils/compiled/esbuild"));
|
|
36
37
|
var import_utils = require("@umijs/utils");
|
|
37
38
|
var import_path = __toESM(require("path"));
|
|
@@ -41,7 +42,7 @@ async function build(opts) {
|
|
|
41
42
|
var _a;
|
|
42
43
|
const outdir = import_path.default.join(import_path.default.dirname(opts.entryPoints[0]), "out");
|
|
43
44
|
const alias = ((_a = opts.config) == null ? void 0 : _a.alias) || {};
|
|
44
|
-
|
|
45
|
+
const buildOptions = {
|
|
45
46
|
// 需要指定 absWorkingDir 兼容 APP_ROOT 的情况
|
|
46
47
|
absWorkingDir: opts.config.cwd,
|
|
47
48
|
format: "esm",
|
|
@@ -55,17 +56,6 @@ async function build(opts) {
|
|
|
55
56
|
".ts": "ts",
|
|
56
57
|
".tsx": "tsx"
|
|
57
58
|
},
|
|
58
|
-
watch: !!opts.watch && {
|
|
59
|
-
onRebuild(err, result) {
|
|
60
|
-
if (err) {
|
|
61
|
-
import_utils.logger.error(`[icons] build failed: ${err}`);
|
|
62
|
-
} else {
|
|
63
|
-
if (opts.watch) {
|
|
64
|
-
opts.watch.onRebuildSuccess({ result });
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
59
|
// do I need this?
|
|
70
60
|
// incremental: true,
|
|
71
61
|
bundle: true,
|
|
@@ -83,9 +73,29 @@ async function build(opts) {
|
|
|
83
73
|
// if we resolve externals first, we will get { external: true }
|
|
84
74
|
(0, import_esbuildExternalPlugin.esbuildExternalPlugin)({ alias }),
|
|
85
75
|
(0, import_esbuildAliasPlugin.esbuildAliasPlugin)({ alias }),
|
|
76
|
+
(0, import_watchRebuild.esbuildWatchRebuildPlugin)({
|
|
77
|
+
onRebuild(err, result) {
|
|
78
|
+
if (err) {
|
|
79
|
+
import_utils.logger.error(`[icons] build failed: ${err}`);
|
|
80
|
+
} else {
|
|
81
|
+
if (opts.watch) {
|
|
82
|
+
opts.watch.onRebuildSuccess({ result });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}),
|
|
86
87
|
...opts.plugins || []
|
|
87
88
|
]
|
|
88
|
-
}
|
|
89
|
+
};
|
|
90
|
+
if (opts.watch) {
|
|
91
|
+
const ctx = await import_esbuild.default.context(buildOptions);
|
|
92
|
+
const result = await ctx.rebuild();
|
|
93
|
+
await ctx.watch();
|
|
94
|
+
return [result, ctx];
|
|
95
|
+
} else {
|
|
96
|
+
const result = await import_esbuild.default.build(buildOptions);
|
|
97
|
+
return [result, void 0];
|
|
98
|
+
}
|
|
89
99
|
}
|
|
90
100
|
// Annotate the CommonJS export names for ESM import in node:
|
|
91
101
|
0 && (module.exports = {
|
|
@@ -102,7 +102,7 @@ var prepare_default = (api) => {
|
|
|
102
102
|
entryPoints.push(import_path.default.join(api.paths.absTmpPath, tmpFilePath));
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
|
-
const buildResult = await build({
|
|
105
|
+
const [buildResult, ctx] = await build({
|
|
106
106
|
entryPoints,
|
|
107
107
|
watch: watch && {
|
|
108
108
|
async onRebuildSuccess({ result }) {
|
|
@@ -126,8 +126,7 @@ var prepare_default = (api) => {
|
|
|
126
126
|
});
|
|
127
127
|
if (watch) {
|
|
128
128
|
(0, import_watch.addUnWatch)(() => {
|
|
129
|
-
|
|
130
|
-
(_a2 = buildResult.stop) == null ? void 0 : _a2.call(buildResult);
|
|
129
|
+
ctx == null ? void 0 : ctx.dispose();
|
|
131
130
|
});
|
|
132
131
|
}
|
|
133
132
|
const fileImports = await parseProjectImportSpecifiers(buildResult);
|
|
@@ -33,6 +33,7 @@ __export(builder_exports, {
|
|
|
33
33
|
loader: () => loader
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(builder_exports);
|
|
36
|
+
var import_watchRebuild = require("@umijs/bundler-esbuild/dist/plugins/watchRebuild");
|
|
36
37
|
var import_esbuild = __toESM(require("@umijs/bundler-utils/compiled/esbuild"));
|
|
37
38
|
var import_utils = require("@umijs/utils");
|
|
38
39
|
var import_path = require("path");
|
|
@@ -55,7 +56,7 @@ async function build(opts) {
|
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
const alias = import_utils.aliasUtils.parseCircleAlias({ alias: api.config.alias });
|
|
58
|
-
|
|
59
|
+
const buildOptions = {
|
|
59
60
|
alias,
|
|
60
61
|
format: "cjs",
|
|
61
62
|
platform: "node",
|
|
@@ -63,15 +64,6 @@ async function build(opts) {
|
|
|
63
64
|
bundle: true,
|
|
64
65
|
logLevel: "silent",
|
|
65
66
|
inject: [(0, import_path.resolve)(api.paths.absTmpPath, "ssr/react-shim.js")],
|
|
66
|
-
watch: watch ? {
|
|
67
|
-
onRebuild(err) {
|
|
68
|
-
import_utils.logger.event("[SSR] Rebuilt");
|
|
69
|
-
delete require.cache[(0, import_utils2.absServerBuildPath)(api)];
|
|
70
|
-
if (err) {
|
|
71
|
-
import_utils.logger.error(err);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
} : false,
|
|
75
67
|
loader,
|
|
76
68
|
entryPoints: [(0, import_path.resolve)(api.paths.absTmpPath, "umi.server.ts")],
|
|
77
69
|
plugins: [
|
|
@@ -79,11 +71,27 @@ async function build(opts) {
|
|
|
79
71
|
(0, import_less_loader.lessLoader)({ cwd: api.cwd }),
|
|
80
72
|
(0, import_css_loader.cssLoader)({ cwd: api.cwd }),
|
|
81
73
|
(0, import_svg_loader.default)({ cwd: api.cwd }),
|
|
82
|
-
(0, import_assets_loader.assetsLoader)({ cwd: api.cwd })
|
|
74
|
+
(0, import_assets_loader.assetsLoader)({ cwd: api.cwd }),
|
|
75
|
+
(0, import_watchRebuild.esbuildWatchRebuildPlugin)({
|
|
76
|
+
onRebuild(err) {
|
|
77
|
+
import_utils.logger.event("[SSR] Rebuilt");
|
|
78
|
+
delete require.cache[(0, import_utils2.absServerBuildPath)(api)];
|
|
79
|
+
if (err) {
|
|
80
|
+
import_utils.logger.error(err);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
})
|
|
83
84
|
],
|
|
84
85
|
outfile: (0, import_utils2.absServerBuildPath)(api),
|
|
85
86
|
external: getExternal()
|
|
86
|
-
}
|
|
87
|
+
};
|
|
88
|
+
if (watch) {
|
|
89
|
+
const ctx = await import_esbuild.default.context(buildOptions);
|
|
90
|
+
await ctx.rebuild();
|
|
91
|
+
await ctx.watch();
|
|
92
|
+
} else {
|
|
93
|
+
await import_esbuild.default.build(buildOptions);
|
|
94
|
+
}
|
|
87
95
|
const diff = new Date().getTime() - now;
|
|
88
96
|
import_utils.logger.info(`[SSR] Compiled in ${diff}ms`);
|
|
89
97
|
}
|
|
@@ -48,7 +48,7 @@ var lessLoader = (opts) => {
|
|
|
48
48
|
const filePath = (0, import_path.join)(args.resolveDir, args.path);
|
|
49
49
|
return {
|
|
50
50
|
path: filePath,
|
|
51
|
-
watchFiles:
|
|
51
|
+
watchFiles: [filePath, ...getLessImports(filePath)]
|
|
52
52
|
};
|
|
53
53
|
});
|
|
54
54
|
build.onLoad({ filter: /\.less$/, namespace: "file" }, async (args) => {
|
|
@@ -370,11 +370,7 @@ export default function EmptyRoute() {
|
|
|
370
370
|
/"routeProps":"(routeProps\[.*?)"/g,
|
|
371
371
|
"...$1"
|
|
372
372
|
);
|
|
373
|
-
|
|
374
|
-
headerImports.push(`import routeProps from './routeProps';`);
|
|
375
|
-
} else {
|
|
376
|
-
headerImports.push(`import routeProps from './routeProps.js';`);
|
|
377
|
-
}
|
|
373
|
+
headerImports.push(`import routeProps from './routeProps';`);
|
|
378
374
|
headerImports.push(`
|
|
379
375
|
if (process.env.NODE_ENV === 'development') {
|
|
380
376
|
Object.entries(routeProps).forEach(([key, value]) => {
|
package/dist/index.js
CHANGED
|
@@ -83,6 +83,7 @@ var src_default = () => {
|
|
|
83
83
|
require.resolve("./features/webpack/webpack"),
|
|
84
84
|
require.resolve("./features/swc/swc"),
|
|
85
85
|
require.resolve("./features/ui/ui"),
|
|
86
|
+
require.resolve("./features/hmrGuardian/hmrGuardian"),
|
|
86
87
|
// commands
|
|
87
88
|
require.resolve("./commands/build"),
|
|
88
89
|
require.resolve("./commands/config/config"),
|
|
@@ -43,13 +43,13 @@ function setupRouteExportExtractor(opts) {
|
|
|
43
43
|
entryFile
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
|
-
api.onBeforeCompiler(
|
|
47
|
-
|
|
46
|
+
api.onBeforeCompiler(async () => {
|
|
47
|
+
await setupExportExtractBuilder({
|
|
48
48
|
api,
|
|
49
49
|
entryFile,
|
|
50
50
|
outFile
|
|
51
|
-
})
|
|
52
|
-
);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
53
|
}
|
|
54
54
|
function generateRouteExportTmpFile(opts) {
|
|
55
55
|
const { api, entryFile, propertyName } = opts;
|
|
@@ -80,12 +80,11 @@ ${defines.join("\n")}
|
|
|
80
80
|
}
|
|
81
81
|
async function setupExportExtractBuilder(opts) {
|
|
82
82
|
const { api, entryFile, outFile } = opts;
|
|
83
|
-
|
|
83
|
+
const buildOptions = {
|
|
84
84
|
format: "esm",
|
|
85
85
|
platform: "browser",
|
|
86
86
|
target: "esnext",
|
|
87
87
|
loader,
|
|
88
|
-
watch: api.env === "development" && {},
|
|
89
88
|
bundle: true,
|
|
90
89
|
logLevel: "error",
|
|
91
90
|
entryPoints: [(0, import_path.join)(api.paths.absTmpPath, entryFile)],
|
|
@@ -111,7 +110,14 @@ async function setupExportExtractBuilder(opts) {
|
|
|
111
110
|
}
|
|
112
111
|
}
|
|
113
112
|
]
|
|
114
|
-
}
|
|
113
|
+
};
|
|
114
|
+
if (api.env === "development") {
|
|
115
|
+
const ctx = await import_esbuild.default.context(buildOptions);
|
|
116
|
+
await ctx.rebuild();
|
|
117
|
+
await ctx.watch();
|
|
118
|
+
} else {
|
|
119
|
+
await import_esbuild.default.build(buildOptions);
|
|
120
|
+
}
|
|
115
121
|
}
|
|
116
122
|
var loader = {
|
|
117
123
|
".aac": "file",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umijs/preset-umi",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.70",
|
|
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",
|
|
@@ -37,20 +37,21 @@
|
|
|
37
37
|
"react-router": "6.3.0",
|
|
38
38
|
"react-router-dom": "6.3.0",
|
|
39
39
|
"regenerator-runtime": "0.13.11",
|
|
40
|
-
"@umijs/
|
|
41
|
-
"@umijs/
|
|
42
|
-
"@umijs/bundler-
|
|
43
|
-
"@umijs/bundler-
|
|
44
|
-
"@umijs/bundler-webpack": "4.0.
|
|
45
|
-
"@umijs/
|
|
46
|
-
"@umijs/
|
|
47
|
-
"@umijs/
|
|
48
|
-
"@umijs/plugin-run": "4.0.
|
|
49
|
-
"@umijs/
|
|
50
|
-
"@umijs/
|
|
51
|
-
"@umijs/
|
|
40
|
+
"@umijs/babel-preset-umi": "4.0.70",
|
|
41
|
+
"@umijs/ast": "4.0.70",
|
|
42
|
+
"@umijs/bundler-utils": "4.0.70",
|
|
43
|
+
"@umijs/bundler-esbuild": "4.0.70",
|
|
44
|
+
"@umijs/bundler-webpack": "4.0.70",
|
|
45
|
+
"@umijs/bundler-vite": "4.0.70",
|
|
46
|
+
"@umijs/core": "4.0.70",
|
|
47
|
+
"@umijs/did-you-know": "1.0.3",
|
|
48
|
+
"@umijs/plugin-run": "4.0.70",
|
|
49
|
+
"@umijs/mfsu": "4.0.70",
|
|
50
|
+
"@umijs/renderer-react": "4.0.70",
|
|
51
|
+
"@umijs/server": "4.0.70",
|
|
52
52
|
"@umijs/ui": "3.0.1",
|
|
53
|
-
"@umijs/
|
|
53
|
+
"@umijs/utils": "4.0.70",
|
|
54
|
+
"@umijs/zod2ts": "4.0.70"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"@manypkg/get-packages": "1.1.3",
|