Skip to content

Commit

Permalink
Fixed Parser so that this Expression can work with ProvidePlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
nveenjain committed Feb 27, 2018
1 parent 5044762 commit 1ab9fdb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2008,7 +2008,7 @@ class Parser extends Tapable {
free = true;
exprName.push(this.scope.renames.get("this"));
} else if (expr.type === "ThisExpression") {
free = false;
free = this.scope.topLevelScope;
exprName.push("this");
} else {
return null;
Expand Down
4 changes: 4 additions & 0 deletions test/configCases/plugins/provide-plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ it("should provide a module for a nested var within a IIFE's argument", function
}(process));
});

it("should provide a module for thisExpression", () => {
(this.aaa).should.be.eql("aaa");
});

it("should provide a module for a nested var within a IIFE's this", function() {
(function() {
(this.env.NODE_ENV).should.be.eql("development");
Expand Down
3 changes: 2 additions & 1 deletion test/configCases/plugins/provide-plugin/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ module.exports = {
es2015: "./harmony",
es2015_name: ["./harmony", "default"],
es2015_alias: ["./harmony", "alias"],
es2015_year: ["./harmony", "year"]
es2015_year: ["./harmony", "year"],
"this.aaa": "./aaa"
})
]
};

0 comments on commit 1ab9fdb

Please sign in to comment.