vite-plus 1.3.0 → 1.4.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.
Files changed (90) hide show
  1. package/AGENTS.md +4 -0
  2. package/LICENSE +1 -878
  3. package/README.md +1 -1
  4. package/bin/vpx +9 -0
  5. package/binding/index.cjs +59 -54
  6. package/binding/index.d.cts +128 -2
  7. package/dist/{agent-97KmGCyL.js → agent-D8oxxhVR.js} +5 -7
  8. package/dist/bin.js +25 -32
  9. package/dist/{cli-parse-DHE8NrBU.js → cli-parse-aeUeFDlC.js} +2 -3
  10. package/dist/command-TjS_6y9O.js +1 -0
  11. package/dist/{command-CdMBoZFD.js → command-rY79K5NI.js} +28 -30
  12. package/dist/{comparison-CmVirWIW-DUGaiYqF.js → comparison-CmVirWIW-UlEf2maz.js} +1 -2
  13. package/dist/config/bin.js +8 -10
  14. package/dist/{constants-DR55DpRm.js → constants-DRUnJ_Dz.js} +3 -5
  15. package/dist/create/bin.d.ts +4 -8
  16. package/dist/create/bin.js +46 -65
  17. package/dist/{define-config-CvE5pHqB.js → define-config-ChwJcu5e.js} +6 -9
  18. package/dist/{define-config-BxDc_9BK.cjs → define-config-Cv2P6NT2.cjs} +7 -12
  19. package/dist/{define-config-Bexdd6RZ.d.ts → define-config-rPhYIFSn.d.ts} +1 -11
  20. package/dist/define-config.cjs +1 -1
  21. package/dist/define-config.d.ts +1 -1
  22. package/dist/define-config.js +1 -1
  23. package/dist/{dist-DIpm7mot.js → dist-Bs0SObNC.js} +73 -145
  24. package/dist/{dist-Cqz8OtiO.js → dist-CdkMvIiQ.js} +11 -5
  25. package/dist/dist-zDZV5eEc.js +3 -0
  26. package/dist/{documentation-DqcZSthV.js → documentation-cv_y0Auv.js} +1 -2
  27. package/dist/{editor-CtJGQP7C.js → editor-ClL78D8u.js} +1490 -4209
  28. package/dist/{help-BmKpeOP9.js → help-B03t_iQ4.js} +1 -2
  29. package/dist/hooks/bin.js +4 -5
  30. package/dist/{hooks-DhwsWb46.js → hooks-xRcJPc-O.js} +5 -4
  31. package/dist/index.cjs +2 -3
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.js +1 -1
  34. package/dist/{json-JP24qHUF.js → json-kl84kDyH.js} +9 -18
  35. package/dist/lint-plugins.cjs +1 -1
  36. package/dist/migration/bin.js +719 -184
  37. package/dist/migration/compat/worker.js +4 -6
  38. package/dist/{oxlint-plugin-config-BIzrO2y2.js → oxlint-plugin-config-BVpqYdcC.js} +3 -4
  39. package/dist/oxlint-plugin.d.ts +0 -2
  40. package/dist/oxlint-plugin.js +6 -7
  41. package/dist/{pack-BK38MLVZ.d.ts → pack-ARPFMefW.d.ts} +0 -2
  42. package/dist/pack-bin.d.ts +1 -3
  43. package/dist/pack-bin.js +3 -4
  44. package/dist/pack.d.ts +1 -1
  45. package/dist/{package-CQDXTm6j.js → package-DzsomcUD.js} +10 -95
  46. package/dist/{package-overrides-D1RcXSFl.js → package-overrides-Ci8GXouY.js} +5 -8
  47. package/dist/picomatch-DEUoj81q.js +1916 -0
  48. package/dist/{prompts-1xNz_ne0.js → prompts-GL1vj0wk.js} +30 -50
  49. package/dist/{protocol-D99W10Qi.js → protocol-CkNmY-Mr.js} +1 -2
  50. package/dist/{report-NhQk8VHb.js → report-DLHO30yZ.js} +2 -2
  51. package/dist/{resolve-vite-config-BVr1SUNg.js → resolve-vite-config-Dn5896A4.js} +9 -25
  52. package/dist/resolve-vite-config-QO6cC0SP.js +1 -0
  53. package/dist/{rolldown-runtime-kJ_i4yPo.js → rolldown-runtime-DegdyBIC.js} +1 -2
  54. package/dist/script-esm-hooks.d.ts +8 -0
  55. package/dist/script-esm-hooks.js +24 -0
  56. package/dist/script-hooks-9Fof5UMY.js +176 -0
  57. package/dist/script-preload.cjs +468 -0
  58. package/dist/script-register.d.ts +1 -0
  59. package/dist/script-register.js +22 -0
  60. package/dist/script-watch.d.ts +1 -0
  61. package/dist/script-watch.js +1908 -0
  62. package/dist/staged/bin.js +53 -2011
  63. package/dist/sync-versions/bin.js +26 -48
  64. package/dist/sync-versions/bin.mjs +109 -217
  65. package/dist/{terminal-MKGAuy-p.js → terminal-BcuPUy-j.js} +1 -2
  66. package/dist/toolchain.js +35 -9
  67. package/dist/toolchain.json +35 -9
  68. package/dist/{tsconfig-zWgHiQ3X.js → tsconfig-Do6MAG_f.js} +1 -1
  69. package/dist/{tsconfig-BZu7kl-x.js → tsconfig-LE_mAwe_.js} +8 -10
  70. package/dist/version.d.ts +1 -3
  71. package/dist/version.js +5 -6
  72. package/dist/versions.js +4 -4
  73. package/dist/{vitest-ecosystem-BU0AqZq-.js → vitest-ecosystem-BeEYz-qF.js} +1 -2
  74. package/dist/{vitest-v5-entry-points-DthU1e_O.js → vitest-v5-entry-points-NyJsFeux.js} +1 -2
  75. package/dist/vpx-bin.d.ts +1 -0
  76. package/dist/vpx-bin.js +232 -0
  77. package/dist/vpx-script-EXgV5QOf.js +434 -0
  78. package/docs/config/run.md +4 -0
  79. package/docs/guide/check.md +1 -0
  80. package/docs/guide/ci.md +13 -3
  81. package/docs/guide/env.md +11 -4
  82. package/docs/guide/global-cli.md +52 -0
  83. package/docs/guide/migrate-rules.md +48 -5
  84. package/docs/guide/migrate.md +5 -5
  85. package/docs/guide/package-management.md +1 -1
  86. package/docs/guide/vpx.md +170 -9
  87. package/package.json +20 -17
  88. package/dist/command-DVTILtS-.js +0 -1
  89. package/dist/dist-Dhu07wmN.js +0 -3
  90. package/dist/resolve-vite-config-7WDtXO4G.js +0 -1
