vite-plus 0.3.1 → 0.3.3

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 (63) hide show
  1. package/README.md +1 -1
  2. package/bin/vp +1 -1
  3. package/binding/index.cjs +137 -56
  4. package/binding/index.d.cts +52 -0
  5. package/dist/{agent-C5jMYVfB.js → agent-Cu6-tXIP.js} +2 -2
  6. package/dist/bin.js +6 -5
  7. package/dist/config/bin.js +2 -2
  8. package/dist/{constants-0IAVgpox.js → constants-C2dTOTe-.js} +2 -2
  9. package/dist/create/bin.js +97 -68
  10. package/dist/{define-config-DIE9de46.cjs → define-config-D0mevyb3.cjs} +1 -1
  11. package/dist/{define-config-U3_xg7i-.js → define-config-IgzmnvvV.js} +2 -2
  12. package/dist/define-config.cjs +1 -1
  13. package/dist/define-config.js +1 -1
  14. package/dist/{editor-B5-lvRaU.js → editor-4sjlHmUh.js} +154 -36
  15. package/dist/index.cjs +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/lint-plugins-dev.d.ts +3 -0
  18. package/dist/lint-plugins-dev.js +2 -0
  19. package/dist/lint-plugins.cjs +21 -0
  20. package/dist/lint-plugins.d.ts +3 -0
  21. package/dist/lint-plugins.js +2 -0
  22. package/dist/migration/bin.js +7 -7
  23. package/dist/{oxlint-plugin-config-Drdl67Xp.js → oxlint-plugin-config-BVqEe9KY.js} +1 -1
  24. package/dist/oxlint-plugin.js +93 -32
  25. package/dist/pack-bin.js +1 -1
  26. package/dist/{package-BZz2Ij68.js → package-CHH8jWan.js} +1 -1
  27. package/dist/{prompts-CtzEgFY-.js → prompts-k14KgthC.js} +1 -1
  28. package/dist/{resolve-vite-config-CGks1xR7.js → resolve-vite-config-BqvS2P98.js} +2 -2
  29. package/dist/{resolve-vite-config-Dnmc-lBc.js → resolve-vite-config-CTOTuqTi.js} +1 -1
  30. package/dist/staged/bin.js +1 -1
  31. package/dist/toolchain.js +8 -8
  32. package/dist/toolchain.json +8 -8
  33. package/dist/{tsconfig-CUggNuJR.js → tsconfig-C3h9CVTA.js} +2 -2
  34. package/dist/{tsconfig-VAbm4ZzJ.js → tsconfig-euB-GmIE.js} +1 -1
  35. package/dist/version.js +2 -2
  36. package/dist/versions.js +4 -4
  37. package/docs/config/fmt.md +4 -2
  38. package/docs/config/lint.md +4 -2
  39. package/docs/config/staged.md +1 -2
  40. package/docs/guide/ci.md +28 -31
  41. package/docs/guide/commit-hooks.md +11 -34
  42. package/docs/guide/create.md +1 -2
  43. package/docs/guide/docker.md +20 -68
  44. package/docs/guide/env.md +56 -22
  45. package/docs/guide/fmt.md +3 -1
  46. package/docs/guide/global-cli.md +426 -0
  47. package/docs/guide/ide-integration.md +1 -2
  48. package/docs/guide/implode.md +14 -1
  49. package/docs/guide/index.md +37 -34
  50. package/docs/guide/install.md +18 -19
  51. package/docs/guide/lint.md +52 -1
  52. package/docs/guide/local-cli.md +123 -0
  53. package/docs/guide/migrate-rules.md +108 -267
  54. package/docs/guide/migrate.md +6 -49
  55. package/docs/guide/monorepo.md +2 -0
  56. package/docs/guide/run.md +1 -1
  57. package/docs/guide/troubleshooting.md +17 -8
  58. package/docs/guide/upgrade-project.md +61 -0
  59. package/docs/guide/upgrade.md +17 -62
  60. package/package.json +26 -17
  61. package/templates/generator/README.md +14 -0
  62. package/templates/generator/bin/index.ts +54 -5
  63. package/docs/guide/installer-env-vars.md +0 -252
@@ -1,15 +1,15 @@
1
1
  import { r as __toESM } from "./rolldown-runtime-CMFfr-1z.js";
2
- import { a as SETUP_VP_VERSION, c as VITEST_VERSION, d as VITE_PLUS_OVERRIDE_PACKAGES, f as VITE_PLUS_VERSION, l as VITE_CONFIG_FILES, m as isForceOverrideMode, n as BASEURL_TSCONFIG_WARNING, o as TSDOWN_MIGRATION_SKILL_URL, s as VITEST_AGE_GATE_EXEMPT_PACKAGES, u as VITE_PLUS_NAME } from "./constants-0IAVgpox.js";
3
- import { i as ensureVitePlusImportRuleDefaults, r as createDefaultVitePlusLintConfig } from "./oxlint-plugin-config-Drdl67Xp.js";
2
+ import { a as SETUP_VP_VERSION, c as VITEST_VERSION, d as VITE_PLUS_OVERRIDE_PACKAGES, f as VITE_PLUS_VERSION, l as VITE_CONFIG_FILES, m as isForceOverrideMode, n as BASEURL_TSCONFIG_WARNING, o as TSDOWN_MIGRATION_SKILL_URL, s as VITEST_AGE_GATE_EXEMPT_PACKAGES, u as VITE_PLUS_NAME } from "./constants-C2dTOTe-.js";
3
+ import { i as ensureVitePlusImportRuleDefaults, r as createDefaultVitePlusLintConfig } from "./oxlint-plugin-config-BVqEe9KY.js";
4
4
  import { a as writeJsonFile, c as parse, i as readJsonFile, n as editJsonFile, o as applyEdits, r as isJsonFile, s as modify, t as detectFormattingOptions } from "./json-cULBl7Pi.js";
