nitro 3.0.260415-beta → 3.0.260522-beta

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.
Files changed (91) hide show
  1. package/dist/THIRD-PARTY-LICENSES.md.gz +0 -0
  2. package/dist/_build/common.mjs +157 -45
  3. package/dist/_build/rolldown.mjs +6 -6
  4. package/dist/_build/rollup.mjs +11 -11
  5. package/dist/_build/vite.build.mjs +3 -3
  6. package/dist/_build/vite.dev.mjs +149 -0
  7. package/dist/_build/vite.env.mjs +177 -0
  8. package/dist/_chunks/nitro.mjs +241 -14
  9. package/dist/_chunks/nitro2.mjs +117 -90
  10. package/dist/_chunks/utils.mjs +4 -4
  11. package/dist/_common.mjs +2 -2
  12. package/dist/_dev.d.mts +1 -1
  13. package/dist/_dev.mjs +7 -6
  14. package/dist/_libs/c12+rc9.mjs +24 -11
  15. package/dist/_libs/c12+readdirp+chokidar.d.mts +7 -8
  16. package/dist/_libs/citty.mjs +1 -1
  17. package/dist/_libs/common.d.mts +37 -0
  18. package/dist/_libs/commondir+is-reference.mjs +3 -3
  19. package/dist/_libs/compatx.d.mts +1 -1
  20. package/dist/_libs/compatx.mjs +1 -1
  21. package/dist/_libs/estree+pluginutils.d.mts +1 -1
  22. package/dist/_libs/estree-walker.mjs +1 -1
  23. package/dist/_libs/hasown+resolve+deepmerge.mjs +62 -49
  24. package/dist/_libs/httpxy.d.mts +2 -4
  25. package/dist/_libs/httpxy.mjs +13 -9
  26. package/dist/_libs/jsonc-parser+workers-utils.d.mts +1579 -0
  27. package/dist/_libs/klona.mjs +1 -1
  28. package/dist/_libs/magic-string.d.mts +1 -1
  29. package/dist/_libs/mlly.d.mts +1 -1
  30. package/dist/_libs/nypm+tinyexec.mjs +137 -113
  31. package/dist/_libs/openapi-types.d.mts +730 -0
  32. package/dist/_libs/perfect-debounce.mjs +1 -1
  33. package/dist/_libs/pkg-types.d.mts +8 -5
  34. package/dist/_libs/plugin-alias.mjs +2 -2
  35. package/dist/_libs/plugin-inject.mjs +4 -2
  36. package/dist/_libs/plugin-json.mjs +2 -2
  37. package/dist/_libs/pluginutils.mjs +18 -5
  38. package/dist/_libs/readdirp+chokidar.mjs +4 -3
  39. package/dist/_libs/remapping.mjs +2 -2
  40. package/dist/_libs/resolve-uri+gen-mapping.mjs +2 -5
  41. package/dist/_libs/rou3.d.mts +1 -1
  42. package/dist/_libs/rou3.mjs +1 -1
  43. package/dist/_libs/std-env.d.mts +1 -1
  44. package/dist/_libs/tsconfck.mjs +1 -1
  45. package/dist/_libs/ultrahtml.mjs +1 -1
  46. package/dist/_libs/unimport+unplugin.mjs +61 -39
  47. package/dist/_libs/unplugin+unimport.d.mts +4 -4
  48. package/dist/_libs/unwasm.d.mts +1 -1
  49. package/dist/_presets.mjs +118 -91
  50. package/dist/builder.d.mts +1 -1
  51. package/dist/builder.mjs +3 -3
  52. package/dist/cli/_chunks/build.mjs +3 -3
  53. package/dist/cli/_chunks/common.mjs +1 -1
  54. package/dist/cli/_chunks/deploy.mjs +2 -2
  55. package/dist/cli/_chunks/dev.mjs +4 -4
  56. package/dist/cli/_chunks/docs.mjs +1 -1
  57. package/dist/cli/_chunks/list.mjs +2 -2
  58. package/dist/cli/_chunks/prepare.mjs +3 -3
  59. package/dist/cli/_chunks/preview.mjs +4 -4
  60. package/dist/cli/_chunks/run.mjs +2 -2
  61. package/dist/cli/_chunks/task.mjs +1 -1
  62. package/dist/cli/index.mjs +1 -1
  63. package/dist/docs/0.docs/5.cache.md +53 -9
  64. package/dist/docs/1.deploy/2.providers/2.aws-amplify.md +3 -3
  65. package/dist/docs/1.deploy/2.providers/21.vercel.md +6 -0
  66. package/dist/docs/3.examples/27.vite-ssr-tsr-react.md +1 -1
  67. package/dist/node_modules/ufo/dist/index.mjs +2 -2
  68. package/dist/node_modules/ufo/package.json +9 -9
  69. package/dist/presets/azure/runtime/azure-swa.mjs +2 -0
  70. package/dist/presets/vercel/runtime/queue.dev.mjs +41 -0
  71. package/dist/runtime/internal/app.mjs +4 -111
  72. package/dist/runtime/internal/route-rules.d.mts +1 -0
  73. package/dist/runtime/internal/route-rules.mjs +29 -1
  74. package/dist/runtime/internal/routes/scalar.mjs +1 -0
  75. package/dist/runtime/virtual/app.d.mts +4 -0
  76. package/dist/runtime/virtual/app.mjs +32 -0
  77. package/dist/types/index.d.mts +959 -1836
  78. package/dist/vite.d.mts +1 -1
  79. package/dist/vite.mjs +23 -331
  80. package/package.json +43 -44
  81. package/dist/THIRD-PARTY-LICENSES.md +0 -1646
  82. package/dist/_chunks/nitro3.mjs +0 -136
  83. package/dist/_chunks/nitro4.mjs +0 -127
  84. package/dist/_libs/_.mjs +0 -2
  85. package/dist/_libs/_2.mjs +0 -2
  86. package/dist/_libs/_3.mjs +0 -2
  87. package/dist/_libs/_4.mjs +0 -2
  88. package/dist/_libs/_5.mjs +0 -2
  89. package/dist/_libs/_6.mjs +0 -2
  90. package/dist/_libs/_7.mjs +0 -2
  91. package/dist/_libs/escape-string-regexp.mjs +0 -5
