File tree 3 files changed +6
-1
lines changed
3 files changed +6
-1
lines changed Original file line number Diff line number Diff line change 1
1
import path from 'path' ;
2
2
const loader = require ( '../index' ) . default ;
3
+ jest . mock ( 'decache' ) ;
3
4
const { operator } = require ( '../index' ) ;
4
5
5
6
describe ( 'js-to-styles-vars-loader' , ( ) => {
Original file line number Diff line number Diff line change 1
1
const path = require ( 'path' ) ;
2
+ const decache = require ( 'decache' ) ;
2
3
3
4
const requireReg = / r e q u i r e \s * \( [ ' | " ] ( .+ ) [ ' | " ] \) (?: \. ( [ ^ ; \s ] + ) ) ? [ ; \s ] / g;
4
5
@@ -37,7 +38,7 @@ const operator = {
37
38
getVarData ( modulePath , webpackContext ) {
38
39
return modulePath . reduce ( ( accumulator , currentPath ) => {
39
40
const modulePath = path . join ( webpackContext . context , currentPath . path ) ;
40
- delete require . cache [ require . resolve ( modulePath ) ] ;
41
+ decache ( modulePath ) ;
41
42
const moduleData = ( currentPath . methodName ) ? require ( modulePath ) [ currentPath . methodName ] : require ( modulePath ) ;
42
43
webpackContext . addDependency ( modulePath ) ;
43
44
return Object . assign ( accumulator , moduleData ) ;
Original file line number Diff line number Diff line change 31
31
"babel-preset-es2015" : " ^6.24.0" ,
32
32
"coveralls" : " ^2.12.0" ,
33
33
"jest" : " ^19.0.2"
34
+ },
35
+ "dependencies" : {
36
+ "decache" : " ^4.1.0"
34
37
}
35
38
}
You can’t perform that action at this time.
0 commit comments