@dimina-kit/compiler 0.0.1-dev.20260706154125 → 0.0.1-dev.20260707110006

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/pool.node.js CHANGED
@@ -177,7 +177,10 @@ function createWorkerSlot({ name, spawnTransport, onEvent }) {
177
177
  // src/pool-node.js
178
178
  var { Worker } = createRequire(import.meta.url)("node:worker_threads");
179
179
  var DEFAULT_SEND_TIMEOUT_MS = 12e4;
180
- var WORKER_DEATH_CODES = /* @__PURE__ */ new Set(["compiler-worker-timeout", "compiler-worker-crashed", "compiler-worker-dead"]);
180
+ var WORKER_DEATH_CODES = /* @__PURE__ */ new Set(["compiler-worker-timeout", "compiler-worker-crashed", "compiler-worker-dead", "compiler-toolchain-dead"]);
181
+ function isDeadToolchainServiceError(message) {
182
+ return /The service (was stopped|is no longer running)/.test(String(message));
183
+ }
181
184
  var DEFAULT_IDLE_SHRINK_MS = 3e5;
182
185
  var chain = Promise.resolve();
183
186
  function createNodeCompilerPool({
@@ -245,18 +248,25 @@ function createNodeCompilerPool({
245
248
  if (err && err.code && !err.stage) err.stage = x.stage;
246
249
  throw err;
247
250
  })));
248
- for (const r of results) {
249
- if (!r || r.type === "error") {
250
- const info = r && r.error;
251
- const cause = info && info.message || "unknown error";
252
- const hint = oxcNativeBindingHint(cause);
253
- const err = new Error(`[compiler] stage "${r && r.stage}" failed: ${cause}${hint ? ` \u2014 ${hint}` : ""}`);
254
- if (info && info.stack) err.stack = info.stack;
255
- err.stage = r && r.stage;
251
+ let firstErr = null;
252
+ for (let i = 0; i < results.length; i++) {
253
+ const r = results[i];
254
+ if (r && r.type !== "error") continue;
255
+ const info = r && r.error;
256
+ const cause = info && info.message || "unknown error";
257
+ const hint = oxcNativeBindingHint(cause) || esbuildAsarSpawnHint(cause);
258
+ const err = new Error(`[compiler] stage "${r && r.stage}" failed: ${cause}${hint ? ` \u2014 ${hint}` : ""}`);
259
+ if (info && info.stack) err.stack = info.stack;
260
+ err.stage = r && r.stage;
261
+ if (isDeadToolchainServiceError(cause)) {
262
+ err.code = "compiler-toolchain-dead";
263
+ workers[i].slot.shrink();
264
+ } else {
256
265
  err.code = "compiler-stage-error";
257
- throw err;
258
266
  }
267
+ if (!firstErr) firstErr = err;
259
268
  }
269
+ if (firstErr) throw firstErr;
260
270
  publishToDist(outputDir, useAppIdDir);
261
271
  return {
262
272
  appId: getAppId(),
@@ -299,6 +309,11 @@ function createNodeCompilerPool({
299
309
  return { build: build2, dispose, stages, _slots: workers };
300
310
  }
301
311
  var STAGE_TITLES = { logic: "\u7F16\u8BD1\u9875\u9762\u903B\u8F91", view: "\u7F16\u8BD1\u9875\u9762\u6587\u4EF6", style: "\u7F16\u8BD1\u6837\u5F0F\u6587\u4EF6" };
312
+ function esbuildAsarSpawnHint(message) {
313
+ const msg = String(message);
314
+ if (!/app\.asar/.test(msg) || !/esbuild/i.test(msg) || !/ENOENT/.test(msg)) return null;
315
+ return "esbuild \u7684\u539F\u751F\u4E8C\u8FDB\u5236\u65E0\u6CD5\u4ECE app.asar \u5185 spawn\uFF08Electron \u53EA\u4E3A execFile \u6253 asar \u8865\u4E01\uFF09\uFF1A\u6253\u5305\u914D\u7F6E\u9700 asarUnpack '**/node_modules/esbuild/**' \u4E0E '**/node_modules/@esbuild/**'\uFF0C\u5E76\u786E\u4FDD ESBUILD_BINARY_PATH \u6307\u5411 app.asar.unpacked \u4E0B\u7684\u771F\u5B9E\u4E8C\u8FDB\u5236\uFF08@dimina-kit/devkit \u5728 asar \u5185\u8FD0\u884C\u65F6\u4F1A\u81EA\u52A8\u8BBE\u7F6E\uFF09";
316
+ }
302
317
  function oxcNativeBindingHint(message) {
303
318
  if (!/Cannot find native binding/i.test(String(message))) return null;
304
319
  return `oxc-parser \u7684\u8FD0\u884C\u65F6\u7ED1\u5B9A\u6CA1\u6709\u88AB\u6253\u8FDB\u5BBF\u4E3B\u5E94\u7528\uFF1A@dimina-kit/compiler \u7684 Node \u7F16\u8BD1\u8DEF\u5F84\u9700\u8981 @oxc-parser/binding-${process.platform}-${process.arch}\uFF08\u5E73\u53F0\u539F\u751F\u7ED1\u5B9A\uFF09\u6216 @oxc-parser/binding-wasm32-wasi\uFF08wasm \u515C\u5E95\uFF09\u4E8C\u8005\u4E4B\u4E00\u5B9E\u9645\u5B58\u5728\u4E8E\u5305\u5185\u3002\u6253\u5305\u5206\u53D1\uFF08\u5982 electron-builder\uFF09\u65F6\u8BF7\u628A\u5176\u4E2D\u4E00\u4E2A\u663E\u5F0F\u58F0\u660E\u4E3A\u5BBF\u4E3B\u4F9D\u8D56\uFF0C\u907F\u514D\u4F9D\u8D56\u6536\u96C6\u65F6\u88AB\u4E22\u5F03`;
@@ -331,6 +346,7 @@ export {
331
346
  createNodeCompilerPool,
332
347
  build as default,
333
348
  disposeDefaultPool,
349
+ esbuildAsarSpawnHint,
334
350
  oxcNativeBindingHint,
335
351
  warmDefaultPool
336
352
  };