@@ -1,10 +1,10 @@
1
- import { r as __toESM, t as __commonJSMin } from "./rolldown-runtime-kJ_i4yPo.js";
2
- import { t as accent } from "./terminal-MKGAuy-p.js";
3
- import { f as VITE_PLUS_VERSION } from "./constants-DR55DpRm.js";
4
- import { a as writeJsonFile, i as readJsonFile } from "./json-JP24qHUF.js";
5
- import { _ as isGreaterThanOrEqual, b as safeRegex, g as formatComparableVersion, l as PRERELEASE, n as COERCE, r as COERCE_FULL, u as PRERELEASE_LOOSE, x as tryParse, y as parse } from "./comparison-CmVirWIW-DUGaiYqF.js";
6
- import { n as runCommandSilently } from "./command-CdMBoZFD.js";
7
- import { t as require_dist } from "./dist-DIpm7mot.js";
1
+ import { r as __toESM, t as __commonJSMin } from "./rolldown-runtime-DegdyBIC.js";
2
+ import { t as accent } from "./terminal-BcuPUy-j.js";
3
+ import { f as VITE_PLUS_VERSION } from "./constants-DRUnJ_Dz.js";
4
+ import { a as writeJsonFile, i as readJsonFile } from "./json-kl84kDyH.js";
5
+ import { _ as isGreaterThanOrEqual, b as safeRegex, g as formatComparableVersion, l as PRERELEASE, n as COERCE, r as COERCE_FULL, u as PRERELEASE_LOOSE, x as tryParse, y as parse } from "./comparison-CmVirWIW-UlEf2maz.js";
6
+ import { i as runCommandSilently, n as getVpCommand } from "./command-rY79K5NI.js";
7
+ import { t as require_dist } from "./dist-Bs0SObNC.js";
8
8
  import path from "node:path";
9
9
  import { downloadPackageManager } from "../binding/index.js";
10
10
  import { stripVTControlCharacters, styleText } from "node:util";
@@ -13,7 +13,7 @@ import process$1, { stdin, stdout } from "node:process";
13
13
  import l__default, * as l from "node:readline";
14
14
  import { ReadStream } from "node:tty";
15
15
  import { randomBytes } from "node:crypto";
