Skip to content

Commit 3905be6

Browse files
Fix esm compatibility for @headlessui/tailwindcss plugin package (#3051)
* Set @headlessui/tailwindcss module type The distributed tailwindcss plugin package uses `.js` for esm files, and `.cjs` for commonjs files. This corresponds to `"type": "module"` in the package.json file. One build script `fix-types.js` was a commonjs script which was breaking this module file naming pattern. Renamed the script to `fix-types.cjs` so that we could then standardise the module type for @headlessui/tailwindcss package as a whole. * Fix esm import of tailwindcss/plugin ESM imports need to specify the filename extension when importing individual files. * update changelog --------- Co-authored-by: Robin Malfait <[email protected]>
1 parent 3070ad9 commit 3905be6

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

packages/@headlessui-tailwindcss/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Fixed
1111

12-
- Fix ESM types ([#2880](https://github.com/tailwindlabs/headlessui/pull/2880))
12+
- Improve CJS types ([#2880](https://github.com/tailwindlabs/headlessui/pull/2880))
13+
- Improve ESM types ([#3051](https://github.com/tailwindlabs/headlessui/pull/3051))
1314

1415
## [0.2.0] - 2023-07-27
1516

packages/@headlessui-tailwindcss/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"main": "dist/index.cjs",
66
"types": "dist/index.d.ts",
77
"module": "dist/headlessui.esm.js",
8+
"type": "module",
89
"license": "MIT",
910
"files": [
1011
"README.md",
@@ -32,7 +33,7 @@
3233
},
3334
"scripts": {
3435
"prepublishOnly": "npm run build",
35-
"build": "../../scripts/build.sh --external:tailwindcss && node ./scripts/fix-types.js",
36+
"build": "../../scripts/build.sh --external:tailwindcss && node ./scripts/fix-types.cjs",
3637
"watch": "../../scripts/watch.sh --external:tailwindcss",
3738
"test": "../../scripts/test.sh",
3839
"lint": "../../scripts/lint.sh",
File renamed without changes.

packages/@headlessui-tailwindcss/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import plugin from 'tailwindcss/plugin'
1+
import plugin from 'tailwindcss/plugin.js'
22

33
interface Options {
44
/**

0 commit comments

Comments
 (0)