Skip to content

Commit c8d6264

Browse files
feat: support rolldown-vite (#7509)
Co-authored-by: Hiroshi Ogawa <hi.ogawa.zz@gmail.com>
1 parent 6db9f52 commit c8d6264

File tree

21 files changed

+629
-1053
lines changed

21 files changed

+629
-1053
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,39 @@ jobs:
157157

158158
- name: Test Browser (webdriverio)
159159
run: pnpm run test:browser:webdriverio
160+
161+
test-rolldown:
162+
needs: changed
163+
# macos-latest is the fastes one
164+
name: 'Rolldown&Test: node-20, macos-latest'
165+
if: needs.changed.outputs.should_skip != 'true'
166+
runs-on: macos-latest
167+
168+
timeout-minutes: 30
169+
170+
steps:
171+
- uses: actions/checkout@v4
172+
173+
- uses: ./.github/actions/setup-and-cache
174+
with:
175+
node-version: 20
176+
177+
- uses: browser-actions/setup-chrome@c785b87e244131f27c9f19c1a33e2ead956ab7ce # v1.7.3
178+
179+
- name: Install
180+
run: pnpm add vite@npm:rolldown-vite && git add . && git commit -m "ci" && pnpm i --prefer-offline --no-frozen-lockfile
181+
182+
- name: Install Playwright Dependencies
183+
run: pnpm exec playwright install --with-deps --only-shell
184+
185+
- name: Build
186+
run: pnpm run build
187+
188+
- name: Test
189+
run: pnpm run test:ci
190+
191+
- name: Test Examples
192+
run: pnpm run test:examples
193+
194+
- name: Test Browser (playwright)
195+
run: pnpm run test:browser:playwright

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"build": "pnpm -r --filter @vitest/ui --filter='./packages/**' run build",
1515
"dev": "NODE_OPTIONS=\"--max-old-space-size=8192\" pnpm -r --parallel --filter='./packages/**' run dev",
1616
"docs": "pnpm -C docs run dev",
17-
"docs:build": "pnpm -C docs run build",
17+
"docs:build": "ROLLDOWN_OPTIONS_VALIDATION=loose pnpm -C docs run build",
1818
"docs:serve": "pnpm -C docs run serve",
1919
"docs:https": "pnpm -C docs run preview-https",
2020
"docs:https-no-prefetch": "pnpm -C docs run preview-https-no-prefetch",
@@ -96,6 +96,7 @@
9696
"esbuild",
9797
"geckodriver",
9898
"msw",
99+
"rolldown",
99100
"sharp",
100101
"svelte-preprocess",
101102
"vue-demi"

packages/runner/src/suite.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ function createSuiteCollector(
366366

367367
if (runner.config.includeTaskLocation) {
368368
const error = stackTraceError.stack!
369-
const stack = findTestFileStackTrace(error, task.each ?? false)
369+
const stack = findTestFileStackTrace(error)
370370
if (stack) {
371371
task.location = stack
372372
}
@@ -460,7 +460,7 @@ function createSuiteCollector(
460460
Error.stackTraceLimit = 15
461461
const error = new Error('stacktrace').stack!
462462
Error.stackTraceLimit = limit
463-
const stack = findTestFileStackTrace(error, suite.each ?? false)
463+
const stack = findTestFileStackTrace(error)
464464
if (stack) {
465465
suite.location = stack
466466
}
@@ -890,21 +890,16 @@ function formatTemplateString(cases: any[], args: any[]): any[] {
890890
return res
891891
}
892892

893-
function findTestFileStackTrace(error: string, each: boolean) {
893+
function findTestFileStackTrace(error: string) {
894+
const testFilePath = getTestFilepath()
894895
// first line is the error message
895896
const lines = error.split('\n').slice(1)
896897
for (const line of lines) {
897898
const stack = parseSingleStack(line)
898-
if (stack && stack.file === getTestFilepath()) {
899+
if (stack && stack.file === testFilePath) {
899900
return {
900901
line: stack.line,
901-
/**
902-
* test.each([1, 2])('name')
903-
* ^ leads here, but should
904-
* ^ lead here
905-
* in source maps it's the same boundary, so it just points to the start of it
906-
*/
907-
column: each ? stack.column + 1 : stack.column,
902+
column: stack.column,
908903
}
909904
}
910905
}

packages/vitest/src/node/plugins/normalizeURL.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export function NormalizeURLPlugin(): Plugin {
2626
const assetImportMetaUrlRE
2727
// vite injects new URL(path, import.meta.url) in the code
2828
// rolldown-vite injects new URL(path, '' + import.meta.url) in the code
29-
= /\bnew\s+URL\s*\(\s*(?:'[^']+'|"[^"]+"|`[^`]+`)\s*,\s*(?:'' \+ )?import\.meta\.url\s*(?:,\s*)?\)/g
29+
= /\bnew\s+URL\s*\(\s*(?:'[^']+'|"[^"]+"|`[^`]+`)\s*,\s*(?:'' \+ )?import\.meta\.url\s*(?:,\s*)?\)/g
3030

3131
let updatedCode = code
3232
let match: RegExpExecArray | null

packages/vitest/src/public/node.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ModuleDiagnostic as _FileDiagnostic } from '../node/reporters/reported-tasks'
2-
import { createServer as _createServer } from 'vite'
2+
import * as vite from 'vite'
33
import { Vitest } from '../node/core'
44
import { TestModule as _TestFile } from '../node/reporters/reported-tasks'
55

@@ -81,8 +81,8 @@ export type {
8181
ResolvedBrowserOptions,
8282
} from '../node/types/browser'
8383
/** @deprecated use `createViteServer` instead */
84-
export const createServer: typeof _createServer = _createServer
85-
export const createViteServer: typeof _createServer = _createServer
84+
export const createServer: typeof vite.createServer = vite.createServer
85+
export const createViteServer: typeof vite.createServer = vite.createServer
8686
export type {
8787
ApiConfig,
8888
BuiltinEnvironment,
@@ -175,4 +175,7 @@ export {
175175
version as viteVersion,
176176
} from 'vite'
177177

178+
// rolldownVersion is exported only by rolldown-vite
179+
export const rolldownVersion: string | undefined = (vite as any).rolldownVersion
180+
178181
export type * as Vite from 'vite'

0 commit comments

Comments
 (0)