@@ -17,21 +17,8 @@ const ExtractImports = require('postcss-modules-extract-imports');
17
17
const Scope = require ( 'postcss-modules-scope' ) ;
18
18
const Parser = require ( 'postcss-modules-parser' ) ;
19
19
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' ) ;
35
22
36
23
module . exports = function setupHook ( {
37
24
extensions = '.css' ,
@@ -47,6 +34,7 @@ module.exports = function setupHook({
47
34
use,
48
35
rootDir : context = process . cwd ( ) ,
49
36
} ) {
37
+ debugSetup ( arguments [ 0 ] ) ;
50
38
validate ( arguments [ 0 ] ) ;
51
39
52
40
const tokensByFile = { } ;
@@ -93,9 +81,12 @@ module.exports = function setupHook({
93
81
? require . resolve ( _to )
94
82
: resolve ( dirname ( from ) , _to ) ;
95
83
84
+
96
85
// checking cache
97
86
let tokens = tokensByFile [ filename ] ;
98
87
if ( tokens ) {
88
+ debugFetch ( `${ filename } → cache` ) ;
89
+ debugFetch ( tokens ) ;
99
90
return tokens ;
100
91
}
101
92
@@ -120,10 +111,29 @@ module.exports = function setupHook({
120
111
processCss ( lazyResult . css , filename ) ;
121
112
}
122
113
114
+ debugFetch ( `${ filename } → fs` ) ;
115
+ debugFetch ( tokens ) ;
116
+
123
117
return tokens ;
124
118
} ;
125
119
126
120
const isException = buildExceptionChecker ( ignore ) ;
127
121
128
122
attachHook ( filename => fetch ( filename , filename ) , '.css' , isException ) ;
129
123
} ;
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