@@ -6,6 +6,7 @@ const identity = require('lodash').identity;
66const readFileSync = require ( 'fs' ) . readFileSync ;
77const relative = require ( 'path' ) . relative ;
88const resolve = require ( 'path' ) . resolve ;
9+ const validate = require ( './validate' ) ;
910
1011const postcss = require ( 'postcss' ) ;
1112const Values = require ( 'postcss-modules-values' ) ;
@@ -27,19 +28,23 @@ module.exports = function setupHook({
2728 use,
2829 rootDir : context = process . cwd ( ) ,
2930} ) {
31+ validate ( arguments [ 0 ] ) ;
32+
3033 const tokensByFile = { } ;
3134
32- let scopedName = function ( ) { } ;
35+ let scopedName ;
3336 if ( generateScopedName ) {
3437 scopedName = typeof generateScopedName !== 'function'
3538 ? genericNames ( generateScopedName || '[name]__[local]___[hash:base64:5]' , { context} )
3639 : generateScopedName ;
3740 } else {
3841 // small fallback
39- scopedName = ( local , filename ) => Scope . generateScopedName ( local , relative ( context , filename ) ) ;
42+ scopedName = ( local , filename ) => {
43+ return Scope . generateScopedName ( local , relative ( context , filename ) ) ;
44+ } ;
4045 }
4146
42- const plugins = [
47+ const plugins = ( use || [
4348 ...prepend ,
4449 Values ,
4550 mode
@@ -50,7 +55,7 @@ module.exports = function setupHook({
5055 : ExtractImports ,
5156 new Scope ( { generateScopedName : scopedName } ) ,
5257 ...append ,
53- ] . concat ( new Parser ( { fetch} ) ) ; // no pushing in order to avoid the possible mutations;
58+ ] ) . concat ( new Parser ( { fetch} ) ) ; // no pushing in order to avoid the possible mutations;
5459
5560 // https://github.com/postcss/postcss#options
5661 const runner = postcss ( plugins ) ;
0 commit comments