Skip to content

Commit c2cc1dd

Browse files
committed
Fix webpack#412 - Support for holes inside Arrays
An array with a hole such as `[,'foo']` is parsed by Esprima as null. Skip its evaluation. Reference: https://code.google.com/p/esprima/issues/detail?id=525#c18 ``` According to https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API#Expressions: interface ArrayExpression <: Expression { type: "ArrayExpression"; elements: [ Expression | null ]; } ```
1 parent 2a419cc commit c2cc1dd

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

lib/Parser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ Parser.prototype.initializeEvaluating = function() {
310310
});
311311
this.plugin("evaluate ArrayExpression", function(expr) {
312312
var items = expr.elements.map(function(element) {
313-
return this.evaluateExpression(element);
313+
return element !== null && this.evaluateExpression(element);
314314
}, this);
315315
if(items.filter(function(i) { return !i; }).length > 0) return;
316316
return new BasicEvaluatedExpression().setItems(items).setRange(expr.range);

0 commit comments

Comments
 (0)