@umijs/preset-umi 4.3.35 → 4.4.0

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.
@@ -68,7 +68,9 @@ async function getPreRenderedHTML(api, htmlTpl, path) {
68
68
  exportStatic: { ignorePreRenderError = false },
69
69
  base
70
70
  } = api.config;
71
- markupRender ?? (markupRender = require((0, import_utils2.absServerBuildPath)(api))._markupGenerator);
71
+ await import((0, import_utils2.absServerBuildPath)(api)).then(
72
+ (res) => markupRender ?? (markupRender = res.default._markupGenerator)
73
+ );
72
74
  try {
73
75
  const location = `${base.endsWith("/") ? base.slice(0, -1) : base}${path}`;
74
76
  const html = await markupRender(location);
@@ -22,49 +22,28 @@ __export(routePrefetch_exports, {
22
22
  default: () => routePrefetch_default
23
23
  });
24
24
  module.exports = __toCommonJS(routePrefetch_exports);
25
- var import_fs = require("fs");
26
- var import_path = require("path");
27
25
  var routePrefetch_default = (api) => {
28
26
  api.describe({
29
27
  config: {
30
28
  schema({ zod }) {
31
- return zod.object({});
29
+ return zod.object({
30
+ defaultPrefetch: zod.enum(["none", "intent", "render", "viewport"]).optional(),
31
+ defaultPrefetchTimeout: zod.number().optional()
32
+ });
32
33
  }
33
34
  },
34
35
  enableBy: api.EnableBy.config
35
36
  });
36
- api.onCheck(() => {
37
- if (!api.config.manifest) {
38
- throw new Error("You must enable manifest to use routePrefetch feature!");
39
- }
40
- });
41
- api.onBuildComplete(() => {
42
- const manifest = (0, import_fs.readFileSync)(
43
- (0, import_path.join)(
44
- api.paths.absOutputPath,
45
- api.config.manifest.fileName || "asset-manifest.json"
46
- ),
47
- "utf-8"
48
- );
49
- const manifestObj = JSON.parse(manifest);
50
- const umiJsFileKey = Object.keys(manifestObj).find(
51
- (key) => key.match(/^umi(.*)\.js$/)
52
- );
53
- if (!umiJsFileKey) {
54
- throw new Error("Cannot find umi.js in manifest.json");
55
- }
56
- const umiJsFileName = manifestObj[umiJsFileKey].replace(
57
- new RegExp("^" + api.config.publicPath),
58
- ""
59
- );
60
- const umiJsFile = (0, import_fs.readFileSync)(
61
- (0, import_path.join)(api.paths.absOutputPath, umiJsFileName),
62
- "utf-8"
63
- );
64
- const prependJS = `window.__umi_manifest__ = ` + manifest + ";";
65
- (0, import_fs.writeFileSync)(
66
- (0, import_path.join)(api.paths.absOutputPath, umiJsFileName),
67
- prependJS + umiJsFile
68
- );
37
+ api.addEntryCodeAhead(() => {
38
+ return `if(typeof window !== 'undefined') window.__umi_route_prefetch__ =
39
+ {
40
+ defaultPrefetch: ${JSON.stringify(
41
+ api.config.routePrefetch.defaultPrefetch || "none"
42
+ )},
43
+ defaultPrefetchTimeout: ${JSON.stringify(
44
+ api.config.routePrefetch.defaultPrefetchTimeout || 50
45
+ )},
46
+ };
47
+ `;
69
48
  });
70
49
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/preset-umi",
3
- "version": "4.3.35",
3
+ "version": "4.4.0",
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",
@@ -21,7 +21,7 @@
21
21
  "dependencies": {
22
22
  "@iconify/utils": "2.1.1",
23
23
  "@svgr/core": "6.5.1",
24
- "@umijs/bundler-mako": "0.9.7",
24
+ "@umijs/bundler-mako": "0.9.9",
25
25
  "@umijs/es-module-parser": "0.0.7",
26
26
  "@umijs/history": "5.3.1",
27
27
  "babel-plugin-dynamic-import-node": "2.3.3",
@@ -41,21 +41,21 @@
41
41
  "react-router": "6.3.0",
42
42
  "react-router-dom": "6.3.0",
43
43
  "regenerator-runtime": "0.13.11",
44
- "@umijs/ast": "4.3.35",
45
- "@umijs/bundler-vite": "4.3.35",
46
- "@umijs/babel-preset-umi": "4.3.35",
47
- "@umijs/bundler-webpack": "4.3.35",
48
- "@umijs/core": "4.3.35",
49
- "@umijs/bundler-utils": "4.3.35",
50
- "@umijs/mfsu": "4.3.35",
51
- "@umijs/plugin-run": "4.3.35",
52
- "@umijs/server": "4.3.35",
53
- "@umijs/renderer-react": "4.3.35",
54
- "@umijs/utils": "4.3.35",
55
- "@umijs/bundler-esbuild": "4.3.35",
56
- "@umijs/zod2ts": "4.3.35",
57
- "@umijs/ui": "3.0.1",
58
- "@umijs/did-you-know": "1.0.3"
44
+ "@umijs/ast": "4.4.0",
45
+ "@umijs/babel-preset-umi": "4.4.0",
46
+ "@umijs/bundler-utils": "4.4.0",
47
+ "@umijs/bundler-webpack": "4.4.0",
48
+ "@umijs/core": "4.4.0",
49
+ "@umijs/mfsu": "4.4.0",
50
+ "@umijs/bundler-vite": "4.4.0",
51
+ "@umijs/bundler-esbuild": "4.4.0",
52
+ "@umijs/did-you-know": "1.0.3",
53
+ "@umijs/plugin-run": "4.4.0",
54
+ "@umijs/renderer-react": "4.4.0",
55
+ "@umijs/server": "4.4.0",
56
+ "@umijs/utils": "4.4.0",
57
+ "@umijs/zod2ts": "4.4.0",
58
+ "@umijs/ui": "3.0.1"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@manypkg/get-packages": "1.1.3",