@@ -32,4 +32,4 @@ function klona(x) {
32
32
  }
33
33
  return tmp || x;
34
34
  }
35
- export { klona as t };
35
+ export { klona };
@@ -215,4 +215,4 @@ declare class MagicString {
215
215
  toString(): string;
216
216
  offset: number;
217
217
  }
218
- export { MagicString as t };
218
+ export { MagicString };
@@ -52,4 +52,4 @@ interface ESMExport {
52
52
  * Represents a declaration export within an ECMAScript module.
53
53
  * Extends {@link ESMExport}.
54
54
  */
55
- export { ESMExport as t };
55
+ export type { ESMExport };
@@ -1,72 +1,72 @@
1
- import { ct as join$1, dt as resolve$1, lt as normalize$1 } from "../_build/common.mjs";
1
+ import { __exportAll } from "../_common.mjs";
2
+ import { join as join$1, normalize as normalize$1, resolve as resolve$1 } from "../_build/common.mjs";
2
3
  import { createRequire } from "node:module";
3
4
  import { existsSync } from "node:fs";
4
5
  import { readFile } from "node:fs/promises";
5
- import { delimiter, dirname, join, normalize, resolve } from "node:path";
6
+ import { delimiter, dirname, join, resolve } from "node:path";
6
7
  import { cwd } from "node:process";
7
8
  import { PassThrough } from "node:stream";
8
9
  import { spawn } from "node:child_process";
9
- import c from "node:readline";
10
- var l = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports);
11
- var u = /* @__PURE__ */ createRequire(import.meta.url);
12
- const d = /^path$/i;
13
- const f = {
10
+ import { pipeline } from "node:stream/promises";
11
+ import l from "node:readline";
12
+ var u = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports);
13
+ var d = /* @__PURE__ */ createRequire(import.meta.url);
14
+ const f = /^path$/i;
15
+ const p = {
14
16
  key: "PATH",
15
17
  value: ""
16
18
  };
