@umijs/bundler-utoopack 4.6.70 → 4.6.72

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.
@@ -147,10 +147,8 @@ function handleMessage(payload) {
147
147
  switch (payload.action) {
148
148
  case ACTIONS.TURBOPACK_CONNECTED:
149
149
  isSocketConnected = true;
150
- console.log('[utoopack] connected.');
151
150
  break;
152
151
  case ACTIONS.BUILDING:
153
- console.log('[utoopack] compiling...');
154
152
  break;
155
153
  case ACTIONS.SYNC:
156
154
  case ACTIONS.BUILT:
package/dist/config.js CHANGED
@@ -587,7 +587,10 @@ function getUserUtoopackConfig(utoopackConfig = {}, opts) {
587
587
  }
588
588
  return userUtoopackConfig;
589
589
  }
590
- function getDefaultPersistentCaching() {
590
+ function getDefaultPersistentCaching(env) {
591
+ if (env === "production") {
592
+ return false;
593
+ }
591
594
  return process.platform !== "win32";
592
595
  }
593
596
  async function getProdUtooPackConfig(rawOpts) {
@@ -677,6 +680,7 @@ async function getProdUtooPackConfig(rawOpts) {
677
680
  emotion
678
681
  },
679
682
  define,
683
+ persistentCaching: getDefaultPersistentCaching("production"),
680
684
  nodePolyfill: true,
681
685
  pluginRuntimeStrategy: "childProcesses",
682
686
  mdx: !!mdx,
@@ -831,7 +835,7 @@ async function getDevUtooPackConfig(rawOpts) {
831
835
  define,
832
836
  stats: true,
833
837
  // Windows persistent cache restore is currently unstable in utoopack dev.
834
- persistentCaching: getDefaultPersistentCaching(),
838
+ persistentCaching: getDefaultPersistentCaching("development"),
835
839
  nodePolyfill: true,
836
840
  pluginRuntimeStrategy: "childProcesses",
837
841
  mdx: !!mdx,
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.70",
3
+ "version": "4.6.72",
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.19",
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.70",
30
- "@umijs/bundler-webpack": "4.6.70"
29
+ "@umijs/bundler-utils": "4.6.72",
30
+ "@umijs/bundler-webpack": "4.6.72"
31
31
  },
32
32
  "publishConfig": {
33
33
  "access": "public"