Skip to content

Commit b7a30c6

Browse files
authored
chore: migrate rolldown-vite to vite 8.0 beta (#335)
1 parent 0131832 commit b7a30c6

10 files changed

Lines changed: 161 additions & 115 deletions

File tree

justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ build:
1717
pnpm --filter @rolldown/pluginutils build
1818
pnpm --filter rolldown build-binding:release
1919
pnpm --filter rolldown build-node
20-
pnpm --filter rolldown-vite build-types
20+
pnpm --filter vite build-types
2121
pnpm --filter=@voidzero-dev/vite-plus build
2222

2323
ready:

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"rolldown": "workspace:*",
3838
"rolldown-plugin-dts": "catalog:",
3939
"tsdown": "catalog:",
40-
"rolldown-vite": "workspace:*"
40+
"vite": "workspace:*"
4141
},
4242
"napi": {
4343
"binaryName": "vite-plus",

packages/cli/snap-tests/command-helper/snap.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ Options:
208208
--base <path> [string] public base path (default: /)
209209
-l, --logLevel <level> [string] info | warn | error | silent
210210
--clearScreen [boolean] allow/disable clear screen when logging
211-
--configLoader <loader> [string] use 'bundle' to bundle the config with esbuild, or 'runner' (experimental) to process it on the fly, or 'native' (experimental) to load using the native runtime (default: bundle)
211+
--configLoader <loader> [string] use 'bundle' to bundle the config with Rolldown, or 'runner' (experimental) to process it on the fly, or 'native' (experimental) to load using the native runtime (default: bundle)
212212
-d, --debug [feat] [string | boolean] show debug logs
213213
-f, --filter <filter> [string] filter debug logs
214214
-m, --mode <mode> [string] set env mode

packages/core/build.ts

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -112,26 +112,16 @@ async function buildVite() {
112112
}
113113
},
114114
},
115-
...config.plugins
116-
.filter((plugin) => {
117-
return !(
118-
typeof plugin === 'object' &&
119-
plugin !== null &&
120-
'name' in plugin &&
121-
plugin.name === 'rollup-plugin-license'
122-
);
123-
})
124-
.map((plugin) => {
125-
if (
126-
typeof plugin === 'object' &&
127-
plugin !== null &&
128-
'name' in plugin &&
129-
plugin.name === 'externalize-vite'
130-
) {
131-
return RewriteImportsPlugin;
132-
}
133-
return plugin;
134-
}),
115+
// Add RewriteImportsPlugin to handle vite/rolldown import rewrites
116+
RewriteImportsPlugin,
117+
...config.plugins.filter((plugin) => {
118+
return !(
119+
typeof plugin === 'object' &&
120+
plugin !== null &&
121+
'name' in plugin &&
122+
plugin.name === 'rollup-plugin-license'
123+
);
124+
}),
135125
];
136126
}
137127

@@ -171,8 +161,10 @@ async function buildVite() {
171161
await writeFile(
172162
dstFilePath,
173163
file
174-
.replaceAll(`"rolldown-vite/`, `"${pkgJson.name}/`)
175-
.replaceAll(`"rolldown-vite"`, `"${pkgJson.name}/vite"`)
164+
// Handle vite v8+ imports (official vite repo uses 'vite' package name)
165+
.replaceAll(`"vite/`, `"${pkgJson.name}/`)
166+
.replaceAll(`"vite"`, `"${pkgJson.name}"`)
167+
// Handle rolldown imports
176168
.replaceAll(`"rolldown/`, `"${pkgJson.name}/rolldown/`)
177169
.replaceAll(`"rolldown"`, `"${pkgJson.name}/rolldown"`),
178170
);

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
"magic-string": "^0.30.21",
164164
"picocolors": "^1.1.1",
165165
"rolldown": "workspace:*",
166-
"rolldown-vite": "workspace:*",
166+
"vite": "workspace:*",
167167
"rollup": "^4.18.0",
168168
"rollup-plugin-license": "^3.6.0",
169169
"tinyglobby": "^0.2.15",

packages/global/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"cross-spawn": "catalog:",
2828
"oxlint": "catalog:",
2929
"oxlint-tsgolint": "catalog:",
30-
"rolldown-vite": "workspace:*",
30+
"vite": "workspace:*",
3131
"validate-npm-package-name": "catalog:"
3232
},
3333
"devDependencies": {
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"rolldown": {
3-
"repo": "git@github.com:rolldown/rolldown.git",
3+
"repo": "https://github.com/rolldown/rolldown.git",
44
"branch": "main",
55
"hash": "c013fc844242178da7c4e9a7ec9f24697efcd726"
66
},
77
"rolldown-vite": {
8-
"repo": "git@github.com:vitejs/rolldown-vite.git",
9-
"branch": "rolldown-vite",
10-
"hash": "ef44d7526b86704667168418f0ed9a0300652297"
8+
"repo": "https://github.com/vitejs/vite.git",
9+
"branch": "main",
10+
"hash": "08c74cc54b1892e1d2f29840c18ef61f05963301"
1111
}
1212
}

packages/tools/src/sync-remote-deps.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ function cloneOrResetRepo(repoUrl: string, dir: string, branch: string = 'main',
8383
return;
8484
}
8585

86-
// Fetch latest commits
87-
execCommand('git fetch origin', dir);
86+
// Fetch latest commits and tags
87+
execCommand('git fetch origin --tags', dir);
8888

8989
if (hash) {
9090
// Reset to specific hash
@@ -93,11 +93,24 @@ function cloneOrResetRepo(repoUrl: string, dir: string, branch: string = 'main',
9393
execCommand(`git reset --hard ${hash}`, dir);
9494
log(`${dir} reset to ${hash.substring(0, 8)}`);
9595
} else {
96-
// Reset to latest
96+
// Reset to latest - check if branch is a tag or a branch
9797
log(`Resetting ${dir} to latest ${branch}...`);
98-
execCommand(`git checkout ${branch}`, dir);
99-
execCommand(`git reset --hard origin/${branch}`, dir);
100-
log(`${dir} reset to latest ${branch}`);
98+
const isTag =
99+
spawnSync('git', ['tag', '-l', branch], {
100+
cwd: dir,
101+
encoding: 'utf-8',
102+
}).stdout.trim() === branch;
103+
104+
if (isTag) {
105+
// For tags, just checkout the tag directly
106+
execCommand(`git checkout ${branch}`, dir);
107+
log(`${dir} reset to tag ${branch}`);
108+
} else {
109+
// For branches, reset to origin/branch
110+
execCommand(`git checkout ${branch}`, dir);
111+
execCommand(`git reset --hard origin/${branch}`, dir);
112+
log(`${dir} reset to latest ${branch}`);
113+
}
101114
}
102115
} catch (err: any) {
103116
log(`Failed to reset ${dir} (${err.message}), removing and re-cloning...`);

0 commit comments

Comments
 (0)