From fcee63d9978d7db15fa60de9bff24e925cdb9fd2 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 10:53:47 +0100 Subject: [PATCH 1/6] =?UTF-8?q?Update=20@types/braces=203.0.4=20=E2=86=92?= =?UTF-8?q?=203.0.5=20(patch)=20(#15612)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/@tailwindcss-upgrade/package.json | 2 +- pnpm-lock.yaml | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/@tailwindcss-upgrade/package.json b/packages/@tailwindcss-upgrade/package.json index f11138db0f89..abfdabe23d95 100644 --- a/packages/@tailwindcss-upgrade/package.json +++ b/packages/@tailwindcss-upgrade/package.json @@ -45,7 +45,7 @@ "tailwindcss": "workspace:*" }, "devDependencies": { - "@types/braces": "^3.0.4", + "@types/braces": "^3.0.5", "@types/node": "catalog:", "@types/postcss-import": "^14.0.3" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4ebbb6d7e35d..95f5cfed9094 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -348,8 +348,8 @@ importers: version: 0.23.2(tree-sitter@0.22.4) devDependencies: '@types/braces': - specifier: ^3.0.4 - version: 3.0.4 + specifier: ^3.0.5 + version: 3.0.5 '@types/node': specifier: 'catalog:' version: 20.14.13 @@ -1830,8 +1830,8 @@ packages: '@types/babel__traverse@7.20.6': resolution: {integrity: sha512-r1bzfrm0tomOI8g1SzvCaQHo6Lcv6zu0EA+W2kHrt8dyrHQxGzBBL4kdkzIS+jBMV+EYcMAEAqXqYaLJq5rOZg==} - '@types/braces@3.0.4': - resolution: {integrity: sha512-0WR3b8eaISjEW7RpZnclONaLFDf7buaowRHdqLp4vLj54AsSAYWfh3DRbfiYJY9XDxMgx1B4sE1Afw2PGpuHOA==} + '@types/braces@3.0.5': + resolution: {integrity: sha512-SQFof9H+LXeWNz8wDe7oN5zu7ket0qwMu5vZubW4GCJ8Kkeh6nBWUz87+KTz/G3Kqsrp0j/W253XJb3KMEeg3w==} '@types/bun@1.1.14': resolution: {integrity: sha512-opVYiFGtO2af0dnWBdZWlioLBoxSdDO5qokaazLhq8XQtGZbY4pY3/JxY8Zdf/hEwGubbp7ErZXoN1+h2yesxA==} @@ -4974,7 +4974,7 @@ snapshots: dependencies: '@babel/types': 7.26.3 - '@types/braces@3.0.4': {} + '@types/braces@3.0.5': {} '@types/bun@1.1.14': dependencies: From ae8fb146a7e65c2174949ed24b1e501c49755261 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Mon, 13 Jan 2025 11:11:35 +0100 Subject: [PATCH 2/6] =?UTF-8?q?Update=20fast-glob=203.3.2=20=E2=86=92=203.?= =?UTF-8?q?3.3=20(patch)=20(#15607)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- integrations/package.json | 2 +- playgrounds/nextjs/package.json | 2 +- pnpm-lock.yaml | 39 ++++++++++++++++++++------------- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/integrations/package.json b/integrations/package.json index 8023842cd36a..62f458c77480 100644 --- a/integrations/package.json +++ b/integrations/package.json @@ -4,6 +4,6 @@ "private": true, "devDependencies": { "dedent": "1.5.3", - "fast-glob": "^3.3.2" + "fast-glob": "^3.3.3" } } diff --git a/playgrounds/nextjs/package.json b/playgrounds/nextjs/package.json index 20c2ae6965de..21748143e110 100644 --- a/playgrounds/nextjs/package.json +++ b/playgrounds/nextjs/package.json @@ -10,7 +10,7 @@ }, "dependencies": { "@tailwindcss/postcss": "workspace:^", - "fast-glob": "^3.3.2", + "fast-glob": "^3.3.3", "next": "15.1.3", "react": "^19.0.0", "react-dom": "^19.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 95f5cfed9094..1ceb3bf9a0de 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -132,8 +132,8 @@ importers: specifier: 1.5.3 version: 1.5.3 fast-glob: - specifier: ^3.3.2 - version: 3.3.2 + specifier: ^3.3.3 + version: 3.3.3 packages/@tailwindcss-browser: devDependencies: @@ -402,8 +402,8 @@ importers: specifier: workspace:^ version: link:../../packages/@tailwindcss-postcss fast-glob: - specifier: ^3.3.2 - version: 3.3.2 + specifier: ^3.3.3 + version: 3.3.3 next: specifier: 15.1.3 version: 15.1.3(@playwright/test@1.49.1)(react-dom@19.0.0(react@19.0.0))(react@19.0.0) @@ -2506,8 +2506,8 @@ packages: resolution: {integrity: sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg==} engines: {node: '>=8.6.0'} - fast-glob@3.3.2: - resolution: {integrity: sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==} + fast-glob@3.3.3: + resolution: {integrity: sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==} engines: {node: '>=8.6.0'} fast-json-stable-stringify@2.1.0: @@ -3091,6 +3091,10 @@ packages: resolution: {integrity: sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==} engines: {node: '>=8.6'} + micromatch@4.0.8: + resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} + engines: {node: '>=8.6'} + mime@3.0.0: resolution: {integrity: sha512-jSCU7/VB1loIWBZe14aEYHU/+1UMEHoaO7qxCOVJOw9GgH72VAWppxNcjU+x9a2k3GSIBXNKxXQFqRvvZ7vr3A==} engines: {node: '>=10.0.0'} @@ -5110,7 +5114,7 @@ snapshots: '@typescript-eslint/types': 8.11.0 '@typescript-eslint/visitor-keys': 8.11.0 debug: 4.3.7 - fast-glob: 3.3.2 + fast-glob: 3.3.3 is-glob: 4.0.3 minimatch: 9.0.5 semver: 7.6.3 @@ -5125,7 +5129,7 @@ snapshots: '@typescript-eslint/types': 8.11.0 '@typescript-eslint/visitor-keys': 8.11.0 debug: 4.3.7 - fast-glob: 3.3.2 + fast-glob: 3.3.3 is-glob: 4.0.3 minimatch: 9.0.5 semver: 7.6.3 @@ -5842,7 +5846,7 @@ snapshots: enhanced-resolve: 5.18.0 eslint: 9.17.0(jiti@2.4.2) eslint-module-utils: 2.12.0(@typescript-eslint/parser@8.11.0(eslint@9.17.0(jiti@2.4.2))(typescript@5.5.4))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3)(eslint@9.17.0(jiti@2.4.2)) - fast-glob: 3.3.2 + fast-glob: 3.3.3 get-tsconfig: 4.8.1 is-bun-module: 1.2.1 is-glob: 4.0.3 @@ -5861,7 +5865,7 @@ snapshots: enhanced-resolve: 5.18.0 eslint: 9.17.0(jiti@2.4.2) eslint-module-utils: 2.12.0(@typescript-eslint/parser@8.11.0(eslint@9.17.0(jiti@2.4.2))(typescript@5.6.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.3)(eslint@9.17.0(jiti@2.4.2)) - fast-glob: 3.3.2 + fast-glob: 3.3.3 get-tsconfig: 4.8.1 is-bun-module: 1.2.1 is-glob: 4.0.3 @@ -6105,13 +6109,13 @@ snapshots: merge2: 1.4.1 micromatch: 4.0.7 - fast-glob@3.3.2: + fast-glob@3.3.3: dependencies: '@nodelib/fs.stat': 2.0.5 '@nodelib/fs.walk': 1.2.8 glob-parent: 5.1.2 merge2: 1.4.1 - micromatch: 4.0.7 + micromatch: 4.0.8 fast-json-stable-stringify@2.1.0: {} @@ -6229,7 +6233,7 @@ snapshots: dependencies: array-union: 2.1.0 dir-glob: 3.0.1 - fast-glob: 3.3.2 + fast-glob: 3.3.3 ignore: 5.3.2 merge2: 1.4.1 slash: 3.0.0 @@ -6237,7 +6241,7 @@ snapshots: globby@14.0.2: dependencies: '@sindresorhus/merge-streams': 2.3.0 - fast-glob: 3.3.2 + fast-glob: 3.3.3 ignore: 5.3.1 path-type: 5.0.0 slash: 5.1.0 @@ -6629,6 +6633,11 @@ snapshots: braces: 3.0.3 picomatch: 2.3.1 + micromatch@4.0.8: + dependencies: + braces: 3.0.3 + picomatch: 2.3.1 + mime@3.0.0: {} mimic-fn@2.1.0: {} @@ -7290,7 +7299,7 @@ snapshots: chokidar: 3.6.0 didyoumean: 1.2.2 dlv: 1.1.3 - fast-glob: 3.3.2 + fast-glob: 3.3.3 glob-parent: 6.0.2 is-glob: 4.0.3 jiti: 1.21.6 From 24f1ee5fc539dac277e2c9421f0ccef44e7636bd Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Sat, 11 Jan 2025 19:59:11 +0100 Subject: [PATCH 3/6] add failing test --- packages/tailwindcss/src/index.test.ts | 47 ++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/packages/tailwindcss/src/index.test.ts b/packages/tailwindcss/src/index.test.ts index 677f33593454..89ddceb10fb6 100644 --- a/packages/tailwindcss/src/index.test.ts +++ b/packages/tailwindcss/src/index.test.ts @@ -1208,6 +1208,53 @@ describe('Parsing themes values from CSS', () => { `) }) + test('`@theme` values can be unset (using the escaped syntax)', async () => { + expect( + await compileCss( + css` + @theme { + --color-red: #f00; + --color-blue: #00f; + --text-sm: 13px; + --text-md: 16px; + + --animate-spin: spin 1s infinite linear; + + @keyframes spin { + to { + transform: rotate(360deg); + } + } + } + @theme { + --color-\*: initial; + --text-md: initial; + --animate-\*: initial; + --keyframes-\*: initial; + } + @theme { + --color-green: #0f0; + } + @tailwind utilities; + `, + ['accent-red', 'accent-blue', 'accent-green', 'text-sm', 'text-md'], + ), + ).toMatchInlineSnapshot(` + ":root { + --text-sm: 13px; + --color-green: #0f0; + } + + .text-sm { + font-size: var(--text-sm); + } + + .accent-green { + accent-color: var(--color-green); + }" + `) + }) + test('all `@theme` values can be unset at once', async () => { expect( await compileCss( From c5f2c56c95cce4bef3f7ff58818200335a576047 Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Sat, 11 Jan 2025 20:02:30 +0100 Subject: [PATCH 4/6] ensure `--color-\*: initial;` works --- packages/tailwindcss/src/theme.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/tailwindcss/src/theme.ts b/packages/tailwindcss/src/theme.ts index 03379c7b4e4c..77f216a8aef8 100644 --- a/packages/tailwindcss/src/theme.ts +++ b/packages/tailwindcss/src/theme.ts @@ -41,6 +41,10 @@ export class Theme { ) {} add(key: string, value: string, options = ThemeOptions.NONE): void { + if (key.endsWith('-\\*')) { + key = key.replace(/-\\\*$/, '-*') + } + if (key.endsWith('-*')) { if (value !== 'initial') { throw new Error(`Invalid theme value \`${value}\` for namespace \`${key}\``) From d2b5d5b3ffde5ceafb971d8dcd45aa8dfd0e105c Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Sun, 12 Jan 2025 11:41:51 +0100 Subject: [PATCH 5/6] use regex replace unconditionally --- packages/tailwindcss/src/theme.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/tailwindcss/src/theme.ts b/packages/tailwindcss/src/theme.ts index 77f216a8aef8..ba280ac36b16 100644 --- a/packages/tailwindcss/src/theme.ts +++ b/packages/tailwindcss/src/theme.ts @@ -1,6 +1,8 @@ import type { AtRule } from './ast' import { escape } from './utils/escape' +const ESCAPED_STAR_REGEX = /-\\\*$/ + export const enum ThemeOptions { NONE = 0, INLINE = 1 << 0, @@ -41,9 +43,7 @@ export class Theme { ) {} add(key: string, value: string, options = ThemeOptions.NONE): void { - if (key.endsWith('-\\*')) { - key = key.replace(/-\\\*$/, '-*') - } + key = key.replace(ESCAPED_STAR_REGEX, '-*') if (key.endsWith('-*')) { if (value !== 'initial') { From 23479d13b230794adcb32827c6f50be5060d558f Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Mon, 13 Jan 2025 11:36:48 +0100 Subject: [PATCH 6/6] use slice instead of a regex replace Introducing MBDD: micro-benchmark driven development! --- packages/tailwindcss/src/theme.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/tailwindcss/src/theme.ts b/packages/tailwindcss/src/theme.ts index ba280ac36b16..a2d3c205fa4a 100644 --- a/packages/tailwindcss/src/theme.ts +++ b/packages/tailwindcss/src/theme.ts @@ -1,8 +1,6 @@ import type { AtRule } from './ast' import { escape } from './utils/escape' -const ESCAPED_STAR_REGEX = /-\\\*$/ - export const enum ThemeOptions { NONE = 0, INLINE = 1 << 0, @@ -43,7 +41,9 @@ export class Theme { ) {} add(key: string, value: string, options = ThemeOptions.NONE): void { - key = key.replace(ESCAPED_STAR_REGEX, '-*') + if (key.endsWith('\\*')) { + key = key.slice(0, -2) + '*' + } if (key.endsWith('-*')) { if (value !== 'initial') {