tailwindcss/packages
Truffle 522288ca08
Serve ESM type declarations to ESM importers of @tailwindcss/postcss (#20228)
## Summary

Fixes #20219.

The `@tailwindcss/postcss` exports map serves the CJS-shaped
`dist/index.d.ts` (`export = _default`) for both the `import` and
`require` conditions, while the correct ESM declaration file
`dist/index.d.mts` (`export { _default as default }`) is built and
published but never referenced. Type checkers that treat the import
condition as ESM reject the default import with TS1192 — concretely,
`deno check` on Deno 2.8.3+ (which ships TypeScript 6.0) fails on
`import tailwindcss from "@tailwindcss/postcss"`.

This splits the export entry into per-condition `types` blocks so ESM
importers resolve `index.d.mts` and CJS consumers keep `index.d.ts` —
the same shape `@tailwindcss/vite` already uses (`"types":
"./dist/index.d.mts"`).

Two notes on the issue as filed:

- Stock `tsc` with NodeNext does **not** reproduce the error
(declaration file format follows the file extension and package `type`,
not the matched condition), so I didn't take the suggested `export =` →
`export default` change in `index.d.ts` — that would break CJS
consumers, and the correct ESM declarations already ship.
- `@tailwindcss/node` has the same single-`types` exports shape; happy
to follow up there if you want parity.

## Test plan

Against `@tailwindcss/postcss@4.3.0` with the published exports map,
then again with only this `package.json` change applied to the installed
package:

```sh
# Deno 2.8.3 (TypeScript 6.0), nodeModulesDir: auto
deno check main.ts   # before: TS1192 "Module ... index.d.ts has no default export" — after: passes
```

```sh
# typescript@6.0.0-dev (NodeNext), one ESM importer + one .cts require importer
tsc --noEmit         # passes both before and after (no regression for npm consumers)
```

`@arethetypeswrong/cli`:

| | published 4.3.0 | with this change |
|---|---|---|
| node16 (from ESM) | 🎭 Masquerading as CJS | 🟢 (ESM) |
| node16 (from CJS) | 🟢 (CJS) | 🟢 (CJS) |
| bundler | 🟢 | 🟢 |
2026-06-12 14:33:16 +00:00
..
@tailwindcss-browser Bump dependencies (#20095) 2026-05-21 17:58:55 +02:00
@tailwindcss-cli Ignore the standalone CLI (#20139) 2026-06-02 12:49:53 +02:00
@tailwindcss-node duration must be at least 500ms 2026-05-26 23:34:51 +02:00
@tailwindcss-postcss Serve ESM type declarations to ESM importers of @tailwindcss/postcss (#20228) 2026-06-12 14:33:16 +00:00
@tailwindcss-standalone Bump dependencies (#20095) 2026-05-21 17:58:55 +02:00
@tailwindcss-upgrade Do not crash when migrating empty classes (#20205) 2026-06-07 21:50:35 +02:00
@tailwindcss-vite Fix 'Sourcemap is likely to be incorrect' warnings when using @tailwindcss/vite (#20103) 2026-05-22 17:57:25 +02:00
@tailwindcss-webpack Add Rspack optional peer dependency for @tailwindcss/webpack (#20027) 2026-05-23 11:14:48 +02:00
internal-example-plugin Prefix internal modules with internal-* (#14074) 2024-07-29 10:58:07 -04:00
tailwindcss Fix canonicalization bug where we end up with a high precision number (#20221) 2026-06-12 00:23:11 +02:00
tsconfig.base.json Improve debug logs (#15303) 2024-12-11 15:27:20 +01:00