Skip to content

Commit 2f3e0ae

Browse files
committed
remove (...) from DefinePlugin.
webpack#729
1 parent 0c8d94f commit 2f3e0ae

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎lib/DefinePlugin.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ DefinePlugin.prototype.apply = function(compiler) {
6868
return res;
6969
});
7070
compiler.parser.plugin("expression " + key, function(expr) {
71-
var dep = new ConstDependency("("+code+")", expr.range);
71+
var dep = new ConstDependency(code, expr.range);
7272
dep.loc = expr.loc;
7373
this.state.current.addDependency(dep);
7474
return true;
@@ -104,7 +104,7 @@ DefinePlugin.prototype.apply = function(compiler) {
104104
return new BasicEvaluatedExpression().setString("object").setRange(expr.range);
105105
});
106106
compiler.parser.plugin("expression " + key, function(expr) {
107-
var dep = new ConstDependency("("+code+")", expr.range);
107+
var dep = new ConstDependency(code, expr.range);
108108
dep.loc = expr.loc;
109109
this.state.current.addDependency(dep);
110110
return true;

‎test/configCases/plugins/define-plugin/index.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ it("should define CODE", function() {
55
if(typeof CODE !== "number") require("fail");
66
});
77
it("should define FUNCTION", function() {
8-
FUNCTION(5).should.be.eql(6);
8+
(FUNCTION(5)).should.be.eql(6);
99
(typeof FUNCTION).should.be.eql("function");
1010
if(typeof FUNCTION !== "function") require("fail");
1111
});
@@ -34,7 +34,7 @@ it("should define OBJECT.SUB.CODE", function() {
3434
}(OBJECT.SUB));
3535
});
3636
it("should define process.env.DEFINED_NESTED_KEY", function() {
37-
process.env.DEFINED_NESTED_KEY.should.be.eql(5);
37+
(process.env.DEFINED_NESTED_KEY).should.be.eql(5);
3838
(typeof process.env.DEFINED_NESTED_KEY).should.be.eql("number");
3939
if(process.env.DEFINED_NESTED_KEY !== 5) require("fail");
4040
if(typeof process.env.DEFINED_NESTED_KEY !== "number") require("fail");
@@ -46,7 +46,7 @@ it("should define process.env.DEFINED_NESTED_KEY", function() {
4646
(indirect.DEFINED_NESTED_KEY).should.be.eql(5);
4747

4848
(function(env) {
49-
env.DEFINED_NESTED_KEY.should.be.eql(5);
49+
(env.DEFINED_NESTED_KEY).should.be.eql(5);
5050
(typeof env.DEFINED_NESTED_KEY).should.be.eql("number");
5151
if(env.DEFINED_NESTED_KEY !== 5) require("fail");
5252
if(typeof env.DEFINED_NESTED_KEY !== "number") require("fail");

‎test/configCases/plugins/define-plugin/webpack.config.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ module.exports = {
1010
SUB: {
1111
UNDEFINED: undefined,
1212
FUNCTION: function(a) { return a + 1; },
13-
CODE: "1+2",
13+
CODE: "(1+2)",
1414
REGEXP: /abc/i
1515
}
1616
},

0 commit comments

Comments
 (0)