Skip to content

Commit 3505fa5

Browse files
Copilothi-ogawa
andauthored
fix(browser): skip esbuild.legalComments when using rolldown-vite (#9803)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: hi-ogawa <4232207+hi-ogawa@users.noreply.github.com> Co-authored-by: Hiroshi Ogawa <hi.ogawa.zz@gmail.com>
1 parent dfb2159 commit 3505fa5

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

packages/browser/src/node/plugin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,9 @@ export default (parentServer: ParentBrowserProject, base = '/'): Plugin[] => {
355355
enforce: 'post',
356356
async config(viteConfig) {
357357
// Enables using ignore hint for coverage providers with @preserve keyword
358-
if (viteConfig.esbuild !== false) {
358+
// Only set esbuild options when not using rolldown-vite (Vite 8+),
359+
// which uses oxc for transformation instead of esbuild
360+
if (!rolldownVersion && viteConfig.esbuild !== false) {
359361
viteConfig.esbuild ||= {}
360362
viteConfig.esbuild.legalComments = 'inline'
361363
}

test/cli/test/oxc.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { runInlineTests } from '#test-utils'
2+
import { expect, test } from 'vitest'
3+
4+
test('oxc config on browser', async () => {
5+
const result = await runInlineTests({
6+
// needs a config file to reproduce
7+
// https://github.com/vitest-dev/vitest/issues/9800
8+
'vitest.config.ts': `
9+
import { playwright } from '@vitest/browser-playwright'
10+
import { defineConfig } from 'vite'
11+
12+
export default defineConfig({
13+
test: {
14+
browser: {
15+
enabled: true,
16+
headless: true,
17+
provider: playwright(),
18+
instances: [
19+
{ browser: 'chromium' },
20+
],
21+
},
22+
},
23+
oxc: {
24+
jsx: {
25+
refresh: false,
26+
}
27+
}
28+
})
29+
`,
30+
'basic.test.ts': `
31+
import { test } from "vitest";
32+
test('basic', () => {});
33+
`,
34+
})
35+
36+
expect(result.stderr).toMatchInlineSnapshot(`""`)
37+
expect(result.errorTree()).toMatchInlineSnapshot(`
38+
{
39+
"basic.test.ts": {
40+
"basic": "passed",
41+
},
42+
}
43+
`)
44+
})

0 commit comments

Comments
 (0)