diff --git a/CHANGELOG.md b/CHANGELOG.md index 29652aa4d..d590b614d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Nothing yet! +### Fixed + +- Bring back type exports for the cjs build of `@tailwindcss/postcss`. ([#14256](https://github.com/tailwindlabs/tailwindcss/pull/14256)) ## [4.0.0-alpha.20] - 2024-08-23 diff --git a/packages/@tailwindcss-postcss/src/index.cts b/packages/@tailwindcss-postcss/src/index.cts new file mode 100644 index 000000000..abc7c2e25 --- /dev/null +++ b/packages/@tailwindcss-postcss/src/index.cts @@ -0,0 +1,7 @@ +import tailwindcss from './index.ts' + +// This is used instead of `export default` to work around a bug in +// `postcss-load-config` + +// @ts-ignore +export = tailwindcss diff --git a/packages/@tailwindcss-postcss/src/index.ts b/packages/@tailwindcss-postcss/src/index.ts index af1ca44b1..2e2641ada 100644 --- a/packages/@tailwindcss-postcss/src/index.ts +++ b/packages/@tailwindcss-postcss/src/index.ts @@ -29,7 +29,7 @@ class DefaultMap extends Map { } } -type PluginOptions = { +export type PluginOptions = { // The base directory to scan for class candidates. base?: string @@ -209,5 +209,4 @@ function optimizeCss( }).code.toString() } -// This is used instead of `export default` to work around a bug in `postcss-load-config` -module.exports = Object.assign(tailwindcss, { postcss: true }) as PluginCreator +export default Object.assign(tailwindcss, { postcss: true }) as PluginCreator diff --git a/packages/@tailwindcss-postcss/tsup.config.ts b/packages/@tailwindcss-postcss/tsup.config.ts index 70094ff8a..76e4fc03b 100644 --- a/packages/@tailwindcss-postcss/tsup.config.ts +++ b/packages/@tailwindcss-postcss/tsup.config.ts @@ -1,11 +1,20 @@ import { defineConfig } from 'tsup' -export default defineConfig({ - format: ['esm', 'cjs'], - clean: true, - minify: true, - cjsInterop: true, - dts: true, - entry: ['src/index.ts'], - noExternal: ['internal-postcss-fix-relative-paths'], -}) +export default defineConfig([ + { + format: ['esm'], + minify: true, + cjsInterop: true, + dts: true, + entry: ['src/index.ts'], + noExternal: ['internal-postcss-fix-relative-paths'], + }, + { + format: ['cjs'], + minify: true, + cjsInterop: true, + dts: true, + entry: ['src/index.cts'], + noExternal: ['internal-postcss-fix-relative-paths'], + }, +]) diff --git a/packages/tailwindcss/src/compat/colors.cts b/packages/tailwindcss/src/compat/colors.cts index 34d90e1e9..b903bf39b 100644 --- a/packages/tailwindcss/src/compat/colors.cts +++ b/packages/tailwindcss/src/compat/colors.cts @@ -1 +1,4 @@ -module.exports = require('./colors.ts').default +import colors from './colors.ts' + +// @ts-ignore +export = colors diff --git a/packages/tailwindcss/src/compat/default-theme.cts b/packages/tailwindcss/src/compat/default-theme.cts index bc1750d7e..235d60252 100644 --- a/packages/tailwindcss/src/compat/default-theme.cts +++ b/packages/tailwindcss/src/compat/default-theme.cts @@ -1 +1,4 @@ -module.exports = require('./default-theme.ts').default +import defaultTheme from './default-theme.ts' + +// @ts-ignore +export = defaultTheme diff --git a/packages/tailwindcss/src/plugin.cts b/packages/tailwindcss/src/plugin.cts index e7000e927..f7bf734ed 100644 --- a/packages/tailwindcss/src/plugin.cts +++ b/packages/tailwindcss/src/plugin.cts @@ -1,5 +1,8 @@ -// This file exists so that `plugin.ts` can be written one time but be compatible with both CJS and -// ESM. Without it we get a `.default` export when using `require` in CJS. +import plugin from './plugin.ts' + +// This file exists so that `plugin.ts` can be written one time but be +// compatible with both CJS and ESM. Without it we get a `.default` export when +// using `require` in CJS. // @ts-ignore -module.exports = require('./plugin.ts').default +export = plugin diff --git a/playgrounds/nextjs/postcss.config.js b/playgrounds/nextjs/postcss.config.js index 6c434006e..d70796632 100644 --- a/playgrounds/nextjs/postcss.config.js +++ b/playgrounds/nextjs/postcss.config.js @@ -1,3 +1,5 @@ +import tailwindcss from '@tailwindcss/postcss' + module.exports = { - plugins: ['@tailwindcss/postcss'], + plugins: [tailwindcss()], }