@@ -8,6 +8,7 @@ import LocalByDefault from 'postcss-modules-local-by-default';
88import Scope from 'postcss-modules-scope' ;
99import Parser from './parser' ;
1010
11+ let importNr = 0 ;
1112let plugins = [ ExtractImports , LocalByDefault , Scope ] ;
1213let rootDir = process . cwd ( ) ;
1314
@@ -16,15 +17,16 @@ export default function (opts = {}) {
1617 rootDir = opts . rootDir ? opts . rootDir : process . cwd ( ) ;
1718}
1819
19- function pathFetcher ( _newPath , sourcePath , trace ) {
20+ function pathFetcher ( _newPath , sourcePath , _trace ) {
21+ const trace = _trace || String . fromCharCode ( importNr ++ ) ;
2022 const newPath = _newPath . replace ( / ^ [ " ' ] | [ " ' ] $ / g, '' ) ;
2123 const filename = / \w / . test ( newPath [ 0 ] )
2224 ? require . resolve ( newPath )
2325 : resolve ( rootDir + dirname ( sourcePath ) , newPath ) ;
2426 const rootRelativePath = sep + relative ( rootDir , filename ) ;
25- const source = readFileSync ( filename , 'utf-8 ' ) ;
27+ const source = readFileSync ( filename , 'utf8 ' ) ;
2628
27- const result = postcss ( plugins . concat ( new Parser ( { pathFetcher } ) ) )
29+ const result = postcss ( plugins . concat ( new Parser ( { pathFetcher, trace } ) ) )
2830 // preprocess
2931 . process ( source , { from : rootRelativePath } )
3032 . root ;
0 commit comments