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 <malfait.robin@gmail.com>
This commit is contained in:
Janeene Beeforth
2024-05-30 00:17:06 +10:00
committed by GitHub
parent 3070ad9d99
commit 3905be67a9
4 changed files with 5 additions and 3 deletions
@@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Fix ESM types ([#2880](https://github.com/tailwindlabs/headlessui/pull/2880))
- Improve CJS types ([#2880](https://github.com/tailwindlabs/headlessui/pull/2880))
- Improve ESM types ([#3051](https://github.com/tailwindlabs/headlessui/pull/3051))
## [0.2.0] - 2023-07-27
@@ -5,6 +5,7 @@
"main": "dist/index.cjs",
"types": "dist/index.d.ts",
"module": "dist/headlessui.esm.js",
"type": "module",
"license": "MIT",
"files": [
"README.md",
@@ -32,7 +33,7 @@
},
"scripts": {
"prepublishOnly": "npm run build",
"build": "../../scripts/build.sh --external:tailwindcss && node ./scripts/fix-types.js",
"build": "../../scripts/build.sh --external:tailwindcss && node ./scripts/fix-types.cjs",
"watch": "../../scripts/watch.sh --external:tailwindcss",
"test": "../../scripts/test.sh",
"lint": "../../scripts/lint.sh",
@@ -1,4 +1,4 @@
import plugin from 'tailwindcss/plugin'
import plugin from 'tailwindcss/plugin.js'
interface Options {
/**