@@ -6,6 +6,7 @@ const identity = require('lodash').identity;
6
6
const readFileSync = require ( 'fs' ) . readFileSync ;
7
7
const relative = require ( 'path' ) . relative ;
8
8
const resolve = require ( 'path' ) . resolve ;
9
+ const validate = require ( './validate' ) ;
9
10
10
11
const postcss = require ( 'postcss' ) ;
11
12
const Values = require ( 'postcss-modules-values' ) ;
@@ -27,19 +28,23 @@ module.exports = function setupHook({
27
28
use,
28
29
rootDir : context = process . cwd ( ) ,
29
30
} ) {
31
+ validate ( arguments [ 0 ] ) ;
32
+
30
33
const tokensByFile = { } ;
31
34
32
- let scopedName = function ( ) { } ;
35
+ let scopedName ;
33
36
if ( generateScopedName ) {
34
37
scopedName = typeof generateScopedName !== 'function'
35
38
? genericNames ( generateScopedName || '[name]__[local]___[hash:base64:5]' , { context} )
36
39
: generateScopedName ;
37
40
} else {
38
41
// 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
+ } ;
40
45
}
41
46
42
- const plugins = [
47
+ const plugins = ( use || [
43
48
...prepend ,
44
49
Values ,
45
50
mode
@@ -50,7 +55,7 @@ module.exports = function setupHook({
50
55
: ExtractImports ,
51
56
new Scope ( { generateScopedName : scopedName } ) ,
52
57
...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;
54
59
55
60
// https://github.com/postcss/postcss#options
56
61
const runner = postcss ( plugins ) ;
0 commit comments