@utoo/pack 1.3.2-alpha.0 → 1.3.3-alpha.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.
@@ -17,6 +17,7 @@ const findRoot_1 = require("../utils/findRoot");
17
17
  const getInitialAssets_1 = require("../utils/getInitialAssets");
18
18
  const htmlEntry_1 = require("../utils/htmlEntry");
19
19
  const normalize_path_1 = require("../utils/normalize-path");
20
+ const runtimePluginStratety_1 = require("../utils/runtimePluginStratety");
20
21
  const validateEntry_1 = require("../utils/validateEntry");
21
22
  const xcodeProfile_1 = require("../utils/xcodeProfile");
22
23
  function build(options, projectPath, rootPath) {
@@ -28,7 +29,7 @@ function build(options, projectPath, rootPath) {
28
29
  return buildInternal(bundleOptions, projectPath, rootPath);
29
30
  }
30
31
  async function buildInternal(bundleOptions, projectPath, rootPath) {
31
- var _a, _b, _c, _d, _e, _f;
32
+ var _a, _b, _c, _d, _e, _f, _g, _h;
32
33
  (0, common_1.blockStdout)();
33
34
  if (process.env.XCODE_PROFILE) {
34
35
  await (0, xcodeProfile_1.xcodeProfilingReady)();
@@ -49,12 +50,13 @@ async function buildInternal(bundleOptions, projectPath, rootPath) {
49
50
  stats: Boolean(process.env.ANALYZE) ||
50
51
  bundleOptions.config.stats ||
51
52
  bundleOptions.config.entry.some((e) => !!e.html),
53
+ pluginRuntimeStrategy: (_d = (_c = bundleOptions === null || bundleOptions === void 0 ? void 0 : bundleOptions.config) === null || _c === void 0 ? void 0 : _c.pluginRuntimeStrategy) !== null && _d !== void 0 ? _d : ((0, runtimePluginStratety_1.useWorkerThreads)() ? "workerThreads" : "childProcesses"),
52
54
  },
53
55
  projectPath: (0, normalize_path_1.normalizePath)(resolvedProjectPath),
54
56
  rootPath: rootPath || projectPath || process.cwd(),
55
57
  packPath: (0, common_1.getPackPath)(),
56
58
  }, {
57
- persistentCaching: (_c = bundleOptions.config.persistentCaching) !== null && _c !== void 0 ? _c : false,
59
+ persistentCaching: (_e = bundleOptions.config.persistentCaching) !== null && _e !== void 0 ? _e : false,
58
60
  });
59
61
  const entrypoints = await project.writeAllEntrypointsToDisk();
60
62
  (0, pack_shared_1.handleIssues)(entrypoints.issues);
@@ -70,20 +72,20 @@ async function buildInternal(bundleOptions, projectPath, rootPath) {
70
72
  ];
71
73
  if (htmlConfigs.length > 0) {
72
74
  const assets = { js: [], css: [] };
73
- const outputDir = ((_d = bundleOptions.config.output) === null || _d === void 0 ? void 0 : _d.path) || path_1.default.join(process.cwd(), "dist");
75
+ const outputDir = ((_f = bundleOptions.config.output) === null || _f === void 0 ? void 0 : _f.path) || path_1.default.join(process.cwd(), "dist");
74
76
  if (assets.js.length === 0 && assets.css.length === 0) {
75
77
  const discovered = (0, getInitialAssets_1.getInitialAssetsFromStats)(outputDir);
76
78
  assets.js.push(...discovered.js);
77
79
  assets.css.push(...discovered.css);
78
80
  }
79
- const publicPath = (_e = bundleOptions.config.output) === null || _e === void 0 ? void 0 : _e.publicPath;
81
+ const publicPath = (_g = bundleOptions.config.output) === null || _g === void 0 ? void 0 : _g.publicPath;
80
82
  for (const config of htmlConfigs) {
81
83
  const plugin = new HtmlPlugin_1.HtmlPlugin(config);
82
84
  await plugin.generate(outputDir, assets, publicPath);
83
85
  }
84
86
  }
85
87
  if (process.env.ANALYZE) {
86
- await analyzeBundle(((_f = bundleOptions.config.output) === null || _f === void 0 ? void 0 : _f.path) || "dist");
88
+ await analyzeBundle(((_h = bundleOptions.config.output) === null || _h === void 0 ? void 0 : _h.path) || "dist");
87
89
  }
88
90
  await project.shutdown();
89
91
  // TODO: Maybe run tasks in worker is a better way, see
@@ -18,7 +18,6 @@ const https_1 = __importDefault(require("https"));
18
18
  const path_1 = __importDefault(require("path"));
19
19
  const webpackCompat_1 = require("../config/webpackCompat");
20
20
  const hmr_1 = require("../core/hmr");
21
- const proxy_hono_1 = require("../core/proxy-hono");
22
21
  const common_1 = require("../utils/common");
23
22
  const findRoot_1 = require("../utils/findRoot");
24
23
  const mkcert_1 = require("../utils/mkcert");
@@ -139,7 +138,7 @@ function serve(options, projectPath, rootPath, serverOptions) {
139
138
  }
140
139
  const HMR_PATH = "/turbopack-hmr";
141
140
  async function runDev(options, projectPath, rootPath, serverOptions) {
142
- var _a, _b, _d, _e, _f, _g;
141
+ var _a, _b, _d, _e;
143
142
  (0, common_1.blockStdout)();
144
143
  process.title = "utoopack-dev-server";
145
144
  if (process.env.XCODE_PROFILE) {
@@ -191,10 +190,6 @@ async function runDev(options, projectPath, rootPath, serverOptions) {
191
190
  console.error("HMR WebSocket error", err);
192
191
  },
193
192
  })));