17
- function p(e) {
19
+ function m(e) {
18
20
  for (const t in e) {
19
- if (!Object.prototype.hasOwnProperty.call(e, t) || !d.test(t)) continue;
21
+ if (!Object.prototype.hasOwnProperty.call(e, t) || !f.test(t)) continue;
20
22
  const n = e[t];
21
- if (!n) return f;
23
+ if (!n) return p;
22
24
  return {
23
25
  key: t,
24
26
  value: n
25
27
  };
26
28
  }
27
- return f;
29
+ return p;
28
30
  }
29
- function m(e, t) {
30
- const i = t.value.split(delimiter);
31
- const o = [];
31
+ function h(e, t) {
32
+ const n = t.value.split(delimiter);
33
+ const r = [];
32
34
  let s = e;
33
35
  let c;
34
36
  do {
35
- o.push(resolve(s, "node_modules", ".bin"));
37
+ r.push(resolve(s, "node_modules", ".bin"));
36
38
  c = s;
37
39
  s = dirname(s);
38
40
  } while (s !== c);
39
- const l = o.concat(i).join(delimiter);
41
+ r.push(dirname(process.execPath));
42
+ const l = r.concat(n).join(delimiter);
40
43
  return {
41
44
  key: t.key,
42
45
  value: l
43
46
  };
44
47
  }
45
- function h(e, t) {
48
+ function g(e, t) {
46
49
  const n = {
47
50
  ...process.env,
48
51
  ...t
49
52
  };
50
- const r = m(e, p(n));
53
+ const r = h(e, m(n));
51
54
  n[r.key] = r.value;
52
55
  return n;
53
56
  }
54
- const g = (e) => {
57
+ const _ = (e) => {
55
58
  let t = e.length;
56
59
  const n = new PassThrough();
57
60
  const r = () => {
58
- if (--t === 0) n.emit("end");
61
+ if (--t === 0) n.end();
59
62
  };
60
- for (const t of e) {
61
- t.pipe(n, { end: false });
62
- t.on("end", r);
63
- }
63
+ for (const t of e) pipeline(t, n, { end: false }).then(r).catch(r);
64
64
  return n;
65
65
  };
66
- var _ = /* @__PURE__ */ l(((e, t) => {
66
+ var v = /* @__PURE__ */ u(((e, t) => {
67
67
  t.exports = a;
68
68
  a.sync = o;
69
- var n = u("fs");
69
+ var n = d("fs");
70
70
  function r(e, t) {
71
71
  var n = t.pathExt !== void 0 ? t.pathExt : process.env.PATHEXT;
72
72
  if (!n) return true;
@@ -91,10 +91,10 @@ var _ = /* @__PURE__ */ l(((e, t) => {
91
91
  return i(n.statSync(e), e, t);
92
92
  }
93
93
  }));
94
- var v = /* @__PURE__ */ l(((e, t) => {
94
+ var y = /* @__PURE__ */ u(((e, t) => {
95
95
  t.exports = r;
96
96
  r.sync = i;
97
- var n = u("fs");
97
+ var n = d("fs");
98
98
  function r(e, t, r) {
99
99
  n.stat(e, function(e, n) {
100
100
  r(e, e ? false : a(n, t));
@@ -119,11 +119,11 @@ var v = /* @__PURE__ */ l(((e, t) => {
119
119
  return n & l || n & c && i === o || n & s && r === a || n & u && a === 0;
120
120
  }
121
121
  }));
122
- var y = /* @__PURE__ */ l(((e, t) => {
123
- u("fs");
122
+ var b = /* @__PURE__ */ u(((e, t) => {
123
+ d("fs");
124
124
  var n;
125
- if (process.platform === "win32" || global.TESTING_WINDOWS) n = _();
126
- else n = v();
125
+ if (process.platform === "win32" || global.TESTING_WINDOWS) n = v();
126
+ else n = y();
127
127
  t.exports = r;
128
128
  r.sync = i;
129
129
  function r(e, t, i) {
@@ -159,11 +159,11 @@ var y = /* @__PURE__ */ l(((e, t) => {
159
159
  }
160
160
  }
161
161
  }));
162
- var b = /* @__PURE__ */ l(((e, t) => {
162
+ var x = /* @__PURE__ */ u(((e, t) => {
163
163
  const n = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
164
- const r = u("path");
164
+ const r = d("path");
165
165
  const i = n ? ";" : ":";
166
- const a = y();
166
+ const a = b();
167
167
  const o = (e) => Object.assign(/* @__PURE__ */ new Error(`not found: ${e}`), { code: "ENOENT" });
168
168
  const s = (e, t) => {
169
169
  const r = t.colon || i;
@@ -229,7 +229,7 @@ var b = /* @__PURE__ */ l(((e, t) => {
229
229
  t.exports = c;
230
230
  c.sync = l;
231
231
  }));
232
- var x = /* @__PURE__ */ l(((e, t) => {
232
+ var S = /* @__PURE__ */ u(((e, t) => {
233
233
  const n = (e = {}) => {
234
234
  const t = e.env || process.env;
235
235
  if ((e.platform || process.platform) !== "win32") return "PATH";
@@ -238,10 +238,10 @@ var x = /* @__PURE__ */ l(((e, t) => {
238
238
  t.exports = n;
239
239
  t.exports.default = n;
240
240
  }));
241
- var S = /* @__PURE__ */ l(((e, t) => {
242
- const n = u("path");
243
- const r = b();
244
- const i = x();
241
+ var C = /* @__PURE__ */ u(((e, t) => {
242
+ const n = d("path");
243
+ const r = x();
244
+ const i = S();
245
245
  function a(e, t) {
246
246
  const a = e.options.env || process.env;
247
247
  const o = process.cwd();
@@ -267,7 +267,7 @@ var S = /* @__PURE__ */ l(((e, t) => {
267
267
  }
268
268
  t.exports = o;
269
269
  }));
270
- var C = /* @__PURE__ */ l(((e, t) => {
270
+ var w = /* @__PURE__ */ u(((e, t) => {
271
271
  const n = /([()\][%!^"`<>&|;, *?])/g;
272
272
  function r(e) {
273
273
  e = e.replace(n, "^$1");
@@ -285,11 +285,11 @@ var C = /* @__PURE__ */ l(((e, t) => {
285
285
  t.exports.command = r;
286
286
  t.exports.argument = i;
287
287
  }));
288
- var w = /* @__PURE__ */ l(((e, t) => {
288
+ var T = /* @__PURE__ */ u(((e, t) => {
289
289
  t.exports = /^#!(.*)/;
290
290
  }));
291
- var T = /* @__PURE__ */ l(((e, t) => {
292
- const n = w();
291
+ var E = /* @__PURE__ */ u(((e, t) => {
292
+ const n = T();
293
293
  t.exports = (e = "") => {
294
294
  const t = e.match(n);
295
295
  if (!t) return null;
@@ -299,9 +299,9 @@ var T = /* @__PURE__ */ l(((e, t) => {
299
299
  return i ? `${a} ${i}` : a;
300
300
  };
301
301
  }));
302
- var E = /* @__PURE__ */ l(((e, t) => {
303
- const n = u("fs");
304
- const r = T();
302
+ var D = /* @__PURE__ */ u(((e, t) => {
303
+ const n = d("fs");
304
+ const r = E();
305
305
  function i(e) {
306
306
  const t = 150;
307
307
  const i = Buffer.alloc(t);
@@ -315,11 +315,11 @@ var E = /* @__PURE__ */ l(((e, t) => {
315
315
  }
316
316
  t.exports = i;
317
317
  }));
318
- var D = /* @__PURE__ */ l(((e, t) => {
319
- const n = u("path");
320
- const r = S();
321
- const i = C();
322
- const a = E();
318
+ var O = /* @__PURE__ */ u(((e, t) => {
319
+ const n = d("path");
320
+ const r = C();
321
+ const i = w();
322
+ const a = D();
323
323
  const o = process.platform === "win32";
324
324
  const s = /\.(?:com|exe)$/i;
325
325
  const c = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
@@ -333,7 +333,7 @@ var D = /* @__PURE__ */ l(((e, t) => {
333
333
  }
334
334
  return e.file;
335
335
  }
336
- function d(e) {
336
+ function u(e) {
337
337
  if (!o) return e;
338
338
  const t = l(e);
339
339
  const r = !s.test(t);
@@ -370,11 +370,11 @@ var D = /* @__PURE__ */ l(((e, t) => {
370
370
  args: t
371
371
  }
372
372
  };
373
- return n.shell ? r : d(r);
373
+ return n.shell ? r : u(r);
374
374
  }
375
375
  t.exports = f;
376
376
  }));
377
- var O = /* @__PURE__ */ l(((e, t) => {
377
+ var k = /* @__PURE__ */ u(((e, t) => {
378
378
  const n = process.platform === "win32";
379
379
  function r(e, t) {
380
380
  return Object.assign(/* @__PURE__ */ new Error(`${t} ${e.command} ENOENT`), {
@@ -411,10 +411,10 @@ var O = /* @__PURE__ */ l(((e, t) => {
411
411
  notFoundError: r
412
412
  };
413
413
  }));
414
- var A = (/* @__PURE__ */ l(((e, t) => {
415
- const n = u("child_process");
416
- const r = D();
417
- const i = O();
414
+ var j = (/* @__PURE__ */ u(((e, t) => {
415
+ const n = d("child_process");
416
+ const r = O();
417
+ const i = k();
418
418
  function a(e, t, a) {
419
419
  const o = r(e, t, a);
420
420
  const s = n.spawn(o.command, o.args, o.options);
@@ -433,9 +433,7 @@ var A = (/* @__PURE__ */ l(((e, t) => {
433
433
  t.exports._parse = r;
434
434
  t.exports._enoent = i;
435
435
  })))();
436
- var j = class extends Error {
437
- result;
438
- output;
436
+ var M = class extends Error {
439
437
  get exitCode() {
440
438
  if (this.result.exitCode !== null) return this.result.exitCode;
441
439
  }
@@ -445,18 +443,12 @@ var j = class extends Error {
445
443
  this.output = t;
446
444
  }
447
445
  };
448
- const M = {
446
+ const P = {
449
447
  timeout: void 0,
450
448
  persist: false
451
449
  };
452
- const N = { windowsHide: true };
453
- function P(e, t) {
454
- return {
455
- command: normalize(e),
456
- args: t ?? []
457
- };
458
- }
459
- function F(e) {
450
+ const I = { windowsHide: true };
451
+ function L(e) {
460
452
  const t = new AbortController();
461
453
  for (const n of e) {
462
454
  if (n.aborted) {
@@ -470,12 +462,14 @@ function F(e) {
470
462
  }
471
463
  return t.signal;
472
464
  }
473
- async function I(e) {
465
+ async function R(e) {
474
466
  let t = "";
475
- for await (const n of e) t += n.toString();
467
+ try {
468
+ for await (const n of e) t += n.toString();
469
+ } catch {}
476
470
  return t;
477
471
  }
478
- var L = class {
472
+ var z = class {
479
473
  _process;
480
474
  _aborted = false;
481
475
  _options;
@@ -495,7 +489,7 @@ var L = class {
495
489
  }
496
490
  constructor(e, t, n) {
497
491
  this._options = {
498
- ...M,
492
+ ...P,
499
493
  ...n
500
494
  };
501
495
  this._command = e;
@@ -514,7 +508,7 @@ var L = class {
514
508
  return this._process?.killed === true;
515
509
  }
516
510
  pipe(e, t, n) {
517
- return z(e, t, {
511
+ return H(e, t, {
518
512
  ...n,
519
513
  stdin: this
520
514
  });
@@ -525,29 +519,30 @@ var L = class {
525
519
  const t = [];
526
520
  if (this._streamErr) t.push(this._streamErr);
527
521
  if (this._streamOut) t.push(this._streamOut);
528
- const n = g(t);
529
- const r = c.createInterface({ input: n });
522
+ const n = _(t);
523
+ const r = l.createInterface({ input: n });
530
524
  for await (const e of r) yield e.toString();
531
525
  await this._processClosed;
532
526
  e.removeAllListeners();
533
527
  if (this._thrownError) throw this._thrownError;
534
- if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new j(this);
528
+ if (this._options?.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new M(this);
535
529
  }
536
530
  async _waitForOutput() {
537
531
  const e = this._process;
538
532
  if (!e) throw new Error("No process was started");
539
- const [t, n] = await Promise.all([this._streamOut ? I(this._streamOut) : "", this._streamErr ? I(this._streamErr) : ""]);
533
+ const [t, n] = await Promise.all([this._streamOut ? R(this._streamOut) : "", this._streamErr ? R(this._streamErr) : ""]);
540
534
  await this._processClosed;
541
- if (this._options?.stdin) await this._options.stdin;
535
+ const { stdin: r } = this._options;
536
+ if (r && typeof r !== "string") await r;
542
537
  e.removeAllListeners();
543
538
  if (this._thrownError) throw this._thrownError;
544
- const r = {
539
+ const i = {
545
540
  stderr: n,
546
541
  stdout: t,
547
542
  exitCode: this.exitCode
548
543
  };
549
- if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new j(this, r);
550
- return r;
544
+ if (this._options.throwOnError && this.exitCode !== 0 && this.exitCode !== void 0) throw new M(this, i);
545
+ return i;
551
546
  }
552
547
  then(e, t) {
553
548
  return this._waitForOutput().then(e, t);
@@ -557,28 +552,28 @@ var L = class {
557
552
  spawn() {
558
553
  const e = cwd();
559
554
  const n = this._options;
560
- const r = {
561
- ...N,
555
+ const i = {
556
+ ...I,
562
557
  ...n.nodeOptions
563
558
  };
564
- const i = [];
559
+ const a = [];
565
560
  this._resetState();
566
- if (n.timeout !== void 0) i.push(AbortSignal.timeout(n.timeout));
567
- if (n.signal !== void 0) i.push(n.signal);
568
- if (n.persist === true) r.detached = true;
569
- if (i.length > 0) r.signal = F(i);
570
- r.env = h(e, r.env);
571
- const { command: a, args: s } = P(this._command, this._args);
572
- const c = (0, A._parse)(a, s, r);
573
- const l = spawn(c.command, c.args, c.options);
574
- if (l.stderr) this._streamErr = l.stderr;
575
- if (l.stdout) this._streamOut = l.stdout;
576
- this._process = l;
577
- l.once("error", this._onError);
578
- l.once("close", this._onClose);
579
- if (n.stdin !== void 0 && l.stdin && n.stdin.process) {
580
- const { stdout: e } = n.stdin.process;
581
- if (e) e.pipe(l.stdin);
561
+ if (n.timeout !== void 0) a.push(AbortSignal.timeout(n.timeout));
562
+ if (n.signal !== void 0) a.push(n.signal);
563
+ if (n.persist === true) i.detached = true;
564
+ if (a.length > 0) i.signal = L(a);
565
+ i.env = g(e, i.env);
566
+ const o = (0, j._parse)(this._command, this._args, i);
567
+ const s = spawn(o.command, o.args, o.options);
568
+ if (s.stderr) this._streamErr = s.stderr;
569
+ if (s.stdout) this._streamOut = s.stdout;
570
+ this._process = s;
571
+ s.once("error", this._onError);
572
+ s.once("close", this._onClose);
573
+ if (s.stdin) {
574
+ const { stdin: e } = n;
575
+ if (typeof e === "string") s.stdin.end(e);
576
+ else e?.process?.stdout?.pipe(s.stdin);
582
577
  }
583
578
  }
584
579
  _resetState() {
@@ -599,12 +594,18 @@ var L = class {
599
594
  if (this._resolveClose) this._resolveClose();
600
595
  };
601
596
  };
602
- const R = (e, t, n) => {
603
- const r = new L(e, t, n);
597
+ const V = (e, t, n) => {
598
+ const r = new z(e, t, n);
604
599
  r.spawn();
605
600
  return r;
606
601
  };
607
- const z = R;
602
+ const H = V;
603
+ var dist_exports = /* @__PURE__ */ __exportAll({
604
+ addDependency: () => addDependency,
605
+ addDevDependency: () => addDevDependency,
606
+ detectPackageManager: () => detectPackageManager,
607
+ packageManagers: () => packageManagers
608
+ });
608
609
  async function findup(cwd, match, options = {}) {
609
610
  const segments = normalize$1(cwd).split("/");
610
611
  while (segments.length > 0) {
@@ -613,11 +614,32 @@ async function findup(cwd, match, options = {}) {
613
614
  segments.pop();
614
615
  }
615
616
  }
616
- async function readPackageJSON(cwd) {
617
+ async function readPackageJSON(cwd, options = {}) {
617
618
  return findup(cwd, (p) => {
618
619
  const pkgPath = join(p, "package.json");
619
620
  if (existsSync(pkgPath)) return readFile(pkgPath, "utf8").then((data) => JSON.parse(data));
620
- });
621
+ }, options);
622
+ }
623
+ async function readInstalledPackageJSON(pkgName, cwd) {
624
+ const pkgJSONPath = await findup(cwd, (p) => {
625
+ const candidate = join(p, "node_modules", pkgName, "package.json");
626
+ if (existsSync(candidate)) return candidate;
627
+ }, { includeParentDirs: true });
628
+ if (!pkgJSONPath) return null;
629
+ try {
630
+ return JSON.parse(await readFile(pkgJSONPath, "utf8"));
631
+ } catch {
632
+ return null;
633
+ }
634
+ }
635
+ async function readPackageJSONFromResolver(requireFn, pkgName) {
636
+ let resolved;
637
+ try {
638
+ resolved = requireFn.resolve(pkgName);
639
+ } catch {
640
+ return null;
641
+ }
642
+ return readPackageJSON(resolved, { includeParentDirs: true });
621
643
  }
622
644
  function cached(fn) {
623
645
  let v;
@@ -632,7 +654,7 @@ function cached(fn) {
632
654
  const hasCorepack = cached(async () => {
633
655
  if (globalThis.process?.versions?.webcontainer) return false;
634
656
  try {
635
- const { exitCode } = await R("corepack", ["--version"]);
657
+ const { exitCode } = await V("corepack", ["--version"]);
636
658
  return exitCode === 0;
637
659
  } catch {
638
660
  return false;
@@ -640,7 +662,7 @@ const hasCorepack = cached(async () => {
640
662
  });
641
663
  async function executeCommand(command, args, options = {}) {
642
664
  const xArgs = command !== "npm" && command !== "bun" && command !== "deno" && options.corepack !== false && await hasCorepack() ? ["corepack", [command, ...args]] : [command, args];
643
- const { exitCode, stdout, stderr } = await R(xArgs[0], xArgs[1], { nodeOptions: {
665
+ const { exitCode, stdout, stderr } = await V(xArgs[0], xArgs[1], { nodeOptions: {
644
666
  cwd: resolve$1(options.cwd || process.cwd()),
645
667
  env: options.env,
646
668
  stdio: options.silent ? "pipe" : "inherit"
@@ -797,8 +819,10 @@ async function addDependency(name, options = {}) {
797
819
  const _require = createRequire(join(resolvedOptions.cwd, "/_.js"));
798
820
  for (const _name of names) {
799
821
  const pkgName = _name.match(/^(.[^@]+)/)?.[0];
800
- const pkg = await readPackageJSON(_require.resolve(pkgName));
801
- if (!pkg?.peerDependencies || pkg?.name !== pkgName) continue;
822
+ if (!pkgName) continue;
823
+ let pkg = await readPackageJSONFromResolver(_require, pkgName);
824
+ if (pkg?.name !== pkgName) pkg = await readInstalledPackageJSON(pkgName, resolvedOptions.cwd);
825
+ if (!pkg?.peerDependencies) continue;
802
826
  for (const [peerDependency, version] of Object.entries(pkg.peerDependencies)) {
803
827
  if (pkg.peerDependenciesMeta?.[peerDependency]?.optional) continue;
804
828
  if (existingPkg?.dependencies?.[peerDependency] || existingPkg?.devDependencies?.[peerDependency]) continue;
@@ -819,4 +843,4 @@ async function addDevDependency(name, options = {}) {
819
843
  dev: true
820
844
  });
821
845
  }
822
- export { packageManagers as i, addDevDependency as n, detectPackageManager as r, addDependency as t };
846
+ export { dist_exports };