diff --git a/CHANGELOG.md b/CHANGELOG.md index 871141654..08c075a94 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,14 +7,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -- Nothing yet! +### Added + +- Add support for `tailwindcss/lib/util/flattenColorPalette` exports ([#15318](https://github.com/tailwindlabs/tailwindcss/pull/15318)) + +### Fixed + +- Fix dependency related warnings when using `@tailwindcss/postcss` on Windows ([#15321](https://github.com/tailwindlabs/tailwindcss/pull/15321)) ## [4.0.0-beta.6] - 2024-12-06 ### Fixed - Ensure `@import "…" reference` never generates utilities ([#15307](https://github.com/tailwindlabs/tailwindcss/pull/15307)) -- Fix dependency related warnings when using `@tailwindcss/postcss` on Windows ## [4.0.0-beta.5] - 2024-12-04 diff --git a/packages/tailwindcss/package.json b/packages/tailwindcss/package.json index 0a36e8f55..37f7c2159 100644 --- a/packages/tailwindcss/package.json +++ b/packages/tailwindcss/package.json @@ -31,6 +31,10 @@ "require": "./src/compat/colors.cts", "import": "./src/compat/colors.ts" }, + "./lib/util/flattenColorPalette": { + "require": "./src/compat/flatten-color-palette.cts", + "import": "./src/compat/flatten-color-palette.ts" + }, "./defaultTheme": { "require": "./src/compat/default-theme.cts", "import": "./src/compat/default-theme.ts" @@ -91,6 +95,10 @@ "require": "./dist/colors.js", "import": "./dist/colors.mjs" }, + "./lib/util/flattenColorPalette": { + "require": "./dist/flatten-color-palette.js", + "import": "./dist/flatten-color-palette.mjs" + }, "./package.json": "./package.json", "./index.css": "./index.css", "./index": "./index.css", diff --git a/packages/tailwindcss/src/compat/config.test.ts b/packages/tailwindcss/src/compat/config.test.ts index b99bc405b..3747f8ae4 100644 --- a/packages/tailwindcss/src/compat/config.test.ts +++ b/packages/tailwindcss/src/compat/config.test.ts @@ -1,7 +1,7 @@ import { describe, expect, test, vi } from 'vitest' import { compile, type Config } from '..' import { default as plugin } from '../plugin' -import { flattenColorPalette } from './flatten-color-palette' +import flattenColorPalette from './flatten-color-palette' const css = String.raw diff --git a/packages/tailwindcss/src/compat/flatten-color-palette.cts b/packages/tailwindcss/src/compat/flatten-color-palette.cts new file mode 100644 index 000000000..d8b4be144 --- /dev/null +++ b/packages/tailwindcss/src/compat/flatten-color-palette.cts @@ -0,0 +1,8 @@ +import flattenColorPalette from './flatten-color-palette.ts' + +// This file exists so that `flatten-color-palette.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 +export = flattenColorPalette diff --git a/packages/tailwindcss/src/compat/flatten-color-palette.test.ts b/packages/tailwindcss/src/compat/flatten-color-palette.test.ts index 3891bbece..7ddda5bd4 100644 --- a/packages/tailwindcss/src/compat/flatten-color-palette.test.ts +++ b/packages/tailwindcss/src/compat/flatten-color-palette.test.ts @@ -1,5 +1,5 @@ import { expect, test } from 'vitest' -import { flattenColorPalette } from './flatten-color-palette' +import flattenColorPalette from './flatten-color-palette' test('it should handle private __CSS_VALUES__ to resolve to the right value', () => { expect( diff --git a/packages/tailwindcss/src/compat/flatten-color-palette.ts b/packages/tailwindcss/src/compat/flatten-color-palette.ts index 03191e2da..ca8845688 100644 --- a/packages/tailwindcss/src/compat/flatten-color-palette.ts +++ b/packages/tailwindcss/src/compat/flatten-color-palette.ts @@ -4,7 +4,7 @@ type Colors = { [key: string | number]: string | Colors } -export function flattenColorPalette(colors: Colors) { +export default function flattenColorPalette(colors: Colors) { let result: Record = {} for (let [root, children] of Object.entries(colors ?? {})) { diff --git a/packages/tailwindcss/tsup.config.ts b/packages/tailwindcss/tsup.config.ts index 1a8e23887..59c8bdfa2 100644 --- a/packages/tailwindcss/tsup.config.ts +++ b/packages/tailwindcss/tsup.config.ts @@ -10,6 +10,7 @@ export default defineConfig([ plugin: 'src/plugin.ts', colors: 'src/compat/colors.ts', 'default-theme': 'src/compat/default-theme.ts', + 'flatten-color-palette': 'src/compat/flatten-color-palette.ts', }, }, { @@ -21,6 +22,7 @@ export default defineConfig([ lib: 'src/index.cts', colors: 'src/compat/colors.cts', 'default-theme': 'src/compat/default-theme.cts', + 'flatten-color-palette': 'src/compat/flatten-color-palette.cts', }, }, ])