Skip to content

Commit 0e05c6a

Browse files
committed
test: skip when not supporting ESM
1 parent 7d0e927 commit 0e05c6a

File tree

6 files changed

+43
-4
lines changed

6 files changed

+43
-4
lines changed

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@
3434
"@rsbuild/core": "^1.1.0",
3535
"@rslib/core": "^0.0.16",
3636
"@types/node": "^22.9.0",
37+
"@types/semver": "^7.5.8",
3738
"playwright": "^1.48.2",
3839
"postcss": "^8.4.47",
40+
"semver": "^7.6.3",
3941
"simple-git-hooks": "^2.11.1",
4042
"tailwindcss": "^3.4.14",
4143
"typescript": "^5.6.3"

pnpm-lock.yaml

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/basic/tailwind.config.js

-2
This file was deleted.

test/config/index.test.ts

+11
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,16 @@ import { fileURLToPath } from 'node:url';
33
import { expect, test } from '@playwright/test';
44
import { createRsbuild } from '@rsbuild/core';
55
import { pluginTailwindCSS } from '../../src';
6+
import { supportESM } from '../helper';
67

78
const __dirname = dirname(fileURLToPath(import.meta.url));
89

910
test('should build with relative config', async ({ page }) => {
11+
test.skip(
12+
!supportESM(),
13+
'Skip since the tailwindcss version does not support ESM configuration',
14+
);
15+
1016
const rsbuild = await createRsbuild({
1117
cwd: __dirname,
1218
rsbuildConfig: {
@@ -39,6 +45,11 @@ test('should build with relative config', async ({ page }) => {
3945
});
4046

4147
test('should build with absolute config', async ({ page }) => {
48+
test.skip(
49+
!supportESM(),
50+
'Skip since the tailwindcss version does not support ESM configuration',
51+
);
52+
4253
const rsbuild = await createRsbuild({
4354
cwd: __dirname,
4455
rsbuildConfig: {

test/helper.ts

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import satisfies from 'semver/functions/satisfies.js';
2+
import pkg from 'tailwindcss/package.json' with { type: 'json' };
3+
14
const portMap = new Map();
25

36
export function getRandomPort(
@@ -12,3 +15,12 @@ export function getRandomPort(
1215
port++;
1316
}
1417
}
18+
19+
export function supportESM(): boolean {
20+
// Tailwind CSS support using ESM configuration in v3.3.0
21+
// See:
22+
// - https://github.com/tailwindlabs/tailwindcss/releases/tag/v3.3.0
23+
// - https://github.com/tailwindlabs/tailwindcss/pull/10785
24+
// - https://github.com/rspack-contrib/rsbuild-plugin-tailwindcss/issues/18
25+
return satisfies(pkg.version, '^3.3.0');
26+
}

test/multi-entries/tailwind.config.js

-2
This file was deleted.

0 commit comments

Comments
 (0)