Skip to content

Commit d661eb1

Browse files
committed
Fix: setConstant and setModuleConstant now function correctly again.
Previously, __filename, __dirname, and other constants were broken. This was due to the refactor of setConstant and setModuleConstant, and the reuse of the variable name "expr"
1 parent 197d2f2 commit d661eb1

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

‎lib/NodeStuffPlugin.js‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ NodeStuffPlugin.prototype.apply = function(compiler) {
2121
compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template());
2222
});
2323
function ignore() { return true; }
24-
function setConstant(expr, value) {
25-
compiler.parser.plugin("expression " + expr, function(expr) {
26-
this.state.current.addVariable(expr, JSON.stringify(value));
24+
function setConstant(expressionName, value) {
25+
compiler.parser.plugin("expression " + expressionName, function(expr) {
26+
this.state.current.addVariable(expressionName, JSON.stringify(value));
2727
return true;
28-
});
28+
});
2929
}
30-
function setModuleConstant(expr, fn) {
31-
compiler.parser.plugin("expression " + expr, function(expr) {
32-
this.state.current.addVariable(expr, JSON.stringify(fn(this.state.module)));
30+
function setModuleConstant(expressionName, fn) {
31+
compiler.parser.plugin("expression " + expressionName, function(expr) {
32+
this.state.current.addVariable(expressionName, JSON.stringify(fn(this.state.module)));
3333
return true;
34-
});
34+
});
3535
}
3636
var context = compiler.context;
3737
if(this.options.__filename === "mock") {

0 commit comments

Comments
 (0)