@@ -12,7 +12,7 @@ const processor = postcss.plugin( 'modules-extract-imports', function ( options
1212 createImportedName = options && options . createImportedName || ( ( importName /*, path*/ ) => `i__imported_${ importName . replace ( / \W / g, '_' ) } _${ importIndex ++ } ` ) ;
1313
1414 // Find any declaration that supports imports
15- css . eachDecl ( declFilter , ( decl ) => {
15+ css . walkDecls ( declFilter , ( decl ) => {
1616 let matches = decl . value . match ( matchImports ) ;
1717 if ( matches ) {
1818 let [ /*match*/ , symbols , doubleQuotePath , singleQuotePath ] = matches ;
@@ -31,7 +31,7 @@ const processor = postcss.plugin( 'modules-extract-imports', function ( options
3131
3232 // If we've found any imports, insert or append :import rules
3333 let existingImports = { } ;
34- css . eachRule ( rule => {
34+ css . walkRules ( rule => {
3535 let matches = icssImport . exec ( rule . selector ) ;
3636 if ( matches ) {
3737 let [ /*match*/ , doubleQuotePath , singleQuotePath ] = matches ;
@@ -40,19 +40,20 @@ const processor = postcss.plugin( 'modules-extract-imports', function ( options
4040 } ) ;
4141
4242 Object . keys ( imports ) . reverse ( ) . forEach ( path => {
43+
4344 let rule = existingImports [ path ] ;
4445 if ( ! rule ) {
4546 rule = postcss . rule ( {
4647 selector : `:import("${ path } ")` ,
47- after : "\n"
48+ raws : { after : "\n" }
4849 } ) ;
4950 css . prepend ( rule ) ;
5051 }
5152 Object . keys ( imports [ path ] ) . forEach ( importedSymbol => {
5253 rule . push ( postcss . decl ( {
5354 value : importedSymbol ,
5455 prop : imports [ path ] [ importedSymbol ] ,
55- before : "\n " ,
56+ raws : { before : "\n " } ,
5657 _autoprefixerDisabled : true
5758 } ) ) ;
5859 } ) ;
0 commit comments