vite-plus 0.3.0 → 0.3.2

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 (95) hide show
  1. package/LICENSE +29 -29
  2. package/README.md +3 -3
  3. package/bin/vp +1 -1
  4. package/binding/index.cjs +60 -56
  5. package/binding/index.d.cts +137 -14
  6. package/dist/{agent-Wqx0MPk0.js → agent-C59HKB4Y.js} +3 -2
  7. package/dist/bin.js +90 -58
  8. package/dist/cli-parse-DHE8NrBU.js +13 -0
  9. package/dist/client/bundledDevClient.mjs +1 -1
  10. package/dist/client/client.mjs +1 -1
  11. package/dist/client/env.mjs +1 -1
  12. package/dist/client.d.ts +1 -1
  13. package/dist/config/bin.js +83 -55
  14. package/dist/{constants-Bn-U8o4v.js → constants-IhOditRA.js} +3 -3
  15. package/dist/create/bin.d.ts +13 -5
  16. package/dist/create/bin.js +50 -193
  17. package/dist/{define-config-GXUdVT-0.js → define-config-DAaCa0U_.js} +2 -2
  18. package/dist/{define-config-DWoAkNdp.d.ts → define-config-DPNEJxPz.d.ts} +5 -9
  19. package/dist/{define-config-WiVlryJ2.cjs → define-config-DpAPETDf.cjs} +1 -1
  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-DfmT__Aw.js +619 -0
  24. package/dist/{editor-CC4DqODz.js → editor-QOIGtmH4.js} +205 -70
  25. package/dist/hooks/bin.js +9 -114
  26. package/dist/{hooks-DFqViZqZ.js → hooks-C-4gykWR.js} +1 -1
  27. package/dist/index.cjs +2 -2
  28. package/dist/index.d.ts +2 -2
  29. package/dist/index.js +2 -2
  30. package/dist/internal.d.ts +1 -1
  31. package/dist/internal.js +1 -1
  32. package/dist/lint-plugins-dev.d.ts +3 -0
  33. package/dist/lint-plugins-dev.js +2 -0
  34. package/dist/lint-plugins.cjs +21 -0
  35. package/dist/lint-plugins.d.ts +3 -0
  36. package/dist/lint-plugins.js +2 -0
  37. package/dist/migration/bin.js +25 -144
  38. package/dist/migration/compat/worker.js +1 -1
  39. package/dist/module-runner.d.ts +1 -1
  40. package/dist/module-runner.js +1 -1
  41. package/dist/{oxlint-plugin-config-DX5ezKbB.js → oxlint-plugin-config-BU42tr8y.js} +1 -1
  42. package/dist/oxlint-plugin.d.ts +2 -2
  43. package/dist/oxlint-plugin.js +93 -32
  44. package/dist/{pack-PvUg_xpv.d.ts → pack-BK38MLVZ.d.ts} +1 -1
  45. package/dist/pack-bin.d.ts +2 -3
  46. package/dist/pack-bin.js +5 -622
  47. package/dist/pack-client.d.ts +1 -1
  48. package/dist/pack.d.ts +2 -2
  49. package/dist/pack.js +1 -1
  50. package/dist/{package-CBe9EWPY.js → package-BB-Jh_z3.js} +1 -1
  51. package/dist/{prompts-DF3yU-eU.js → prompts-CujFOJXu.js} +3 -1400
  52. package/dist/{report-ZNR1Mk6h.js → report-CK5TnTsr.js} +1 -0
  53. package/dist/resolve-vite-config-6Nox70uP.js +2 -0
  54. package/dist/{resolve-vite-config-ipGb39Jo.js → resolve-vite-config-CHHjsjKJ.js} +3 -3
  55. package/dist/semver-CaDAb8vV.js +1400 -0
  56. package/dist/staged/bin.js +83 -218
  57. package/dist/sync-versions/bin.d.ts +1 -0
  58. package/dist/sync-versions/bin.js +3884 -0
  59. package/dist/sync-versions/bin.mjs +13323 -0
  60. package/dist/toolchain.js +10 -10
  61. package/dist/toolchain.json +10 -10
  62. package/dist/{tsconfig-LD2QhQ0O.js → tsconfig-DCtWfQPA.js} +2 -2
  63. package/dist/{tsconfig-BVHG3DpR.js → tsconfig-MXktI3SX.js} +1 -1
  64. package/dist/tsgolint-path.d.ts +3 -4
  65. package/dist/types/customEvent.d.ts +1 -1
  66. package/dist/types/hmrPayload.d.ts +1 -1
  67. package/dist/types/hot.d.ts +1 -1
  68. package/dist/types/import-meta.d.ts +1 -1
  69. package/dist/types/importGlob.d.ts +1 -1
  70. package/dist/types/importMeta.d.ts +1 -1
  71. package/dist/types/metadata.d.ts +1 -1
  72. package/dist/version.d.ts +2 -3
  73. package/dist/version.js +2 -2
  74. package/dist/versions.js +5 -5
  75. package/dist/vitest-ecosystem-BiRqcaRI.js +23 -0
  76. package/docs/config/fmt.md +4 -2
  77. package/docs/config/lint.md +4 -2
  78. package/docs/guide/check.md +1 -0
  79. package/docs/guide/ci.md +42 -2
  80. package/docs/guide/env.md +148 -52
  81. package/docs/guide/fmt.md +3 -1
  82. package/docs/guide/ide-integration.md +14 -2
  83. package/docs/guide/index.md +1 -1
  84. package/docs/guide/install.md +4 -1
  85. package/docs/guide/installer-env-vars.md +45 -1
  86. package/docs/guide/lint.md +58 -1
  87. package/docs/guide/migrate-rules.md +95 -2
  88. package/docs/guide/migrate.md +1 -1
  89. package/docs/guide/monorepo.md +2 -0
  90. package/docs/guide/troubleshooting.md +14 -0
  91. package/package.json +27 -20
  92. package/templates/generator/README.md +14 -0
  93. package/templates/generator/bin/index.ts +54 -5
  94. package/dist/lib-L3DWSRQp.js +0 -75
  95. package/dist/{log-update-DHZRyJ2m.js → log-update-CoW8Z4Dl.js} +1 -1
