|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +import Parser from 'css-modules-loader-core/lib/parser'; |
| 4 | + |
| 5 | +class SyncParser extends Parser { |
| 6 | + plugin(css, result) { |
| 7 | + this.fetchAllImports(css); |
| 8 | + this.linkImportedSymbols(css); |
| 9 | + this.extractExports(css); |
| 10 | + } |
| 11 | + |
| 12 | + fetchImport(importNode, relativeTo, depNr) { |
| 13 | + let file = importNode.selector.match( importRegexp )[1]; |
| 14 | + let depTrace = this.trace + String.fromCharCode(depNr); |
| 15 | + let exp = this.pathFetcher(file, relativeTo, depTrace); |
| 16 | + |
| 17 | + importNode.each(decl => { |
| 18 | + if (decl.type === 'decl') { |
| 19 | + this.translations[decl.prop] = exports[decl.value] |
| 20 | + } |
| 21 | + }); |
| 22 | + |
| 23 | + importNode.removeSelf(); |
| 24 | + } |
| 25 | + |
| 26 | + fetchImport( importNode, relativeTo, depNr ) { |
| 27 | + let file = importNode.selector.match( importRegexp )[1], |
| 28 | + depTrace = this.trace + String.fromCharCode(depNr) |
| 29 | + return this.pathFetcher( file, relativeTo, depTrace ).then( exports => { |
| 30 | + importNode.each( decl => { |
| 31 | + if ( decl.type == 'decl' ) { |
| 32 | + this.translations[decl.prop] = exports[decl.value] |
| 33 | + } |
| 34 | + } ) |
| 35 | + importNode.removeSelf() |
| 36 | + }, err => console.log( err ) ) |
| 37 | + } |
| 38 | +} |
| 39 | + |
| 40 | +export default SyncParser; |
0 commit comments