@@ -9,7 +9,7 @@ export default class Parser {
99 }
1010
1111 plugin ( css , result ) {
12- return this . fetchAllImports ( css )
12+ return Promise . all ( this . fetchAllImports ( css ) )
1313 . then ( _ => this . extractExports ( css ) )
1414 }
1515
@@ -20,13 +20,7 @@ export default class Parser {
2020 imports . push ( this . fetchImport ( node , css . source . input . from ) )
2121 }
2222 } )
23- return Promise . all ( imports )
24- . then ( fetchedState => {
25- return Promise . all ( fetchedState . map (
26- ( { loaderData, propResolver} ) =>
27- this . pathFetcher . load ( loaderData ) . then ( propResolver )
28- ) )
29- } )
23+ return imports
3024 }
3125
3226 extractExports ( css ) {
@@ -38,8 +32,8 @@ export default class Parser {
3832 handleExport ( exportNode ) {
3933 exportNode . each ( decl => {
4034 if ( decl . type == 'decl' ) {
41- Object . keys ( this . translations ) . forEach ( translation => {
42- decl . value = decl . value . replace ( translation , this . translations [ translation ] )
35+ Object . keys ( this . translations ) . forEach ( translation => {
36+ decl . value = decl . value . replace ( translation , this . translations [ translation ] )
4337 } )
4438 this . exportTokens [ decl . prop ] = decl . value
4539 }
@@ -49,19 +43,13 @@ export default class Parser {
4943
5044 fetchImport ( importNode , relativeTo ) {
5145 let file = importNode . selector . match ( importRegexp ) [ 1 ]
52- console . log ( "FETCHING " + file )
53- return this . pathFetcher . fetch ( file , relativeTo )
54- . then ( state => {
55- state . propResolver = exports => {
56- console . log ( "RESOLVING " + file )
57- importNode . each ( decl => {
58- if ( decl . type == 'decl' ) {
59- this . translations [ decl . value ] = exports [ decl . prop ]
60- }
61- } )
62- importNode . removeSelf ( )
46+ return this . pathFetcher ( file , relativeTo ) . then ( exports => {
47+ importNode . each ( decl => {
48+ if ( decl . type == 'decl' ) {
49+ this . translations [ decl . value ] = exports [ decl . prop ]
6350 }
64- return state
65- } )
51+ } )
52+ importNode . removeSelf ( )
53+ } , err => console . log ( err ) )
6654 }
6755}
0 commit comments