diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ff6cdbb6..f046da58c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed -- Ensure that the `containers` JS theme key is added to the `--container-*` namespace. ([#16169](https://github.com/tailwindlabs/tailwindcss/pull/16169)) +- Ensure that the `containers` JS theme key is added to the `--container-*` namespace ([#16169](https://github.com/tailwindlabs/tailwindcss/pull/16169)) - Fix missing `@keyframes` definition ([#16237](https://github.com/tailwindlabs/tailwindcss/pull/16237)) +- Vite: Skip parsing stylesheets with the `?commonjs-proxy` flag ([#16238](https://github.com/tailwindlabs/tailwindcss/pull/16238)) ## [4.0.3] - 2025-02-01 diff --git a/integrations/vite/index.test.ts b/integrations/vite/index.test.ts index eebe11127..c0bee2b87 100644 --- a/integrations/vite/index.test.ts +++ b/integrations/vite/index.test.ts @@ -841,6 +841,49 @@ test( }, ) +test( + `does not interfere with ?commonjs-proxy modules`, + { + fs: { + 'package.json': json` + { + "type": "module", + "dependencies": { + "@tailwindcss/vite": "workspace:^", + "tailwindcss": "workspace:^", + "plotly.js": "^3", + "vite": "^6" + } + } + `, + 'vite.config.ts': ts` + import tailwindcss from '@tailwindcss/vite' + import { defineConfig } from 'vite' + + export default defineConfig({ + build: { cssMinify: false }, + plugins: [tailwindcss()], + }) + `, + 'index.html': html` + + + + `, + 'src/index.js': js`import Plotly from 'plotly.js/lib/core'`, + }, + }, + async ({ exec, expect, fs }) => { + await exec('pnpm vite build') + + let files = await fs.glob('dist/**/*.css') + expect(files).toHaveLength(1) + let [filename] = files[0] + + await fs.expectFileToContain(filename, [candidate`maplibregl-map`]) + }, +) + function firstLine(str: string) { return str.split('\n')[0] } diff --git a/packages/@tailwindcss-vite/src/index.ts b/packages/@tailwindcss-vite/src/index.ts index c7cc111fa..0d7440094 100644 --- a/packages/@tailwindcss-vite/src/index.ts +++ b/packages/@tailwindcss-vite/src/index.ts @@ -7,7 +7,8 @@ import path from 'node:path' import type { Plugin, ResolvedConfig, Rollup, Update, ViteDevServer } from 'vite' const DEBUG = env.DEBUG -const SPECIAL_QUERY_RE = /[?&](raw|url)\b/ +const SPECIAL_QUERY_RE = /[?&](?:worker|sharedworker|raw|url)\b/ +const COMMON_JS_PROXY_RE = /\?commonjs-proxy/ const INLINE_STYLE_ID_RE = /[?&]index\=\d+\.css$/ const IGNORED_DEPENDENCIES = ['tailwind-merge'] @@ -315,8 +316,9 @@ function isPotentialCssRootFile(id: string) { let isCssFile = (extension === 'css' || id.includes('&lang.css') || id.match(INLINE_STYLE_ID_RE)) && // Don't intercept special static asset resources - !SPECIAL_QUERY_RE.test(id) - + !SPECIAL_QUERY_RE.test(id) && + !COMMON_JS_PROXY_RE.test(id) + if (isCssFile) console.log(id) return isCssFile }