@umijs/preset-umi 4.0.69 → 4.0.71

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.
@@ -130,6 +130,9 @@ umi build --clean
130
130
  let stats;
131
131
  if (api.config.vite) {
132
132
  stats = await bundlerVite.build(opts);
133
+ } else if (process.env.OKAM) {
134
+ const { build } = require(process.env.OKAM);
135
+ stats = await build(opts);
133
136
  } else {
134
137
  const absOutputPath = (0, import_path.resolve)(
135
138
  opts.cwd,
@@ -73,7 +73,7 @@ var dev_config_default = (api) => {
73
73
  }
74
74
  });
75
75
  const opts = {
76
- config: api.config,
76
+ config: { ...api.config, forkTSChecker: false },
77
77
  pkg: api.pkg,
78
78
  cwd: api.cwd,
79
79
  rootDir: process.cwd(),
@@ -43,9 +43,9 @@ var prettier_default = (api) => {
43
43
  fn: async () => {
44
44
  const h = new import_utils2.GeneratorHelper(api);
45
45
  h.addDevDeps({
46
- prettier: "^2",
47
- "prettier-plugin-organize-imports": "^2",
48
- "prettier-plugin-packagejson": "^2"
46
+ prettier: "^2.8.8",
47
+ "prettier-plugin-organize-imports": "^3.2.2",
48
+ "prettier-plugin-packagejson": "^2.4.3"
49
49
  });
50
50
  (0, import_fs.writeFileSync)(
51
51
  (0, import_path.join)(api.cwd, ".prettierrc"),
@@ -37,6 +37,7 @@ var lint_default = (api) => {
37
37
  api.registerCommand({
38
38
  name: "lint",
39
39
  description: "lint source code using eslint and stylelint",
40
+ configResolveMode: "loose",
40
41
  details: `
41
42
  umi lint
42
43
 
@@ -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.build({
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: [(0, import_utils2.esbuildIgnorePathPrefixPlugin)()],
54
- watch: {
55
- onRebuild(error) {
56
- if (error)
57
- import_utils.logger.error("Compile api routes failed: ", error);
58
- Object.keys(require.cache).forEach((modulePath) => {
59
- if (modulePath.startsWith((0, import_path.join)(api.paths.cwd, import_constants.OUTPUT_PATH)))
60
- delete require.cache[modulePath];
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 = {});
@@ -98,6 +98,8 @@ var esbuildHelperChecker_default = (api) => {
98
98
  }
99
99
  });
100
100
  api.onBuildComplete(async ({ err }) => {
101
+ if (process.env.OKAM)
102
+ return;
101
103
  if (err)
102
104
  return;
103
105
  const jsMinifier = api.config.jsMinifier || "esbuild";
@@ -0,0 +1,7 @@
1
+ export declare function defaultRenameVisitor(): {
2
+ visitor: {
3
+ ExportDefaultDeclaration: {
4
+ enter(path: any, state: any): void;
5
+ };
6
+ };
7
+ };
@@ -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,2 @@
1
+ import { IApi } from '../../types';
2
+ export default function (api: IApi): void;
@@ -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 = {});
@@ -323,7 +323,7 @@ interface IUmiIconProps extends React.SVGAttributes<SVGElement> {
323
323
  }
324
324
 
325
325
  export const Icon = React.forwardRef<HTMLSpanElement, IUmiIconProps>((props, ref) => {
326
- const { icon, hover, style, className = '' , rotate, flip, ...extraProps } = props;
326
+ const { icon, hover, style, className = '' , rotate, spin, flip, ...extraProps } = props;
327
327
  const iconName = normalizeIconName(alias[icon] || icon);
328
328
  const Component = iconsMap[iconName];
329
329
  if (!Component) {
@@ -331,7 +331,7 @@ export const Icon = React.forwardRef<HTMLSpanElement, IUmiIconProps>((props, ref
331
331
  return null;
332
332
  }
333
333
  const HoverComponent = hover ? iconsMap[normalizeIconName(alias[hover] || hover)] : null;
334
- const cls = props.spin ? 'umiIconLoadingCircle' : undefined;
334
+ const cls = spin ? 'umiIconLoadingCircle' : undefined;
335
335
  const svgStyle = {};
336
336
  const transform: string[] = [];
337
337
  if (rotate) {
@@ -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<esbuild.BuildResult & {
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
- return await import_esbuild.default.build({
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
- var _a2;
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
- await import_esbuild.default.build({
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: !!build.initialOptions.watch ? [filePath, ...getLessImports(filePath)] : void 0
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
- if (process.env.NODE_ENV === "test") {
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]) => {
@@ -479,13 +475,15 @@ if (process.env.NODE_ENV === 'development') {
479
475
  });
480
476
  }
481
477
  if (api.appData.framework === "react") {
482
- const historyPath = api.config.historyWithQuery ? (0, import_utils.winPath)((0, import_path.dirname)(require.resolve("@umijs/history/package.json"))) : rendererPath;
478
+ const { historyWithQuery, reactRouter5Compat } = api.config;
479
+ const historyPath = historyWithQuery ? (0, import_utils.winPath)((0, import_path.dirname)(require.resolve("@umijs/history/package.json"))) : rendererPath;
483
480
  api.writeTmpFile({
484
481
  noPluginDir: true,
485
482
  path: "core/history.ts",
486
483
  tplPath: (0, import_path.join)(import_constants.TEMPLATES_DIR, "history.tpl"),
487
484
  context: {
488
- historyPath
485
+ historyPath,
486
+ reactRouter5Compat
489
487
  }
490
488
  });
491
489
  api.writeTmpFile({
@@ -493,7 +491,8 @@ if (process.env.NODE_ENV === 'development') {
493
491
  path: "core/historyIntelli.ts",
494
492
  tplPath: (0, import_path.join)(import_constants.TEMPLATES_DIR, "historyIntelli.tpl"),
495
493
  context: {
496
- historyPath
494
+ historyPath,
495
+ reactRouter5Compat
497
496
  }
498
497
  });
499
498
  }
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"),
@@ -1,4 +1,4 @@
1
- import type { IApi } from 'umi';
1
+ import type { IApi } from '../types';
2
2
  interface IRouteExportExtractor {
3
3
  api: IApi;
4
4
  entryFile: string;
@@ -43,13 +43,13 @@ function setupRouteExportExtractor(opts) {
43
43
  entryFile
44
44
  });
45
45
  });
46
- api.onBeforeCompiler(
47
- async () => await setupExportExtractBuilder({
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
- await import_esbuild.default.build({
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.69",
3
+ "version": "4.0.71",
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/ast": "4.0.69",
41
- "@umijs/babel-preset-umi": "4.0.69",
42
- "@umijs/bundler-vite": "4.0.69",
43
- "@umijs/bundler-utils": "4.0.69",
44
- "@umijs/bundler-webpack": "4.0.69",
45
- "@umijs/core": "4.0.69",
46
- "@umijs/mfsu": "4.0.69",
47
- "@umijs/renderer-react": "4.0.69",
48
- "@umijs/plugin-run": "4.0.69",
49
- "@umijs/server": "4.0.69",
50
- "@umijs/zod2ts": "4.0.69",
51
- "@umijs/utils": "4.0.69",
52
- "@umijs/ui": "3.0.1",
53
- "@umijs/did-you-know": "1.0.3"
40
+ "@umijs/bundler-esbuild": "4.0.71",
41
+ "@umijs/bundler-utils": "4.0.71",
42
+ "@umijs/ast": "4.0.71",
43
+ "@umijs/bundler-vite": "4.0.71",
44
+ "@umijs/babel-preset-umi": "4.0.71",
45
+ "@umijs/bundler-webpack": "4.0.71",
46
+ "@umijs/core": "4.0.71",
47
+ "@umijs/did-you-know": "1.0.3",
48
+ "@umijs/mfsu": "4.0.71",
49
+ "@umijs/plugin-run": "4.0.71",
50
+ "@umijs/renderer-react": "4.0.71",
51
+ "@umijs/server": "4.0.71",
52
+ "@umijs/utils": "4.0.71",
53
+ "@umijs/zod2ts": "4.0.71",
54
+ "@umijs/ui": "3.0.1"
54
55
  },
55
56
  "devDependencies": {
56
57
  "@manypkg/get-packages": "1.1.3",
@@ -16,6 +16,12 @@ export function createHistory(opts: any) {
16
16
  basename = opts.basename;
17
17
  }
18
18
 
19
+ {{#reactRouter5Compat}}
20
+ h.goBack = function() {
21
+ h.back();
22
+ };
23
+ {{/reactRouter5Compat}}
24
+
19
25
  history = {
20
26
  ...h,
21
27
  push(to, state) {
@@ -71,9 +71,17 @@ type UmiTo = UmiPathname | UmiPath
71
71
 
72
72
  type UmiPush = (to: UmiTo, state?: any) => void
73
73
  type UmiReplace = (to: UmiTo, state?: any) => void
74
+ {{#reactRouter5Compat}}
75
+ type UmiGoBack = () => void
76
+ {{/reactRouter5Compat}}
77
+
78
+
74
79
  export interface UmiHistory extends History {
75
80
  push: UmiPush
76
81
  replace: UmiReplace
82
+ {{#reactRouter5Compat}}
83
+ goBack: UmiGoBack
84
+ {{/reactRouter5Compat}}
77
85
  }
78
86
 
79
87
  // --- type utils ---