11import debug from 'debug' ;
22import hook from './hook' ;
33import identity from 'lodash.identity' ;
4- import { get } from './extractor' ;
4+ import extractor from './extractor' ;
55import { readFileSync } from 'fs' ;
66import { dirname , resolve } from 'path' ;
77import { removeQuotes } from './utility' ;
88
99// cache
1010let tokensByFile = { } ;
1111// global
12- let extractorOptions ;
12+ let instance = extractor ( { } , fetch ) ;
1313let processorOptions = { } ;
1414let preProcess = identity ;
1515let postProcess ;
@@ -26,7 +26,7 @@ const debugSetup = debug('css-modules:setup');
2626 */
2727export default function setup ( { extensions : extraExtensions , preprocessCss, processCss, to, ...rest } = { } ) {
2828 debugSetup ( arguments [ 0 ] ) ;
29- extractorOptions = rest ;
29+ instance = extractor ( rest , fetch ) ;
3030 processorOptions = { to} ;
3131 preProcess = preprocessCss || identity ;
3232 postProcess = processCss || null ;
@@ -60,8 +60,7 @@ function fetch(_to, from) {
6060 debugFetch ( { cache : false , filename} ) ;
6161 const CSSSource = preProcess ( readFileSync ( filename , 'utf8' ) , filename ) ;
6262 // 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 } ) ) ;
6564
6665 // https://github.com/postcss/postcss/blob/master/docs/api.md#lazywarnings
6766 lazyResult . warnings ( ) . forEach ( message => console . warn ( message . text ) ) ;
0 commit comments