diff --git a/playground/vue-lib/__tests__/vue-lib.spec.ts b/playground/vue-lib/__tests__/vue-lib.spec.ts index c3ba7923..d001fe88 100644 --- a/playground/vue-lib/__tests__/vue-lib.spec.ts +++ b/playground/vue-lib/__tests__/vue-lib.spec.ts @@ -1,27 +1,34 @@ import path from 'node:path' import type { Rollup } from 'vite' import { build } from 'vite' +import * as vite from 'vite' import { describe, expect, test } from 'vitest' +const isRolldownVite = 'rolldownVersion' in vite + describe('vue component library', () => { - test('should output tree shakeable css module code', async () => { - // Build lib - await build({ - logLevel: 'silent', - configFile: path.resolve(__dirname, '../vite.config.lib.ts'), - }) - // Build app - const { output } = (await build({ - logLevel: 'silent', - configFile: path.resolve(__dirname, '../vite.config.consumer.ts'), - })) as Rollup.RollupOutput - const { code } = output.find( - (e) => e.type === 'chunk' && e.isEntry, - ) as Rollup.OutputChunk - // Unused css module should be treeshaked - expect(code).toContain('styleA') // styleA is used by CompA - expect(code).not.toContain('styleB') // styleB is not used - }) + // skip this test for now with rolldown-vite due to https://github.com/oxc-project/oxc/issues/10033 + test.skipIf(isRolldownVite)( + 'should output tree shakeable css module code', + async () => { + // Build lib + await build({ + logLevel: 'silent', + configFile: path.resolve(__dirname, '../vite.config.lib.ts'), + }) + // Build app + const { output } = (await build({ + logLevel: 'silent', + configFile: path.resolve(__dirname, '../vite.config.consumer.ts'), + })) as Rollup.RollupOutput + const { code } = output.find( + (e) => e.type === 'chunk' && e.isEntry, + ) as Rollup.OutputChunk + // Unused css module should be treeshaked + expect(code).toContain('styleA') // styleA is used by CompA + expect(code).not.toContain('styleB') // styleB is not used + }, + ) test('should inject css when cssCodeSplit = true', async () => { // Build lib diff --git a/playground/vue-sourcemap/__tests__/vue-sourcemap.spec.ts b/playground/vue-sourcemap/__tests__/vue-sourcemap.spec.ts index 7e03da16..1f9a0987 100644 --- a/playground/vue-sourcemap/__tests__/vue-sourcemap.spec.ts +++ b/playground/vue-sourcemap/__tests__/vue-sourcemap.spec.ts @@ -1,5 +1,6 @@ import { URL } from 'node:url' import { describe, expect, test } from 'vitest' +import * as vite from 'vite' import { extractSourcemap, formatSourcemapForSnapshot, @@ -9,6 +10,8 @@ import { serverLogs, } from '~utils' +const isRolldownVite = 'rolldownVersion' in vite + describe.runIf(isServe)('serve:vue-sourcemap', () => { const getStyleTagContentIncluding = async (content: string) => { const styles = await page.$$('style') @@ -28,7 +31,8 @@ describe.runIf(isServe)('serve:vue-sourcemap', () => { expect(formatSourcemapForSnapshot(map)).toMatchSnapshot('serve-js') }) - test('ts', async () => { + // skip this test for now with rolldown-vite as the snapshot is slightly different + test.skipIf(isRolldownVite)('ts', async () => { const res = await page.request.get(new URL('./Ts.vue', page.url()).href) const js = await res.text() const map = extractSourcemap(js) diff --git a/playground/vue/__tests__/vue.spec.ts b/playground/vue/__tests__/vue.spec.ts index 1c403fed..57a2091a 100644 --- a/playground/vue/__tests__/vue.spec.ts +++ b/playground/vue/__tests__/vue.spec.ts @@ -1,5 +1,6 @@ import { describe, expect, test } from 'vitest' import { version } from 'vue' +import * as vite from 'vite' import { browserLogs, editFile, @@ -12,6 +13,8 @@ import { untilUpdated, } from '~utils' +const isRolldownVite = 'rolldownVersion' in vite + test('should render', async () => { expect(await page.textContent('h1')).toMatch(`Vue version ${version}`) }) @@ -461,7 +464,11 @@ describe('template parse options', () => { }) }) -test.runIf(isBuild)('scoped style should be tree-shakeable', async () => { - const indexCss = findAssetFile(/index-[\w-]+\.css/) - expect(indexCss).not.toContain('.tree-shake-scoped-style') -}) +// skip this test for now with rolldown-vite as this requires https://github.com/rolldown/rolldown/issues/4812 to be implemented +test.runIf(isBuild && !isRolldownVite)( + 'scoped style should be tree-shakeable', + async () => { + const indexCss = findAssetFile(/index-[\w-]+\.css/) + expect(indexCss).not.toContain('.tree-shake-scoped-style') + }, +) diff --git a/vitest.config.e2e.ts b/vitest.config.e2e.ts index 35b9bdf4..fc6b5895 100644 --- a/vitest.config.e2e.ts +++ b/vitest.config.e2e.ts @@ -1,5 +1,6 @@ import { resolve } from 'node:path' -import { defineConfig } from 'vitest/config' +import { defaultExclude, defineConfig } from 'vitest/config' +import * as vite from 'vite' const timeout = process.env.CI ? 50000 : 30000 @@ -15,6 +16,11 @@ export default defineConfig({ }, test: { include: ['./playground/**/*.spec.[tj]s'], + exclude: [ + ...defaultExclude, + // plugin-legacy is not supported with rolldown-vite + ...('rolldownVersion' in vite ? ['./playground/vue-legacy/**/*'] : []), + ], setupFiles: ['./playground/vitestSetup.ts'], globalSetup: ['./playground/vitestGlobalSetup.ts'], testTimeout: timeout,