Skip to content

Commit ec58edc

Browse files
authored
feat: add rolldown and rolldown-vite as sub packages (#271)
1 parent 2f7f168 commit ec58edc

43 files changed

Lines changed: 14097 additions & 2606 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: 'Build with Upstream Repositories'
2+
description: 'Builds Vite+ with the upstream repositories'
3+
inputs:
4+
target:
5+
description: 'The target platform'
6+
required: true
7+
runs:
8+
using: 'composite'
9+
steps:
10+
- name: Build
11+
shell: bash
12+
if: ${{ inputs.target == 'x86_64-unknown-linux-gnu' }}
13+
run: |
14+
pnpm --filter @rolldown/pluginutils build
15+
pnpm --filter rolldown build-binding:release --target ${{ inputs.target }} --use-napi-cross
16+
pnpm --filter rolldown build-node
17+
pnpm --filter rolldown-vite build-types
18+
CC="x86_64-unknown-linux-gnu-cc" pnpm --filter=@voidzero-dev/vite-plus build --target ${{ inputs.target }} --use-napi-cross
19+
env:
20+
TARGET_CC: clang
21+
22+
- name: Build
23+
shell: bash
24+
if: ${{ inputs.target == 'aarch64-unknown-linux-gnu' }}
25+
run: |
26+
pnpm --filter @rolldown/pluginutils build
27+
pnpm --filter rolldown build-binding:release --target ${{ inputs.target }} --use-napi-cross
28+
pnpm --filter rolldown build-node
29+
pnpm --filter rolldown-vite build-types
30+
pnpm --filter=@voidzero-dev/vite-plus build --target ${{ inputs.target }} --use-napi-cross
31+
env:
32+
TARGET_CC: clang
33+
34+
- name: Build
35+
shell: bash
36+
if: ${{ !contains(inputs.target, 'linux') }}
37+
run: |
38+
pnpm --filter @rolldown/pluginutils build
39+
pnpm --filter rolldown build-binding:release --target ${{ inputs.target }}
40+
pnpm --filter rolldown build-node
41+
pnpm --filter rolldown-vite build-types
42+
pnpm --filter=@voidzero-dev/vite-plus build --target ${{ inputs.target }}

.github/actions/clone/action.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: 'Clone Repositories'
2+
description: 'Clone self and upstream repositories'
3+
runs:
4+
using: 'composite'
5+
steps:
6+
- name: Output rolldown and rolldown-vite hash
7+
shell: bash
8+
id: upstream-versions
9+
run: |
10+
node -e "console.log('ROLLDOWN_HASH=' + require('./packages/tools/.upstream-versions.json').rolldown.hash)" >> $GITHUB_OUTPUT
11+
node -e "console.log('ROLLDOWN_VITE_HASH=' + require('./packages/tools/.upstream-versions.json')['rolldown-vite'].hash)" >> $GITHUB_OUTPUT
12+
13+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
14+
with:
15+
repository: rolldown/rolldown
16+
path: rolldown
17+
ref: ${{ steps.upstream-versions.outputs.ROLLDOWN_HASH }}
18+
19+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
20+
with:
21+
repository: vitejs/rolldown-vite
22+
path: rolldown-vite
23+
ref: ${{ steps.upstream-versions.outputs.ROLLDOWN_VITE_HASH }}

.github/workflows/ci.yml

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ jobs:
4040
runs-on: ${{ matrix.os }}
4141
steps:
4242
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
43-
with:
44-
persist-credentials: false
45-
submodules: true
43+
- uses: ./.github/actions/clone
4644

4745
- uses: oxc-project/setup-rust@d286d43bc1f606abbd98096666ff8be68c8d5f57 # v1.0.0
4846
with:
@@ -66,9 +64,7 @@ jobs:
6664
runs-on: ubuntu-latest
6765
steps:
6866
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
69-
with:
70-
persist-credentials: false
71-
submodules: true
67+
- uses: ./.github/actions/clone
7268

7369
- name: Configure Git for access to vite-task
7470
run: git config --global url."https://x-access-token:${{ secrets.VITE_TASK_TOKEN }}@github.com/".insteadOf "https://github.com/"
@@ -101,9 +97,7 @@ jobs:
10197
runs-on: ubuntu-latest
10298
steps:
10399
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
104-
with:
105-
persist-credentials: false
106-
submodules: true
100+
- uses: ./.github/actions/clone
107101

108102
- name: Configure Git for access to vite-task
109103
run: git config --global url."https://x-access-token:${{ secrets.VITE_TASK_TOKEN }}@github.com/".insteadOf "https://github.com/"
@@ -115,12 +109,14 @@ jobs:
115109

116110
- uses: oxc-project/setup-node@fdbf0dfd334c4e6d56ceeb77d91c76339c2a0885 # v1.0.4
117111

112+
- name: build
113+
uses: ./.github/actions/build-upstream
114+
with:
115+
target: x86_64-unknown-linux-gnu
116+
118117
- name: Build self
119118
run: pnpm bootstrap-cli
120119

121-
- name: Run self
122-
run: vite run -r build
123-
124120
- name: Print help for built-in commands
125121
run: |
126122
vite -h
@@ -142,9 +138,7 @@ jobs:
142138
runs-on: ${{ matrix.os }}
143139
steps:
144140
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
145-
with:
146-
persist-credentials: false
147-
submodules: true
141+
- uses: ./.github/actions/clone
148142

149143
- name: Configure Git for access to vite-task
150144
run: git config --global url."https://x-access-token:${{ secrets.VITE_TASK_TOKEN }}@github.com/".insteadOf "https://github.com/"
@@ -162,6 +156,11 @@ jobs:
162156

163157
- uses: oxc-project/setup-node@fdbf0dfd334c4e6d56ceeb77d91c76339c2a0885 # v1.0.4
164158

159+
- name: Build with upstream
160+
uses: ./.github/actions/build-upstream
161+
with:
162+
target: ${{ matrix.os == 'ubuntu-latest' && 'x86_64-unknown-linux-gnu' || matrix.os == 'windows-latest' && 'x86_64-pc-windows-msvc' || 'aarch64-apple-darwin' }}
163+
165164
- name: Build CLI
166165
run: pnpm run bootstrap-cli
167166

@@ -192,9 +191,7 @@ jobs:
192191
if: ${{ github.ref_name == 'main' }}
193192
steps:
194193
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
195-
with:
196-
persist-credentials: false
197-
submodules: true
194+
- uses: ./.github/actions/clone
198195

199196
- name: Configure Git for access to vite-task
200197
run: git config --global url."https://x-access-token:${{ secrets.VITE_TASK_TOKEN }}@github.com/".insteadOf "https://github.com/"

.github/workflows/release.yml

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ jobs:
2525
# - aarch64-pc-windows-msvc
2626
steps:
2727
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
28-
with:
29-
persist-credentials: false
30-
submodules: true
31-
28+
- uses: ./.github/actions/clone
29+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
3230
- uses: oxc-project/setup-rust@d286d43bc1f606abbd98096666ff8be68c8d5f57 # v1.0.2
3331
with:
3432
save-cache: ${{ github.ref_name == 'main' }}
@@ -37,6 +35,10 @@ jobs:
3735
- name: Rustup Adds Target
3836
run: rustup target add ${{ matrix.settings.target }}
3937

38+
- name: Rustup Adds Target for rolldown
39+
working-directory: rolldown
40+
run: rustup target add ${{ matrix.settings.target }}
41+
4042
- name: Add musl target (x86_64)
4143
if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' }}
4244
run: rustup target add x86_64-unknown-linux-musl
@@ -45,38 +47,45 @@ jobs:
4547
if: ${{ matrix.settings.target == 'aarch64-unknown-linux-gnu' }}
4648
run: rustup target add aarch64-unknown-linux-musl
4749

50+
- name: Add rolldown host target
51+
if: ${{ matrix.settings.target == 'aarch64-unknown-linux-gnu' }}
52+
working-directory: rolldown
53+
run: rustup target add x86_64-unknown-linux-gnu
54+
4855
- uses: oxc-project/setup-node@fdbf0dfd334c4e6d56ceeb77d91c76339c2a0885 # v1.0.4
4956

57+
- name: Build host rolldown
58+
if: ${{ matrix.settings.target == 'aarch64-unknown-linux-gnu' }}
59+
run: pnpm --filter rolldown build-binding:release --target x86_64-unknown-linux-gnu
60+
5061
- name: Set binding version
5162
run: pnpm exec tool replace-file-content packages/cli/binding/Cargo.toml 'version = "0.0.0"' 'version = "0.0.0-${{ github.sha }}"'
5263

5364
- name: Configure Git for access to vite-task
5465
run: git config --global url."https://x-access-token:${{ secrets.VITE_TASK_TOKEN }}@github.com/".insteadOf "https://github.com/"
5566

5667
- name: Build
57-
if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' }}
58-
run: pnpm --filter=@voidzero-dev/vite-plus build --target ${{ matrix.settings.target }} --use-napi-cross
59-
env:
60-
CC: x86_64-unknown-linux-gnu-cc
61-
TARGET_CC: clang
62-
63-
- name: Build
64-
if: ${{ matrix.settings.target == 'aarch64-unknown-linux-gnu' }}
65-
run: pnpm --filter=@voidzero-dev/vite-plus build --target ${{ matrix.settings.target }} --use-napi-cross
66-
env:
67-
TARGET_CC: clang
68-
69-
- name: Build
70-
if: ${{ !contains(matrix.settings.target, 'linux') }}
71-
run: pnpm --filter=@voidzero-dev/vite-plus build --target ${{ matrix.settings.target }}
68+
uses: ./.github/actions/build-upstream
69+
with:
70+
target: ${{ matrix.settings.target }}
7271

73-
- name: Upload artifact
72+
- name: Upload Vite+ artifact
7473
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
7574
with:
76-
name: bindings-${{ matrix.settings.target }}
75+
name: vite-plus-native-${{ matrix.settings.target }}
7776
path: ./packages/cli/binding/*.node
7877
if-no-files-found: error
7978

79+
- name: Upload rolldown artifact
80+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
81+
with:
82+
name: rolldown-native-${{ matrix.settings.target }}
83+
path: ./rolldown/packages/rolldown/src/*.node
84+
if-no-files-found: error
85+
- name: Remove .node files before upload dist
86+
if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' }}
87+
run: rm ./packages/cli/dist/**/*.node
88+
8089
- name: Upload cli dist
8190
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
8291
if: ${{ matrix.settings.target == 'x86_64-unknown-linux-gnu' }}
@@ -93,18 +102,13 @@ jobs:
93102
packages: write
94103
steps:
95104
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
96-
with:
97-
persist-credentials: false
98-
submodules: true
105+
- uses: ./.github/actions/clone
99106

100107
- uses: oxc-project/setup-node@fdbf0dfd334c4e6d56ceeb77d91c76339c2a0885 # v1.0.4
101108

102109
- name: Configure Git for access to vite-task
103110
run: git config --global url."https://x-access-token:${{ secrets.VITE_TASK_TOKEN }}@github.com/".insteadOf "https://github.com/"
104111

105-
- name: Bootstrap
106-
run: pnpm bootstrap-cli:ci
107-
108112
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
109113
with:
110114
path: packages/cli/dist
@@ -114,7 +118,13 @@ jobs:
114118
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
115119
with:
116120
path: packages/cli/dist
117-
pattern: bindings-*
121+
pattern: vite-plus-native-*
122+
merge-multiple: true
123+
124+
- uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
125+
with:
126+
path: packages/cli/dist/vite
127+
pattern: rolldown-native-*
118128
merge-multiple: true
119129

120130
- name: Set npm packages version

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ dist
44
.claude/settings.local.json
55
*.tsbuildinfo
66
.DS_Store
7+
rolldown
8+
rolldown-vite

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# Vite+
22

3+
## Pull upstream dependencies
4+
5+
```
6+
pnpm tools sync-remote
7+
```
8+
9+
## Build Vite+ and upstream dependencies
10+
11+
```
12+
just build
13+
```
14+
315
## Install internal global cli
416

517
Add the following lines to your `~/.npmrc` file:

justfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ init:
1212
cargo binstall watchexec-cli cargo-insta typos-cli cargo-shear dprint taplo-cli -y
1313
pnpm run bootstrap-cli
1414

15+
build:
16+
pnpm --filter @rolldown/pluginutils build
17+
pnpm --filter rolldown build-binding:release
18+
pnpm --filter rolldown build-node
19+
pnpm --filter rolldown-vite build-types
20+
pnpm --filter=@voidzero-dev/vite-plus build
21+
1522
ready:
1623
git diff --exit-code --quiet
1724
typos

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vite-plus-monorepo",
33
"license": "BUSL-1.1",
44
"private": true,
5-
"packageManager": "pnpm@10.17.1",
5+
"packageManager": "pnpm@10.19.0",
66
"engines": {
77
"node": "^20.19.0 || >=22.12.0"
88
},
@@ -13,8 +13,8 @@
1313
"copy-bindings": "cp -r ./packages/cli/binding/*.node ./packages/cli/dist && cp -r ./packages/cli/binding/*.node ./packages/global/dist",
1414
"install-global-cli": "npm install -g ./packages/global",
1515
"typecheck": "tsc -b tsconfig.json",
16-
"lint": "vite lint && vite run typecheck",
17-
"test": "vite test run && pnpm -r snap-test",
16+
"lint": "vite lint",
17+
"test": "vite test run --config vite.config.ts && pnpm -r snap-test",
1818
"prepare": "husky"
1919
},
2020
"devDependencies": {

packages/cli/binding/src/commands/doc.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::future::Future;
1+
use std::{future::Future, iter::once};
22

33
use petgraph::stable_graph::StableGraph;
44
use vite_error::Error as ViteError;
@@ -14,10 +14,17 @@ pub async fn doc<
1414
workspace: &Workspace,
1515
args: &Vec<String>,
1616
) -> Result<ExecutionSummary, Error> {
17+
let ResolveCommandResult { bin_path, envs } =
18+
resolve_doc_command().await.map_err(|e| Error::Anyhow(e.into()))?;
1719
let wrapped_command =
18-
|| async { resolve_doc_command().await.map_err(|e| Error::Anyhow(e.into())) };
19-
let resolved_task =
20-
ResolvedTask::resolve_from_builtin(workspace, wrapped_command, "doc", args.iter()).await?;
20+
|| async { Ok(ResolveCommandResult { bin_path: "node".into(), envs: envs.clone() }) };
21+
let resolved_task = ResolvedTask::resolve_from_builtin(
22+
workspace,
23+
wrapped_command,
24+
"doc",
25+
once(&bin_path).chain(args.iter()),
26+
)
27+
.await?;
2128
let mut task_graph: StableGraph<ResolvedTask, ()> = Default::default();
2229
task_graph.add_node(resolved_task);
2330
ExecutionPlan::plan(task_graph, false)?.execute(workspace).await

packages/cli/binding/src/commands/fmt.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{collections::HashMap, future::Future};
1+
use std::{collections::HashMap, future::Future, iter::once};
22

33
use petgraph::stable_graph::StableGraph;
44
use serde::{Deserialize, Serialize};
@@ -22,10 +22,17 @@ pub async fn fmt<
2222
workspace: &Workspace,
2323
args: &Vec<String>,
2424
) -> Result<ExecutionSummary, Error> {
25+
let ResolveCommandResult { bin_path, envs } =
26+
resolve_fmt_command().await.map_err(|e| Error::Anyhow(e.into()))?;
2527
let wrapped_command =
26-
|| async { resolve_fmt_command().await.map_err(|e| Error::Anyhow(e.into())) };
27-
let resolved_task =
28-
ResolvedTask::resolve_from_builtin(workspace, wrapped_command, "fmt", args.iter()).await?;
28+
|| async { Ok(ResolveCommandResult { bin_path: "node".into(), envs: envs.clone() }) };
29+
let resolved_task = ResolvedTask::resolve_from_builtin(
30+
workspace,
31+
wrapped_command,
32+
"fmt",
33+
once(&bin_path).chain(args.iter()),
34+
)
35+
.await?;
2936
let mut task_graph: StableGraph<ResolvedTask, ()> = Default::default();
3037
task_graph.add_node(resolved_task);
3138
ExecutionPlan::plan(task_graph, false)?.execute(workspace).await

0 commit comments

Comments
 (0)