194
- const proxyRules = (_g = (_f = bundleOptions.config) === null || _f === void 0 ? void 0 : _f.devServer) === null || _g === void 0 ? void 0 : _g.proxy;
195
- if (proxyRules && proxyRules.length > 0) {
196
- app.use("*", (0, proxy_hono_1.createHttpProxyMiddleware)(proxyRules));
197
- }
198
193
  // GET handles HEAD automatically in Hono; serveStatic serves both
199
194
  app.get("/*", (0, serve_static_1.serveStatic)({
200
195
  root: distRoot,
package/cjs/core/hmr.js CHANGED
@@ -14,6 +14,7 @@ const common_1 = require("../utils/common");
14
14
  const getInitialAssets_1 = require("../utils/getInitialAssets");
15
15
  const htmlEntry_1 = require("../utils/htmlEntry");
16
16
  const normalize_path_1 = require("../utils/normalize-path");
17
+ const runtimePluginStratety_1 = require("../utils/runtimePluginStratety");
17
18
  const validateEntry_1 = require("../utils/validateEntry");
18
19
  const project_1 = require("./project");
19
20
  const wsServer = new ws_1.WebSocketServer({ noServer: true });
@@ -23,7 +24,7 @@ var pack_shared_2 = require("@utoo/pack-shared");
23
24
  Object.defineProperty(exports, "HMR_ACTIONS_SENT_TO_BROWSER", { enumerable: true, get: function () { return pack_shared_2.HMR_ACTIONS_SENT_TO_BROWSER; } });
24
25
  exports.FAST_REFRESH_RUNTIME_RELOAD = "Fast Refresh had to perform a full reload due to a runtime error.";
25
26
  async function createHotReloader(bundleOptions, projectPath, rootPath) {
26
- var _a, _b;
27
+ var _a, _b, _c, _d;
27
28
  const resolvedProjectPath = projectPath || process.cwd();
28
29
  (0, htmlEntry_1.processHtmlEntry)(bundleOptions.config, resolvedProjectPath);
29
30
  (0, validateEntry_1.validateEntryPaths)(bundleOptions.config, resolvedProjectPath);
@@ -46,12 +47,13 @@ async function createHotReloader(bundleOptions, projectPath, rootPath) {
46
47
  minify: false,
47
48
  moduleIds: "named",
48
49
  },
50
+ pluginRuntimeStrategy: (_c = (_b = bundleOptions === null || bundleOptions === void 0 ? void 0 : bundleOptions.config) === null || _b === void 0 ? void 0 : _b.pluginRuntimeStrategy) !== null && _c !== void 0 ? _c : ((0, runtimePluginStratety_1.useWorkerThreads)() ? "workerThreads" : "childProcesses"),
49
51
  },
50
52
  projectPath: (0, normalize_path_1.normalizePath)(resolvedProjectPath),
51
53
  rootPath: rootPath || projectPath || process.cwd(),
52
54
  packPath: (0, common_1.getPackPath)(),
53
55
  }, {
54
- persistentCaching: (_b = bundleOptions.config.persistentCaching) !== null && _b !== void 0 ? _b : false,
56
+ persistentCaching: (_d = bundleOptions.config.persistentCaching) !== null && _d !== void 0 ? _d : false,
55
57
  });
56
58
  const entrypointsSubscription = project.entrypointsSubscribe();
57
59
  let currentEntriesHandlingResolve;
@@ -0,0 +1 @@
1
+ export declare function useWorkerThreads(): boolean;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.useWorkerThreads = useWorkerThreads;
7
+ const semver_1 = __importDefault(require("semver"));
8
+ function useWorkerThreads() {
9
+ const WORKER_THREADS_SAFE_RANGE = ">=24.13.1 <25.0.0 || >=25.4.0";
10
+ return semver_1.default.satisfies(process.version, WORKER_THREADS_SAFE_RANGE, {
11
+ includePrerelease: true,
12
+ });
13
+ }