@umijs/preset-umi 4.1.3 → 4.1.5

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.
@@ -73,7 +73,9 @@ async function getMarkupArgs(opts) {
73
73
  async modifyHTML(memo, args) {
74
74
  let $ = import_cheerio.default.load(memo, {
75
75
  // @ts-ignore
76
- decodeEntities: false
76
+ decodeEntities: false,
77
+ // reduce memory overhead, to avoid oom in antd site with `exportStatic: {}`
78
+ _useHtmlParser2: true
77
79
  });
78
80
  $ = await opts.api.applyPlugins({
79
81
  key: "modifyHTML",
@@ -55,7 +55,7 @@ var jest_default = (api) => {
55
55
  jest: jestMajorVersion,
56
56
  "@types/jest": jestMajorVersion,
57
57
  // we use `jest.config.ts` so jest needs ts and ts-node
58
- typescript: "^4",
58
+ typescript: "^5",
59
59
  "ts-node": "^10",
60
60
  "cross-env": "^7"
61
61
  };
@@ -40,12 +40,12 @@ var precommit_default = (api) => {
40
40
  const h = new import_utils2.GeneratorHelper(api);
41
41
  const cliName = api.appData.umi.cliName;
42
42
  h.addDevDeps({
43
- husky: "^8",
43
+ husky: "^9",
44
44
  prettier: "^2",
45
- typescript: "^4",
45
+ typescript: "^5",
46
46
  "lint-staged": "^13"
47
47
  });
48
- h.addScript("prepare", "husky install");
48
+ h.addScript("prepare", "husky");
49
49
  if (!(0, import_fs.existsSync)((0, import_path.join)(api.cwd, ".lintstagedrc")) && !api.pkg["lint-staged"]) {
50
50
  (0, import_fs.writeFileSync)(
51
51
  (0, import_path.join)(api.cwd, ".lintstagedrc"),
@@ -79,9 +79,6 @@ var precommit_default = (api) => {
79
79
  (0, import_fs.writeFileSync)(
80
80
  (0, import_path.join)(api.cwd, ".husky/commit-msg"),
81
81
  `
82
- #!/usr/bin/env sh
83
- . "$(dirname -- "$0")/_/husky.sh"
84
-
85
82
  npx --no-install ${cliName} verify-commit $1
86
83
  `.trimStart()
87
84
  );
@@ -94,9 +91,6 @@ npx --no-install ${cliName} verify-commit $1
94
91
  (0, import_fs.writeFileSync)(
95
92
  (0, import_path.join)(api.cwd, ".husky/pre-commit"),
96
93
  `
97
- #!/usr/bin/env sh
98
- . "$(dirname -- "$0")/_/husky.sh"
99
-
100
94
  npx --no-install lint-staged --quiet
101
95
  `.trimStart()
102
96
  );
@@ -51,7 +51,7 @@ var tsconfig_default = (api) => {
51
51
  }
52
52
  const reactMajorVersion = parseInt(reactVersion.split(".")[0], 10) || 18;
53
53
  h.addDevDeps({
54
- typescript: "^4",
54
+ typescript: "^5",
55
55
  "@types/react": `^${reactMajorVersion}`,
56
56
  "@types/react-dom": `^${reactMajorVersion}`
57
57
  });
@@ -56,11 +56,15 @@ async function checkDir(opts) {
56
56
  }
57
57
  const conflicts = Object.keys(varMap).filter((v) => varMap[v].length > 1).map((v) => `${v} (${varMap[v].join(", ")})`);
58
58
  if (conflicts.length) {
59
- throw new Error(
60
- `Found conflicts in esbuild helpers: ${conflicts.join(
61
- ", "
62
- )}, please set esbuildMinifyIIFE: true in your config file.`
59
+ import_utils.logger.fatal(
60
+ import_utils.chalk.yellow(
61
+ `Found conflicts in esbuild helpers: ${conflicts.join(", ")}`
62
+ )
63
63
  );
64
+ import_utils.logger.info(
65
+ `please set ${import_utils.chalk.blue("esbuildMinifyIIFE: true")} in your config file`
66
+ );
67
+ throw new Error(`Found conflicts in esbuild helpers.`);
64
68
  }
65
69
  import_utils.logger.info(`[esbuildHelperChecker] No conflicts found.`);
66
70
  }
@@ -98,6 +102,8 @@ var esbuildHelperChecker_default = (api) => {
98
102
  }
99
103
  });
100
104
  api.onBuildComplete(async ({ err }) => {
105
+ if (api.config.vite)
106
+ return;
101
107
  if (process.env.OKAM)
102
108
  return;
103
109
  if (err)
@@ -124,13 +124,16 @@ var exportStatic_default = (api) => {
124
124
  const { publicPath } = api.config;
125
125
  const htmlData = api.appData.exportHtmlData;
126
126
  const htmlFiles = [];
127
+ const { markupArgs: defaultMarkupArgs } = opts;
128
+ let asyncMarkupArgs;
127
129
  for (const { file, route, prerender } of htmlData) {
128
- let { markupArgs } = opts;
130
+ let markupArgs = defaultMarkupArgs;
129
131
  if (api.config.ssr && prerender) {
130
- markupArgs.scripts.forEach((script) => {
131
- if (script.src) {
132
- script.async = true;
133
- }
132
+ markupArgs = asyncMarkupArgs ?? (asyncMarkupArgs = {
133
+ ...markupArgs,
134
+ scripts: markupArgs.scripts.map(
135
+ (script) => script.src ? { ...script, async: true } : script
136
+ )
134
137
  });
135
138
  }
136
139
  if (publicPath.startsWith(".")) {
@@ -143,10 +143,20 @@ async function getRoutePathFilesMap(routes, fileChunksMap, opts) {
143
143
  var routePreloadOnLoad_default = (api) => {
144
144
  let routeChunkFilesMap;
145
145
  api.describe({
146
- enableBy: () => Boolean(api.pkg.name)
146
+ enableBy: () => {
147
+ var _a;
148
+ return (
149
+ // enable when package name available
150
+ // because preload script use package name as attribute prefix value
151
+ Boolean(api.pkg.name) && // vite mode is not supported currently
152
+ !api.config.vite && // mpa mode is unnecessary
153
+ !api.config.mpa && // only esm router needs this feature
154
+ ((_a = api.config.routeLoader) == null ? void 0 : _a.moduleType) === "esm"
155
+ );
156
+ }
147
157
  });
148
158
  api.addHTMLHeadScripts(() => {
149
- if (api.name === "build") {
159
+ if (api.name === "build" && routeChunkFilesMap) {
150
160
  return api.config.tern ? (
151
161
  // map mode
152
162
  [
@@ -200,15 +210,17 @@ var routePreloadOnLoad_default = (api) => {
200
210
  routeFileChunksMap,
201
211
  { resolver, absPagesPath: api.paths.absPagesPath }
202
212
  );
203
- routeChunkFilesMap = {
204
- p: api.pkg.name,
205
- b: api.appData.bundler,
206
- f: Object.entries(routeChunkFiles).sort((a, b) => a[1].index - b[1].index).map(([k, { id }]) => [k, id]),
207
- // sort similar to react-router@6
208
- r: (0, import_utils.lodash)(routeFilesMap).toPairs().sort(
209
- ([a], [b]) => computeRouteScore(a) - computeRouteScore(b)
210
- ).fromPairs().value()
211
- };
213
+ if (!import_utils.lodash.isEmpty(routeChunkFiles) && !import_utils.lodash.isEmpty(routeFilesMap)) {
214
+ routeChunkFilesMap = {
215
+ p: api.pkg.name,
216
+ b: api.appData.bundler,
217
+ f: Object.entries(routeChunkFiles).sort((a, b) => a[1].index - b[1].index).map(([k, { id }]) => [k, id]),
218
+ // sort similar to react-router@6
219
+ r: (0, import_utils.lodash)(routeFilesMap).toPairs().sort(
220
+ ([a], [b]) => computeRouteScore(a) - computeRouteScore(b)
221
+ ).fromPairs().value()
222
+ };
223
+ }
212
224
  }
213
225
  });
214
226
  };
@@ -51,9 +51,9 @@ var build2 = async (api, opts) => {
51
51
  ]);
52
52
  delete bundlerOpts.onBuildComplete;
53
53
  bundlerOpts.watch = api.env === "development";
54
- bundlerOpts.chainWebpack = async (memo) => {
54
+ bundlerOpts.chainWebpack = async (memo, opts2) => {
55
55
  const absOutputFile = (0, import_utils2.absServerBuildPath)(api);
56
- await oChainWebpack(memo);
56
+ await oChainWebpack(memo, { ...opts2, ssr: true });
57
57
  memo.entryPoints.clear();
58
58
  memo.entry("umi").add((0, import_path.resolve)(api.paths.absTmpPath, "umi.server.ts"));
59
59
  memo.target("node");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/preset-umi",
3
- "version": "4.1.3",
3
+ "version": "4.1.5",
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",
@@ -39,21 +39,21 @@
39
39
  "react-router": "6.3.0",
40
40
  "react-router-dom": "6.3.0",
41
41
  "regenerator-runtime": "0.13.11",
42
- "@umijs/ast": "4.1.3",
43
- "@umijs/babel-preset-umi": "4.1.3",
44
- "@umijs/bundler-esbuild": "4.1.3",
45
- "@umijs/bundler-utils": "4.1.3",
46
- "@umijs/bundler-vite": "4.1.3",
47
- "@umijs/bundler-webpack": "4.1.3",
48
- "@umijs/core": "4.1.3",
49
- "@umijs/mfsu": "4.1.3",
50
- "@umijs/plugin-run": "4.1.3",
51
- "@umijs/did-you-know": "1.0.3",
52
- "@umijs/server": "4.1.3",
53
- "@umijs/renderer-react": "4.1.3",
42
+ "@umijs/ast": "4.1.5",
43
+ "@umijs/bundler-utils": "4.1.5",
44
+ "@umijs/bundler-vite": "4.1.5",
45
+ "@umijs/core": "4.1.5",
46
+ "@umijs/bundler-esbuild": "4.1.5",
47
+ "@umijs/mfsu": "4.1.5",
48
+ "@umijs/plugin-run": "4.1.5",
49
+ "@umijs/server": "4.1.5",
50
+ "@umijs/babel-preset-umi": "4.1.5",
51
+ "@umijs/bundler-webpack": "4.1.5",
52
+ "@umijs/zod2ts": "4.1.5",
53
+ "@umijs/renderer-react": "4.1.5",
54
+ "@umijs/utils": "4.1.5",
54
55
  "@umijs/ui": "3.0.1",
55
- "@umijs/utils": "4.1.3",
56
- "@umijs/zod2ts": "4.1.3"
56
+ "@umijs/did-you-know": "1.0.3"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@manypkg/get-packages": "1.1.3",
@@ -67,7 +67,7 @@
67
67
  "multer": "1.4.4",
68
68
  "os-locale": "^6.0.2",
69
69
  "sirv": "2.0.2",
70
- "vite": "4.3.1"
70
+ "vite": "4.5.2"
71
71
  },
72
72
  "publishConfig": {
73
73
  "access": "public"