Skip to content

Commit

Permalink
Merge pull request #6408 from ocombe/fix/#6407-empty-array
Browse files Browse the repository at this point in the history
fix(ConcatenatedModule): don't throw on arrays with empty values
  • Loading branch information
sokra committed Jan 29, 2018
2 parents 3972d9a + 2aebfbe commit ddb1fad
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/optimize/ConcatenatedModule.js
Expand Up @@ -143,6 +143,7 @@ function getPathInAst(ast, node) {
}

function enterNode(n) {
if(!n) return undefined;
const r = n.range;
if(r) {
if(r[0] <= nr[0] && r[1] >= nr[1]) {
Expand Down
4 changes: 4 additions & 0 deletions test/cases/scope-hoisting/issue-6407/import-one.js
@@ -0,0 +1,4 @@
function foo(n) {
return 'bar';
}
export default [, foo];
4 changes: 4 additions & 0 deletions test/cases/scope-hoisting/issue-6407/import-two.js
@@ -0,0 +1,4 @@
function foo(n) {
return 'bar';
}
export default [, foo];
11 changes: 11 additions & 0 deletions test/cases/scope-hoisting/issue-6407/index.js
@@ -0,0 +1,11 @@
import importOne from './import-one';
import importTwo from './import-two';

it("should concatenate modules default exports and empty array values", function() {
importOne.length.should.be.eql(2);
(typeof importOne[0]).should.be.eql('undefined');
(typeof importOne[1]).should.be.eql('function');
importTwo.length.should.be.eql(2);
(typeof importTwo[0]).should.be.eql('undefined');
(typeof importTwo[1]).should.be.eql('function');
});

0 comments on commit ddb1fad

Please sign in to comment.