From 4cbb8845a3f179fa9e029f5099409e977798af05 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Tue, 14 Oct 2025 20:22:46 +0200 Subject: [PATCH 1/2] make TypeScript happy --- packages/tailwindcss/src/at-import.test.ts | 22 ++++++++++++++++--- .../src/compat/apply-compat-hooks.ts | 2 +- .../src/compat/apply-config-to-theme.test.ts | 8 +++++++ .../compat/apply-keyframes-to-theme.test.ts | 12 ++++++---- .../src/compat/apply-keyframes-to-theme.ts | 1 - .../src/compat/config/resolve-config.test.ts | 20 +++++++++++++++++ .../src/compat/container-config.test.ts | 8 +++++++ .../src/compat/screens-config.test.ts | 8 +++++++ packages/tailwindcss/src/important.test.ts | 1 + packages/tailwindcss/src/index.bench.ts | 2 +- packages/tailwindcss/src/plugin.test.ts | 2 ++ .../src/source-maps/source-map.test.ts | 2 +- .../tailwindcss/src/source-maps/source-map.ts | 2 +- scripts/pack-packages.mjs | 2 +- 14 files changed, 79 insertions(+), 13 deletions(-) diff --git a/packages/tailwindcss/src/at-import.test.ts b/packages/tailwindcss/src/at-import.test.ts index 3beed978973a..49fbbc043d95 100644 --- a/packages/tailwindcss/src/at-import.test.ts +++ b/packages/tailwindcss/src/at-import.test.ts @@ -15,12 +15,15 @@ async function run( candidates = [], optimize = true, }: { - loadStylesheet?: (id: string, base: string) => Promise<{ content: string; base: string }> + loadStylesheet?: ( + id: string, + base: string, + ) => Promise<{ content: string; base: string; path: string }> loadModule?: ( id: string, base: string, resourceHint: 'plugin' | 'config', - ) => Promise<{ module: Config | Plugin; base: string }> + ) => Promise<{ module: Config | Plugin; base: string; path: string }> candidates?: string[] optimize?: boolean }, @@ -41,6 +44,7 @@ test('can resolve relative @imports', async () => { } `, base: '/root/foo', + path: '', } } @@ -67,6 +71,7 @@ test('can recursively resolve relative @imports', async () => { @import './bar/baz.css'; `, base: '/root/foo', + path: '', } } else if (base === '/root/foo' && id === './bar/baz.css') { return { @@ -76,6 +81,7 @@ test('can recursively resolve relative @imports', async () => { } `, base: '/root/foo/bar', + path: '', } } @@ -107,6 +113,7 @@ let loadStylesheet = async (id: string) => { return { content: exampleCSS, base: '/root', + path: '', } } @@ -415,6 +422,7 @@ test('supports theme(reference) imports', async () => { } `, base: '', + path: '', }), candidates: ['text-red-500'], }, @@ -435,8 +443,9 @@ test('updates the base when loading modules inside nested files', async () => { @plugin './nested-plugin.js'; `, base: '/root/foo', + path: '', }) - let loadModule = vi.fn().mockResolvedValue({ base: '', module: () => {} }) + let loadModule = vi.fn().mockResolvedValue({ base: '', path: '', module: () => {} }) expect( ( @@ -464,6 +473,7 @@ test('emits the right base for @source directives inside nested files', async () @source './nested/**/*.css'; `, base: '/root/foo', + path: '', }) let compiler = await compile( @@ -488,6 +498,7 @@ test('emits the right base for @source found inside JS configs and plugins from @plugin './nested-plugin.js'; `, base: '/root/foo', + path: '', }) let loadModule = vi.fn().mockImplementation((id: string) => { let base = id.includes('nested') ? '/root/foo' : '/root' @@ -502,12 +513,14 @@ test('emits the right base for @source found inside JS configs and plugins from plugins: [plugin(() => {}, { content: [pluginGlob] })], } satisfies Config, base: base + '-config', + path: '', } } else { let glob = id.includes('nested') ? './nested-plugin/*.html' : './root-plugin/*.html' return { module: plugin(() => {}, { content: [glob] }), base: base + '-plugin', + path: '', } } }) @@ -540,6 +553,7 @@ test('it crashes when inside a cycle', async () => { @import 'foo.css'; `, base: '/root', + path: '', }) await expect( @@ -568,6 +582,7 @@ test('resolves @reference as `@import "…" reference`', async () => { } `, base: '/root/foo', + path: '', } } @@ -600,6 +615,7 @@ test('resolves `@variant` used as `@custom-variant` inside `@reference`', async } `, base: '/root/foo', + path: '', } } diff --git a/packages/tailwindcss/src/compat/apply-compat-hooks.ts b/packages/tailwindcss/src/compat/apply-compat-hooks.ts index 2f88ed800307..766264742bca 100644 --- a/packages/tailwindcss/src/compat/apply-compat-hooks.ts +++ b/packages/tailwindcss/src/compat/apply-compat-hooks.ts @@ -353,7 +353,7 @@ function upgradeToFullPluginSupport({ // config would otherwise expand into namespaces like `background-color` which // core utilities already read from. applyConfigToTheme(designSystem, resolvedUserConfig, replacedThemeKeys) - applyKeyframesToTheme(designSystem, resolvedUserConfig, replacedThemeKeys) + applyKeyframesToTheme(designSystem, resolvedUserConfig) registerThemeVariantOverrides(resolvedUserConfig, designSystem) registerScreensConfig(resolvedUserConfig, designSystem) diff --git a/packages/tailwindcss/src/compat/apply-config-to-theme.test.ts b/packages/tailwindcss/src/compat/apply-config-to-theme.test.ts index 3a748fd8b306..83fc2f2c94e9 100644 --- a/packages/tailwindcss/src/compat/apply-config-to-theme.test.ts +++ b/packages/tailwindcss/src/compat/apply-config-to-theme.test.ts @@ -83,6 +83,7 @@ test('config values can be merged into the theme', () => { }, base: '/root', reference: false, + src: undefined, }, ]) applyConfigToTheme(design, resolvedConfig, replacedThemeKeys) @@ -160,6 +161,8 @@ test('will reset default theme values with overwriting theme values', () => { }, }, base: '/root', + reference: false, + src: undefined, }, ]) applyConfigToTheme(design, resolvedConfig, replacedThemeKeys) @@ -189,6 +192,8 @@ test('invalid keys are not merged into the theme', () => { }, }, base: '/root', + reference: false, + src: undefined, }, ]) @@ -227,6 +232,8 @@ test('converts opacity modifiers from decimal to percentage values', () => { }, }, base: '/root', + reference: false, + src: undefined, }, ]) applyConfigToTheme(design, resolvedConfig, replacedThemeKeys) @@ -261,6 +268,7 @@ test('handles setting theme keys to null', async () => { }, base: '/root', reference: false, + src: undefined, }, ]) applyConfigToTheme(design, resolvedConfig, replacedThemeKeys) diff --git a/packages/tailwindcss/src/compat/apply-keyframes-to-theme.test.ts b/packages/tailwindcss/src/compat/apply-keyframes-to-theme.test.ts index a0b1c54d5d61..aed761fcec03 100644 --- a/packages/tailwindcss/src/compat/apply-keyframes-to-theme.test.ts +++ b/packages/tailwindcss/src/compat/apply-keyframes-to-theme.test.ts @@ -9,7 +9,7 @@ test('keyframes can be merged into the theme', () => { let theme = new Theme() let design = buildDesignSystem(theme) - let { resolvedConfig, replacedThemeKeys } = resolveConfig(design, [ + let { resolvedConfig } = resolveConfig(design, [ { config: { theme: { @@ -28,9 +28,11 @@ test('keyframes can be merged into the theme', () => { }, }, base: '/root', + reference: false, + src: undefined, }, ]) - applyKeyframesToTheme(design, resolvedConfig, replacedThemeKeys) + applyKeyframesToTheme(design, resolvedConfig) expect(toCss(design.theme.getKeyframes())).toMatchInlineSnapshot(` "@keyframes fade-in { @@ -70,7 +72,7 @@ test('will append to the default keyframes with new keyframes', () => { ]), ) - let { resolvedConfig, replacedThemeKeys } = resolveConfig(design, [ + let { resolvedConfig } = resolveConfig(design, [ { config: { theme: { @@ -91,9 +93,11 @@ test('will append to the default keyframes with new keyframes', () => { }, }, base: '/root', + reference: false, + src: undefined, }, ]) - applyKeyframesToTheme(design, resolvedConfig, replacedThemeKeys) + applyKeyframesToTheme(design, resolvedConfig) expect(toCss(design.theme.getKeyframes())).toMatchInlineSnapshot(` "@keyframes slide-in { diff --git a/packages/tailwindcss/src/compat/apply-keyframes-to-theme.ts b/packages/tailwindcss/src/compat/apply-keyframes-to-theme.ts index a58ca13df861..d5855545f1c6 100644 --- a/packages/tailwindcss/src/compat/apply-keyframes-to-theme.ts +++ b/packages/tailwindcss/src/compat/apply-keyframes-to-theme.ts @@ -6,7 +6,6 @@ import { objectToAst } from './plugin-api' export function applyKeyframesToTheme( designSystem: DesignSystem, resolvedConfig: Pick, - replacedThemeKeys: Set, ) { for (let rule of keyframesToRules(resolvedConfig)) { designSystem.theme.addKeyframes(rule) diff --git a/packages/tailwindcss/src/compat/config/resolve-config.test.ts b/packages/tailwindcss/src/compat/config/resolve-config.test.ts index e47fa4eda47d..d8cc21a1013b 100644 --- a/packages/tailwindcss/src/compat/config/resolve-config.test.ts +++ b/packages/tailwindcss/src/compat/config/resolve-config.test.ts @@ -20,6 +20,8 @@ test('top level theme keys are replaced', () => { }, }, base: '/root', + reference: false, + src: undefined, }, { config: { @@ -30,6 +32,8 @@ test('top level theme keys are replaced', () => { }, }, base: '/root', + reference: false, + src: undefined, }, { config: { @@ -40,6 +44,8 @@ test('top level theme keys are replaced', () => { }, }, base: '/root', + reference: false, + src: undefined, }, ]) @@ -73,6 +79,8 @@ test('theme can be extended', () => { }, }, base: '/root', + reference: false, + src: undefined, }, { config: { @@ -85,6 +93,8 @@ test('theme can be extended', () => { }, }, base: '/root', + reference: false, + src: undefined, }, ]) @@ -120,6 +130,8 @@ test('theme keys can reference other theme keys using the theme function regardl }, }, base: '/root', + reference: false, + src: undefined, }, { config: { @@ -133,6 +145,8 @@ test('theme keys can reference other theme keys using the theme function regardl }, }, base: '/root', + reference: false, + src: undefined, }, { config: { @@ -145,6 +159,8 @@ test('theme keys can reference other theme keys using the theme function regardl }, }, base: '/root', + reference: false, + src: undefined, }, ]) @@ -212,6 +228,8 @@ test('theme keys can read from the CSS theme', () => { }, }, base: '/root', + reference: false, + src: undefined, }, ]) @@ -274,6 +292,7 @@ test('handles null as theme values', () => { }, base: '/root', reference: false, + src: undefined, }, { config: { @@ -287,6 +306,7 @@ test('handles null as theme values', () => { }, base: '/root', reference: false, + src: undefined, }, ]) diff --git a/packages/tailwindcss/src/compat/container-config.test.ts b/packages/tailwindcss/src/compat/container-config.test.ts index b5618de84135..22841efbf211 100644 --- a/packages/tailwindcss/src/compat/container-config.test.ts +++ b/packages/tailwindcss/src/compat/container-config.test.ts @@ -27,6 +27,7 @@ test('creates a custom utility to extend the built-in container', async () => { }, }, base: '/root', + path: '', }), }) @@ -85,6 +86,7 @@ test('allows padding to be defined at custom breakpoints', async () => { }, }, base: '/root', + path: '', }), }) @@ -146,6 +148,7 @@ test('allows breakpoints to be overwritten', async () => { }, }, base: '/root', + path: '', }), }) @@ -212,6 +215,7 @@ test('padding applies to custom `container` screens', async () => { }, }, base: '/root', + path: '', }), }) @@ -275,6 +279,7 @@ test("an empty `screen` config will undo all custom media screens and won't appl }, }, base: '/root', + path: '', }), }) @@ -340,6 +345,7 @@ test('legacy container component does not interfere with new --container variabl }, }, base: '/root', + path: '', }), }) @@ -386,6 +392,7 @@ test('combines custom padding and screen overwrites', async () => { }, }, base: '/root', + path: '', }), }) @@ -498,6 +505,7 @@ test('filters out complex breakpoints', async () => { }, }, base: '/root', + path: '', }), }) diff --git a/packages/tailwindcss/src/compat/screens-config.test.ts b/packages/tailwindcss/src/compat/screens-config.test.ts index ac73d8216976..26dac06321e4 100644 --- a/packages/tailwindcss/src/compat/screens-config.test.ts +++ b/packages/tailwindcss/src/compat/screens-config.test.ts @@ -31,6 +31,7 @@ test('CSS `--breakpoint-*` merge with JS config `screens`', async () => { }, }, base: '/root', + path: '', }), }) @@ -115,6 +116,7 @@ test('JS config `screens` extend CSS `--breakpoint-*`', async () => { }, }, base: '/root', + path: '', }), }) @@ -207,6 +209,7 @@ test('JS config `screens` only setup, even if those match the default-theme expo }, }, base: '/root', + path: '', }), }) @@ -288,6 +291,7 @@ test('JS config `screens` overwrite CSS `--breakpoint-*`', async () => { }, }, base: '/root', + path: '', }), }) @@ -389,6 +393,7 @@ test('JS config with `theme: { extends }` should not include the `default-config }, }, base: '/root', + path: '', }), }) @@ -473,6 +478,7 @@ describe('complex screen configs', () => { }, }, base: '/root', + path: '', }), }) @@ -553,6 +559,7 @@ describe('complex screen configs', () => { }, }, base: '/root', + path: '', }), }) @@ -628,6 +635,7 @@ test('JS config `screens` can overwrite default CSS `--breakpoint-*`', async () }, }, base: '/root', + path: '', }), }) diff --git a/packages/tailwindcss/src/important.test.ts b/packages/tailwindcss/src/important.test.ts index 145f42062367..cd5af637c10f 100644 --- a/packages/tailwindcss/src/important.test.ts +++ b/packages/tailwindcss/src/important.test.ts @@ -41,6 +41,7 @@ test('Utilities can be marked with important', async () => { loadStylesheet: async (id: string, base: string) => ({ base, content: '@tailwind utilities;', + path: '', }), }) diff --git a/packages/tailwindcss/src/index.bench.ts b/packages/tailwindcss/src/index.bench.ts index fb9cd0e71084..0ca33fde1ef3 100644 --- a/packages/tailwindcss/src/index.bench.ts +++ b/packages/tailwindcss/src/index.bench.ts @@ -7,7 +7,7 @@ const root = process.env.FOLDER || process.cwd() const css = String.raw bench('compile', async () => { - let scanner = new Scanner({ sources: [{ base: root, pattern: '**/*' }] }) + let scanner = new Scanner({ sources: [{ base: root, pattern: '**/*', negated: true }] }) let candidates = scanner.scan() let { build } = await compile(css` diff --git a/packages/tailwindcss/src/plugin.test.ts b/packages/tailwindcss/src/plugin.test.ts index 9af3a55fbb58..485381cdeeb3 100644 --- a/packages/tailwindcss/src/plugin.test.ts +++ b/packages/tailwindcss/src/plugin.test.ts @@ -19,6 +19,7 @@ test('plugin', async () => { }) }), base: '/root', + path: '', }), }) @@ -49,6 +50,7 @@ test('plugin.withOptions', async () => { } }), base: '/root', + path: '', }), }) diff --git a/packages/tailwindcss/src/source-maps/source-map.test.ts b/packages/tailwindcss/src/source-maps/source-map.test.ts index 4c9939baef02..1e55caec7846 100644 --- a/packages/tailwindcss/src/source-maps/source-map.test.ts +++ b/packages/tailwindcss/src/source-maps/source-map.test.ts @@ -409,7 +409,7 @@ test('license comments preserve source locations', async ({ expect }) => { }) test('license comments with new lines preserve source locations', async ({ expect }) => { - let { sources, annotations, css } = await run({ + let { sources, annotations } = await run({ input: `/*! some \n comment */`, }) diff --git a/packages/tailwindcss/src/source-maps/source-map.ts b/packages/tailwindcss/src/source-maps/source-map.ts index 1e1e8e7a0deb..284bcd9d6832 100644 --- a/packages/tailwindcss/src/source-maps/source-map.ts +++ b/packages/tailwindcss/src/source-maps/source-map.ts @@ -90,7 +90,7 @@ export function createSourceMap({ ast }: { ast: AstNode[] }) { } // Get all the indexes from the mappings - walk(ast, (node: AstNode) => { + walk(ast, (node) => { if (!node.src || !node.dst) return let originalSource = sourceTable.get(node.src[0]) diff --git a/scripts/pack-packages.mjs b/scripts/pack-packages.mjs index 7bec3eda4dd2..a3d34da6fcfd 100644 --- a/scripts/pack-packages.mjs +++ b/scripts/pack-packages.mjs @@ -28,7 +28,7 @@ for (let path of paths) { await fs.rm(path.join(root, 'dist'), { recursive: true, force: true }) Promise.all( - [...workspaces.entries()].map(async ([name, { version, dir }]) => { + [...workspaces.entries()].map(async ([name, { dir }]) => { function pack() { return new Promise((resolve) => { exec( From 14efbe558d390f3c8dc1a63a7c02cdc80ea27e28 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Tue, 14 Oct 2025 21:48:03 +0200 Subject: [PATCH 2/2] fallback `rem` to `null` --- packages/tailwindcss/src/constant-fold-declaration.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/tailwindcss/src/constant-fold-declaration.ts b/packages/tailwindcss/src/constant-fold-declaration.ts index 2ae6b2557c60..230ef9fa73f4 100644 --- a/packages/tailwindcss/src/constant-fold-declaration.ts +++ b/packages/tailwindcss/src/constant-fold-declaration.ts @@ -4,7 +4,7 @@ import * as ValueParser from './value-parser' // Assumption: We already assume that we receive somewhat valid `calc()` // expressions. So we will see `calc(1 + 1)` and not `calc(1+1)` -export function constantFoldDeclaration(input: string, rem: number | null): string { +export function constantFoldDeclaration(input: string, rem: number | null = null): string { let folded = false let valueAst = ValueParser.parse(input)