1
1
import debug from 'debug' ;
2
2
import hook from './hook' ;
3
3
import identity from 'lodash.identity' ;
4
- import { get } from './extractor' ;
4
+ import extractor from './extractor' ;
5
5
import { readFileSync } from 'fs' ;
6
6
import { dirname , resolve } from 'path' ;
7
7
import { removeQuotes } from './utility' ;
8
8
9
9
// cache
10
10
let tokensByFile = { } ;
11
11
// global
12
- let extractorOptions ;
12
+ let instance = extractor ( { } , fetch ) ;
13
13
let processorOptions = { } ;
14
14
let preProcess = identity ;
15
15
let postProcess ;
@@ -26,7 +26,7 @@ const debugSetup = debug('css-modules:setup');
26
26
*/
27
27
export default function setup ( { extensions : extraExtensions , preprocessCss, processCss, to, ...rest } = { } ) {
28
28
debugSetup ( arguments [ 0 ] ) ;
29
- extractorOptions = rest ;
29
+ instance = extractor ( rest , fetch ) ;
30
30
processorOptions = { to} ;
31
31
preProcess = preprocessCss || identity ;
32
32
postProcess = processCss || null ;
@@ -60,8 +60,7 @@ function fetch(_to, from) {
60
60
debugFetch ( { cache : false , filename} ) ;
61
61
const CSSSource = preProcess ( readFileSync ( filename , 'utf8' ) , filename ) ;
62
62
// https://github.com/postcss/postcss/blob/master/docs/api.md#processorprocesscss-opts
63
- const lazyResult = get ( extractorOptions , fetch )
64
- . process ( CSSSource , Object . assign ( processorOptions , { from : filename } ) ) ;
63
+ const lazyResult = instance . process ( CSSSource , Object . assign ( processorOptions , { from : filename } ) ) ;
65
64
66
65
// https://github.com/postcss/postcss/blob/master/docs/api.md#lazywarnings
67
66
lazyResult . warnings ( ) . forEach ( message => console . warn ( message . text ) ) ;
0 commit comments