This commit is contained in:
Alex 2024-04-06 15:28:43 -04:00
parent dbfdf67983
commit 1109ff0dea
7 changed files with 256 additions and 146 deletions

View File

@ -1,10 +1,11 @@
{
"name": "@aet/babel-tailwind",
"version": "0.0.1-beta.2",
"version": "0.0.1-beta.3",
"main": "dist/index.js",
"license": "MIT",
"private": true,
"scripts": {
"build": "tsup --dts",
"build": "./scripts/index.ts",
"test": "vitest"
},
"files": [
@ -13,22 +14,23 @@
"devDependencies": {
"@aet/eslint-rules": "^0.0.19",
"@types/babel__core": "^7.20.5",
"@types/bun": "^1.0.12",
"@types/lodash": "^4.17.0",
"@types/node": "^20.12.2",
"@types/node": "^20.12.5",
"esbuild": "^0.20.2",
"esbuild-register": "^3.5.0",
"prettier": "^3.2.5",
"tailwindcss": "^3.4.3",
"tsup": "^8.0.2",
"typescript": "^5.4.3",
"vite": "^5.2.7",
"typescript": "^5.4.4",
"vite": "^5.2.8",
"vitest": "^1.4.0"
},
"peerDependencies": {
"tailwindcss": "^3.4.3"
},
"dependencies": {
"@babel/core": "^7.24.3",
"@babel/core": "^7.24.4",
"@emotion/hash": "^0.9.1",
"lodash": "^4.17.21",
"postcss": "^8.4.38"

175
pnpm-lock.yaml generated
View File

@ -6,8 +6,8 @@ settings:
dependencies:
'@babel/core':
specifier: ^7.24.3
version: 7.24.3
specifier: ^7.24.4
version: 7.24.4
'@emotion/hash':
specifier: ^0.9.1
version: 0.9.1
@ -21,16 +21,19 @@ dependencies:
devDependencies:
'@aet/eslint-rules':
specifier: ^0.0.19
version: 0.0.19(eslint@8.57.0)(typescript@5.4.3)
version: 0.0.19(eslint@8.57.0)(typescript@5.4.4)
'@types/babel__core':
specifier: ^7.20.5
version: 7.20.5
'@types/bun':
specifier: ^1.0.12
version: 1.0.12
'@types/lodash':
specifier: ^4.17.0
version: 4.17.0
'@types/node':
specifier: ^20.12.2
version: 20.12.2
specifier: ^20.12.5
version: 20.12.5
esbuild:
specifier: ^0.20.2
version: 0.20.2
@ -45,16 +48,16 @@ devDependencies:
version: 3.4.3
tsup:
specifier: ^8.0.2
version: 8.0.2(postcss@8.4.38)(typescript@5.4.3)
version: 8.0.2(postcss@8.4.38)(typescript@5.4.4)
typescript:
specifier: ^5.4.3
version: 5.4.3
specifier: ^5.4.4
version: 5.4.4
vite:
specifier: ^5.2.7
version: 5.2.7(@types/node@20.12.2)
specifier: ^5.2.8
version: 5.2.8(@types/node@20.12.5)
vitest:
specifier: ^1.4.0
version: 1.4.0(@types/node@20.12.2)
version: 1.4.0(@types/node@20.12.5)
packages:
@ -63,7 +66,7 @@ packages:
engines: {node: '>=0.10.0'}
dev: true
/@aet/eslint-rules@0.0.19(eslint@8.57.0)(typescript@5.4.3):
/@aet/eslint-rules@0.0.19(eslint@8.57.0)(typescript@5.4.4):
resolution: {integrity: sha512-RO9JBZcdY2HVvWPvqlob2yNwszXwOPUL81uXCg3IrjDi7Ka48zWsfEyMpF/w/3jNgwhYxDBLTJAhHABuJ2LtXQ==}
peerDependencies:
eslint: ^8.53.0
@ -71,10 +74,10 @@ packages:
dependencies:
'@eslint-community/eslint-utils': 4.4.0(eslint@8.57.0)
'@types/eslint': 8.56.6
'@typescript-eslint/eslint-plugin': 7.4.0(@typescript-eslint/parser@7.4.0)(eslint@8.57.0)(typescript@5.4.3)
'@typescript-eslint/parser': 7.4.0(eslint@8.57.0)(typescript@5.4.3)
'@typescript-eslint/type-utils': 7.4.0(eslint@8.57.0)(typescript@5.4.3)
'@typescript-eslint/utils': 7.4.0(eslint@8.57.0)(typescript@5.4.3)
'@typescript-eslint/eslint-plugin': 7.4.0(@typescript-eslint/parser@7.4.0)(eslint@8.57.0)(typescript@5.4.4)
'@typescript-eslint/parser': 7.4.0(eslint@8.57.0)(typescript@5.4.4)
'@typescript-eslint/type-utils': 7.4.0(eslint@8.57.0)(typescript@5.4.4)
'@typescript-eslint/utils': 7.4.0(eslint@8.57.0)(typescript@5.4.4)
aria-query: 5.3.0
axe-core: 4.9.0
axobject-query: 4.0.0
@ -103,7 +106,7 @@ packages:
resolve: 2.0.0-next.5
semver: 7.6.0
tsconfig-paths: 4.2.0
typescript: 5.4.3
typescript: 5.4.4
transitivePeerDependencies:
- eslint-import-resolver-typescript
- eslint-import-resolver-webpack
@ -135,17 +138,17 @@ packages:
engines: {node: '>=6.9.0'}
dev: false
/@babel/core@7.24.3:
resolution: {integrity: sha512-5FcvN1JHw2sHJChotgx8Ek0lyuh4kCKelgMTTqhYJJtloNvUfpAFMeNQUtdlIaktwrSV9LtCdqwk48wL2wBacQ==}
/@babel/core@7.24.4:
resolution: {integrity: sha512-MBVlMXP+kkl5394RBLSxxk/iLTeVGuXTV3cIDXavPpMMqnSnt6apKgan/U8O3USWZCWZT/TbgfEpKa4uMgN4Dg==}
engines: {node: '>=6.9.0'}
dependencies:
'@ampproject/remapping': 2.3.0
'@babel/code-frame': 7.24.2
'@babel/generator': 7.24.1
'@babel/generator': 7.24.4
'@babel/helper-compilation-targets': 7.23.6
'@babel/helper-module-transforms': 7.23.3(@babel/core@7.24.3)
'@babel/helpers': 7.24.1
'@babel/parser': 7.24.1
'@babel/helper-module-transforms': 7.23.3(@babel/core@7.24.4)
'@babel/helpers': 7.24.4
'@babel/parser': 7.24.4
'@babel/template': 7.24.0
'@babel/traverse': 7.24.1
'@babel/types': 7.24.0
@ -158,8 +161,8 @@ packages:
- supports-color
dev: false
/@babel/generator@7.24.1:
resolution: {integrity: sha512-DfCRfZsBcrPEHUfuBMgbJ1Ut01Y/itOs+hY2nFLgqsqXd52/iSiVq5TITtUasIUgm+IIKdY2/1I7auiQOEeC9A==}
/@babel/generator@7.24.4:
resolution: {integrity: sha512-Xd6+v6SnjWVx/nus+y0l1sxMOTOMBkyL4+BIdbALyatQnAe/SRVjANeDPSCYaX+i1iJmuGSKf3Z+E+V/va1Hvw==}
engines: {node: '>=6.9.0'}
dependencies:
'@babel/types': 7.24.0
@ -206,13 +209,13 @@ packages:
'@babel/types': 7.24.0
dev: false
/@babel/helper-module-transforms@7.23.3(@babel/core@7.24.3):
/@babel/helper-module-transforms@7.23.3(@babel/core@7.24.4):
resolution: {integrity: sha512-7bBs4ED9OmswdfDzpz4MpWgSrV7FXlc3zIagvLFjS5H+Mk7Snr21vQ6QwrsoCGMfNC4e4LQPdoULEt4ykz0SRQ==}
engines: {node: '>=6.9.0'}
peerDependencies:
'@babel/core': ^7.0.0
dependencies:
'@babel/core': 7.24.3
'@babel/core': 7.24.4
'@babel/helper-environment-visitor': 7.22.20
'@babel/helper-module-imports': 7.24.3
'@babel/helper-simple-access': 7.22.5
@ -247,8 +250,8 @@ packages:
engines: {node: '>=6.9.0'}
dev: false
/@babel/helpers@7.24.1:
resolution: {integrity: sha512-BpU09QqEe6ZCHuIHFphEFgvNSrubve1FtyMton26ekZ85gRGi6LrTF7zArARp2YvyFxloeiRmtSCq5sjh1WqIg==}
/@babel/helpers@7.24.4:
resolution: {integrity: sha512-FewdlZbSiwaVGlgT1DPANDuCHaDMiOo+D/IDYRFYjHOuv66xMSJ7fQwwODwRNAPkADIO/z1EoF/l2BCWlWABDw==}
engines: {node: '>=6.9.0'}
dependencies:
'@babel/template': 7.24.0
@ -273,13 +276,22 @@ packages:
hasBin: true
dependencies:
'@babel/types': 7.24.0
dev: true
/@babel/parser@7.24.4:
resolution: {integrity: sha512-zTvEBcghmeBma9QIGunWevvBAp4/Qu9Bdq+2k0Ot4fVMD6v3dsC9WOcRSKk7tRRyBM/53yKMJko9xOatGQAwSg==}
engines: {node: '>=6.0.0'}
hasBin: true
dependencies:
'@babel/types': 7.24.0
dev: false
/@babel/template@7.24.0:
resolution: {integrity: sha512-Bkf2q8lMB0AFpX0NFEqSbx1OkTHf0f+0j82mkw+ZpzBnkk7e9Ql0891vlfgi+kHwOk8tQjiQHpqh4LaSa0fKEA==}
engines: {node: '>=6.9.0'}
dependencies:
'@babel/code-frame': 7.24.2
'@babel/parser': 7.24.1
'@babel/parser': 7.24.4
'@babel/types': 7.24.0
dev: false
@ -288,12 +300,12 @@ packages:
engines: {node: '>=6.9.0'}
dependencies:
'@babel/code-frame': 7.24.2
'@babel/generator': 7.24.1
'@babel/generator': 7.24.4
'@babel/helper-environment-visitor': 7.22.20
'@babel/helper-function-name': 7.23.0
'@babel/helper-hoist-variables': 7.22.5
'@babel/helper-split-export-declaration': 7.22.6
'@babel/parser': 7.24.1
'@babel/parser': 7.24.4
'@babel/types': 7.24.0
debug: 4.3.4
globals: 11.12.0
@ -1018,6 +1030,12 @@ packages:
'@babel/types': 7.24.0
dev: true
/@types/bun@1.0.12:
resolution: {integrity: sha512-qPb5FcygbpSS1NDBjWyQCWeI9kKXwSYSR1Enu7yb+gMXgFwGMhlyOvgV/7FGrdvAjlSXWRY6IDepos7k8WzAtQ==}
dependencies:
bun-types: 1.0.36
dev: true
/@types/eslint@8.56.6:
resolution: {integrity: sha512-ymwc+qb1XkjT/gfoQwxIeHZ6ixH23A+tCT2ADSA/DPVKzAjwYkTXBMCQ/f6fe4wEa85Lhp26VPeUxI7wMhAi7A==}
dependencies:
@ -1037,8 +1055,14 @@ packages:
resolution: {integrity: sha512-t7dhREVv6dbNj0q17X12j7yDG4bD/DHYX7o5/DbDxobP0HnGPgpRz2Ej77aL7TZT3DSw13fqUTj8J4mMnqa7WA==}
dev: true
/@types/node@20.12.2:
resolution: {integrity: sha512-zQ0NYO87hyN6Xrclcqp7f8ZbXNbRfoGWNcMvHTPQp9UUrwI0mI7XBz+cu7/W6/VClYo2g63B0cjull/srU7LgQ==}
/@types/node@20.11.30:
resolution: {integrity: sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw==}
dependencies:
undici-types: 5.26.5
dev: true
/@types/node@20.12.5:
resolution: {integrity: sha512-BD+BjQ9LS/D8ST9p5uqBxghlN+S42iuNxjsUGjeZobe/ciXzk2qb1B6IXc6AnRLS+yFJRpN2IPEHMzwspfDJNw==}
dependencies:
undici-types: 5.26.5
dev: true
@ -1051,7 +1075,13 @@ packages:
resolution: {integrity: sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==}
dev: true
/@typescript-eslint/eslint-plugin@7.4.0(@typescript-eslint/parser@7.4.0)(eslint@8.57.0)(typescript@5.4.3):
/@types/ws@8.5.10:
resolution: {integrity: sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A==}
dependencies:
'@types/node': 20.12.5
dev: true
/@typescript-eslint/eslint-plugin@7.4.0(@typescript-eslint/parser@7.4.0)(eslint@8.57.0)(typescript@5.4.4):
resolution: {integrity: sha512-yHMQ/oFaM7HZdVrVm/M2WHaNPgyuJH4WelkSVEWSSsir34kxW2kDJCxlXRhhGWEsMN0WAW/vLpKfKVcm8k+MPw==}
engines: {node: ^18.18.0 || >=20.0.0}
peerDependencies:
@ -1063,10 +1093,10 @@ packages:
optional: true
dependencies:
'@eslint-community/regexpp': 4.10.0
'@typescript-eslint/parser': 7.4.0(eslint@8.57.0)(typescript@5.4.3)
'@typescript-eslint/parser': 7.4.0(eslint@8.57.0)(typescript@5.4.4)
'@typescript-eslint/scope-manager': 7.4.0
'@typescript-eslint/type-utils': 7.4.0(eslint@8.57.0)(typescript@5.4.3)
'@typescript-eslint/utils': 7.4.0(eslint@8.57.0)(typescript@5.4.3)
'@typescript-eslint/type-utils': 7.4.0(eslint@8.57.0)(typescript@5.4.4)
'@typescript-eslint/utils': 7.4.0(eslint@8.57.0)(typescript@5.4.4)
'@typescript-eslint/visitor-keys': 7.4.0
debug: 4.3.4
eslint: 8.57.0
@ -1074,13 +1104,13 @@ packages:
ignore: 5.3.1
natural-compare: 1.4.0
semver: 7.6.0
ts-api-utils: 1.3.0(typescript@5.4.3)
typescript: 5.4.3
ts-api-utils: 1.3.0(typescript@5.4.4)
typescript: 5.4.4
transitivePeerDependencies:
- supports-color
dev: true
/@typescript-eslint/parser@7.4.0(eslint@8.57.0)(typescript@5.4.3):
/@typescript-eslint/parser@7.4.0(eslint@8.57.0)(typescript@5.4.4):
resolution: {integrity: sha512-ZvKHxHLusweEUVwrGRXXUVzFgnWhigo4JurEj0dGF1tbcGh6buL+ejDdjxOQxv6ytcY1uhun1p2sm8iWStlgLQ==}
engines: {node: ^18.18.0 || >=20.0.0}
peerDependencies:
@ -1092,11 +1122,11 @@ packages:
dependencies:
'@typescript-eslint/scope-manager': 7.4.0
'@typescript-eslint/types': 7.4.0
'@typescript-eslint/typescript-estree': 7.4.0(typescript@5.4.3)
'@typescript-eslint/typescript-estree': 7.4.0(typescript@5.4.4)
'@typescript-eslint/visitor-keys': 7.4.0
debug: 4.3.4
eslint: 8.57.0
typescript: 5.4.3
typescript: 5.4.4
transitivePeerDependencies:
- supports-color
dev: true
@ -1109,7 +1139,7 @@ packages:
'@typescript-eslint/visitor-keys': 7.4.0
dev: true
/@typescript-eslint/type-utils@7.4.0(eslint@8.57.0)(typescript@5.4.3):
/@typescript-eslint/type-utils@7.4.0(eslint@8.57.0)(typescript@5.4.4):
resolution: {integrity: sha512-247ETeHgr9WTRMqHbbQdzwzhuyaJ8dPTuyuUEMANqzMRB1rj/9qFIuIXK7l0FX9i9FXbHeBQl/4uz6mYuCE7Aw==}
engines: {node: ^18.18.0 || >=20.0.0}
peerDependencies:
@ -1119,12 +1149,12 @@ packages:
typescript:
optional: true
dependencies:
'@typescript-eslint/typescript-estree': 7.4.0(typescript@5.4.3)
'@typescript-eslint/utils': 7.4.0(eslint@8.57.0)(typescript@5.4.3)
'@typescript-eslint/typescript-estree': 7.4.0(typescript@5.4.4)
'@typescript-eslint/utils': 7.4.0(eslint@8.57.0)(typescript@5.4.4)
debug: 4.3.4
eslint: 8.57.0
ts-api-utils: 1.3.0(typescript@5.4.3)
typescript: 5.4.3
ts-api-utils: 1.3.0(typescript@5.4.4)
typescript: 5.4.4
transitivePeerDependencies:
- supports-color
dev: true
@ -1134,7 +1164,7 @@ packages:
engines: {node: ^18.18.0 || >=20.0.0}
dev: true
/@typescript-eslint/typescript-estree@7.4.0(typescript@5.4.3):
/@typescript-eslint/typescript-estree@7.4.0(typescript@5.4.4):
resolution: {integrity: sha512-A99j5AYoME/UBQ1ucEbbMEmGkN7SE0BvZFreSnTd1luq7yulcHdyGamZKizU7canpGDWGJ+Q6ZA9SyQobipePg==}
engines: {node: ^18.18.0 || >=20.0.0}
peerDependencies:
@ -1150,13 +1180,13 @@ packages:
is-glob: 4.0.3
minimatch: 9.0.3
semver: 7.6.0
ts-api-utils: 1.3.0(typescript@5.4.3)
typescript: 5.4.3
ts-api-utils: 1.3.0(typescript@5.4.4)
typescript: 5.4.4
transitivePeerDependencies:
- supports-color
dev: true
/@typescript-eslint/utils@7.4.0(eslint@8.57.0)(typescript@5.4.3):
/@typescript-eslint/utils@7.4.0(eslint@8.57.0)(typescript@5.4.4):
resolution: {integrity: sha512-NQt9QLM4Tt8qrlBVY9lkMYzfYtNz8/6qwZg8pI3cMGlPnj6mOpRxxAm7BMJN9K0AiY+1BwJ5lVC650YJqYOuNg==}
engines: {node: ^18.18.0 || >=20.0.0}
peerDependencies:
@ -1167,7 +1197,7 @@ packages:
'@types/semver': 7.5.8
'@typescript-eslint/scope-manager': 7.4.0
'@typescript-eslint/types': 7.4.0
'@typescript-eslint/typescript-estree': 7.4.0(typescript@5.4.3)
'@typescript-eslint/typescript-estree': 7.4.0(typescript@5.4.4)
eslint: 8.57.0
semver: 7.6.0
transitivePeerDependencies:
@ -1382,6 +1412,13 @@ packages:
engines: {node: '>=6'}
dev: true
/bun-types@1.0.36:
resolution: {integrity: sha512-gaIb1SyhB0JZfIEg73/kSFhqolUqJXC68peguhXGwqr27HuvI8nkD0LTIHp/1DY4cNadfXHYgYrZIWX7oEoXlg==}
dependencies:
'@types/node': 20.11.30
'@types/ws': 8.5.10
dev: true
/bundle-require@4.0.2(esbuild@0.19.12):
resolution: {integrity: sha512-jwzPOChofl67PSTW2SGubV9HBQAhhR2i6nskiOThauo9dzwDUgOWQScFVaJkjEfYX+UXiD+LEx8EblQMc2wIag==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
@ -1773,7 +1810,7 @@ packages:
eslint-import-resolver-webpack:
optional: true
dependencies:
'@typescript-eslint/parser': 7.4.0(eslint@8.57.0)(typescript@5.4.3)
'@typescript-eslint/parser': 7.4.0(eslint@8.57.0)(typescript@5.4.4)
debug: 3.2.7
eslint: 8.57.0
eslint-import-resolver-node: 0.3.9
@ -3275,13 +3312,13 @@ packages:
hasBin: true
dev: true
/ts-api-utils@1.3.0(typescript@5.4.3):
/ts-api-utils@1.3.0(typescript@5.4.4):
resolution: {integrity: sha512-UQMIo7pb8WRomKR1/+MFVLTroIvDVtMX3K6OUir8ynLyzB8Jeriont2bTAtmNPa1ekAgN7YPDyf6V+ygrdU+eQ==}
engines: {node: '>=16'}
peerDependencies:
typescript: '>=4.2.0'
dependencies:
typescript: 5.4.3
typescript: 5.4.4
dev: true
/ts-interface-checker@0.1.13:
@ -3297,7 +3334,7 @@ packages:
strip-bom: 3.0.0
dev: true
/tsup@8.0.2(postcss@8.4.38)(typescript@5.4.3):
/tsup@8.0.2(postcss@8.4.38)(typescript@5.4.4):
resolution: {integrity: sha512-NY8xtQXdH7hDUAZwcQdY/Vzlw9johQsaqf7iwZ6g1DOUlFYQ5/AtVAjTvihhEyeRlGo4dLRVHtrRaL35M1daqQ==}
engines: {node: '>=18'}
hasBin: true
@ -3331,7 +3368,7 @@ packages:
source-map: 0.8.0-beta.0
sucrase: 3.35.0
tree-kill: 1.2.2
typescript: 5.4.3
typescript: 5.4.4
transitivePeerDependencies:
- supports-color
- ts-node
@ -3364,8 +3401,8 @@ packages:
engines: {node: '>=8'}
dev: true
/typescript@5.4.3:
resolution: {integrity: sha512-KrPd3PKaCLr78MalgiwJnA25Nm8HAmdwN3mYUYZgG/wizIo9EainNVQI9/yDavtVFRN2h3k8uf3GLHuhDMgEHg==}
/typescript@5.4.4:
resolution: {integrity: sha512-dGE2Vv8cpVvw28v8HCPqyb08EzbBURxDpuhJvTrusShUfGnhHBafDsLdS1EhhxyL6BJQE+2cT3dDPAv+MQ6oLw==}
engines: {node: '>=14.17'}
hasBin: true
dev: true
@ -3405,7 +3442,7 @@ packages:
spdx-expression-parse: 3.0.1
dev: true
/vite-node@1.4.0(@types/node@20.12.2):
/vite-node@1.4.0(@types/node@20.12.5):
resolution: {integrity: sha512-VZDAseqjrHgNd4Kh8icYHWzTKSCZMhia7GyHfhtzLW33fZlG9SwsB6CEhgyVOWkJfJ2pFLrp/Gj1FSfAiqH9Lw==}
engines: {node: ^18.0.0 || >=20.0.0}
hasBin: true
@ -3414,7 +3451,7 @@ packages:
debug: 4.3.4
pathe: 1.1.2
picocolors: 1.0.0
vite: 5.2.7(@types/node@20.12.2)
vite: 5.2.8(@types/node@20.12.5)
transitivePeerDependencies:
- '@types/node'
- less
@ -3426,8 +3463,8 @@ packages:
- terser
dev: true
/vite@5.2.7(@types/node@20.12.2):
resolution: {integrity: sha512-k14PWOKLI6pMaSzAuGtT+Cf0YmIx12z9YGon39onaJNy8DLBfBJrzg9FQEmkAM5lpHBZs9wksWAsyF/HkpEwJA==}
/vite@5.2.8(@types/node@20.12.5):
resolution: {integrity: sha512-OyZR+c1CE8yeHw5V5t59aXsUPPVTHMDjEZz8MgguLL/Q7NblxhZUlTu9xSPqlsUO/y+X7dlU05jdhvyycD55DA==}
engines: {node: ^18.0.0 || >=20.0.0}
hasBin: true
peerDependencies:
@ -3454,7 +3491,7 @@ packages:
terser:
optional: true
dependencies:
'@types/node': 20.12.2
'@types/node': 20.12.5
esbuild: 0.20.2
postcss: 8.4.38
rollup: 4.13.2
@ -3462,7 +3499,7 @@ packages:
fsevents: 2.3.3
dev: true
/vitest@1.4.0(@types/node@20.12.2):
/vitest@1.4.0(@types/node@20.12.5):
resolution: {integrity: sha512-gujzn0g7fmwf83/WzrDTnncZt2UiXP41mHuFYFrdwaLRVQ6JYQEiME2IfEjU3vcFL3VKa75XhI3lFgn+hfVsQw==}
engines: {node: ^18.0.0 || >=20.0.0}
hasBin: true
@ -3487,7 +3524,7 @@ packages:
jsdom:
optional: true
dependencies:
'@types/node': 20.12.2
'@types/node': 20.12.5
'@vitest/expect': 1.4.0
'@vitest/runner': 1.4.0
'@vitest/snapshot': 1.4.0
@ -3505,8 +3542,8 @@ packages:
strip-literal: 2.1.0
tinybench: 2.6.0
tinypool: 0.8.3
vite: 5.2.7(@types/node@20.12.2)
vite-node: 1.4.0(@types/node@20.12.2)
vite: 5.2.8(@types/node@20.12.5)
vite-node: 1.4.0(@types/node@20.12.5)
why-is-node-running: 2.2.2
transitivePeerDependencies:
- less

21
scripts/index.ts Executable file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env bun
import { type Options, build } from "tsup";
import tsupConfig from "../tsup.config";
import { pick } from "lodash";
import pkg from "../package.json" with { type: "json" };
await build(tsupConfig as Options);
await Bun.write(
"dist/package.json",
JSON.stringify(
pick(pkg, ["name", "version", "license", "dependencies", "author"]),
null,
2
)
);
await Bun.write(
`dist/base.d.ts`,
`/**\n * \`@tailwind base\` component.\n */\nexport {};`
);
process.exit(0);

View File

@ -1,15 +1,14 @@
import { promises as fs } from "node:fs";
import { resolve } from "node:path";
import { build } from "esbuild";
import { build, transformSync } from "esbuild";
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { OutputChunk, rollup } from "rollup";
import rollupBabel from "@rollup/plugin-babel";
import rollupCSS from "rollup-plugin-css-only";
import { name } from "../package.json" with { type: "json" };
import {
type TailwindPluginOptions,
babelPlugin,
getClassName,
getTailwindPlugins,
createPostCSS,
} from "./index";
const folder = resolve(import.meta.dirname, "temp");
@ -73,4 +72,30 @@ describe("babel-tailwind", () => {
expect(js.text).toContain(`className: "${clsName}"`);
expect(css.text).toMatch(`.${clsName} {\n text-align: center;\n}`);
});
const minCSS = (text: string) =>
transformSync(text, { minify: true, loader: "css" })!.code;
it("supports importing tailwind/base", async () => {
const postcss = createPostCSS({ tailwindConfig: {} });
const base = (await postcss("@tailwind base;")).css;
const outputFiles = await compileESBuild(
{
tailwindConfig: {},
clsx: "emotion",
},
/* tsx */ `
import "${name}/base";
`
);
expect(outputFiles).toHaveLength(2);
const js = outputFiles.find(file => file.path.endsWith(".js"))!;
const css = outputFiles.find(file => file.path.endsWith(".css"))!;
// expect(js.text).toContain(`import "./base.css";`);
expect(js.text).toBe("");
expect(minCSS(css.text)).toContain(minCSS(base));
});
});

View File

@ -13,6 +13,10 @@ const PLUGIN_NAME = "tailwind";
const ESBUILD_NAMESPACE = "babel-tailwind";
const ROLLUP_PREFIX = "\0tailwind:";
const { name } = [require][0](
process.env.BABEL_TAILWIND_BUILD ? "./package.json" : "../package.json"
);
const definePlugin =
<T>(fn: (runtime: typeof babel) => babel.Visitor<babel.PluginPass & T>) =>
(runtime: typeof babel) => {
@ -34,12 +38,25 @@ function matchPath(
fn?.(nodePath);
}
/**
* Tagged template macro function for Tailwind classes
* @example "tw" => tw`p-2 text-center`
*/
export type TaggedTailwindFunction = (strings: TemplateStringsArray) => string;
const tailwindDirectives = ["components", "utilities", "variants"] as const;
export interface TailwindPluginOptions {
/**
* Tailwind CSS configuration
*/
tailwindConfig: Omit<Config, "content">;
/**
* Directives to prefix to all Tailwind stylesheets
*/
directives?: (typeof tailwindDirectives)[number][] | "all";
/**
* Additional PostCSS plugins (optional)
*/
@ -51,6 +68,15 @@ export interface TailwindPluginOptions {
*/
jsxAttributeName?: string;
/**
* Tagged template macro function to use for Tailwind classes
* @default "tw"
* @example
* declare const tw: TaggedTailwindFunction;
* "tw" => tw`p-2 text-center`
*/
taggedTemplateName?: string;
/**
* The prefix to use for the generated class names.
* @default className => `tw-${hash(className)}`
@ -71,50 +97,51 @@ type GetClassName = (className: string) => string;
*/
export const getClassName: GetClassName = cls => "tw-" + hash(cls);
const babelTailwind = (
interface BabelPluginState {
getCx: () => t.Identifier;
tailwindMap: Map<string, string>;
}
function babelTailwind(
styleMap: Map<string, string>,
{
clsx,
getClassName: getClass = getClassName,
taggedTemplateName,
jsxAttributeName = "css",
}: TailwindPluginOptions
) =>
definePlugin<{
getCx: () => t.Identifier;
tailwindMap: Map<string, string>;
}>(({ types: t }) => ({
) {
function getClsxImport(t: typeof babel.types, cx: t.Identifier) {
switch (clsx) {
case "emotion":
return t.importDeclaration(
[t.importSpecifier(cx, t.identifier("cx"))],
t.stringLiteral("@emotion/css")
);
case "clsx":
return t.importDeclaration(
[t.importDefaultSpecifier(cx)],
t.stringLiteral("clsx")
);
case "classnames":
return t.importDeclaration(
[t.importDefaultSpecifier(cx)],
t.stringLiteral("classnames")
);
default:
throw new Error("Unknown clsx library");
}
}
return definePlugin<BabelPluginState>(({ types: t }) => ({
Program: {
enter(path, state) {
let cx: t.Identifier;
state.tailwindMap = new Map();
function getClsxImport() {
switch (clsx) {
case "emotion":
return t.importDeclaration(
[t.importSpecifier(cx, t.identifier("cx"))],
t.stringLiteral("@emotion/css")
);
case "clsx":
return t.importDeclaration(
[t.importDefaultSpecifier(cx)],
t.stringLiteral("clsx")
);
case "classnames":
return t.importDeclaration(
[t.importDefaultSpecifier(cx)],
t.stringLiteral("classnames")
);
default:
throw new Error("Unknown clsx library");
}
}
state.getCx = () => {
if (cx == null) {
cx = path.scope.generateUidIdentifier("cx");
path.node.body.unshift(getClsxImport());
path.node.body.unshift(getClsxImport(t, cx));
}
return t.cloneNode(cx);
};
@ -140,14 +167,16 @@ const babelTailwind = (
},
TaggedTemplateExpression(path, { tailwindMap }) {
if (taggedTemplateName == null) return;
const {
tag,
quasi: { quasis, expressions },
} = path.node;
if (!t.isIdentifier(tag, { name: "tw" })) return;
if (!t.isIdentifier(tag, { name: taggedTemplateName })) return;
if (expressions.length) {
throw new Error("tw`` should not contain expressions");
throw new Error(`${taggedTemplateName}\`\` should not contain expressions`);
}
const value = quasis[0].value.cooked;
@ -220,6 +249,7 @@ const babelTailwind = (
path.remove();
},
}));
}
/**
* An esbuild plugin that processes files with Babel if `getPlugins` returns any plugins.
@ -264,7 +294,12 @@ export const babelPlugin = ({
type Compile = ReturnType<typeof createPostCSS>;
function createPostCSS({ tailwindConfig, postCSSPlugins = [] }: TailwindPluginOptions) {
/** @internal */
export function createPostCSS({
tailwindConfig,
postCSSPlugins = [],
directives,
}: Pick<TailwindPluginOptions, "tailwindConfig" | "postCSSPlugins" | "directives">) {
const post = postcss([
tailwind({
...tailwindConfig,
@ -272,7 +307,11 @@ function createPostCSS({ tailwindConfig, postCSSPlugins = [] }: TailwindPluginOp
}),
...postCSSPlugins,
]);
return (css: string) => post.process(css, { from: undefined });
const appliedDirectives = directives === "all" ? tailwindDirectives : directives;
const directiveTexts = appliedDirectives?.map(d => `@tailwind ${d};\n`).join("") ?? "";
return (css: string) => post.process(directiveTexts + css, { from: undefined });
}
const esbuildPlugin = (
@ -292,7 +331,19 @@ const esbuildPlugin = (
}
});
build.onResolve({ filter: RegExp(`^${name}/base$`) }, () => ({
path: "directive:babel",
namespace: ESBUILD_NAMESPACE,
}));
build.onLoad({ filter: /.*/, namespace: ESBUILD_NAMESPACE }, async ({ path }) => {
if (path === "directive:babel") {
return {
contents: (await compile(`@tailwind base;`)).css!,
loader: "css",
};
}
if (!styleMap.has(path)) return;
const result = await compile(styleMap.get(path)!);

32
src/modules.d.ts vendored
View File

@ -1,32 +0,0 @@
declare module "rollup-plugin-css-only" {
import { OutputBundle, Plugin } from "rollup";
namespace css {
interface Options {
/**
* All CSS files will be parsed by default, but you can also specifically include files
*/
include?: ReadonlyArray<string | RegExp> | string | RegExp | null;
/**
* CSS files to exclude from being parsed
*/
exclude?: ReadonlyArray<string | RegExp> | string | RegExp | null;
/**
* Callback that will be called ongenerate
*/
output?:
| boolean
| string
| ((
styles: string,
styleNodes: Record<string, string>,
bundle: OutputBundle
) => void)
| null
| undefined;
}
}
function css(options?: css.Options): Plugin;
export = css;
}

View File

@ -6,6 +6,12 @@ export default defineConfig({
splitting: false,
sourcemap: false,
clean: true,
dts: true,
treeshake: true,
platform: "node",
define: {
"process.env.BABEL_TAILWIND_BUILD": "true",
},
esbuildOptions(options) {
options.banner = {
...options.banner,