16
- //#region ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
16
+ // ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/utils.js
17
17
  const getCodePointsLength$1 = (() => {
18
18
  const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
19
19
  return (input) => {
@@ -29,8 +29,7 @@ const isFullWidth$1 = (x) => {
29
29
  const isWideNotCJKTNotEmoji$1 = (x) => {
30
30
  return x === 8987 || x === 9001 || x >= 12272 && x <= 12287 || x >= 12289 && x <= 12350 || x >= 12441 && x <= 12543 || x >= 12549 && x <= 12591 || x >= 12593 && x <= 12686 || x >= 12688 && x <= 12771 || x >= 12783 && x <= 12830 || x >= 12832 && x <= 12871 || x >= 12880 && x <= 19903 || x >= 65040 && x <= 65049 || x >= 65072 && x <= 65106 || x >= 65108 && x <= 65126 || x >= 65128 && x <= 65131 || x >= 127488 && x <= 127490 || x >= 127504 && x <= 127547 || x >= 127552 && x <= 127560 || x >= 131072 && x <= 196605 || x >= 196608 && x <= 262141;
31
31
  };
32
- //#endregion
33
- //#region ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
32
+ // ../../node_modules/.pnpm/fast-string-truncated-width@3.0.3/node_modules/fast-string-truncated-width/dist/index.js
34
33
  const ANSI_RE$1 = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
35
34
  const CONTROL_RE$1 = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
36
35
  const CJKT_WIDE_RE$1 = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy;
@@ -119,8 +118,7 @@ const getStringTruncatedWidth$1 = (input, truncationOptions = {}, widthOptions =
119
118
  ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
120
119
  };
121
120
  };
122
- //#endregion
123
- //#region ../../node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
121
+ // ../../node_modules/.pnpm/fast-string-width@3.0.2/node_modules/fast-string-width/dist/index.js
124
122
  const NO_TRUNCATION$2 = {
125
123
  limit: Infinity,
126
124
  ellipsis: "",
@@ -129,8 +127,7 @@ const NO_TRUNCATION$2 = {
129
127
  const fastStringWidth$1 = (input, options = {}) => {
130
128
  return getStringTruncatedWidth$1(input, NO_TRUNCATION$2, options).width;
131
129
  };
132
- //#endregion
133
- //#region ../../node_modules/.pnpm/fast-wrap-ansi@0.2.0/node_modules/fast-wrap-ansi/lib/main.js
130
+ // ../../node_modules/.pnpm/fast-wrap-ansi@0.2.0/node_modules/fast-wrap-ansi/lib/main.js
134
131
  const ESC$2 = "\x1B";
135
132
  const CSI$2 = "›";
136
133
  const END_CODE$1 = 39;
@@ -294,8 +291,7 @@ const CRLF_OR_LF$1 = /\r?\n/;
294
291
  function wrapAnsi$1(string, columns, options) {
295
292
  return String(string).normalize().split(CRLF_OR_LF$1).map((line) => exec$1(line, columns, options)).join("\n");
296
293
  }
297
- //#endregion
298
- //#region ../../node_modules/.pnpm/@clack+core@1.5.1/node_modules/@clack/core/dist/index.mjs
294
+ // ../../node_modules/.pnpm/@clack+core@1.5.1/node_modules/@clack/core/dist/index.mjs
299
295
  var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
300
296
  const ESC = "\x1B";
301
297
  const CSI = `${ESC}[`;
@@ -782,8 +778,7 @@ var n = class extends y {
782
778
  });
783
779
  }
784
780
  };
785
- //#endregion
786
- //#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
781
+ // ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js
787
782
  var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
788
783
  let p = process || {};
789
784
  let argv = p.argv || [];
@@ -852,8 +847,7 @@ var require_picocolors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
852
847
  module.exports = createColors();
853
848
  module.exports.createColors = createColors;
854
849
  }));
855
- //#endregion
856
- //#region ../../node_modules/.pnpm/sisteransi@2.0.0/node_modules/sisteransi/dist/index.js
850
+ // ../../node_modules/.pnpm/sisteransi@2.0.0/node_modules/sisteransi/dist/index.js
857
851
  var import_picocolors = /* @__PURE__ */ __toESM(require_picocolors(), 1);
858
852
  const ESC$1 = "\x1B";
859
853
  const CSI$1 = `${ESC$1}[`;
@@ -896,8 +890,7 @@ const erase = {
896
890
  return clear;
897
891
  }
898
892
  };
899
- //#endregion
900
- //#region ../prompts/dist/index.mjs
893
+ // ../prompts/dist/index.mjs
901
894
  const getCodePointsLength = (() => {
902
895
  const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
903
896
  return (input) => {
@@ -1851,8 +1844,7 @@ const text = (opts) => {
1851
1844
  }
1852
1845
  }).prompt();
1853
1846
  };
1854
- //#endregion
1855
- //#region ../../node_modules/.pnpm/verkit@0.5.0/node_modules/verkit/dist/version-Co1j9Tpq.js
1847
+ // ../../node_modules/.pnpm/verkit@0.5.0/node_modules/verkit/dist/version-Co1j9Tpq.js
1856
1848
  const COERCE_EXACT = safeRegex(COERCE);
1857
1849
  const COERCE_FULL_EXACT = safeRegex(COERCE_FULL);
1858
1850
  safeRegex(`^${PRERELEASE}$`);
