Skip to content

Commit 02e5495

Browse files
authored
chore: make ecosystem-ci pass with rolldown-vite (#602)
1 parent 256ac31 commit 02e5495

File tree

4 files changed

+48
-24
lines changed

4 files changed

+48
-24
lines changed

playground/vue-lib/__tests__/vue-lib.spec.ts

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,34 @@
11
import path from 'node:path'
22
import type { Rollup } from 'vite'
33
import { build } from 'vite'
4+
import * as vite from 'vite'
45
import { describe, expect, test } from 'vitest'
56

7+
const isRolldownVite = 'rolldownVersion' in vite
8+
69
describe('vue component library', () => {
7-
test('should output tree shakeable css module code', async () => {
8-
// Build lib
9-
await build({
10-
logLevel: 'silent',
11-
configFile: path.resolve(__dirname, '../vite.config.lib.ts'),
12-
})
13-
// Build app
14-
const { output } = (await build({
15-
logLevel: 'silent',
16-
configFile: path.resolve(__dirname, '../vite.config.consumer.ts'),
17-
})) as Rollup.RollupOutput
18-
const { code } = output.find(
19-
(e) => e.type === 'chunk' && e.isEntry,
20-
) as Rollup.OutputChunk
21-
// Unused css module should be treeshaked
22-
expect(code).toContain('styleA') // styleA is used by CompA
23-
expect(code).not.toContain('styleB') // styleB is not used
24-
})
10+
// skip this test for now with rolldown-vite due to https://github.com/oxc-project/oxc/issues/10033
11+
test.skipIf(isRolldownVite)(
12+
'should output tree shakeable css module code',
13+
async () => {
14+
// Build lib
15+
await build({
16+
logLevel: 'silent',
17+
configFile: path.resolve(__dirname, '../vite.config.lib.ts'),
18+
})
19+
// Build app
20+
const { output } = (await build({
21+
logLevel: 'silent',
22+
configFile: path.resolve(__dirname, '../vite.config.consumer.ts'),
23+
})) as Rollup.RollupOutput
24+
const { code } = output.find(
25+
(e) => e.type === 'chunk' && e.isEntry,
26+
) as Rollup.OutputChunk
27+
// Unused css module should be treeshaked
28+
expect(code).toContain('styleA') // styleA is used by CompA
29+
expect(code).not.toContain('styleB') // styleB is not used
30+
},
31+
)
2532

2633
test('should inject css when cssCodeSplit = true', async () => {
2734
// Build lib

playground/vue-sourcemap/__tests__/vue-sourcemap.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { URL } from 'node:url'
22
import { describe, expect, test } from 'vitest'
3+
import * as vite from 'vite'
34
import {
45
extractSourcemap,
56
formatSourcemapForSnapshot,
@@ -9,6 +10,8 @@ import {
910
serverLogs,
1011
} from '~utils'
1112

13+
const isRolldownVite = 'rolldownVersion' in vite
14+
1215
describe.runIf(isServe)('serve:vue-sourcemap', () => {
1316
const getStyleTagContentIncluding = async (content: string) => {
1417
const styles = await page.$$('style')
@@ -28,7 +31,8 @@ describe.runIf(isServe)('serve:vue-sourcemap', () => {
2831
expect(formatSourcemapForSnapshot(map)).toMatchSnapshot('serve-js')
2932
})
3033

31-
test('ts', async () => {
34+
// skip this test for now with rolldown-vite as the snapshot is slightly different
35+
test.skipIf(isRolldownVite)('ts', async () => {
3236
const res = await page.request.get(new URL('./Ts.vue', page.url()).href)
3337
const js = await res.text()
3438
const map = extractSourcemap(js)

playground/vue/__tests__/vue.spec.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, expect, test } from 'vitest'
22
import { version } from 'vue'
3+
import * as vite from 'vite'
34
import {
45
browserLogs,
56
editFile,
@@ -12,6 +13,8 @@ import {
1213
untilUpdated,
1314
} from '~utils'
1415

16+
const isRolldownVite = 'rolldownVersion' in vite
17+
1518
test('should render', async () => {
1619
expect(await page.textContent('h1')).toMatch(`Vue version ${version}`)
1720
})
@@ -461,7 +464,11 @@ describe('template parse options', () => {
461464
})
462465
})
463466

464-
test.runIf(isBuild)('scoped style should be tree-shakeable', async () => {
465-
const indexCss = findAssetFile(/index-[\w-]+\.css/)
466-
expect(indexCss).not.toContain('.tree-shake-scoped-style')
467-
})
467+
// skip this test for now with rolldown-vite as this requires https://github.com/rolldown/rolldown/issues/4812 to be implemented
468+
test.runIf(isBuild && !isRolldownVite)(
469+
'scoped style should be tree-shakeable',
470+
async () => {
471+
const indexCss = findAssetFile(/index-[\w-]+\.css/)
472+
expect(indexCss).not.toContain('.tree-shake-scoped-style')
473+
},
474+
)

vitest.config.e2e.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { resolve } from 'node:path'
2-
import { defineConfig } from 'vitest/config'
2+
import { defaultExclude, defineConfig } from 'vitest/config'
3+
import * as vite from 'vite'
34

45
const timeout = process.env.CI ? 50000 : 30000
56

@@ -15,6 +16,11 @@ export default defineConfig({
1516
},
1617
test: {
1718
include: ['./playground/**/*.spec.[tj]s'],
19+
exclude: [
20+
...defaultExclude,
21+
// plugin-legacy is not supported with rolldown-vite
22+
...('rolldownVersion' in vite ? ['./playground/vue-legacy/**/*'] : []),
23+
],
1824
setupFiles: ['./playground/vitestSetup.ts'],
1925
globalSetup: ['./playground/vitestGlobalSetup.ts'],
2026
testTimeout: timeout,

0 commit comments

Comments
 (0)