@@ -151,3 +151,41 @@ test('sass importer resolves pkg: specifiers via oxc-resolver', async () => {
151151 await fs . rm ( root , { recursive : true , force : true } )
152152 }
153153} )
154+
155+ test ( 'sass importer honors sass condition name' , async ( ) => {
156+ const root = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , 'knighted-sass-conditions-' ) )
157+ try {
158+ const srcDir = path . join ( root , 'src' )
159+ const stylesDir = path . join ( srcDir , 'styles' )
160+ await fs . mkdir ( stylesDir , { recursive : true } )
161+ await fs . writeFile ( path . join ( stylesDir , 'sass.scss' ) , '.sass { color: blue; }' )
162+ await fs . writeFile ( path . join ( stylesDir , 'default.scss' ) , '.default { color: red; }' )
163+ await fs . writeFile (
164+ path . join ( root , 'package.json' ) ,
165+ JSON . stringify (
166+ {
167+ name : 'knighted-sass-conditions-fixture' ,
168+ type : 'module' ,
169+ imports : {
170+ '#styles/entry.scss' : {
171+ sass : './src/styles/sass.scss' ,
172+ default : './src/styles/default.scss' ,
173+ } ,
174+ } ,
175+ } ,
176+ null ,
177+ 2 ,
178+ ) ,
179+ )
180+
181+ const importer = __sassInternals . createSassImporter ( { cwd : root } )
182+ const containing = pathToFileURL ( path . join ( srcDir , 'entry.scss' ) )
183+ const resolved = await importer . canonicalize ( 'pkg:#styles/entry.scss' , {
184+ containingUrl : containing ,
185+ } )
186+ assert . ok ( resolved , 'expected pkg: specifier to resolve' )
187+ assert . ok ( resolved ?. href . endsWith ( '/sass.scss' ) )
188+ } finally {
189+ await fs . rm ( root , { recursive : true , force : true } )
190+ }
191+ } )
0 commit comments