Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: add support for tailwindcss v4 #25

Merged
merged 39 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2c5ee15
refactor: remove tailwind imports
zcf0508 Apr 8, 2024
b212151
feat: support tailwind 4
zcf0508 Apr 8, 2024
fbd47d3
refactor: update test
zcf0508 Apr 8, 2024
4d516e2
Merge remote-tracking branch 'upstream/main'
zcf0508 Apr 9, 2024
e43fc2e
Merge branch 'feat/tailwindcss-v4' into pr/zcf0508/18
schoero Apr 30, 2024
fc31880
Merge pull request #18 from zcf0508/main
schoero Apr 30, 2024
c2f64c0
ci: inline tests
schoero Apr 30, 2024
0ba39d3
chore: change semver range
schoero Apr 30, 2024
8a78f2a
chore: remove `local-pkg`
schoero Apr 30, 2024
9387362
chore: add `fast-glob` as a dependency
schoero Apr 30, 2024
e8f29a2
refactor: add lightningcss
schoero May 2, 2024
5e2f974
refactor: use tailwindcss v3 and tailwindcss v4 simultaneously
schoero May 2, 2024
ce97bd7
chore: regenerate `package-lock.json`
schoero May 2, 2024
7c203b7
fix: cache full context/design system
schoero May 2, 2024
5daf852
fix: load tailwind config without import assertions
schoero May 2, 2024
641b3c1
chore: fix semver range
schoero May 2, 2024
2590d8c
fix: dynamically import tailwind versions
schoero May 2, 2024
f78f1cf
fix: use `import-sync` to dynamically and synchronously import tailwi…
schoero May 2, 2024
6b2593e
refactor: simplify build system (#26)
schoero May 4, 2024
e49285d
Merge branch 'refactor/next' into feat/tailwindcss-v4
schoero May 4, 2024
752fbd3
refactor: use `require` for synchronous dynamic imports
schoero May 5, 2024
a9d1b2b
fix: infinite recursion
schoero May 5, 2024
739064d
Merge branch 'main' into feat/tailwindcss-v4
schoero May 20, 2024
803a96e
style: code cleanup
schoero May 20, 2024
73e2da2
Merge branch 'main' into feat/tailwindcss-v4
schoero May 23, 2024
a0832cd
feat: resolve import statements
schoero May 24, 2024
2172647
wip: try to replace imports with custom visitor
schoero May 24, 2024
1d8deb6
Merge branch 'main' into feat/tailwindcss-v4
schoero May 28, 2024
e0ecdd5
Merge branch 'main' into feat/tailwindcss-v4
schoero May 28, 2024
3c5a7b4
Merge branch 'main' into feat/tailwindcss-v4
schoero Aug 14, 2024
5f7c806
Merge branch 'v2' into feat/tailwindcss-v4
schoero Jan 19, 2025
4d03bb9
refactor: remove `lightningcss`
schoero Jan 23, 2025
9adb607
refactor: use `synckit` to run async tasks in worker thread
schoero Jan 23, 2025
00f4045
style: eslint fixes
schoero Jan 23, 2025
81cef99
fix: caching of tailwindcss 3
schoero Jan 23, 2025
a943f34
fix: rewrite recursive config finder
schoero Jan 23, 2025
8b74109
fix: entry point option
schoero Jan 23, 2025
e5f2c56
fix: use file url on windows
schoero Jan 23, 2025
1b4008b
refactor!: drop support for node <=18
schoero Jan 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"objstr",
"OBJSTR",
"quasis",
"shadcn"
"shadcn",
"synckit"
]
}
11 changes: 7 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/setup-node@v4
with:
cache: npm
node-version: 22
node-version: 23

- name: Install dependencies
run: npm ci
Expand All @@ -40,16 +40,19 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test
- name: Run tests with tailwindcss v3
run: npm run test:v3

- name: Run tests with tailwindcss v4
run: npm run test:v4

strategy:
fail-fast: true
matrix:
node:
- 18
- 20
- 22
- 23
os:
- ubuntu-latest
- windows-latest
Expand Down
36 changes: 26 additions & 10 deletions build/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
import { writeFile } from "fs/promises";
import { $ } from "readable-tailwind:build:utils.js";
import { mkdir, writeFile } from "fs/promises";
import { transformImports } from "readable-tailwind:build:transform.js";
import { $ } from "readable-tailwind:build:utils.js";

const esmDir = "lib/esm"
const cjsDir = "lib/cjs"
async function build(){

await $`npx tsc --module preserve --project tsconfig.build.esm.json --outDir ${esmDir}`
await $`npx tsc-alias --outDir ${esmDir}`
await writeFile(`${esmDir}/package.json`, JSON.stringify({ type: "module" }), "utf-8")
const esmDir = "lib/esm"
const cjsDir = "lib/cjs"

await $`npx tsc --module commonjs --moduleResolution node --project tsconfig.build.cjs.json --verbatimModuleSyntax false --outDir ${cjsDir}`
await $`npx tsc-alias --outDir ${cjsDir}`
await writeFile(`${cjsDir}/package.json`, JSON.stringify({ type: "commonjs" }), "utf-8")
console.info("Building ESM...")
await mkdir(esmDir, { recursive: true });
await $`npx tsc --project tsconfig.build.esm.json --outDir ${esmDir}`
await $`npx tsc-alias --outDir ${esmDir}`
await writeFile(`${esmDir}/package.json`, JSON.stringify({ type: "module" }), "utf-8")
await transformImports([`${esmDir}/**/*.js`], "tailwindcss3", "tailwindcss")
await transformImports([`${esmDir}/**/*.js`], "tailwindcss4", "tailwindcss")

console.info("Building CJS...")
await mkdir(cjsDir, { recursive: true });
await $`npx tsc --project tsconfig.build.cjs.json --outDir ${cjsDir}`
await $`npx tsc-alias --outDir ${cjsDir}`
await writeFile(`${cjsDir}/package.json`, JSON.stringify({ type: "commonjs" }), "utf-8")
await transformImports([`${cjsDir}/**/*.js`], "tailwindcss3", "tailwindcss")
await transformImports([`${cjsDir}/**/*.js`], "tailwindcss4", "tailwindcss")

console.info("Build complete")

}

build().catch(console.error);
13 changes: 13 additions & 0 deletions build/transform.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { readFile, writeFile } from 'fs/promises';
import { glob } from 'glob'

export async function transformImports(globPatterns: string[], search: string, replace: string) {
const files = await glob(globPatterns);

for(const file of files) {
const content = await readFile(file, 'utf-8');
const transformed = content.replaceAll(search, replace);

await writeFile(file, transformed);
}
}
12 changes: 11 additions & 1 deletion docs/rules/sort-classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,19 @@ Enforce the order of tailwind classes. It is possible to sort classes alphabetic

<br/>

- `entryPoint`

The path to the entry file of the tailwind css config. If not specified, the plugin will fall back to the default configuration.
The tailwind config is used to determine the sorting order.

**Type**: `string`
**Default**: `undefined`

<br/>

- `tailwindConfig`

The path to the tailwind config file. If not specified, the plugin will try to find it automatically or falls back to the default configuration.
The path to the `tailwind.config.js` file. If not specified, the plugin will try to find it automatically or falls back to the default configuration.
The tailwind config is used to determine the sorting order.

**Type**: `string`
Expand Down
Loading
Loading