@umijs/preset-umi 4.0.75 → 4.0.77

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.
@@ -93,7 +93,8 @@ var configPlugins_default = (api) => {
93
93
  history: { type: "browser" },
94
94
  svgr: {},
95
95
  ignoreMomentLocale: true,
96
- mfsu: { strategy: "eager" }
96
+ mfsu: { strategy: "eager" },
97
+ routeLoader: { moduleType: "esm" }
97
98
  };
98
99
  const bundleSchemas = api.config.vite ? (0, import_schema.getSchemas)() : (0, import_schema2.getSchemas)();
99
100
  const extraSchemas = (0, import_schema3.getSchemas)();
@@ -91,6 +91,9 @@ function getSchemas() {
91
91
  message: 'publicPath must be "auto" or end with /'
92
92
  }),
93
93
  reactRouter5Compat: ({ zod }) => zod.union([zod.boolean(), zod.object({})]),
94
+ routeLoader: ({ zod }) => zod.object({
95
+ moduleType: zod.enum(["esm", "cjs"])
96
+ }),
94
97
  routes: ({ zod }) => {
95
98
  const routeSchema = zod.union([
96
99
  zod.object({
@@ -65,6 +65,9 @@ function getExportHtmlData(routes) {
65
65
  }
66
66
  async function getPreRenderedHTML(api, htmlTpl, path) {
67
67
  var _a, _b;
68
+ const {
69
+ exportStatic: { ignorePreRenderError = false }
70
+ } = api.config;
68
71
  markupRender ?? (markupRender = require((0, import_utils2.absServerBuildPath)(api))._markupGenerator);
69
72
  try {
70
73
  const markup = await markupRender(path);
@@ -80,6 +83,9 @@ async function getPreRenderedHTML(api, htmlTpl, path) {
80
83
  import_utils.logger.info(`Pre-render for ${path}`);
81
84
  } catch (err) {
82
85
  import_utils.logger.error(`Pre-render ${path} error: ${err}`);
86
+ if (!ignorePreRenderError) {
87
+ throw err;
88
+ }
83
89
  }
84
90
  return htmlTpl;
85
91
  }
@@ -105,7 +111,8 @@ var exportStatic_default = (api) => {
105
111
  extraRoutePaths: zod.union([
106
112
  zod.function(),
107
113
  zod.array(zod.string())
108
- ])
114
+ ]),
115
+ ignorePreRenderError: zod.boolean().default(false)
109
116
  }).deepPartial()
110
117
  },
111
118
  enableBy: api.EnableBy.config
@@ -180,6 +180,7 @@ async function getRoutes(opts) {
180
180
  }
181
181
  async function getRouteComponents(opts) {
182
182
  const imports = Object.keys(opts.routes).map((key) => {
183
+ var _a;
183
184
  const useSuspense = opts.api.appData.framework === "react" ? true : false;
184
185
  const route = opts.routes[key];
185
186
  if (!route.file) {
@@ -209,6 +210,11 @@ async function getRouteComponents(opts) {
209
210
  if (process.env.NODE_ENV === "test") {
210
211
  return `'${key}': require('${(0, import_utils.winPath)(path)}').default,`;
211
212
  }
213
+ if (((_a = opts.api.config.routeLoader) == null ? void 0 : _a.moduleType) === "cjs") {
214
+ return useSuspense ? `'${key}': React.lazy(() => Promise.resolve(require('${(0, import_utils.winPath)(
215
+ path
216
+ )}'))),` : `'${key}': () => Promise.resolve(require('${(0, import_utils.winPath)(path)}')),`;
217
+ }
212
218
  return useSuspense ? `'${key}': React.lazy(() => import(/* webpackChunkName: "${webpackChunkName}" */'${(0, import_utils.winPath)(
213
219
  path
214
220
  )}')),` : `'${key}': () => import(/* webpackChunkName: "${webpackChunkName}" */'${(0, import_utils.winPath)(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/preset-umi",
3
- "version": "4.0.75",
3
+ "version": "4.0.77",
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,21 +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.75",
41
- "@umijs/babel-preset-umi": "4.0.75",
42
- "@umijs/bundler-utils": "4.0.75",
43
- "@umijs/bundler-esbuild": "4.0.75",
44
- "@umijs/bundler-webpack": "4.0.75",
45
- "@umijs/bundler-vite": "4.0.75",
46
- "@umijs/mfsu": "4.0.75",
47
- "@umijs/core": "4.0.75",
48
- "@umijs/plugin-run": "4.0.75",
49
- "@umijs/server": "4.0.75",
50
- "@umijs/renderer-react": "4.0.75",
51
- "@umijs/utils": "4.0.75",
52
- "@umijs/zod2ts": "4.0.75",
40
+ "@umijs/ast": "4.0.77",
41
+ "@umijs/babel-preset-umi": "4.0.77",
42
+ "@umijs/bundler-esbuild": "4.0.77",
43
+ "@umijs/bundler-utils": "4.0.77",
44
+ "@umijs/bundler-vite": "4.0.77",
45
+ "@umijs/bundler-webpack": "4.0.77",
46
+ "@umijs/core": "4.0.77",
47
+ "@umijs/mfsu": "4.0.77",
53
48
  "@umijs/did-you-know": "1.0.3",
54
- "@umijs/ui": "3.0.1"
49
+ "@umijs/plugin-run": "4.0.77",
50
+ "@umijs/renderer-react": "4.0.77",
51
+ "@umijs/server": "4.0.77",
52
+ "@umijs/ui": "3.0.1",
53
+ "@umijs/utils": "4.0.77",
54
+ "@umijs/zod2ts": "4.0.77"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@manypkg/get-packages": "1.1.3",