@umijs/bundler-utoopack 4.6.71 → 4.6.73

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/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { IOpts } from './types';
3
3
  export { findRootDir } from '@utoo/pack';
4
4
  export * from './config';
5
5
  export type { IUtoopackUserConfig } from './types';
6
+ export declare function isUtoopackProxyStartupError(error: any, utooServePort: number): boolean;
6
7
  export declare function build(opts: IOpts): Promise<any>;
7
8
  export declare function buildSSR(opts: IOpts & {
8
9
  serverBuildPath: string;
package/dist/index.js CHANGED
@@ -33,7 +33,8 @@ __export(src_exports, {
33
33
  build: () => build,
34
34
  buildSSR: () => buildSSR,
35
35
  dev: () => dev,
36
- findRootDir: () => import_pack.findRootDir
36
+ findRootDir: () => import_pack.findRootDir,
37
+ isUtoopackProxyStartupError: () => isUtoopackProxyStartupError
37
38
  });
38
39
  module.exports = __toCommonJS(src_exports);
39
40
  var import_bundler_utils = require("@umijs/bundler-utils");
@@ -47,6 +48,9 @@ var import_config = require("./config");
47
48
  var import_util = require("./util");
48
49
  var import_pack = require("@utoo/pack");
49
50
  __reExport(src_exports, require("./config"), module.exports);
51
+ function isUtoopackProxyStartupError(error, utooServePort) {
52
+ return (error == null ? void 0 : error.code) === "ECONNREFUSED" && Number(error == null ? void 0 : error.port) === utooServePort && (!(error == null ? void 0 : error.address) || error.address === "127.0.0.1");
53
+ }
50
54
  function getUtoopackRootDir(cwd, utoopackConfig, findRootDir2) {
51
55
  const normalizedCwd = (0, import_config.normalizeUtoopackPath)(cwd);
52
56
  if (typeof (utoopackConfig == null ? void 0 : utoopackConfig.root) === "string") {
@@ -229,6 +233,23 @@ async function dev(opts) {
229
233
  },
230
234
  skipToNextHandlerFilter: function(proxyRes) {
231
235
  return proxyRes.statusCode !== 200 && proxyRes.statusCode !== 304;
236
+ },
237
+ proxyErrorHandler: function(err, res, next) {
238
+ if (isUtoopackProxyStartupError(err, utooServePort)) {
239
+ if (!res.headersSent) {
240
+ res.writeHead(503, { "Content-Type": "text/plain" });
241
+ }
242
+ return res.end("Utoopack dev server is starting.");
243
+ }
244
+ if ((err == null ? void 0 : err.code) === "ECONNRESET") {
245
+ res.setHeader(
246
+ "X-Timeout-Reason",
247
+ "express-http-proxy reset the request."
248
+ );
249
+ res.writeHead(504, { "Content-Type": "text/plain" });
250
+ return res.end();
251
+ }
252
+ return next(err);
232
253
  }
233
254
  })
234
255
  );
@@ -335,5 +356,6 @@ async function dev(opts) {
335
356
  buildSSR,
336
357
  dev,
337
358
  findRootDir,
359
+ isUtoopackProxyStartupError,
338
360
  ...require("./config")
339
361
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/bundler-utoopack",
3
- "version": "4.6.71",
3
+ "version": "4.6.73",
4
4
  "description": "@umijs/bundler-utoopack",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,7 +14,7 @@
14
14
  "dist"
15
15
  ],
16
16
  "dependencies": {
17
- "@utoo/pack": "1.4.18",
17
+ "@utoo/pack": "1.4.20",
18
18
  "compression": "^1.7.4",
19
19
  "connect-history-api-fallback": "^2.0.0",
20
20
  "cors": "^2.8.5",
@@ -26,8 +26,8 @@
26
26
  "resolve-url-loader": "5.0.0",
27
27
  "sass": "1.54.0",
28
28
  "sass-loader": "13.2.0",
29
- "@umijs/bundler-utils": "4.6.71",
30
- "@umijs/bundler-webpack": "4.6.71"
29
+ "@umijs/bundler-webpack": "4.6.73",
30
+ "@umijs/bundler-utils": "4.6.73"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"