Skip to content

Commit 085f66e

Browse files
Copilotfengmk2Brooooooklyn
authored
chore(cli): ship rolldown-vite instead of vite with npm alias support (#65)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: fengmk2 <156269+fengmk2@users.noreply.github.com> Co-authored-by: MK <fengmk2@gmail.com> Co-authored-by: LongYinan <lynweklm@gmail.com> Co-authored-by: Brooooooklyn <3468483+Brooooooklyn@users.noreply.github.com>
1 parent 3cff2af commit 085f66e

8 files changed

Lines changed: 240 additions & 41 deletions

File tree

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,12 @@ jobs:
105105

106106
- name: Run self
107107
run: ./target/debug/vt run -r build
108+
109+
- name: Print help for built-in commands
110+
run: |
111+
export PATH="$PATH:$(pwd)/packages/cli/bin"
112+
vite-plus -h
113+
vite-plus run -h
114+
vite-plus lint -h
115+
vite-plus test -h
116+
vite-plus build -h

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"lint-staged": "^16.1.2",
2020
"oxlint": "catalog:",
2121
"typescript": "catalog:",
22-
"vite": "catalog:",
22+
"rolldown-vite": "catalog:",
2323
"vite-plus": "workspace:*"
2424
},
2525
"lint-staged": {

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
],
3030
"dependencies": {
3131
"oxlint": "catalog:",
32-
"vite": "catalog:",
32+
"rolldown-vite": "catalog:",
3333
"vitest": "catalog:"
3434
},
3535
"devDependencies": {

packages/cli/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
type UserConfigFn,
66
type UserConfigFnObject,
77
type UserConfigFnPromise,
8-
} from 'vite';
8+
} from 'rolldown-vite';
99
import { type ViteUserConfig } from 'vitest/config';
1010

1111
type ExtendsConfig<T> = T extends UserConfig ? T & { extends?: string; test?: ViteUserConfig['test'] }

packages/cli/src/vite.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,29 @@ const require = createRequire(import.meta.url);
2222
* - binPath: Absolute path to the Vite CLI entry point (vite.js)
2323
* - envs: Environment variables to set when executing Vite
2424
*
25-
* The function uses require.resolve to find the vite package installation,
26-
* then constructs the path to the CLI binary within the package.
25+
* The function first tries to resolve vite package, then falls back
26+
* to rolldown-vite package (for direct rolldown-vite installations).
27+
* It constructs the path to the CLI binary within the resolved package.
2728
*/
2829
export async function vite(): Promise<{
2930
binPath: string;
3031
envs: Record<string, string>;
3132
}> {
32-
// Find the vite package.json to locate the installation directory
33-
const pkgJsonPath = require.resolve('vite/package.json', {
34-
paths: [process.cwd(), dirname(fileURLToPath(import.meta.url))],
35-
});
33+
const resolvePaths = [process.cwd(), dirname(fileURLToPath(import.meta.url))];
34+
35+
let pkgJsonPath: string;
36+
try {
37+
// First try to resolve vite package.json
38+
pkgJsonPath = require.resolve('vite/package.json', {
39+
paths: resolvePaths,
40+
});
41+
} catch {
42+
// Fallback to rolldown-vite package.json (for direct rolldown-vite installations)
43+
pkgJsonPath = require.resolve('rolldown-vite/package.json', {
44+
paths: resolvePaths,
45+
});
46+
}
47+
3648
// Vite's CLI binary is located at bin/vite.js relative to the package root
3749
const binPath = join(dirname(pkgJsonPath), 'bin', 'vite.js');
3850

packages/global/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"dependencies": {
2323
"oxlint": "*",
24-
"vite": "*",
24+
"rolldown-vite": "*",
2525
"vitest": "*"
2626
},
2727
"devDependencies": {

0 commit comments

Comments
 (0)