Skip to content

Commit 53496a0

Browse files
committed
Added addDependency for required files and cleared require cache in order to fix Webpack watch
1 parent 08ec36a commit 53496a0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

index.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ const operator = {
3636

3737
getVarData (modulePath, webpackContext) {
3838
return modulePath.reduce( (accumulator, currentPath) => {
39-
const moduleData = (currentPath.methodName)? require(path.join(webpackContext.context, currentPath.path))[currentPath.methodName] : require(path.join(webpackContext.context, currentPath.path));
39+
const modulePath = path.join(webpackContext.context, currentPath.path);
40+
delete require.cache[require.resolve(modulePath)];
41+
const moduleData = (currentPath.methodName)? require(modulePath)[currentPath.methodName] : require(modulePath);
42+
webpackContext.addDependency(modulePath)
4043
return Object.assign(accumulator, moduleData);
4144
}, {});
4245
},

0 commit comments

Comments
 (0)