Skip to content

Commit be306cf

Browse files
committed
typeof require supported
1 parent f28c6ad commit be306cf

4 files changed

Lines changed: 11 additions & 2 deletions

File tree

lib/parse.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,17 @@ function walkExpression(context, expression) {
155155
if(expression.expressions)
156156
walkExpressions(context, expression.expressions);
157157
break;
158-
case "UnaryExpression":
159158
case "UpdateExpression":
160159
walkExpression(context, expression.argument);
161160
break;
161+
case "UnaryExpression":
162+
if(expression.operator === "typeof" &&
163+
expression.argument &&
164+
expression.argument.type === "Identifier" &&
165+
expression.argument.name === "require")
166+
break;
167+
walkExpression(context, expression.argument);
168+
break;
162169
case "BinaryExpression":
163170
case "LogicalExpression":
164171
walkExpression(context, expression.left);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpack",
3-
"version": "0.2.7",
3+
"version": "0.2.8",
44
"author": "Tobias Koppers @sokra",
55
"description": "Packs CommonJs Modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand.",
66
"dependencies": {

test/browsertest/folder/typeof.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = typeof require;

test/browsertest/lib/index.web.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function testCase(number) {
3737
testCase(1);
3838
testCase(2);
3939
testCase(3);
40+
window.test(require("../folder/typeof") === "function", "typeof require should be function");
4041

4142
var error = null;
4243
try {

0 commit comments

Comments
 (0)