Skip to content

Commit

Permalink
support parsing null dependencies. fix #2
Browse files Browse the repository at this point in the history
  • Loading branch information
lepture committed Apr 19, 2013
1 parent 424dfd8 commit cacb749
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,12 @@ function getDefine(node) {
return el.getValue();
}
});
dependencyNode = secondChild;
} else if (secondChild instanceof UglifyJS.AST_Null) {
if (factory instanceof UglifyJS.AST_Function) {
dependencies = getRequires(factory);
}
}
dependencyNode = secondChild;
}
}
return {
Expand Down
9 changes: 9 additions & 0 deletions tests/ast.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ describe('ast.parse', function() {
].join('\n');
ast.parseFirst(code).id.should.equal('jquery');
});

it('can parse null dependencies', function() {
var code = [
"define('id', null, function(require) {",
" require('jquery');",
"})"
].join('\n');
ast.parseFirst(code).dependencies.should.eql(['jquery']);
});
});

describe('ast.modify', function() {
Expand Down

0 comments on commit cacb749

Please sign in to comment.