@@ -17,21 +17,8 @@ const ExtractImports = require('postcss-modules-extract-imports');
1717const Scope = require ( 'postcss-modules-scope' ) ;
1818const Parser = require ( 'postcss-modules-parser' ) ;
1919
20- /**
21- * @param {function|regex|string } ignore glob, regex or function
22- * @return {function }
23- */
24- function buildExceptionChecker ( ignore ) {
25- if ( ignore instanceof RegExp ) {
26- return filepath => ignore . test ( filepath ) ;
27- }
28-
29- if ( typeof ignore === 'string' ) {
30- return filepath => globToRegex ( ignore ) . test ( filepath ) ;
31- }
32-
33- return ignore || negate ( identity ) ;
34- }
20+ const debugFetch = require ( 'debug' ) ( 'css-modules:fetch' ) ;
21+ const debugSetup = require ( 'debug' ) ( 'css-modules:setup' ) ;
3522
3623module . exports = function setupHook ( {
3724 extensions = '.css' ,
@@ -47,6 +34,7 @@ module.exports = function setupHook({
4734 use,
4835 rootDir : context = process . cwd ( ) ,
4936} ) {
37+ debugSetup ( arguments [ 0 ] ) ;
5038 validate ( arguments [ 0 ] ) ;
5139
5240 const tokensByFile = { } ;
@@ -93,9 +81,12 @@ module.exports = function setupHook({
9381 ? require . resolve ( _to )
9482 : resolve ( dirname ( from ) , _to ) ;
9583
84+
9685 // checking cache
9786 let tokens = tokensByFile [ filename ] ;
9887 if ( tokens ) {
88+ debugFetch ( `${ filename } → cache` ) ;
89+ debugFetch ( tokens ) ;
9990 return tokens ;
10091 }
10192
@@ -120,10 +111,29 @@ module.exports = function setupHook({
120111 processCss ( lazyResult . css , filename ) ;
121112 }
122113
114+ debugFetch ( `${ filename } → fs` ) ;
115+ debugFetch ( tokens ) ;
116+
123117 return tokens ;
124118 } ;
125119
126120 const isException = buildExceptionChecker ( ignore ) ;
127121
128122 attachHook ( filename => fetch ( filename , filename ) , '.css' , isException ) ;
129123} ;
124+
125+ /**
126+ * @param {function|regex|string } ignore glob, regex or function
127+ * @return {function }
128+ */
129+ function buildExceptionChecker ( ignore ) {
130+ if ( ignore instanceof RegExp ) {
131+ return filepath => ignore . test ( filepath ) ;
132+ }
133+
134+ if ( typeof ignore === 'string' ) {
135+ return filepath => globToRegex ( ignore ) . test ( filepath ) ;
136+ }
137+
138+ return ignore || negate ( identity ) ;
139+ }
0 commit comments