@@ -1885,8 +1877,7 @@ function coerce(value, options = {}) {
1885
1877
  function getMajor(version, options = {}) {
1886
1878
  return parse(version, options).major;
1887
1879
  }
1888
- //#endregion
1889
- //#region src/types/package.ts
1880
+ // src/types/package.ts
1890
1881
  const PackageManager = {
1891
1882
  pnpm: "pnpm",
1892
1883
  npm: "npm",
@@ -1899,8 +1890,7 @@ const DependencyType = {
1899
1890
  peerDependencies: "peerDependencies",
1900
1891
  optionalDependencies: "optionalDependencies"
1901
1892
  };
1902
- //#endregion
1903
- //#region src/utils/spinner.ts
1893
+ // src/utils/spinner.ts
1904
1894
  function getSpinner(interactive) {
1905
1895
  if (interactive) return spinner();
1906
1896
  return {
@@ -1922,8 +1912,7 @@ function getSilentSpinner() {
1922
1912
  message: () => {}
1923
1913
  };
1924
1914
  }
1925
- //#endregion
1926
- //#region src/utils/approve-builds.ts
1915
+ // src/utils/approve-builds.ts
1927
1916
  /**
1928
1917
  * pnpm prints this prefix whenever it gates a dependency's build (install /
1929
1918
  * postinstall) script behind explicit approval. It appears both in the pnpm
@@ -2161,13 +2150,12 @@ async function detectGatedBuilds(installCwd, packageManager, pendingBuildsFromIn
2161
2150
  if (packageManager === PackageManager.pnpm || packageManager === PackageManager.yarn || packageManager === PackageManager.npm) return pendingBuildsFromInstall ?? [];
2162
2151
  if (packageManager === PackageManager.bun) {
2163
2152
  const { exitCode, stdout, stderr } = await runCommandSilently({
2164
- command: process.env.VP_CLI_BIN ?? "vp",
2165
- args: [
2153
+ ...getVpCommand([
2166
2154
  "exec",
2167
2155
  "bun",
2168
2156
  "pm",
2169
2157
  "untrusted"
2170
- ],
2158
+ ]),
2171
2159
  cwd: installCwd,
2172
2160
  envs: process.env
2173
2161
  });
@@ -2199,8 +2187,7 @@ async function runBuildAndReport(args, cwd, packages, interactive, silent, extra
2199
2187
  const spinner = silent ? getSilentSpinner() : getSpinner(interactive);
2200
2188
  spinner.start(`Building ${packages.join(", ")}...`);
2201
2189
  const { exitCode, stdout, stderr } = await runCommandSilently({
2202
- command: process.env.VP_CLI_BIN ?? "vp",
2203
- args,
2190
+ ...getVpCommand(args),
2204
2191
  cwd,
2205
2192
  envs: extraEnv ? {
2206
2193
  ...process.env,
@@ -2228,12 +2215,11 @@ async function runBuildAndReport(args, cwd, packages, interactive, silent, extra
2228
2215
  async function approveNpmScripts(installCwd, packages, interactive, silent) {
2229
2216
  const approveCommand = `vp pm approve-builds ${packages.join(" ")}`;
2230
2217
  const { exitCode, stdout, stderr } = await runCommandSilently({
2231
- command: process.env.VP_CLI_BIN ?? "vp",
2232
- args: [
2218
+ ...getVpCommand([
2233
2219
  "pm",
2234
2220
  "approve-builds",
2235
2221
  ...packages
2236
- ],
2222
+ ]),
2237
2223
  cwd: installCwd,
2238
2224
  envs: process.env
2239
2225
  });
@@ -2335,8 +2321,7 @@ async function approveBuilds(options) {
2335
2321
  ...selected
2336
2322
  ], cwd, selected, interactive, silent);
2337
2323
  }
2338
- //#endregion
2339
- //#region src/utils/yaml.ts
2324
+ // src/utils/yaml.ts
2340
2325
  var import_dist = require_dist();
2341
2326
  function readYamlFile(file) {
2342
2327
  const content = fs.readFileSync(file, "utf-8");
@@ -2351,8 +2336,7 @@ function editYamlFile(file, callback) {
2351
2336
  function scalarString(value) {
2352
2337
  return new import_dist.Scalar(value);
2353
2338
  }
2354
- //#endregion
2355
- //#region src/utils/preview-registry.ts
2339
+ // src/utils/preview-registry.ts
2356
2340
  const DEFAULT_BRIDGE_REGISTRY = "https://registry-bridge.viteplus.dev/";
2357
2341
  const REGISTRY_MARKER = "# vite-plus preview build registry bridge (auto-added by vp)";
2358
2342
  const BRIDGE_HOST = "registry-bridge.viteplus.dev";
@@ -2479,8 +2463,7 @@ function reconcilePreviewBridgeRegistry(projectRoot, version = process.env.VP_VE
2479
2463
  const clearedYarnrc = clearYarnBerryRegistry(projectRoot);
2480
2464
  return clearedNpmrc || clearedYarnrc;
2481
2465
  }
2482
- //#endregion
2483
- //#region src/utils/prompts.ts
2466
+ // src/utils/prompts.ts
2484
2467
  /**
2485
2468
  * pnpm v11 promoted `ERR_PNPM_IGNORED_BUILDS` from a warning to a hard
2486
2469
  * exit-1. Auto-installs run by `vp migrate` / `vp create` happen before the
@@ -2545,8 +2528,7 @@ async function runViteInstall(cwd, interactive, extraArgs, options) {
2545
2528
  const startTime = Date.now();
2546
2529
  spinner.start(`Installing dependencies...`);
2547
2530
  const { exitCode, stderr, stdout } = await runCommandSilently({
2548
- command: process.env.VP_CLI_BIN ?? "vp",
2549
- args: ["install", ...installArgs],
2531
+ ...getVpCommand(["install", ...installArgs]),
2550
2532
  cwd,
2551
2533
  envs: process.env
2552
2534
  });
@@ -2578,12 +2560,11 @@ async function runViteFmt(cwd, interactive, paths, options) {
2578
2560
  const startTime = Date.now();
2579
2561
  spinner.start(`Formatting code...`);
2580
2562
  const { exitCode, stderr, stdout } = await runCommandSilently({
2581
- command: options?.command ?? process.env.VP_CLI_BIN ?? "vp",
2582
- args: [
2563
+ ...getVpCommand([
2583
2564
  ...options?.commandArgs ?? [],
2584
2565
  "fmt",
2585
2566
  ...paths ?? []
2586
- ],
2567
+ ], options?.command),
2587
2568
  cwd,
2588
2569
  envs: process.env
2589
2570
  });
@@ -2667,5 +2648,4 @@ async function resolveGitInit(options, isMonorepo) {
2667
2648
  function defaultInteractive() {
2668
2649
  return !process.env.CI && process.stdin.isTTY;
2669
2650
  }
2670
- //#endregion
2671
2651
  export { text as A, confirm as C, outro as D, multiselect as E, isCancel as M, select as O, normalize$1 as S, log as T, getSpinner as _, resolveGitInit as a, coerce as b, selectPackageManager as c, readYamlFile as d, scalarString as f, getSilentSpinner as g, resolveApproveBuildTargets as h, promptGitHooks as i, require_picocolors as j, spinner as k, upgradeYarn as l, detectGatedBuilds as m, defaultInteractive as n, runViteFmt as o, approveBuilds as p, downloadPackageManager$1 as r, runViteInstall as s, cancelAndExit as t, editYamlFile as u, DependencyType as v, intro as w, getMajor as x, PackageManager as y };
@@ -1,4 +1,3 @@
1
- //#region src/migration/compat/protocol.ts
1
+ // src/migration/compat/protocol.ts
2
2
  const ROLLDOWN_COMPAT_RESULT_PREFIX = "VITE_PLUS_ROLLDOWN_COMPAT_RESULT=";
3
- //#endregion
4
3
  export { ROLLDOWN_COMPAT_RESULT_PREFIX as t };
@@ -1,4 +1,4 @@
1
- //#region src/migration/report.ts
1
+ // src/migration/report.ts
2
2
  function createMigrationReport() {
3
3
  return {
4
4
  createdViteConfigCount: 0,
@@ -14,6 +14,7 @@ function createMigrationReport() {
14
14
  rewrittenImportErrors: [],
15
15
  eslintMigrated: false,
16
16
  tsupMigrated: false,
17
+ tsxMigrated: false,
17
18
  prettierMigrated: false,
18
19
  nodeVersionFileMigrated: false,
19
20
  setupVpVersionUpdatedFileCount: 0,
@@ -33,5 +34,4 @@ function addManualStep(report, step) {
33
34
  if (!report || report.manualSteps.includes(step)) return;
34
35
  report.manualSteps.push(step);
35
36
  }
36
- //#endregion
37
37
  export { addMigrationWarning as n, createMigrationReport as r, addManualStep as t };
@@ -1,8 +1,9 @@
1
- import { l as VITE_CONFIG_FILES } from "./constants-DR55DpRm.js";
2
- import { u as withConfigMetadataResolution } from "./define-config-CvE5pHqB.js";
1
+ import { l as VITE_CONFIG_FILES } from "./constants-DRUnJ_Dz.js";
2
+ import { u as withConfigMetadataResolution } from "./define-config-ChwJcu5e.js";
3
3
  import path from "node:path";
4
+ import { findMonorepoRoot } from "../binding/index.js";
4
5
  import fs from "node:fs";
5
- //#region src/resolve-vite-config.ts
6
+ // src/resolve-vite-config.ts
6
7
  /**
7
8
  * Find a vite config file by walking up from `startDir` to `stopDir`.
8
9
  * Returns the absolute path of the first config file found, or undefined.
@@ -10,13 +11,15 @@ import fs from "node:fs";
10
11
  function findViteConfigUp(startDir, stopDir) {
11
12
  let dir = path.resolve(startDir);
12
13
  const stop = path.resolve(stopDir);
14
+ const relative = path.relative(stop, dir);
15
+ if (relative === ".." || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) return;
13
16
  while (true) {
14
17
  for (const filename of VITE_CONFIG_FILES) {
15
18
  const filePath = path.join(dir, filename);
16
19
  if (fs.existsSync(filePath)) return filePath;
17
20
  }
18
21
  const parent = path.dirname(dir);
19
- if (parent === dir || !parent.startsWith(stop)) break;
22
+ if (dir === stop || parent === dir) break;
20
23
  dir = parent;
21
24
  }
22
25
  }
@@ -33,31 +36,13 @@ function hasViteConfig(dir) {
33
36
  return findViteConfig(dir) !== void 0;
34
37
  }
35
38
  /**
36
- * Find the workspace root by walking up from `startDir` looking for
37
- * monorepo indicators (pnpm-workspace.yaml, workspaces in package.json, lerna.json).
38
- */
39
- function findWorkspaceRoot(startDir) {
40
- let dir = path.resolve(startDir);
41
- while (true) {
42
- if (fs.existsSync(path.join(dir, "pnpm-workspace.yaml"))) return dir;
43
- const pkgPath = path.join(dir, "package.json");
44
- if (fs.existsSync(pkgPath)) try {
45
- if (JSON.parse(fs.readFileSync(pkgPath, "utf-8")).workspaces) return dir;
46
- } catch {}
47
- if (fs.existsSync(path.join(dir, "lerna.json"))) return dir;
48
- const parent = path.dirname(dir);
49
- if (parent === dir) break;
50
- dir = parent;
51
- }
52
- }
53
- /**
54
39
  * Resolve vite.config.ts and return the config object.
55
40
  */
56
41
  async function resolveViteConfig(cwd, options) {
57
42
  const { resolveConfig } = await import("./index.js");
58
43
  return withConfigMetadataResolution(async () => {
59
44
  if (options?.traverseUp && !hasViteConfig(cwd)) {
60
- const workspaceRoot = findWorkspaceRoot(cwd);
45
+ const workspaceRoot = findMonorepoRoot(cwd);
61
46
  if (workspaceRoot) {
62
47
  const configFile = findViteConfigUp(path.dirname(cwd), workspaceRoot);
63
48
  if (configFile) return resolveConfig({
@@ -86,5 +71,4 @@ async function resolveUniversalViteConfig(err, viteConfigCwd) {
86
71
  throw resolveErr;
87
72
  }
88
73
  }
89
- //#endregion
90
- export { resolveUniversalViteConfig as a, hasViteConfig as i, findViteConfigUp as n, resolveViteConfig as o, findWorkspaceRoot as r, findViteConfig as t };
74
+ export { resolveViteConfig as a, resolveUniversalViteConfig as i, findViteConfigUp as n, hasViteConfig as r, findViteConfig as t };
@@ -0,0 +1 @@
1
+ export { i as resolveUniversalViteConfig } from "./resolve-vite-config-Dn5896A4.js";
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from "node:module";
2
- //#region \0rolldown/runtime.js
2
+ // \0rolldown/runtime.js
3
3
  var __create = Object.create;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -22,5 +22,4 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
22
22
  enumerable: true
23
23
  }) : target, mod));
24
24
  var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
25
- //#endregion
26
25
  export { __require as n, __toESM as r, __commonJSMin as t };
@@ -0,0 +1,8 @@
1
+ import { InitializeHook, LoadHook, ResolveHook } from "node:module";
2
+ import { MessagePort } from "node:worker_threads";
3
+ /** Receives the port `script-register.ts` relays watch reports through. */
4
+ export declare const initialize: InitializeHook<{
5
+ watchPort?: MessagePort;
6
+ } | undefined>;
7
+ export declare const resolve: ResolveHook;
8
+ export declare const load: LoadHook;
@@ -0,0 +1,24 @@
1
+ import { i as resolveWithOxcNode, r as loadOxcNode, s as withFlush, t as HELPER_MODULE_NAME } from "./script-hooks-9Fof5UMY.js";
2
+ import { MessageChannel, isMainThread } from "node:worker_threads";
3
+ // src/script-esm-hooks.ts
4
+ const oxcNode = loadOxcNode();
5
+ if (!isMainThread) new MessageChannel().port1.ref();
6
+ const resolveHook = (specifier, context, nextResolve) => resolveWithOxcNode(oxcNode, specifier, context, nextResolve);
7
+ const loadHook = (url, context, nextLoad) => oxcNode.load(url, context, nextLoad, HELPER_MODULE_NAME);
8
+ /** Under watch mode, the hooks wrapped to report what each call read or looked for. */
9
+ let watchHooks;
10
+ /** Receives the port `script-register.ts` relays watch reports through. */
11
+ const initialize = (data) => {
12
+ const port = data?.watchPort;
13
+ if (port) {
14
+ port.unref();
15
+ const sink = (message) => port.postMessage(message);
16
+ watchHooks = {
17
+ resolve: withFlush(resolveHook, sink, oxcNode.takeWatchDependencies),
18
+ load: withFlush(loadHook, sink, oxcNode.takeWatchDependencies)
19
+ };
20
+ }
21
+ };
22
+ const resolve = (specifier, context, nextResolve) => (watchHooks?.resolve ?? resolveHook)(specifier, context, nextResolve);
23
+ const load = (url, context, nextLoad) => (watchHooks?.load ?? loadHook)(url, context, nextLoad);
24
+ export { initialize, load, resolve };
@@ -0,0 +1,176 @@
1
+ import { createRequire } from "node:module";
2
+ import { MessageChannel, isMainThread, receiveMessageOnPort } from "node:worker_threads";
3
+ // ../../oxc-node/packages/core/watch-report.mjs
4
+ const WATCH_CHANNEL = "@oxc-node/core:watch-deps";
5
+ /**
6
+ * Where this thread sends its reports, or `null` when nobody is watching. With
7
+ * `null` nothing is wrapped, opened or listened to.
8
+ *
9
+ * @returns {((message: { "watch:import": string[] }) => void) | null}
10
+ */
11
+ function watchSink() {
12
+ if (!process.env.WATCH_REPORT_DEPENDENCIES) return null;
13
+ if (isMainThread) {
14
+ if (typeof process.send !== "function") return null;
15
+ const seen = /* @__PURE__ */ new Set();
16
+ const send = (message) => {
17
+ const url = message?.["watch:import"]?.[0];
18
+ if (typeof url !== "string" || seen.has(url) || !process.connected) return;
19
+ seen.add(url);
20
+ try {
21
+ process.send(message, () => {});
22
+ } catch {}
23
+ };
24
+ const channel = new BroadcastChannel(WATCH_CHANNEL);
25
+ channel.onmessage = (event) => send(event.data);
26
+ channel.unref();
27
+ return send;
28
+ }
29
+ const channel = new BroadcastChannel(WATCH_CHANNEL);
30
+ channel.unref();
31
+ return (message) => channel.postMessage(message);
32
+ }
33
+ /**
34
+ * Send what the binding recorded, one URL per message: the watch parent reads a
35
+ * whole array in one `try`, so one bad entry would drop the rest. `oxnode watch`
36
+ * reads the `oxc-node` key to tell these from what Node.js reports (a tsconfig
37
+ * in `node_modules` counts, an imported file there does not); Node.js ignores it.
38
+ *
39
+ * @param {(message: { "watch:import": string[], "oxc-node": true }) => void} sink
40
+ * @param {() => string[]} take the binding's `takeWatchDependencies`
41
+ */
42
+ function flush(sink, take) {
43
+ for (const url of take()) sink({
44
+ "watch:import": [url],
45
+ "oxc-node": true
46
+ });
47
+ }
48
+ /**
49
+ * `fn`, flushing after each call whether it returns, throws or returns a promise.
50
+ * A failed resolve records its candidates and then throws, which is exactly the
51
+ * case that has to be reported. `sink` and `take` are as for `flush`.
52
+ */
53
+ function withFlush(fn, sink, take) {
54
+ return function(...args) {
55
+ let result;
56
+ try {
57
+ result = fn.apply(this, args);
58
+ } catch (error) {
59
+ flush(sink, take);
60
+ throw error;
61
+ }
62
+ if (result && typeof result.then === "function") return result.then((value) => {
63
+ flush(sink, take);
64
+ return value;
65
+ }, (error) => {
66
+ flush(sink, take);
67
+ throw error;
68
+ });
69
+ flush(sink, take);
70
+ return result;
71
+ };
72
+ }
73
+ /**
74
+ * For `module.register()`: the hooks run on a thread of their own with no
75
+ * `process.send`, so they post into the returned port and the thread that
76
+ * registered them forwards to `sink`. `take` is as for `flush`: what this thread's
77
+ * binding recorded is drained here too, before the process ends.
78
+ */
79
+ function createRelay(sink, take) {
80
+ const { port1, port2 } = new MessageChannel();
81
+ port1.on("message", sink);
82
+ port1.unref();
83
+ const drain = () => {
84
+ let received;
85
+ while (received = receiveMessageOnPort(port1)) sink(received.message);
86
+ flush(sink, take);
87
+ };
88
+ process.on("uncaughtExceptionMonitor", drain);
89
+ process.on("exit", drain);
90
+ return port2;
91
+ }
92
+ // src/script-hooks.ts
93
+ /**
94
+ * Shared pieces of the `vpx <script>` loader (see `script-preload.ts`).
95
+ */
96
+ /**
97
+ * The oxc-node hooks compiled into the Vite+ binding. Required, not imported: importing
98
+ * `index.js` makes a `module.register()` hooks thread translate the whole CommonJS
99
+ * binding for ESM, and `module.register()` waits for that (5-13 ms).
100
+ */
101
+ function loadOxcNode() {
102
+ return createRequire(import.meta.url)("../binding/index.cjs").oxcNode;
103
+ }
104
+ const WATCH_SINK = Symbol.for("vite-plus:script-watch-sink");
105
+ /**
106
+ * Where this thread reports the files watch mode restarts on, or `null` when nobody is
107
+ * watching (see oxc-node's `watchSink()`). It opens a channel, so it runs once per thread:
108
+ * the preload and the `--import` entry are separate bundles and share it here.
109
+ */
110
+ function threadWatchSink() {
111
+ const holder = globalThis;
112
+ if (holder[WATCH_SINK] === void 0) holder[WATCH_SINK] = watchSink();
113
+ return holder[WATCH_SINK];
114
+ }
115
+ /**
116
+ * Whether to use the in-thread `module.registerHooks()` instead of the off-thread
117
+ * `module.register()`, which needs a hooks thread (about twice the startup time) and
118
+ * which Node.js deprecates from 25.9 (DEP0205).
119
+ *
120
+ * The in-thread hooks need two fixes: a sync resolve hook had its `conditions`
121
+ * overridden (nodejs/node#59011, in 22.19 and 24.5), and a sync load hook could not
122
+ * return a null source for CommonJS (nodejs/node#59929, in 22.22.3 and 24.11.1). tsx
123
+ * switches at the same releases. Upstream oxc-node waits for 26.2 for a third fix,
124
+ * nodejs/node#62920 (also in 24.18.0), which only matters when a load hook returns
125
+ * CommonJS source. These hooks return it only for source another hook supplied, so
126
+ * without that fix `require()` inside such a module can fail.
127
+ */
128
+ function canRegisterSyncHooks(version) {
129
+ const [major = 0, minor = 0, patch = 0] = version.split(".").map(Number);
130
+ if (major === 22) return minor > 22 || minor === 22 && patch >= 3;
131
+ if (major === 24) return minor > 11 || minor === 11 && patch >= 1;
132
+ return major >= 26;
133
+ }
134
+ /**
135
+ * The module name oxc-node gives the runtime helpers it injects, passed to its transformer
136
+ * and load hook. Only these hooks emit it, so they redirect only their own helper imports,
137
+ * not `@oxc-node/core/helpers/*` imports that another oxc-node copy produced.
138
+ */
139
+ const HELPER_MODULE_NAME = "vite-plus:oxc-node";
140
+ const OXC_NODE_HELPERS = `${HELPER_MODULE_NAME}/helpers/`;
141
+ const RUNTIME_HELPERS = "@oxc-project/runtime/helpers/";
142
+ /**
143
+ * oxc-node lowers class fields, static blocks, `using`, and legacy decorators to
144
+ * helper imports. The same helpers ship in `@oxc-project/runtime`, a dependency of
145
+ * `vite-plus`; the hooks resolve them from here, because the user's project usually
146
+ * does not have it.
147
+ */
148
+ function runtimeHelperSpecifier(specifier) {
149
+ return specifier.startsWith(OXC_NODE_HELPERS) ? RUNTIME_HELPERS + specifier.slice(OXC_NODE_HELPERS.length) : void 0;
150
+ }
151
+ /** URL that runtime helper imports resolve from: this package. */
152
+ const HELPERS_PARENT_URL = import.meta.url;
153
+ /**
154
+ * Whether this request comes from `require()`. Only `module.registerHooks()` shows
155
+ * `require()` to the hooks; those requests stay on Node.js' CommonJS resolution and
156
+ * the `pirates` hook. A CommonJS context never carries `importAttributes`.
157
+ */
158
+ function isCommonJsRequire(context) {
159
+ return context?.importAttributes === void 0;
160
+ }
161
+ /**
162
+ * The resolve hook for both hook paths: `require()` stays on Node.js' resolution, where
163
+ * `routeHelperRequires` maps runtime helpers (it resolves from the requiring file and
164
+ * ignores a `parentURL`), runtime helper imports resolve from this package, and
165
+ * everything else goes through oxc-node.
166
+ */
167
+ function resolveWithOxcNode(oxcNode, specifier, context, nextResolve) {
168
+ if (isCommonJsRequire(context)) return nextResolve(specifier, context);
169
+ const helper = runtimeHelperSpecifier(specifier);
170
+ if (helper) return nextResolve(helper, {
171
+ ...context,
172
+ parentURL: HELPERS_PARENT_URL
173
+ });
174
+ return oxcNode.createResolve(specifier, context, nextResolve);
175
+ }
176
+ export { threadWatchSink as a, resolveWithOxcNode as i, canRegisterSyncHooks as n, createRelay as o, loadOxcNode as r, withFlush as s, HELPER_MODULE_NAME as t };