@@ -3194,6 +3194,8 @@ function isPreProcessor(lang: any): lang is PreprocessLang {
31943194 return lang && preprocessorSet . has ( lang )
31953195}
31963196
3197+ const absoluteOrProtocolRelativeUrlRE = / ^ (?: [ a - z ] + : ) ? \/ \/ / i
3198+
31973199const importEsbuild = createCachedImport ( ( ) => import ( 'esbuild' ) )
31983200
31993201const importLightningCSS = createCachedImport ( ( ) => import ( 'lightningcss' ) )
@@ -3268,6 +3270,12 @@ async function compileLightningCSS(
32683270 return publicFile
32693271 }
32703272
3273+ // contrary to lightningcss, postcss-import does this internally
3274+ if ( absoluteOrProtocolRelativeUrlRE . test ( id ) ) {
3275+ // @ts -expect-error -- https://github.com/parcel-bundler/lightningcss/pull/1261
3276+ return { external : id } as string
3277+ }
3278+
32713279 // NOTE: with `transformer: 'postcss'`, CSS modules `composes` tried to resolve with
32723280 // all resolvers, but in `transformer: 'lightningcss'`, only the one for the
32733281 // current file type is used.
@@ -3308,7 +3316,7 @@ async function compileLightningCSS(
33083316 config . command === 'build'
33093317 ? ! ! config . build . sourcemap
33103318 : config . css . devSourcemap ,
3311- analyzeDependencies : true ,
3319+ analyzeDependencies : { preserveImports : true } ,
33123320 cssModules : cssModuleRE . test ( id )
33133321 ? ( config . css . lightningcss ?. cssModules ?? true )
33143322 : undefined ,
@@ -3391,8 +3399,14 @@ async function compileLightningCSS(
33913399 )
33923400 break
33933401 }
3402+ case 'import' : {
3403+ css = css . replace ( dep . placeholder , dep . url )
3404+ break
3405+ }
33943406 default :
3395- throw new Error ( `Unsupported dependency type: ${ dep . type } ` )
3407+ throw new Error (
3408+ `Unsupported dependency type: ${ ( dep satisfies never as any ) . type } ` ,
3409+ )
33963410 }
33973411 }
33983412
0 commit comments