Serve ESM type declarations to ESM importers of @tailwindcss/postcss#20228
Conversation
The exports map served the CJS-shaped `dist/index.d.ts` (`export =`) for both the `import` and `require` conditions, while the correct ESM declaration file `dist/index.d.mts` was built and published but never referenced. Type checkers that treat the import condition as ESM (TypeScript 6.0 via `deno check` in Deno 2.8.3+) reject the default import with TS1192. Split the export entry into per-condition blocks so ESM importers get `index.d.mts` and CJS consumers keep `index.d.ts`, mirroring the shape `@tailwindcss/vite` already uses. Fixes tailwindlabs#20219
Confidence Score: 5/5Safe to merge — the exports map change is minimal, exactly parallels how other packages in this repo are structured, and both generated declaration files already exist in the published artifact. Both No files require special attention. The single Reviews (1): Last reviewed commit: "Add changelog entry" | Re-trigger Greptile |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
WalkthroughThis PR updates the export map in the 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Fixes #20219.
The
@tailwindcss/postcssexports map serves the CJS-shapeddist/index.d.ts(export = _default) for both theimportandrequireconditions, while the correct ESM declaration filedist/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 checkon Deno 2.8.3+ (which ships TypeScript 6.0) fails onimport tailwindcss from "@tailwindcss/postcss".This splits the export entry into per-condition
typesblocks so ESM importers resolveindex.d.mtsand CJS consumers keepindex.d.ts— the same shape@tailwindcss/vitealready uses ("types": "./dist/index.d.mts").Two notes on the issue as filed:
tscwith NodeNext does not reproduce the error (declaration file format follows the file extension and packagetype, not the matched condition), so I didn't take the suggestedexport =→export defaultchange inindex.d.ts— that would break CJS consumers, and the correct ESM declarations already ship.@tailwindcss/nodehas the same single-typesexports shape; happy to follow up there if you want parity.Test plan
Against
@tailwindcss/postcss@4.3.0with the published exports map, then again with only thispackage.jsonchange applied to the installed package:@arethetypeswrong/cli: