From 3386049b7bfc6b5beea06075258ca766c200af5a Mon Sep 17 00:00:00 2001 From: Robin Malfait Date: Fri, 9 May 2025 22:04:48 +0200 Subject: [PATCH] =?UTF-8?q?Fix=20upgrade=20error=20when=20using=20`@import?= =?UTF-8?q?=20=E2=80=A6=20source(=E2=80=A6)`=20(#17963)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR fixes an issue when running the upgrade tool and if any of the CSS files has an import that looks like this: ```css @import "tailwindcss" source("…"); ``` This was trying to resolve `tailwindcss" source("…` instead of `tailwindcss`. This PR fixes that. ## Test plan 1. Ran it locally on a project Before: image After: image --- CHANGELOG.md | 1 + packages/@tailwindcss-upgrade/src/codemods/css/analyze.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d76daf0f..9b08ea20a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Allow `_` before numbers during candidate extraction ([#17961](https://github.com/tailwindlabs/tailwindcss/pull/17961)) +- Upgrade: Fix error when using `@import … source(…)` ([#17963](https://github.com/tailwindlabs/tailwindcss/pull/17963)) ## [4.1.6] - 2025-05-09 diff --git a/packages/@tailwindcss-upgrade/src/codemods/css/analyze.ts b/packages/@tailwindcss-upgrade/src/codemods/css/analyze.ts index c27f5c956..954d8ce0f 100644 --- a/packages/@tailwindcss-upgrade/src/codemods/css/analyze.ts +++ b/packages/@tailwindcss-upgrade/src/codemods/css/analyze.ts @@ -39,7 +39,7 @@ export async function analyze(stylesheets: Stylesheet[]) { AtRule: { import(node) { // Find what the import points to - let id = node.params.match(/['"](.*)['"]/)?.[1] + let id = node.params.match(/['"](.*?)['"]/)?.[1] if (!id) return let basePath = node.source?.input.file