@@ -1963,3 +1963,80 @@ test(
19631963 ` )
19641964 } ,
19651965)
1966+
1967+ test (
1968+ 'relative imports without a relative path prefix are migrated to include a relative path prefix' ,
1969+ {
1970+ fs : {
1971+ 'package.json' : json `
1972+ {
1973+ "dependencies" : {
1974+ "tailwindcss" : "workspace:^" ,
1975+ "@tailwindcss/upgrade" : "workspace:^"
1976+ }
1977+ }
1978+ ` ,
1979+ 'tailwind.config.js' : js `module .exports = {}` ,
1980+ 'src/index.css' : css `
1981+ @import 'tailwindcss/base' ;
1982+ @import 'tailwindcss/components' ;
1983+ @import 'styles/components' ;
1984+ @import 'tailwindcss/utilities' ;
1985+ ` ,
1986+ 'src/styles/components.css' : css `
1987+ .btn {
1988+ @apply bg-black px-4 py-2 rounded-md text-white font-medium hover:bg-zinc-800;
1989+ }
1990+ ` ,
1991+ } ,
1992+ } ,
1993+ async ( { fs, exec } ) => {
1994+ await exec ( 'npx @tailwindcss/upgrade --force' )
1995+
1996+ expect ( await fs . dumpFiles ( './src/**/*.css' ) ) . toMatchInlineSnapshot ( `
1997+ "
1998+ --- ./src/index.css ---
1999+ @import 'tailwindcss';
2000+ @import './styles/components.css' layer(components);
2001+
2002+ /*
2003+ The default border color has changed to \`currentColor\` in Tailwind CSS v4,
2004+ so we've added these compatibility styles to make sure everything still
2005+ looks the same as it did with Tailwind CSS v3.
2006+
2007+ If we ever want to remove these styles, we need to add an explicit border
2008+ color utility to any element that depends on these defaults.
2009+ */
2010+ @layer base {
2011+ *,
2012+ ::after,
2013+ ::before,
2014+ ::backdrop,
2015+ ::file-selector-button {
2016+ border-color: var(--color-gray-200, currentColor);
2017+ }
2018+ }
2019+ /*
2020+ Form elements have a 1px border by default in Tailwind CSS v4, so we've
2021+ added these compatibility styles to make sure everything still looks the
2022+ same as it did with Tailwind CSS v3.
2023+
2024+ If we ever want to remove these styles, we need to add \`border-0\` to
2025+ any form elements that shouldn't have a border.
2026+ */
2027+ @layer base {
2028+ input:where(:not([type='button'], [type='reset'], [type='submit'])),
2029+ select,
2030+ textarea {
2031+ border-width: 0;
2032+ }
2033+ }
2034+
2035+ --- ./src/styles/components.css ---
2036+ .btn {
2037+ @apply bg-black px-4 py-2 rounded-md text-white font-medium hover:bg-zinc-800;
2038+ }
2039+ "
2040+ ` )
2041+ } ,
2042+ )
0 commit comments