5
- import { n as detectPackageMetadata, r as getScopeFromPackageName } from "./package-BZz2Ij68.js";
6
- import { C as multiselect, S as log, T as select, _ as getSpinner, b as confirm, d as readYamlFile, f as scalarString, g as getSilentSpinner, k as isCancel, t as cancelAndExit, u as editYamlFile, y as PackageManager } from "./prompts-CtzEgFY-.js";
5
+ import { n as detectPackageMetadata, r as getScopeFromPackageName } from "./package-CHH8jWan.js";
6
+ import { C as multiselect, S as log, T as select, _ as getSpinner, b as confirm, d as readYamlFile, f as scalarString, g as getSilentSpinner, k as isCancel, t as cancelAndExit, u as editYamlFile, y as PackageManager } from "./prompts-k14KgthC.js";
7
7
  import { t as require_semver } from "./semver-CaDAb8vV.js";
8
- import { l as displayRelative, u as rulesDir } from "./agent-C5jMYVfB.js";
8
+ import { l as displayRelative, u as rulesDir } from "./agent-Cu6-tXIP.js";
9
9
  import { n as addMigrationWarning, t as addManualStep } from "./report-CK5TnTsr.js";
10
10
  import { n as runCommandSilently, r as require_cross_spawn } from "./command-CguLh2KL.js";
11
11
  import { t as require_dist } from "./dist-BDYZP12R.js";
12
- import { a as hasBaseUrlInTsconfig, c as hasVitestTypesInTsconfig, l as removeDeprecatedTsconfigFalseOption, n as findTsconfigFiles, s as hasTypesToRewriteInTsconfig, u as rewriteTypesInTsconfig } from "./tsconfig-CUggNuJR.js";
12
+ import { a as hasBaseUrlInTsconfig, c as hasVitestTypesInTsconfig, l as removeDeprecatedTsconfigFalseOption, n as findTsconfigFiles, s as hasTypesToRewriteInTsconfig, u as rewriteTypesInTsconfig } from "./tsconfig-C3h9CVTA.js";
13
13
  import { n as extractOverrideTargetName, t as isAlignableVitestEcosystemPackage } from "./vitest-ecosystem-BiRqcaRI.js";
14
14
  import { i as findUnsafeHookInstallPath, t as SUPPORTED_GIT_HOOK_NAMES } from "./hooks-C-4gykWR.js";
15
15
  import path, { posix, win32 } from "node:path";
@@ -62,13 +62,14 @@ const BROWSER_PROVIDER_PEER_DEPS = {
62
62
  "@vitest/browser-playwright": "playwright",
63
63
  "@vitest/browser-webdriverio": "webdriverio"
64
64
  };
65
- const PROVIDER_PEER_VERSION_SIBLINGS = {
66
- playwright: ["@playwright/test"],
67
- webdriverio: ["@wdio/cli", "@wdio/globals"]
68
- };
65
+ const RUNTIME_PEER_INCLUDED_BY = { playwright: ["@playwright/test"] };
66
+ const PROVIDER_PEER_VERSION_SIBLINGS = { webdriverio: ["@wdio/cli", "@wdio/globals"] };
69
67
  function findDeclaredSpec(pkg, name) {
70
68
  return pkg.dependencies?.[name] ?? pkg.devDependencies?.[name] ?? pkg.peerDependencies?.[name] ?? pkg.optionalDependencies?.[name];
71
69
  }