@@ -306,6 +306,7 @@ export interface TreeShakeOptions {
306
306
  */
307
307
  invalidImportSideEffects?: boolean;
308
308
  }
309
+
309
310
  export interface Comment {
310
311
  type: 'Line' | 'Block';
311
312
  value: string;
@@ -332,6 +333,7 @@ export declare const enum Severity {
332
333
  Warning = 'Warning',
333
334
  Advice = 'Advice',
334
335
  }
336
+
335
337
  export declare class ParseResult {
336
338
  get program(): import('@oxc-project/types').Program;
337
339
  get module(): EcmaScriptModule;
@@ -610,6 +612,7 @@ export interface ValueSpan {
610
612
  start: number;
611
613
  end: number;
612
614
  }
615
+
613
616
  export declare class ResolverFactory {
614
617
  constructor(options?: NapiResolveOptions | undefined | null);
615
618
  static default(): ResolverFactory;
@@ -919,6 +922,7 @@ export interface TsconfigOptions {
919
922
  */
920
923
  references?: 'auto';
921
924
  }
925
+
922
926
  export interface SourceMap {
923
927
  file?: string;
924
928
  mappings: string;
@@ -929,6 +933,7 @@ export interface SourceMap {
929
933
  version: number;
930
934
  x_google_ignoreList?: Array<number>;
931
935
  }
936
+
932
937
  export interface ArrowFunctionsOptions {
933
938
  /**
934
939
  * This option enables the following:
@@ -1604,6 +1609,7 @@ export interface TypeScriptOptions {
1604
1609
  */
1605
1610
  rewriteImportExtensions?: 'rewrite' | 'remove' | boolean;
1606
1611
  }
1612
+
1607
1613
  export declare class BindingBundleEndEventData {
1608
1614
  output: string;
1609
1615
  duration: number;
@@ -1694,6 +1700,12 @@ export declare class BindingDevEngine {
1694
1700
  * actual module and its dependencies.
1695
1701
  */
1696
1702
  compileEntry(moduleId: string, clientId: string): Promise<BindingLazyChunkOutput>;
1703
+ /**
1704
+ * Same data the plugin-context `getModuleInfo` returns, readable from the engine
1705
+ * handle at any time (no hook context needed).
1706
+ */
1707
+ getModuleInfo(moduleId: string): BindingModuleInfo | null;
1708
+ getModuleIds(): Array<string>;
1697
1709
  }
1698
1710
 
1699
1711
  export declare class BindingLoadPluginContext {
@@ -2002,8 +2014,8 @@ export declare class TraceSubscriberGuard {
2002
2014
  }
2003
2015
 
2004
2016
  export declare class TsconfigCache {
2005
- /** Create a new transform cache with auto tsconfig discovery enabled. */
2006
- constructor(yarnPnp: boolean);
2017
+ /** Create a new transform cache with auto or manual tsconfig discovery enabled. */
2018
+ constructor(yarnPnp: boolean, pathToTsconfig?: string | undefined | null);
2007
2019
  /**
2008
2020
  * Clear the cache.
2009
2021
  *
@@ -2174,6 +2186,7 @@ export interface BindingDevOptions {
2174
2186
  onAdditionalAssets?: undefined | ((output: BindingOutputs) => void | Promise<void>);
2175
2187
  rebuildStrategy?: BindingRebuildStrategy;
2176
2188
  watch?: BindingDevWatchOptions;
2189
+ hotUpdate?: boolean;
2177
2190
  }
2178
2191
 
2179
2192
  export interface BindingDevtoolsOptions {
@@ -2288,9 +2301,10 @@ export interface BindingEnhancedTransformOptions {
2288
2301
  /**
2289
2302
  * Configure tsconfig handling.
2290
2303
  * - true: Auto-discover and load the nearest tsconfig.json
2304
+ * - string: Use the tsconfig at the provided path
2291
2305
  * - TsconfigRawOptions: Use the provided inline tsconfig options
2292
2306
  */
2293
- tsconfig?: boolean | BindingTsconfigRawOptions;
2307
+ tsconfig?: boolean | string | BindingTsconfigRawOptions;
2294
2308
  /** An input source map to collapse with the output source map. */
2295
2309
  inputMap?: SourceMap;
2296
2310
  }
@@ -2698,11 +2712,12 @@ export interface BindingManualCodeSplittingOptions {
2698
2712
  maxSize?: number;
2699
2713
  minModuleSize?: number;
2700
2714
  maxModuleSize?: number;
2715
+ internalInvalidateModuleInfoCache?: () => void;
2701
2716
  }
2702
2717
 
2703
2718
  export interface BindingMatchGroup {
2704
- name: string | ((id: string, ctx: BindingChunkingContext) => VoidNullable<string>);
2705
- test?: string | RegExp | ((id: string) => VoidNullable<boolean>);
2719
+ name: string | ((ids: Array<string>, ctx: BindingChunkingContext) => Array<VoidNullable<string>>);
2720
+ test?: string | RegExp | ((ids: Array<string>) => Uint8Array);
2706
2721
  priority?: number;
2707
2722
  minSize?: number;
2708
2723
  minShareCount?: number;
@@ -2802,6 +2817,7 @@ export interface BindingOutputOptions {
2802
2817
  export interface BindingOutputs {
2803
2818
  chunks: Array<BindingOutputChunk>;
2804
2819
  assets: Array<BindingOutputAsset>;
2820
+ mangleCache?: Record<string, string | false>;
2805
2821
  }
2806
2822
 
2807
2823
  export interface BindingOverwriteOptions {
@@ -2913,14 +2929,14 @@ export interface BindingPluginOptions {
2913
2929
  renderErrorMeta?: BindingPluginHookMeta;
2914
2930
  generateBundle?: (
2915
2931
  ctx: BindingPluginContext,
2916
- bundle: BindingErrorsOr<BindingOutputs>,
2932
+ bundle: BindingResult<BindingOutputs>,
2917
2933
  isWrite: boolean,
2918
2934
  opts: BindingNormalizedOptions,
2919
2935
  ) => MaybePromise<VoidNullable<JsChangedOutputs>>;
2920
2936
  generateBundleMeta?: BindingPluginHookMeta;
2921
2937
  writeBundle?: (
2922
2938
  ctx: BindingPluginContext,
2923
- bundle: BindingErrorsOr<BindingOutputs>,
2939
+ bundle: BindingResult<BindingOutputs>,
2924
2940
  opts: BindingNormalizedOptions,
2925
2941
  ) => MaybePromise<VoidNullable<JsChangedOutputs>>;
2926
2942
  writeBundleMeta?: BindingPluginHookMeta;
@@ -3214,6 +3230,7 @@ export interface BindingViteReporterPluginConfig {
3214
3230
 
3215
3231
  export interface BindingViteResolvePluginConfig {
3216
3232
  resolveOptions: BindingViteResolvePluginResolveOptions;
3233
+ tsconfig?: string;
3217
3234
  environmentConsumer: string;
3218
3235
  environmentName: string;
3219
3236
  builtins: Array<BindingStringOrRegex>;
@@ -3259,6 +3276,7 @@ export interface BindingViteResolvePluginResolveOptions {
3259
3276
 
3260
3277
  export interface BindingViteTransformPluginConfig {
3261
3278
  root: string;
3279
+ tsconfig?: string;
3262
3280
  include?: Array<BindingStringOrRegex>;
3263
3281
  exclude?: Array<BindingStringOrRegex>;
3264
3282
  jsxRefreshInclude?: Array<BindingStringOrRegex>;
@@ -3388,7 +3406,7 @@ export interface PreRenderedChunk {
3388
3406
  /** Whether this chunk is a dynamic entry point. */
3389
3407
  isDynamicEntry: boolean;
3390
3408
  /** The id of a module that this chunk corresponds to. */
3391
- facadeModuleId?: string;
3409
+ facadeModuleId: string | null;
3392
3410
  /** The list of ids of modules included in this chunk. */
3393
3411
  moduleIds: Array<string>;
3394
3412
  /** Exported variable names from this chunk. */
@@ -3424,6 +3442,7 @@ export declare function startAsyncRuntime(): void;
3424
3442
  export interface ViteImportGlobMeta {
3425
3443
  isSubImportsPattern?: boolean;
3426
3444
  }
3445
+
3427
3446
  /** Error from batch import rewriting */
3428
3447
  export interface BatchRewriteError {
3429
3448
  /** The file path that had an error */
@@ -3440,16 +3459,20 @@ export interface BatchRewriteResult {
3440
3459
  preservedVitestFiles: Array<string>;
3441
3460
  /** Files that had errors */
3442
3461
  errors: Array<BatchRewriteError>;
3462
+ /** Pack configurations that need manual migration */
3463
+ warnings: Array<BatchRewriteError>;
3443
3464
  }
3444
3465
 
3445
3466
  /** Configuration options passed from JavaScript to Rust. */
3446
3467
  export interface CliOptions {
3447
- lint: (err: Error | null) => Promise<JsCommandResolvedResult>;
3448
- fmt: (err: Error | null) => Promise<JsCommandResolvedResult>;
3449
- vite: (err: Error | null) => Promise<JsCommandResolvedResult>;
3450
- test: (err: Error | null) => Promise<JsCommandResolvedResult>;
3451
- pack: (err: Error | null) => Promise<JsCommandResolvedResult>;
3452
- doc: (err: Error | null) => Promise<JsCommandResolvedResult>;
3468
+ /** The current JavaScript runtime (`process.execPath`). */
3469
+ nodeExecPath: string;
3470
+ lint: (err: Error | null, arg: JsCommandContext) => Promise<JsCommandResolvedResult>;
3471
+ fmt: (err: Error | null, arg: JsCommandContext) => Promise<JsCommandResolvedResult>;
3472
+ vite: (err: Error | null, arg: JsCommandContext) => Promise<JsCommandResolvedResult>;
3473
+ test: (err: Error | null, arg: JsCommandContext) => Promise<JsCommandResolvedResult>;
3474
+ pack: (err: Error | null, arg: JsCommandContext) => Promise<JsCommandResolvedResult>;
3475
+ doc: (err: Error | null, arg: JsCommandContext) => Promise<JsCommandResolvedResult>;
3453
3476
  cwd?: string;
3454
3477
  /** Whether the user supplied the global `-C` option. */
3455
3478
  explicitChdir?: boolean;
@@ -3463,6 +3486,32 @@ export interface CliOptions {
3463
3486
  resolveUniversalViteConfig: (err: Error | null, arg: string) => Promise<string>;
3464
3487
  }
3465
3488
 
3489
+ export interface CliParseError {
3490
+ kind: string;
3491
+ message: string;
3492
+ }
3493
+
3494
+ export interface ConfigArgs {
3495
+ hooksDir?: string;
3496
+ hooks?: boolean;
3497
+ agent?: boolean;
3498
+ }
3499
+
3500
+ export interface CreateArgs {
3501
+ templateName?: string;
3502
+ directory?: string;
3503
+ agent?: false | string | Array<string>;
3504
+ editor?: false | string;
3505
+ git?: boolean;
3506
+ hooks?: boolean;
3507
+ packageManager?: 'pnpm' | 'npm' | 'yarn' | 'bun';
3508
+ approveBuilds?: boolean;
3509
+ verbose?: boolean;
3510
+ interactive?: boolean;
3511
+ list?: boolean;
3512
+ templateArgs: Array<string>;
3513
+ }
3514
+
3466
3515
  /**
3467
3516
  * Detect the workspace root and package manager type and version
3468
3517
  *
@@ -3569,6 +3618,17 @@ export declare function getVpDirs(): VpDirsJs;
3569
3618
  */
3570
3619
  export declare function hasConfigKey(viteConfigPath: string, configKey: string): boolean;
3571
3620
 
3621
+ export interface HooksArgs {
3622
+ command: 'enable' | 'disable' | 'status';
3623
+ hooksDir?: string;
3624
+ }
3625
+
3626
+ /** Execution context after command dispatch selects the working directory. */
3627
+ export interface JsCommandContext {
3628
+ cwd: string;
3629
+ args: Array<string>;
3630
+ }
3631
+
3572
3632
  /** Result returned by JavaScript resolver functions. */
3573
3633
  export interface JsCommandResolvedResult {
3574
3634
  binPath: string;
@@ -3651,6 +3711,50 @@ export declare function mergeTsdownConfig(
3651
3711
  tsdownConfigPath: string,
3652
3712
  ): MergeJsonConfigResult;
3653
3713
 
3714
+ export interface MigrateArgs {
3715
+ path?: string;
3716
+ agent?: false | string | Array<string>;
3717
+ editor?: false | string;
3718
+ hooks?: boolean;
3719
+ interactive?: boolean;
3720
+ full?: boolean;
3721
+ }
3722
+
3723
+ export declare function parseConfigArgs(argv: Array<string>): ParseConfigArgsOutcome;
3724
+
3725
+ export type ParseConfigArgsOutcome =
3726
+ | { status: 'ok'; value: ConfigArgs }
3727
+ | { status: 'exit'; code: number }
3728
+ | { status: 'error'; error: CliParseError };
3729
+
3730
+ export declare function parseCreateArgs(argv: Array<string>): ParseCreateArgsOutcome;
3731
+
3732
+ export type ParseCreateArgsOutcome =
3733
+ | { status: 'ok'; value: CreateArgs }
3734
+ | { status: 'exit'; code: number }
3735
+ | { status: 'error'; error: CliParseError };
3736
+
3737
+ export declare function parseHooksArgs(argv: Array<string>): ParseHooksArgsOutcome;
3738
+
3739
+ export type ParseHooksArgsOutcome =
3740
+ | { status: 'ok'; value: HooksArgs }
3741
+ | { status: 'exit'; code: number }
3742
+ | { status: 'error'; error: CliParseError };
3743
+
3744
+ export declare function parseMigrateArgs(argv: Array<string>): ParseMigrateArgsOutcome;
3745
+
3746
+ export type ParseMigrateArgsOutcome =
3747
+ | { status: 'ok'; value: MigrateArgs }
3748
+ | { status: 'exit'; code: number }
3749
+ | { status: 'error'; error: CliParseError };
3750
+
3751
+ export declare function parseStagedArgs(argv: Array<string>): ParseStagedArgsOutcome;
3752
+
3753
+ export type ParseStagedArgsOutcome =
3754
+ | { status: 'ok'; value: StagedArgs }
3755
+ | { status: 'exit'; code: number }
3756
+ | { status: 'error'; error: CliParseError };
3757
+
3654
3758
  /** Access modes for a path. */
3655
3759
  export interface PathAccess {
3656
3760
  /** Whether the path was read */
@@ -3709,6 +3813,7 @@ export declare function rewriteEslint(scriptsJson: string): string | null;
3709
3813
  export declare function rewriteImportsInDirectory(
3710
3814
  root: string,
3711
3815
  preserveVitestInNuxtPackages?: boolean | undefined | null,
3816
+ oxlintOwnerDirs?: Array<string> | undefined | null,
3712
3817
  ): BatchRewriteResult;
3713
3818
 
3714
3819
  /**
@@ -3835,6 +3940,24 @@ export interface RunCommandResult {
3835
3940
  */
3836
3941
  export declare function shouldPrintVitePlusHeader(): boolean;
3837
3942
 
3943
+ export interface StagedArgs {
3944
+ allowEmpty?: boolean;
3945
+ concurrent?: boolean | number;
3946
+ continueOnError?: boolean;
3947
+ cwd?: string;
3948
+ debug?: boolean;
3949
+ diff?: string;
3950
+ diffFilter?: string;
3951
+ failOnChanges?: boolean;
3952
+ hidePartiallyStaged?: boolean;
3953
+ hideUnstaged?: boolean;
3954
+ quiet?: boolean;
3955
+ relative?: boolean;
3956
+ revert?: boolean;
3957
+ stash?: boolean;
3958
+ verbose?: boolean;
3959
+ }
3960
+
3838
3961
  /**
3839
3962
  * Set the value of a top-level config key in a vite config file (upsert)
3840
3963
  *
@@ -1,4 +1,5 @@
1
- import { A as isCancel, C as log, E as select, w as multiselect } from "./prompts-DF3yU-eU.js";
1
+ import { a as SETUP_VP_VERSION } from "./constants-IhOditRA.js";
2
+ import { C as multiselect, S as log, T as select, k as isCancel } from "./prompts-CujFOJXu.js";
2
3
  import path from "node:path";
3
4
  import { styleText } from "node:util";
4
5
  import fs from "node:fs";
@@ -110,7 +111,7 @@ jobs:
110
111
  with:
111
112
  persist-credentials: false
112
113
  - name: Set up Vite+
113
- uses: voidzero-dev/setup-vp@v1
114
+ uses: voidzero-dev/setup-vp@${SETUP_VP_VERSION}
114
115
  with:
115
116
  cache: true
116
117
  run-install: true
package/dist/bin.js CHANGED
@@ -1,13 +1,15 @@
1
1
  import { t as renderCliDoc } from "./help-BmKpeOP9.js";
2
2
  import { c as warnMsg, i as log, n as errorMsg, o as printHeader, t as accent } from "./terminal-MKGAuy-p.js";
3
- import { g as resolveBundled, h as resolve$1, i as DEFAULT_ENVS, l as VITE_CONFIG_FILES, n as BASEURL_TSCONFIG_WARNING, r as CONFIG_METADATA_ENV, u as VITE_PLUS_NAME } from "./constants-Bn-U8o4v.js";
4
- import { r as createDefaultVitePlusLintConfig } from "./oxlint-plugin-config-DX5ezKbB.js";
3
+ import { g as resolveBundled, h as resolve$1, i as DEFAULT_ENVS, l as VITE_CONFIG_FILES, n as BASEURL_TSCONFIG_WARNING, r as CONFIG_METADATA_ENV, u as VITE_PLUS_NAME } from "./constants-IhOditRA.js";
4
+ import { r as createDefaultVitePlusLintConfig } from "./oxlint-plugin-config-BU42tr8y.js";
5
5
  import { t as resolveTsgolintExecutable } from "./tsgolint-path-CbDReEOx.js";
6
- import { i as resolveUniversalViteConfig } from "./resolve-vite-config-ipGb39Jo.js";
7
- import path, { dirname, join } from "node:path";
6
+ import { a as readNearestPackageJson } from "./package-BB-Jh_z3.js";
7
+ import { t as cac } from "./dist-DfmT__Aw.js";
8
+ import { createRequire } from "node:module";
9
+ import path, { dirname, join, resolve } from "node:path";
8
10
  import { fileURLToPath } from "node:url";
9
11
  import { ensureBlockingStdio, hasConfigKey, mergeJsonConfig, run } from "../binding/index.js";
10
- import fs, { readFileSync } from "node:fs";
12
+ import fs, { existsSync, readFileSync } from "node:fs";
11
13
  //#region src/help.ts
12
14
  const commandHelpDocs = {
13
15
  dev: {
@@ -934,6 +936,10 @@ const commandHelpDocs = {
934
936
  label: "--fix",
935
937
  description: "Auto-fix format and lint issues"
936
938
  },
939
+ {
940
+ label: "--quiet",
941
+ description: "Disable reporting on warnings, only errors are reported"
942
+ },
937
943
  {
938
944
  label: "--no-fmt",
939
945
  description: "Skip format check"
@@ -1093,10 +1099,6 @@ const commandHelpDocs = {
1093
1099
  label: "--copy <dir>",
1094
1100
  description: "Copy files to output dir"
1095
1101
  },
1096
- {
1097
- label: "--public-dir <dir>",
1098
- description: "Alias for --copy, deprecated"
1099
- },
1100
1102
  {
1101
1103
  label: "--tsconfig <tsconfig>",
1102
1104
  description: "Set tsconfig path"
@@ -1515,7 +1517,7 @@ async function applyToolInitConfigToViteConfig(command, args, projectPath = proc
1515
1517
  }
1516
1518
  if (spec.configKey === "lint" && hasTriggerFlag(args, ["--init"])) {
1517
1519
  const lintInitConfigPath = path.join(projectPath, ".vite-plus-lint-init.oxlintrc.json");
1518
- const { fixBaseUrlInTsconfig, hasBaseUrlInTsconfig } = await import("./tsconfig-BVHG3DpR.js");
1520
+ const { fixBaseUrlInTsconfig, hasBaseUrlInTsconfig } = await import("./tsconfig-MXktI3SX.js");
1519
1521
  await fixBaseUrlInTsconfig(projectPath);
1520
1522
  const hasBaseUrl = hasBaseUrlInTsconfig(projectPath);
1521
1523
  const initConfig = createDefaultVitePlusLintConfig({ includeTypeAwareDefaults: !hasBaseUrl });
@@ -1618,26 +1620,49 @@ async function lint() {
1618
1620
  };
1619
1621
  }
1620
1622
  //#endregion
1623
+ //#region src/resolve-core.ts
1624
+ const CORE_PACKAGE_NAME = "@voidzero-dev/vite-plus-core";
1625
+ function checkCoreVersion(packageJsonPath, expectedVersion) {
1626
+ const pkg = JSON.parse(readFileSync(packageJsonPath, "utf8"));
1627
+ if (pkg.name !== CORE_PACKAGE_NAME || pkg.version !== expectedVersion) throw new Error(`Expected ${CORE_PACKAGE_NAME}@${expectedVersion}, but found ${pkg.name}@${pkg.version} at ${packageJsonPath}. Run \`vp migrate\` to align the Vite alias, then run \`vp install\`.`);
1628
+ }
1629
+ function checkProjectCoreVersion(cwd, corePackageJsonPath, expectedVersion) {
1630
+ const projectPackage = readNearestPackageJson(cwd);
1631
+ if (![
1632
+ "dependencies",
1633
+ "devDependencies",
1634
+ "optionalDependencies",
1635
+ "peerDependencies"
1636
+ ].some((field) => Object.hasOwn(projectPackage?.[field] ?? {}, "vite"))) return;
1637
+ const projectRequire = createRequire(join(cwd, "package.json"));
1638
+ let projectPackageJsonPath;
1639
+ try {
1640
+ projectPackageJsonPath = projectRequire.resolve("vite/package.json");
1641
+ } catch (cause) {
1642
+ if (cause.code !== "MODULE_NOT_FOUND") throw cause;
1643
+ }
1644
+ if (projectPackageJsonPath && projectPackageJsonPath !== corePackageJsonPath) checkCoreVersion(projectPackageJsonPath, expectedVersion);
1645
+ }
1646
+ /** Resolve the same core dependency as the CLI's static `vite` re-exports. */
1647
+ function resolveCore(subpath = "", cwd = process.cwd(), modulePath = import.meta.url) {
1648
+ const cliRequire = createRequire(modulePath);
1649
+ const { version: expectedVersion } = JSON.parse(readFileSync(cliRequire.resolve("vite-plus/package.json"), "utf8"));
1650
+ let corePackageJsonPath;
1651
+ try {
1652
+ corePackageJsonPath = cliRequire.resolve("vite/package.json");
1653
+ } catch (cause) {
1654
+ throw new Error("Could not resolve the bundled Vite dependency. Run `vp install`.", { cause });
1655
+ }
1656
+ checkCoreVersion(corePackageJsonPath, expectedVersion);
1657
+ checkProjectCoreVersion(cwd, corePackageJsonPath, expectedVersion);
1658
+ return cliRequire.resolve(`vite${subpath}`);
1659
+ }
1660
+ //#endregion
1621
1661
  //#region src/resolve-pack.ts
1622
- /**
1623
- * Tsdown tool resolver for the vite-plus CLI.
1624
- *
1625
- * This module exports a function that resolves the Tsdown binary path
1626
- * using Node.js module resolution. The resolved path is passed back
1627
- * to the Rust core, which then executes Tsdown for running pack.
1628
- *
1629
- * Used for: `vite-plus pack` command
1630
- */
1631
- /**
1632
- * Resolves the Tsdown binary path and environment variables.
1633
- *
1634
- * @returns Promise containing:
1635
- * - binPath: Absolute path to the Tsdown CLI entry point
1636
- * - envs: Environment variables to set when executing Tsdown
1637
- *
1638
- * Tsdown is a tool that provides a library for building JavaScript/TypeScript libraries.
1639
- */
1640
- async function pack() {
1662
+ /** Validate the target project's core alias before starting the bundled pack entry. */
1663
+ async function pack(err, { cwd }) {
1664
+ if (err) throw err;
1665
+ resolveCore("/pack", cwd);
1641
1666
  return {
1642
1667
  binPath: join(import.meta.dirname, "pack-bin.js"),
1643
1668
  envs: { ...DEFAULT_ENVS }
@@ -1687,35 +1712,39 @@ async function test() {
1687
1712
  }
1688
1713
  //#endregion
1689
1714
  //#region src/resolve-vite.ts
1690
- /**
1691
- * Vite tool resolver for the vite-plus CLI.
1692
- *
1693
- * This module exports a function that resolves the Vite binary path
1694
- * using Node.js module resolution. The resolved path is passed back
1695
- * to the Rust core, which then executes Vite with the appropriate
1696
- * command and arguments.
1697
- *
1698
- * Used for: `vite-plus build` and potentially `vite-plus dev` commands
1699
- */
1700
- /**
1701
- * Resolves the Vite binary path and environment variables.
1702
- *
1703
- * @returns Promise containing:
1704
- * - binPath: Absolute path to the Vite CLI entry point (vite.js)
1705
- * - envs: Environment variables to set when executing Vite
1706
- *
1707
- * The function first tries to resolve vite package, then falls back
1708
- * to vite package (for direct vite installations).
1709
- * It constructs the path to the CLI binary within the resolved package.
1710
- */
1711
- async function vite() {
1712
- const vitePackagePath = dirname(resolve$1("@voidzero-dev/vite-plus-core"));
1715
+ function resolveViteRoot({ cwd, args }) {
1716
+ const cli = cac();
1717
+ const command = cli.command("[root]").allowUnknownOptions();
1718
+ for (const flag of [
1719
+ "--clearScreen",
1720
+ "--cors",
1721
+ "--strictPort",
1722
+ "--force",
1723
+ "--experimentalBundle",
1724
+ "--emptyOutDir",
1725
+ "-w, --watch",
1726
+ "--app",
1727
+ "-h, --help",
1728
+ "-v, --version"
1729
+ ]) command.option(flag, "");
1730
+ const parsed = cli.parse([
1731
+ "node",
1732
+ "vite",
1733
+ ...args
1734
+ ], { run: false });
1735
+ return resolve(cwd, parsed.args[0] ?? ".");
1736
+ }
1737
+ /** Resolve the bundled CLI for dev, build, and preview from the selected project root. */
1738
+ async function vite(err, context) {
1739
+ if (err) throw err;
1740
+ const vitePackagePath = dirname(resolveCore("", resolveViteRoot(context)));
1741
+ const binPath = join(vitePackagePath, "cli.js");
1742
+ if (!existsSync(binPath)) throw new Error(`Could not find the bundled Vite CLI at ${binPath}. Run \`vp install\`.`);
1743
+ const envs = { ...DEFAULT_ENVS };
1744
+ if (process.env.DEBUG_DISABLE_SOURCE_MAP) envs.DEBUG_DISABLE_SOURCE_MAP = process.env.DEBUG_DISABLE_SOURCE_MAP;
1713
1745
  return {
1714
- binPath: join(vitePackagePath, "cli.js"),
1715
- envs: process.env.DEBUG_DISABLE_SOURCE_MAP ? {
1716
- ...DEFAULT_ENVS,
1717
- DEBUG_DISABLE_SOURCE_MAP: process.env.DEBUG_DISABLE_SOURCE_MAP
1718
- } : { ...DEFAULT_ENVS }
1746
+ binPath,
1747
+ envs
1719
1748
  };
1720
1749
  }
1721
1750
  //#endregion
@@ -1723,7 +1752,7 @@ async function vite() {
1723
1752
  /**
1724
1753
  * Unified entry point for both the local CLI (via bin/vp) and the global CLI (via Rust vp binary).
1725
1754
  *
1726
- * Global commands (create, migrate, config, hooks, staged, --version) are handled by tsdown-bundled modules.
1755
+ * Global commands (create, migrate, sync-versions, config, hooks, staged, --version) are handled by tsdown-bundled modules.
1727
1756
  * All other commands are delegated to the Rust core through NAPI bindings, which
1728
1757
  * uses JavaScript tool resolver functions to locate tool binaries.
1729
1758
  *
@@ -1782,17 +1811,20 @@ const cliDistDir = path.dirname(fileURLToPath(import.meta.url));
1782
1811
  const vitePlusPackagePath = path.dirname(cliDistDir);
1783
1812
  if (maybePrintCommandHelp(args)) {} else if (command === "create") await import("./create/bin.js");
1784
1813
  else if (command === "migrate") await import("./migration/bin.js");
1814
+ else if (command === "sync-versions") await import("./sync-versions/bin.js");
1785
1815
  else if (command === "config") await import("./config/bin.js");
1786
1816
  else if (command === "hooks") await import("./hooks/bin.js");
1787
1817
  else if (command === "--version" || command === "-V") await import("./version.js");
1788
1818
  else if (command === "staged") await import("./staged/bin.js");
1789
1819
  else try {
1820
+ const { resolveUniversalViteConfig } = await import("./resolve-vite-config-6Nox70uP.js");
1790
1821
  const initInspection = inspectInitCommand(command, args.slice(1));
1791
1822
  if (initInspection.handled && initInspection.configKey && initInspection.hasExistingConfigKey && initInspection.existingViteConfigPath) {
1792
1823
  log(`Skipped initialization: '${accent(initInspection.configKey)}' already exists in '${accent(path.basename(initInspection.existingViteConfigPath))}'.`);
1793
1824
  process.exit(0);
1794
1825
  }
1795
1826
  const exitCode = await run({
1827
+ nodeExecPath: process.execPath,
1796
1828
  lint,
1797
1829
  pack,
1798
1830
  fmt,
@@ -0,0 +1,13 @@
1
+ import { n as errorMsg, o as printHeader } from "./terminal-MKGAuy-p.js";
2
+ //#region src/utils/cli-parse.ts
3
+ function unwrapCliParseOutcome(outcome) {
4
+ if (outcome.status === "exit") process.exit(outcome.code);
5
+ if (outcome.status === "error") {
6
+ printHeader();
7
+ errorMsg(outcome.error.message.replace(/^error:\s*/, ""));
8
+ process.exit(1);
9
+ }
10
+ return outcome.value;
11
+ }
12
+ //#endregion
13
+ export { unwrapCliParseOutcome as t };
@@ -1 +1 @@
1
- export * from '@voidzero-dev/vite-plus-core/dist/client/bundledDevClient.mjs';
1
+ export * from 'vite/dist/client/bundledDevClient.mjs';
@@ -1 +1 @@
1
- export * from '@voidzero-dev/vite-plus-core/dist/client/client.mjs';
1
+ export * from 'vite/dist/client/client.mjs';
@@ -1 +1 @@
1
- export * from '@voidzero-dev/vite-plus-core/dist/client/env.mjs';
1
+ export * from 'vite/dist/client/env.mjs';
package/dist/client.d.ts CHANGED
@@ -1 +1 @@
1
- /// <reference types="@voidzero-dev/vite-plus-core/client" />
1
+ /// <reference types="vite/client" />