Skip to content

Commit e0b358d

Browse files
authored
feat: allow overriding rolldown version (#450)
* feat: allow overriding rolldown version * refactor: use `applyPackageOverrides` to override rolldown
1 parent 3950c88 commit e0b358d

File tree

5 files changed

+51
-4
lines changed

5 files changed

+51
-4
lines changed

.github/workflows/ecosystem-ci-selected.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ on:
4141
vite_plugin_react_repo:
4242
description: "vite-plugin-react repository to use"
4343
type: string
44+
rolldownRef:
45+
description: "rolldown commit sha to use from pkg.pr.new"
46+
type: string
4447
suite:
4548
description: "testsuite to run"
4649
required: true
@@ -101,12 +104,14 @@ jobs:
101104
pnpm tsx ecosystem-ci.ts
102105
"--$REF_TYPE" "$REF"
103106
--repo "$REPO"
107+
${ROLLDOWN_REF:+--rolldown-ref "$ROLLDOWN_REF"}
104108
"$SUITE"
105109
id: ecosystem-ci-run
106110
env:
107111
REF_TYPE: ${{ inputs.refType }}
108112
REF: ${{ inputs.ref }}
109113
REPO: ${{ inputs.repo }}
114+
ROLLDOWN_REF: ${{ inputs.rolldownRef }}
110115
SUITE: ${{ inputs.suite }}
111116
VITE_PLUGIN_REACT_REF: ${{ inputs.vite_plugin_react_ref }}
112117
VITE_PLUGIN_REACT_REPO: ${{ inputs.vite_plugin_react_repo }}

.github/workflows/ecosystem-ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ on:
3737
required: true
3838
type: string
3939
default: "vitejs/vite"
40+
rolldownRef:
41+
description: "rolldown commit sha to use from pkg.pr.new"
42+
type: string
4043
sendDiscordReport:
4144
description: "send results to discord"
4245
type: boolean
@@ -98,12 +101,14 @@ jobs:
98101
pnpm tsx ecosystem-ci.ts
99102
"--$REF_TYPE" "$REF"
100103
--repo "$REPO"
104+
${ROLLDOWN_REF:+--rolldown-ref "$ROLLDOWN_REF"}
101105
"$SUITE"
102106
id: ecosystem-ci-run
103107
env:
104108
REF_TYPE: ${{ inputs.refType || github.event.client_payload.refType || 'branch' }}
105109
REF: ${{ inputs.ref || github.event.client_payload.ref || 'main' }}
106110
REPO: ${{ inputs.repo || github.event.client_payload.repo || 'vitejs/vite' }}
111+
ROLLDOWN_REF: ${{ inputs.rolldownRef || github.event.client_payload.rolldownRef }}
107112
SUITE: ${{ matrix.suite }}
108113
- if: always() && (inputs.sendDiscordReport || github.event_name != 'workflow_dispatch')
109114
run: pnpm tsx discord-webhook.ts

ecosystem-ci.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ cli
2222
.option('--tag <tag>', 'vite tag to use')
2323
.option('--commit <commit>', 'vite commit sha to use')
2424
.option('--release <version>', 'vite release to use from npm registry')
25+
.option(
26+
'--rolldown-ref <commit>',
27+
'rolldown commit sha to use from pkg.pr.new',
28+
)
2529
.action(async (suites, options: CommandOptions) => {
2630
if (options.commit) {
2731
const url = `https://pkg.pr.new/vite@${options.commit}`
28-
//eslint-disable-next-line n/no-unsupported-features/node-builtins
2932
const { status } = await fetch(url)
3033
if (status === 200) {
3134
options.release = url
@@ -34,12 +37,25 @@ cli
3437
console.log(`continuous release available on ${url}`)
3538
}
3639
}
40+
let rolldownRelease: string | undefined
41+
if (options.rolldownRef) {
42+
const url = `https://pkg.pr.new/rolldown@${options.rolldownRef}`
43+
const { status } = await fetch(url)
44+
if (status === 200) {
45+
rolldownRelease = url
46+
console.log(`rolldown continuous release available on ${url}`)
47+
} else {
48+
throw new Error(
49+
`rolldown continuous release not found for ref ${options.rolldownRef} (HTTP ${status}): ${url}`,
50+
)
51+
}
52+
}
3753
const { root, vitePath, workspace } = await setupEnvironment()
3854
const suitesToRun = getSuitesToRun(suites, root)
3955
let viteMajor
4056
if (!options.release) {
4157
await setupViteRepo(options)
42-
await buildVite({ verify: options.verify })
58+
await buildVite({ verify: options.verify, rolldownRelease })
4359
viteMajor = parseViteMajor(vitePath)
4460
} else {
4561
viteMajor = parseMajorVersion(options.release)
@@ -50,6 +66,7 @@ cli
5066
viteMajor,
5167
workspace,
5268
release: options.release,
69+
rolldownRelease,
5370
verify: options.verify,
5471
skipGit: false,
5572
}

types.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export interface RunOptions {
1515
verify?: boolean
1616
skipGit?: boolean
1717
release?: string
18+
rolldownRelease?: string
1819
agent?: (typeof AGENTS)[number]
1920
build?: Task | Task[]
2021
test?: Task | Task[]
@@ -34,6 +35,7 @@ export interface CommandOptions {
3435
release?: string
3536
verify?: boolean
3637
skipGit?: boolean
38+
rolldownRef?: string
3739
}
3840

3941
export interface RepoOptions {

utils.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,9 @@ export async function runInRepo(options: RunOptions & RepoOptions) {
352352
...localOverrides,
353353
}
354354
}
355+
if (options.rolldownRelease) {
356+
overrides.rolldown = options.rolldownRelease
357+
}
355358
await applyPackageOverrides(agent, dir, pkg, overrides)
356359
await beforeBuildCommand?.(pkg.scripts)
357360
await buildCommand?.(pkg.scripts)
@@ -414,12 +417,27 @@ export async function getPermanentRef() {
414417
}
415418
}
416419

417-
export async function buildVite({ verify = false }) {
420+
export async function buildVite({
421+
verify = false,
422+
rolldownRelease,
423+
}: { verify?: boolean; rolldownRelease?: string } = {}) {
418424
cd(vitePath)
425+
419426
const frozenInstall = getCommand('pnpm', 'frozen')
420427
const runBuild = getCommand('pnpm', 'run', ['build'])
421428
const runTest = getCommand('pnpm', 'run', ['test'])
422-
await $`${serializeCommand(frozenInstall)}`
429+
430+
if (rolldownRelease) {
431+
const pkgFile = path.join(vitePath, 'package.json')
432+
const pkg = JSON.parse(await fs.promises.readFile(pkgFile, 'utf-8'))
433+
// Override rolldown in vite's monorepo so it builds against the specified version
434+
await applyPackageOverrides('pnpm', vitePath, pkg, {
435+
rolldown: rolldownRelease,
436+
})
437+
console.log(`overridden rolldown in vite repo with ${rolldownRelease}`)
438+
} else {
439+
await $`${serializeCommand(frozenInstall)}`
440+
}
423441
await $`${serializeCommand(runBuild)}`
424442
if (verify) {
425443
await $`${serializeCommand(runTest)}`

0 commit comments

Comments
 (0)