70
+ function hasProviderPeerDependency(pkg, runtimePeer) {
71
+ return findDeclaredSpec(pkg, runtimePeer) !== void 0 || (RUNTIME_PEER_INCLUDED_BY[runtimePeer] ?? []).some((packageName) => findDeclaredSpec(pkg, packageName) !== void 0);
72
+ }
72
73
  function resolveProviderPeerSpec(pkg, peer, supportCatalog, catalogDependencyResolver) {
73
74
  if (supportCatalog && catalogDependencyResolver?.("catalog:", peer) !== void 0) return "catalog:";
74
75
  for (const sibling of PROVIDER_PEER_VERSION_SIBLINGS[peer] ?? []) {
@@ -175,6 +176,24 @@ function pnpmMajor(version) {
175
176
  const coerced = version ? import_semver.default.coerce(version)?.version : void 0;
176
177
  return coerced ? import_semver.default.major(coerced) : void 0;
177
178
  }
179
+ const OXLINT_PLUGINS_PACKAGE = "@oxlint/plugins";
180
+ const OXLINT_PLUGIN_API_PACKAGES = ["oxlint", OXLINT_PLUGINS_PACKAGE];
181
+ function packageOwnsOxlintApi(pkg) {
182
+ return pkg.optionalDependencies?.["@oxlint/plugins"] !== void 0 || OXLINT_PLUGIN_API_PACKAGES.some((name) => pkg.dependencies?.[name] !== void 0 || pkg.peerDependencies?.[name] !== void 0);
183
+ }
184
+ /**
185
+ * Capture plugin owners before manifest edits, so the import rewriter can
186
+ * preserve their upstream API imports after those edits.
187
+ */
188
+ function collectOxlintOwnerDirs(rootDir, packages) {
189
+ const owners = [];
190
+ const candidates = [rootDir, ...(packages ?? []).map((pkg) => path.join(rootDir, pkg.path))];
191
+ for (const dir of candidates) {
192
+ const pkg = readPackageJsonIfExists(path.join(dir, "package.json"));
193
+ if (pkg && packageOwnsOxlintApi(pkg)) owners.push(dir);
194
+ }
195
+ return owners;
196
+ }
178
197
  //#endregion
179
198
  //#region src/migration/detector.ts
180
199
  const PRETTIER_PACKAGE_JSON_CONFIG = "package.json#prettier";
@@ -331,6 +350,18 @@ function detectEslintProject(projectPath, packages) {
331
350
  legacyConfigFile
332
351
  };
333
352
  }
353
+ function extractSkippedRules(output) {
354
+ const lines = output.toString().replaceAll("\r\n", "\n").split("\n");
355
+ const start = lines.findIndex((line) => /^\s*Skipped \d+ rules:/.test(line));
356
+ if (start === -1) return;
357
+ const indentation = lines[start].search(/\S/);
358
+ const block = [lines[start].trim()];
359
+ for (const line of lines.slice(start + 1)) {
360
+ if (line.trim() === "" || line.search(/\S/) <= indentation) break;
361
+ block.push(` ${line.slice(indentation)}`);
362
+ }
363
+ return block.join("\n");
364
+ }
334
365
  /**
335
366
  * Run a `vp dlx @oxlint/migrate` step with graceful error handling.
336
367
  * Returns true on success, false on failure (spawn error or non-zero exit).
@@ -352,13 +383,16 @@ async function runOxlintMigrateStep(vpBin, cwd, migratePackage, args, spinner, f
352
383
  const stderr = result.stderr.toString().trim();
353
384
  if (stderr) log.warn(`⚠ ${stderr}`);
354
385
  log.info(manualHint);
355
- return false;
386
+ return { ok: false };
356
387
  }
357
- return true;
388
+ return {
389
+ ok: true,
390
+ skippedRules: extractSkippedRules(result.stdout)
391
+ };
358
392
  } catch {
359
393
  spinner.stop(failMessage);
360
394
  log.info(manualHint);
361
- return false;
395
+ return { ok: false };
362
396
  }
363
397
  }
364
398
  async function migrateEslintToOxlint(projectPath, interactive, eslintConfigFile, packages, options) {
@@ -374,10 +408,12 @@ async function migrateEslintToOxlint(projectPath, interactive, eslintConfigFile,
374
408
  "--details"
375
409
  ];
376
410
  spinner.start("Migrating ESLint config to Oxlint...");
377
- if (!await runOxlintMigrateStep(vpBin, projectPath, migratePackage, migrateArgs, spinner, "ESLint migration failed", `You can run \`vp dlx ${migratePackage} ${migrateArgs.join(" ")}\` manually later`)) return false;
411
+ const migrateResult = await runOxlintMigrateStep(vpBin, projectPath, migratePackage, migrateArgs, spinner, "ESLint migration failed", `You can run \`vp dlx ${migratePackage} ${migrateArgs.join(" ")}\` manually later`);
412
+ if (!migrateResult.ok) return false;
378
413
  spinner.stop("ESLint config migrated to .oxlintrc.json");
414
+ if (migrateResult.skippedRules) warnMigration(migrateResult.skippedRules, options?.report);
379
415
  spinner.start("Replacing ESLint comments with Oxlint equivalents...");
380
- if (await runOxlintMigrateStep(vpBin, projectPath, migratePackage, ["--replace-eslint-comments"], spinner, "ESLint comment replacement failed", `You can run \`vp dlx ${migratePackage} --replace-eslint-comments\` manually later`)) spinner.stop("ESLint comments replaced");
416
+ if ((await runOxlintMigrateStep(vpBin, projectPath, migratePackage, ["--replace-eslint-comments"], spinner, "ESLint comment replacement failed", `You can run \`vp dlx ${migratePackage} --replace-eslint-comments\` manually later`)).ok) spinner.stop("ESLint comments replaced");
381
417
  }
382
418
  if (options?.report) options.report.eslintMigrated = true;
383
419
  const preserveJsPlugins = collectJsPluginPackageNames(projectPath);
@@ -653,6 +689,14 @@ function jsPluginsToNamespaces(entries) {
653
689
  ns.delete("");
654
690
  return ns;
655
691
  }
692
+ function stripUnsupportedReactRefreshOption(rules) {
693
+ const rule = rules?.["react/only-export-components"];
694
+ if (!Array.isArray(rule)) return false;
695
+ const options = rule[1];
696
+ if (!options || typeof options !== "object" || Array.isArray(options) || !("allowCompoundComponents" in options)) return false;
697
+ delete options.allowCompoundComponents;
698
+ return true;
699
+ }
656
700
  /**
657
701
  * Sanitize the `.oxlintrc.json` produced by `@oxlint/migrate` (in-place)
658
702
  * before it gets merged into `vite.config.ts`. Drop references that
@@ -674,6 +718,7 @@ function jsPluginsToNamespaces(entries) {
674
718
  function sanitizeMigratedOxlintConfig(config, availablePackages, report) {
675
719
  const allDroppedJsPlugins = /* @__PURE__ */ new Set();
676
720
  const allDroppedPlugins = /* @__PURE__ */ new Set();
721
+ let droppedReactRefreshOption = stripUnsupportedReactRefreshOption(config.rules);
677
722
  const baseSplit = partitionJsPlugins(config.jsPlugins ?? [], availablePackages);
678
723
  for (const n of baseSplit.dropped) allDroppedJsPlugins.add(n);
679
724
  if (config.jsPlugins && baseSplit.dropped.length > 0) config.jsPlugins = baseSplit.kept;
@@ -690,6 +735,7 @@ function sanitizeMigratedOxlintConfig(config, availablePackages, report) {
690
735
  if (Object.keys(filtered).length !== Object.keys(config.rules).length) config.rules = filtered;
691
736
  }
692
737
  if (Array.isArray(config.overrides)) for (const override of config.overrides) {
738
+ if (stripUnsupportedReactRefreshOption(override.rules)) droppedReactRefreshOption = true;
693
739
  let overrideSurvivors = [];
694
740
  if (override.jsPlugins) {
695
741
  const split = partitionJsPlugins(override.jsPlugins, availablePackages);
@@ -710,6 +756,7 @@ function sanitizeMigratedOxlintConfig(config, availablePackages, report) {
710
756
  if (Object.keys(filtered).length !== Object.keys(override.rules).length) override.rules = filtered;
711
757
  }
712
758
  }
759
+ if (droppedReactRefreshOption) warnMigration("The bundled Oxlint does not support react/only-export-components.allowCompoundComponents. Removed this option from the migrated config; compound component exports may now report lint errors.", report);
713
760
  if (allDroppedJsPlugins.size > 0) warnMigration(`Stripped JS plugin reference(s) from the generated lint config: ${[...allDroppedJsPlugins].join(", ")}. No matching package is present in this workspace, so loading them at lint time would fail. If you want their Oxlint coverage back, install each package (e.g. \`vp install <name>\`) and add its name back to \`lint.jsPlugins\` in vite.config.ts.`, report);
714
761
  if (allDroppedPlugins.size > 0) warnMigration(`Stripped unknown plugin reference(s) from the generated lint config: ${[...allDroppedPlugins].join(", ")}. These aren't native Oxlint plugins and no surviving JS plugin contributes them.`, report);
715
762
  }
@@ -8069,6 +8116,12 @@ const VITEST_SCAN_SKIP_DIRS = /* @__PURE__ */ new Set([
8069
8116
  ".vite",
8070
8117
  ".cache"
8071
8118
  ]);
8119
+ const OXLINT_RETENTION_SKIP_DIRS = /* @__PURE__ */ new Set([
8120
+ "node_modules",
8121
+ ".git",
8122
+ ".hg",
8123
+ ".svn"
8124
+ ]);
8072
8125
  /**
8073
8126
  * Detect whether a package uses vitest's browser mode.
8074
8127
  *
@@ -8093,26 +8146,35 @@ const VITEST_SCAN_SKIP_DIRS = /* @__PURE__ */ new Set([
8093
8146
  * is a separate package that the migration scans on its own pass, so the root
8094
8147
  * package must not inherit a browser-mode signal from a sub-package.
8095
8148
  */
8096
- function sourceTreeMatches(projectPath, matchesContent) {
8097
- const scanDir = (dir, isRoot) => {
8149
+ function sourceTreeMatches(projectPath, matchesContent, options = {}) {
8150
+ const skipDirs = options.skipDirs ?? VITEST_SCAN_SKIP_DIRS;
8151
+ function scanDir(dir, isRoot) {
8098
8152
  let entries;
8099
8153
  try {
8100
8154
  entries = fs.readdirSync(dir, { withFileTypes: true });
8101
8155
  } catch {
8102
8156
  return false;
8103
8157
  }
8104
- if (!isRoot && entries.some((e) => e.isFile() && e.name === "package.json")) return false;
8158
+ if (!options.crossPackageBoundaries && !isRoot && entries.some((e) => e.isFile() && e.name === "package.json")) return false;
8105
8159
  for (const entry of entries) {
8106
8160
  const entryPath = path.join(dir, entry.name);
8107
8161
  if (entry.isDirectory()) {
8108
- if (VITEST_SCAN_SKIP_DIRS.has(entry.name)) continue;
8162
+ if (skipDirs.has(entry.name)) continue;
8109
8163
  if (scanDir(entryPath, false)) return true;
8110
- } else if (entry.isFile() && VITEST_SCAN_EXTENSIONS.has(path.extname(entry.name))) try {
8111
- if (matchesContent(fs.readFileSync(entryPath, "utf8"))) return true;
8164
+ } else if (entry.isFile() && (VITEST_SCAN_EXTENSIONS.has(path.extname(entry.name)) || options.includePackageReferences && entry.name === "package.json")) try {
8165
+ let content = fs.readFileSync(entryPath, "utf8");
8166
+ if (entry.name === "package.json") {
8167
+ const pkg = JSON.parse(content);
8168
+ content = JSON.stringify({
8169
+ imports: pkg.imports,
8170
+ scripts: pkg.scripts
8171
+ });
8172
+ }
8173
+ if (matchesContent(content)) return true;
8112
8174
  } catch {}
8113
8175
  }
8114
8176
  return false;
8115
- };
8177
+ }
8116
8178
  return scanDir(projectPath, true);
8117
8179
  }
8118
8180
  function sourceTreeReferencesAny(projectPath, hints) {
@@ -8161,6 +8223,39 @@ function collectProviderSourceModes(projectPath) {
8161
8223
  for (const provider of OPT_IN_BROWSER_PROVIDERS) modes[provider] = sourceTreeReferencesAny(projectPath, BROWSER_PROVIDER_SPECIFIER_HINTS[provider]);
8162
8224
  return modes;
8163
8225
  }
8226
+ /**
8227
+ * Check final source, build output, package import aliases, and package scripts.
8228
+ * A substring scan conservatively retains references the rewriter leaves alone,
8229
+ * including require calls, type references, and strings.
8230
+ */
8231
+ function sourceTreeReferencesOxlintPluginsPackage(projectPath) {
8232
+ return sourceTreeMatches(projectPath, (content) => content.includes(OXLINT_PLUGINS_PACKAGE), {
8233
+ crossPackageBoundaries: true,
8234
+ includePackageReferences: true,
8235
+ skipDirs: OXLINT_RETENTION_SKIP_DIRS
8236
+ });
8237
+ }
8238
+ /**
8239
+ * Drop `@oxlint/plugins` from devDependencies once nothing names it any more.
8240
+ *
8241
+ * Runs AFTER the import rewrite, so the scan sees final source. Skips a package
8242
+ * that owns the API as a runtime or peer dependency, and skips any package
8243
+ * whose source or build output still names it.
8244
+ */
8245
+ function dropDeadOxlintPluginsDependency(rootDir, packages) {
8246
+ const dirs = [rootDir, ...(packages ?? []).map((pkg) => path.join(rootDir, pkg.path))];
8247
+ for (const dir of dirs) {
8248
+ const packageJsonPath = path.join(dir, "package.json");
8249
+ const pkg = readPackageJsonIfExists(packageJsonPath);
8250
+ if (pkg?.devDependencies?.["@oxlint/plugins"] === void 0) continue;
8251
+ if (packageOwnsOxlintApi(pkg) || sourceTreeReferencesOxlintPluginsPackage(dir)) continue;
8252
+ editJsonFile(packageJsonPath, (json) => {
8253
+ if (json.devDependencies?.["@oxlint/plugins"] === void 0) return;
8254
+ delete json.devDependencies[OXLINT_PLUGINS_PACKAGE];
8255
+ return json;
8256
+ });
8257
+ }
8258
+ }
8164
8259
  //#endregion
8165
8260
  //#region src/migration/migrator/vite-plus-bootstrap.ts
8166
8261
  function bunWorkspaceDeclaresPackages(workspaces) {
@@ -8301,8 +8396,7 @@ function reconcileVitePlusBootstrapPackage(projectPath, pkg, vitePlusVersion, pa
8301
8396
  pkg.devDependencies[provider] = getCatalogDependencySpec(void 0, VITEST_VERSION, supportCatalog && packageManager !== PackageManager.bun, { preferredCatalogSpec: catalogDependencyResolver?.preferredCatalogSpec });
8302
8397
  }
8303
8398
  const frameworkPeer = BROWSER_PROVIDER_PEER_DEPS[provider];
8304
- const frameworkPresent = dependencyGroups.some((dependencies) => dependencies?.[frameworkPeer] !== void 0);
8305
- if (frameworkPeer && !frameworkPresent) {
8399
+ if (!hasProviderPeerDependency(pkg, frameworkPeer)) {
8306
8400
  pkg.devDependencies ??= {};
8307
8401
  pkg.devDependencies[frameworkPeer] = resolveProviderPeerSpec(pkg, frameworkPeer, supportCatalog, catalogDependencyResolver);
8308
8402
  }
@@ -8762,11 +8856,23 @@ function rewritePackageJson(pkg, packageManager, isMonorepo, skipStagedMigration
8762
8856
  }
8763
8857
  }
8764
8858
  const hasBrowserDepSignal = VITEST_BROWSER_DEP_NAMES.some((name) => dependencyGroups.some(({ dependencies }) => dependencies?.[name] !== void 0));
8859
+ const ownsOxlintApi = packageOwnsOxlintApi(pkg);
8860
+ if (pkg.devDependencies?.["@oxlint/plugins"] !== void 0 && !ownsOxlintApi) needVitePlus = true;
8765
8861
  for (const name of REMOVE_PACKAGES) {
8766
8862
  let wasRemoved = false;
8767
- for (const { dependencies } of dependencyGroups) if (dependencies?.[name]) {
8768
- delete dependencies[name];
8769
- wasRemoved = true;
8863
+ for (const { dependencyField, dependencies } of dependencyGroups) {
8864
+ if (ownsOxlintApi && (dependencyField === "peerDependencies" || dependencyField === "dependencies") && OXLINT_PLUGIN_API_PACKAGES.includes(name)) {
8865
+ const current = dependencies?.[name];
8866
+ if (current?.startsWith("catalog:") && dependencies) {
8867
+ const resolved = catalogDependencyResolver?.(current, name);
8868
+ if (resolved) dependencies[name] = resolved;
8869
+ }
8870
+ continue;
8871
+ }
8872
+ if (dependencies?.[name]) {
8873
+ delete dependencies[name];
8874
+ wasRemoved = true;
8875
+ }
8770
8876
  }
8771
8877
  if (wasRemoved) needVitePlus = true;
8772
8878
  }
@@ -8782,8 +8888,7 @@ function rewritePackageJson(pkg, packageManager, isMonorepo, skipStagedMigration
8782
8888
  pkg.devDependencies[provider] = getCatalogDependencySpec(void 0, VITEST_VERSION, supportCatalog && packageManager !== PackageManager.bun, { preferredCatalogSpec: catalogDependencyResolver?.preferredCatalogSpec });
8783
8889
  }
8784
8890
  const peer = BROWSER_PROVIDER_PEER_DEPS[provider];
8785
- const peerPresent = findDeclaredSpec(pkg, peer);
8786
- if (peer && !peerPresent) {
8891
+ if (!hasProviderPeerDependency(pkg, peer)) {
8787
8892
  pkg.devDependencies ??= {};
8788
8893
  pkg.devDependencies[peer] = resolveProviderPeerSpec(pkg, peer, supportCatalog, catalogDependencyResolver);
8789
8894
  }
@@ -8911,15 +9016,21 @@ export default defineConfig({});
8911
9016
  */
8912
9017
  function mergeTsdownConfigFile(projectPath, silent = false, report) {
8913
9018
  const configs = detectConfigs(projectPath);
8914
- if (!configs.tsdownConfig) return;
9019
+ if (!configs.tsdownConfig) return false;
9020
+ const createdViteConfig = !configs.viteConfig;
8915
9021
  const viteConfig = ensureViteConfig(projectPath, configs, silent, report);
8916
9022
  const fullViteConfigPath = path.join(projectPath, viteConfig);
8917
9023
  const fullTsdownConfigPath = path.join(projectPath, configs.tsdownConfig);
8918
9024
  if (configs.tsdownConfig.endsWith(".json")) {
8919
9025
  mergeAndRemoveJsonConfig(projectPath, viteConfig, configs.tsdownConfig, "pack", silent, report);
8920
- return;
9026
+ return createdViteConfig || !fs.existsSync(fullTsdownConfigPath);
8921
9027
  }
8922
9028
  const tsdownRelativePath = `./${configs.tsdownConfig}`;
9029
+ if (hasConfigKey(fullViteConfigPath, "pack")) {
9030
+ const viteConfigContent = fs.readFileSync(fullViteConfigPath, "utf8");
9031
+ if (![tsdownRelativePath, tsdownRelativePath.replace(/\.mts$/, ".mjs").replace(/\.cts$/, ".cjs").replace(/\.ts$/, ".js")].some((importPath) => viteConfigContent.includes(`from '${importPath}'`) || viteConfigContent.includes(`from "${importPath}"`))) infoMigration(`Please manually merge ${displayRelative(fullTsdownConfigPath)} into ${displayRelative(fullViteConfigPath)}, see https://viteplus.dev/guide/migrate#tsdown`, report);
9032
+ return false;
9033
+ }
8923
9034
  const result = mergeTsdownConfig(fullViteConfigPath, tsdownRelativePath);
8924
9035
  if (result.updated) {
8925
9036
  fs.writeFileSync(fullViteConfigPath, result.content);
@@ -8927,6 +9038,7 @@ function mergeTsdownConfigFile(projectPath, silent = false, report) {
8927
9038
  if (!silent) log.success(`✔ Added import for ${displayRelative(fullTsdownConfigPath)} in ${displayRelative(fullViteConfigPath)}`);
8928
9039
  }
8929
9040
  infoMigration(`Please manually merge ${displayRelative(fullTsdownConfigPath)} into ${displayRelative(fullViteConfigPath)}, see https://viteplus.dev/guide/migrate#tsdown`, report);
9041
+ return createdViteConfig || result.updated;
8930
9042
  }
8931
9043
  /**
8932
9044
  * Merge oxlint and oxfmt config into vite.config.ts
@@ -9067,8 +9179,8 @@ function wrapLazyPluginsInViteConfig(projectPath, silent = false, report) {
9067
9179
  * This rewrites vite/vitest imports to @voidzero-dev/vite-plus
9068
9180
  * @param projectPath - The root directory to search for files
9069
9181
  */
9070
- function rewriteAllImports(projectPath, silent = false, report, preserveNuxtVitestImports = true) {
9071
- const result = rewriteImportsInDirectory(projectPath, preserveNuxtVitestImports);
9182
+ function rewriteAllImports(projectPath, silent = false, report, preserveNuxtVitestImports = true, oxlintOwnerDirs = []) {
9183
+ const result = rewriteImportsInDirectory(projectPath, preserveNuxtVitestImports, oxlintOwnerDirs);
9072
9184
  const modified = result.modifiedFiles.length;
9073
9185
  const preserved = result.preservedVitestFiles.length;
9074
9186
  const errors = result.errors.length;
@@ -9577,11 +9689,13 @@ function finalizeCoreMigrationForExistingVitePlus(workspaceInfo, silent = false,
9577
9689
  const result = {
9578
9690
  scripts: false,
9579
9691
  tsconfigTypes: false,
9580
- imports: false
9692
+ imports: false,
9693
+ tsdownConfig: false
9581
9694
  };
9582
9695
  if (pending.scripts) for (const projectPath of projectPaths) result.scripts = rewriteCorePackageScripts(projectPath) || result.scripts;
9583
9696
  if (pending.tsconfigTypes) for (const projectPath of projectPaths) result.tsconfigTypes = rewriteTsconfigTypes(projectPath, silent, report) || result.tsconfigTypes;
9584
9697
  result.imports = rewriteAllImports(workspaceInfo.rootDir, silent, report, true);
9698
+ for (const projectPath of projectPaths) result.tsdownConfig = mergeTsdownConfigFile(projectPath, silent, report) || result.tsdownConfig;
9585
9699
  return result;
9586
9700
  }
9587
9701
  //#endregion
@@ -9592,6 +9706,7 @@ function rewriteStandaloneProject(projectPath, workspaceInfo, skipStagedMigratio
9592
9706
  const packageManager = workspaceInfo.packageManager;
9593
9707
  const catalogDependencyResolver = createCatalogDependencyResolver(projectPath, packageManager);
9594
9708
  const vitestEcosystemPackages = collectVitestEcosystemInstallDependencyNames(projectPath);
9709
+ const oxlintOwnerDirs = collectOxlintOwnerDirs(projectPath, workspaceInfo.packages);
9595
9710
  const providerSourceModes = collectProviderSourceModes(projectPath);
9596
9711
  const browserMode = usesVitestBrowserMode(projectPath);
9597
9712
  const retainedVitestModule = sourceTreeReferencesRetainedVitestModule(projectPath);
@@ -9688,7 +9803,8 @@ function rewriteStandaloneProject(projectPath, workspaceInfo, skipStagedMigratio
9688
9803
  injectLintTypeCheckDefaults(projectPath, silent, report);
9689
9804
  injectFmtDefaults(projectPath, silent, report);
9690
9805
  mergeTsdownConfigFile(projectPath, silent, report);
9691
- rewriteAllImports(projectPath, silent, report, true);
9806
+ rewriteAllImports(projectPath, silent, report, true, oxlintOwnerDirs);
9807
+ dropDeadOxlintPluginsDependency(projectPath, workspaceInfo.packages);
9692
9808
  wrapLazyPluginsInViteConfig(projectPath, silent, report);
9693
9809
  setPackageManager(projectPath, workspaceInfo.downloadPackageManager);
9694
9810
  }
@@ -9698,6 +9814,7 @@ function rewriteStandaloneProject(projectPath, workspaceInfo, skipStagedMigratio
9698
9814
  */
9699
9815
  function rewriteMonorepo(workspaceInfo, skipStagedMigration, silent = false, report) {
9700
9816
  const catalogDependencyResolver = createCatalogDependencyResolver(workspaceInfo.rootDir, workspaceInfo.packageManager);
9817
+ const oxlintOwnerDirs = collectOxlintOwnerDirs(workspaceInfo.rootDir, workspaceInfo.packages);
9701
9818
  const pnpmMajorVersion = pnpmMajor(workspaceInfo.downloadPackageManager.version);
9702
9819
  const usePnpmWorkspaceSettings = pnpmSupportsWorkspaceSettings(workspaceInfo.downloadPackageManager.version);
9703
9820
  const workspaceShouldAllowBrowserBuilds = workspaceUsesWebdriverio(workspaceInfo.rootDir, workspaceInfo.packages);
@@ -9724,7 +9841,8 @@ function rewriteMonorepo(workspaceInfo, skipStagedMigration, silent = false, rep
9724
9841
  injectLintTypeCheckDefaults(workspaceInfo.rootDir, silent, report);
9725
9842
  injectFmtDefaults(workspaceInfo.rootDir, silent, report);
9726
9843
  mergeTsdownConfigFile(workspaceInfo.rootDir, silent, report);
9727
- rewriteAllImports(workspaceInfo.rootDir, silent, report, true);
9844
+ rewriteAllImports(workspaceInfo.rootDir, silent, report, true, oxlintOwnerDirs);
9845
+ dropDeadOxlintPluginsDependency(workspaceInfo.rootDir, workspaceInfo.packages);
9728
9846
  wrapLazyPluginsInViteConfig(workspaceInfo.rootDir, silent, report);
9729
9847
  for (const pkg of workspaceInfo.packages) wrapLazyPluginsInViteConfig(path.join(workspaceInfo.rootDir, pkg.path), silent, report);
9730
9848
  setPackageManager(workspaceInfo.rootDir, workspaceInfo.downloadPackageManager);
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_define_config = require("./define-config-DIE9de46.cjs");
1
+ const require_define_config = require("./define-config-D0mevyb3.cjs");
2
2
  //#region src/index.cts
3
3
  const vite = require("vite");
4
4
  const { configDefaults, coverageConfigDefaults, defaultBrowserPort, defaultExclude, defaultInclude } = require("vitest/config");
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as defineConfig, c as lazyPlugins, o as defineProject } from "./define-config-U3_xg7i-.js";
1
+ import { a as defineConfig, c as lazyPlugins, o as defineProject } from "./define-config-IgzmnvvV.js";
2
2
  import { configDefaults, coverageConfigDefaults, defaultBrowserPort, defaultExclude, defaultInclude } from "vitest/config";
3
3
  export * from "vite";
4
4
  export { configDefaults, coverageConfigDefaults, defaultBrowserPort, defaultExclude, defaultInclude, defineConfig, defineProject, lazyPlugins };
@@ -0,0 +1,3 @@
1
+ import { RuleTester } from "oxlint/plugins-dev";
2
+ export type * from "oxlint/plugins-dev";
3
+ export { RuleTester };
@@ -0,0 +1,2 @@
1
+ import { RuleTester } from "oxlint/plugins-dev";
2
+ export { RuleTester };
@@ -0,0 +1,21 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("./define-config-D0mevyb3.cjs");
3
+ let _oxlint_plugins = require("@oxlint/plugins");
4
+ Object.defineProperty(exports, "definePlugin", {
5
+ enumerable: true,
6
+ get: function() {
7
+ return _oxlint_plugins.definePlugin;
8
+ }
9
+ });
10
+ Object.defineProperty(exports, "defineRule", {
11
+ enumerable: true,
12
+ get: function() {
13
+ return _oxlint_plugins.defineRule;
14
+ }
15
+ });
16
+ Object.defineProperty(exports, "eslintCompatPlugin", {
17
+ enumerable: true,
18
+ get: function() {
19
+ return _oxlint_plugins.eslintCompatPlugin;
20
+ }
21
+ });
@@ -0,0 +1,3 @@
1
+ import { definePlugin, defineRule, eslintCompatPlugin } from "@oxlint/plugins";
2
+ export type * from "@oxlint/plugins";
3
+ export { definePlugin, defineRule, eslintCompatPlugin };
@@ -0,0 +1,2 @@
1
+ import { definePlugin, defineRule, eslintCompatPlugin } from "@oxlint/plugins";
2
+ export { definePlugin, defineRule, eslintCompatPlugin };
@@ -1,15 +1,15 @@
1
1
  import { r as __toESM } from "../rolldown-runtime-CMFfr-1z.js";
2
2
  import { a as muted, c as warnMsg, i as log, o as printHeader, r as formatDuration, t as accent } from "../terminal-MKGAuy-p.js";
3
- import { a as SETUP_VP_VERSION, f as VITE_PLUS_VERSION, m as isForceOverrideMode } from "../constants-0IAVgpox.js";
3
+ import { a as SETUP_VP_VERSION, f as VITE_PLUS_VERSION, m as isForceOverrideMode } from "../constants-C2dTOTe-.js";
4
4
  import { a as writeJsonFile, i as readJsonFile } from "../json-cULBl7Pi.js";
5
- import { a as readNearestPackageJson, i as hasVitePlusDependency } from "../package-BZz2Ij68.js";
6
- import { E as spinner, S as log$1, T as select, b as confirm, c as selectPackageManager, i as promptGitHooks, k as isCancel, l as upgradeYarn, n as defaultInteractive, o as runViteFmt, r as downloadPackageManager$1, s as runViteInstall, t as cancelAndExit, w as outro, y as PackageManager } from "../prompts-CtzEgFY-.js";
5
+ import { a as readNearestPackageJson, i as hasVitePlusDependency } from "../package-CHH8jWan.js";
6
+ import { E as spinner, S as log$1, T as select, b as confirm, c as selectPackageManager, i as promptGitHooks, k as isCancel, l as upgradeYarn, n as defaultInteractive, o as runViteFmt, r as downloadPackageManager$1, s as runViteInstall, t as cancelAndExit, w as outro, y as PackageManager } from "../prompts-k14KgthC.js";
7
7
  import { t as require_semver } from "../semver-CaDAb8vV.js";
8
- import { i as selectAgentTargetPaths, l as displayRelative, n as detectAgentConflicts, r as detectExistingAgentTargetPaths, s as writeAgentInstructions } from "../agent-C5jMYVfB.js";
8
+ import { i as selectAgentTargetPaths, l as displayRelative, n as detectAgentConflicts, r as detectExistingAgentTargetPaths, s as writeAgentInstructions } from "../agent-Cu6-tXIP.js";
9
9
  import { n as addMigrationWarning, r as createMigrationReport } from "../report-CK5TnTsr.js";
10
- import { $ as warnIncompatibleEslintIntegration, A as detectYarnPnpMode, B as migrateTsupToTsdown, C as injectLintTypeCheckDefaults, D as detectVitePlusBootstrapPending, E as collectToolchainVersionChanges, F as addFrameworkShim, G as migratePrettierToOxfmt, H as warnMissingTsupConfig, I as detectFramework, J as confirmEslintMigration, L as hasFrameworkShim, O as ensureVitePlusBootstrap, R as confirmTsupMigration, T as mergeViteConfigFiles, U as confirmPrettierMigration, W as detectPrettierProject, X as detectIncompatibleEslintIntegration, Y as detectEslintProject, Z as migrateEslintToOxlint, _ as installGitHooks, d as finalizeCoreMigrationForExistingVitePlus, et as warnLegacyEslintConfig, f as detectNodeVersionManagerFile, g as detectLegacyGitHooksMigrationCandidate, i as selectEditor, j as detectWorkspace$1, k as configureYarnNodeModulesMode, l as rewriteStandaloneProject, m as migrateSetupVpVersion, nt as checkViteVersion, o as writeEditorConfigs, p as migrateNodeVersionManagerFile, q as warnPackageLevelPrettier, r as isJsonLikeFile, rt as checkVitestVersion, s as rewriteMonorepo, t as detectEditorConflicts, tt as warnPackageLevelEslint, u as detectPendingCoreMigration, v as preflightGitHooksSetup, w as mergeTsdownConfigFile, y as shouldSkipStagedMigrationForHooks, z as detectTsupProject } from "../editor-B5-lvRaU.js";
10
+ import { $ as warnIncompatibleEslintIntegration, A as detectYarnPnpMode, B as migrateTsupToTsdown, C as injectLintTypeCheckDefaults, D as detectVitePlusBootstrapPending, E as collectToolchainVersionChanges, F as addFrameworkShim, G as migratePrettierToOxfmt, H as warnMissingTsupConfig, I as detectFramework, J as confirmEslintMigration, L as hasFrameworkShim, O as ensureVitePlusBootstrap, R as confirmTsupMigration, T as mergeViteConfigFiles, U as confirmPrettierMigration, W as detectPrettierProject, X as detectIncompatibleEslintIntegration, Y as detectEslintProject, Z as migrateEslintToOxlint, _ as installGitHooks, d as finalizeCoreMigrationForExistingVitePlus, et as warnLegacyEslintConfig, f as detectNodeVersionManagerFile, g as detectLegacyGitHooksMigrationCandidate, i as selectEditor, j as detectWorkspace$1, k as configureYarnNodeModulesMode, l as rewriteStandaloneProject, m as migrateSetupVpVersion, nt as checkViteVersion, o as writeEditorConfigs, p as migrateNodeVersionManagerFile, q as warnPackageLevelPrettier, r as isJsonLikeFile, rt as checkVitestVersion, s as rewriteMonorepo, t as detectEditorConflicts, tt as warnPackageLevelEslint, u as detectPendingCoreMigration, v as preflightGitHooksSetup, w as mergeTsdownConfigFile, y as shouldSkipStagedMigrationForHooks, z as detectTsupProject } from "../editor-4sjlHmUh.js";
11
11
  import { n as runCommandSilently } from "../command-CguLh2KL.js";
12
- import { a as hasBaseUrlInTsconfig, i as fixBaseUrlInTsconfig, t as confirmBaseUrlFix } from "../tsconfig-CUggNuJR.js";
12
+ import { a as hasBaseUrlInTsconfig, i as fixBaseUrlInTsconfig, t as confirmBaseUrlFix } from "../tsconfig-C3h9CVTA.js";
13
13
  import { t as unwrapCliParseOutcome } from "../cli-parse-DHE8NrBU.js";
14
14
  import { t as ROLLDOWN_COMPAT_RESULT_PREFIX } from "../protocol-D99W10Qi.js";
15
15
  import path from "node:path";
@@ -887,7 +887,7 @@ async function main() {
887
887
  report.dependencyUpgrades = await collectToolchainVersionChanges(workspaceInfoOptional.rootDir);
888
888
  updateMigrationProgress("Rewriting toolchain imports across the workspace");
889
889
  const coreMigrationResult = finalizeCoreMigrationForExistingVitePlus(workspaceInfoOptional, true, report, pendingCoreMigration);
890
- if (coreMigrationResult.scripts || coreMigrationResult.tsconfigTypes || coreMigrationResult.imports) didMigrate = true;
890
+ if (coreMigrationResult.scripts || coreMigrationResult.tsconfigTypes || coreMigrationResult.imports || coreMigrationResult.tsdownConfig) didMigrate = true;
891
891
  clearMigrationProgress();
892
892
  const fullSetup = options.full === true;
893
893
  const skippedSetupCandidates = !fullSetup && !hasExplicitExistingVitePlusSetupRequest(options) && hasExistingVitePlusMigrationCandidates(workspaceInfoOptional, options);
@@ -1,4 +1,4 @@
1
- import { u as VITE_PLUS_NAME } from "./constants-0IAVgpox.js";
1
+ import { u as VITE_PLUS_NAME } from "./constants-C2dTOTe-.js";
2
2
  //#region src/oxlint-plugin-config.ts
3
3
  const VITE_PLUS_OXLINT_PLUGIN_NAME = VITE_PLUS_NAME;
4
4
  const VITE_PLUS_OXLINT_PLUGIN_SPECIFIER = `${VITE_PLUS_NAME}/oxlint-plugin`;