@@ -84,54 +84,63 @@ module.exports = (options = {}) => {
8484 } ) ;
8585
8686 root . walkDecls ( / ^ c o m p o s e s $ / , ( declaration ) => {
87- const matches = declaration . value . match ( matchImports ) ;
87+ const multiple = declaration . value . split ( "," ) ;
88+ const values = [ ] ;
8889
89- if ( ! matches ) {
90- return ;
91- }
92-
93- let tmpSymbols ;
94- let [
95- ,
96- /*match*/ symbols ,
97- doubleQuotePath ,
98- singleQuotePath ,
99- global ,
100- ] = matches ;
101-
102- if ( global ) {
103- // Composing globals simply means changing these classes to wrap them in global(name)
104- tmpSymbols = symbols . split ( / \s + / ) . map ( ( s ) => `global(${ s } )` ) ;
105- } else {
106- const importPath = doubleQuotePath || singleQuotePath ;
90+ multiple . forEach ( ( value ) => {
91+ const matches = value . trim ( ) . match ( matchImports ) ;
10792
108- let parent = declaration . parent ;
109- let parentIndexes = "" ;
93+ if ( ! matches ) {
94+ values . push ( value ) ;
11095
111- while ( parent . type !== "root" ) {
112- parentIndexes =
113- parent . parent . index ( parent ) + "_" + parentIndexes ;
114- parent = parent . parent ;
96+ return ;
11597 }
11698
117- const { selector } = declaration . parent ;
118- const parentRule = `_${ parentIndexes } ${ selector } ` ;
119-
120- addImportToGraph ( importPath , parentRule , graph , visited ) ;
99+ let tmpSymbols ;
100+ let [
101+ ,
102+ /*match*/ symbols ,
103+ doubleQuotePath ,
104+ singleQuotePath ,
105+ global ,
106+ ] = matches ;
107+
108+ if ( global ) {
109+ // Composing globals simply means changing these classes to wrap them in global(name)
110+ tmpSymbols = symbols . split ( / \s + / ) . map ( ( s ) => `global(${ s } )` ) ;
111+ } else {
112+ const importPath = doubleQuotePath || singleQuotePath ;
121113
122- importDecls [ importPath ] = declaration ;
123- imports [ importPath ] = imports [ importPath ] || { } ;
114+ let parent = declaration . parent ;
115+ let parentIndexes = "" ;
124116
125- tmpSymbols = symbols . split ( / \s + / ) . map ( ( s ) => {
126- if ( ! imports [ importPath ] [ s ] ) {
127- imports [ importPath ] [ s ] = createImportedName ( s , importPath ) ;
117+ while ( parent . type !== "root" ) {
118+ parentIndexes =
119+ parent . parent . index ( parent ) + "_" + parentIndexes ;
120+ parent = parent . parent ;
128121 }
129122
130- return imports [ importPath ] [ s ] ;
131- } ) ;
132- }
123+ const { selector } = declaration . parent ;
124+ const parentRule = `_${ parentIndexes } ${ selector } ` ;
125+
126+ addImportToGraph ( importPath , parentRule , graph , visited ) ;
127+
128+ importDecls [ importPath ] = declaration ;
129+ imports [ importPath ] = imports [ importPath ] || { } ;
130+
131+ tmpSymbols = symbols . split ( / \s + / ) . map ( ( s ) => {
132+ if ( ! imports [ importPath ] [ s ] ) {
133+ imports [ importPath ] [ s ] = createImportedName ( s , importPath ) ;
134+ }
135+
136+ return imports [ importPath ] [ s ] ;
137+ } ) ;
138+ }
139+
140+ values . push ( tmpSymbols . join ( " " ) ) ;
141+ } ) ;
133142
134- declaration . value = tmpSymbols . join ( " " ) ;
143+ declaration . value = values . join ( ", " ) ;
135144 } ) ;
136145
137146 const importsOrder = topologicalSort ( graph , failOnWrongOrder ) ;
0 commit comments