From af2436a3b8d87727c51ccef77bae8ba972d27272 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 26 Apr 2026 22:17:14 -0500 Subject: [PATCH] Handle bare CSS @import specifiers for Tailwind v4 Tailwind v4 projects typically include `@import "tailwindcss";` in their CSS entry and often `@import` third-party CSS plugins like `tw-animate-css`. Both cases were broken: 1. esbuild tried to resolve `tailwindcss` through the ESM CDN as JS, producing 'Cannot import <...> into a CSS file'. The existing CSS-importer guard used `new URL(args.importer)` to detect CSS importers, but esbuild passes fs-namespace importers as plain paths (e.g. `/projects/foo/src/index.css`) which don't parse as URLs, so the guard never fired. 2. `@tailwindcss/browser@4` only resolves a hardcoded set of `@import` specifiers (`tailwindcss`, `tailwindcss/preflight`, `tailwindcss/theme`, `tailwindcss/utilities`) and throws 'The browser build does not support @import for ' for everything else, so plugin packages couldn't be preserved as external either. Detect CSS importers with a plain string match and split behavior: `tailwindcss` and its subpaths stay external so the v4 runtime can handle them, while other bare CSS imports fall through to the normal esm.sh resolution path. esm.sh redirects CSS-only packages to their `.css` entry and `onLoad` picks `loader: "css"` via the content-type mapping, so the dependency is bundled inline. The combined CSS then lands in the `