Skip to content
This repository has been archived by the owner on Oct 9, 2020. It is now read-only.

Commit

Permalink
handle array bundling consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
guybedford committed Aug 30, 2016
1 parent fede396 commit dc7e502
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
19 changes: 18 additions & 1 deletion lib/arithmetic.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,23 @@ exports.traceExpression = function(builder, expression, traceOpts) {
if (!expression)
throw new Error('A module expression must be provided to trace.');

if (expression instanceof Array) {
var tree = {};
return Promise.all(expression.map(function(moduleName) {
return builder.loader.normalize(moduleName)
.then(function(normalized) {
var canonical = builder.getCanonicalName(normalized);
return builder.tracer.getLoadRecord(canonical, traceOpts)
.then(function(load) {
tree[canonical] = load;
});
});
}))
.then(function() {
return tree;
});
}

return Promise
.resolve(expandAndCanonicalizeExpression(builder, expression))
.then(function processExpandedOperations(expandedOperations) {
Expand All @@ -249,7 +266,7 @@ exports.traceExpression = function(builder, expression, traceOpts) {
});
};

function expandAndCanonicalizeExpression(builder, expression){
function expandAndCanonicalizeExpression(builder, expression) {
var operations = parseExpression(expression);
var expandPromise = Promise.resolve(1);
var expandedOperations = [];
Expand Down
10 changes: 2 additions & 8 deletions lib/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -656,10 +656,7 @@ Builder.prototype.bundle = function(expressionOrTree, outFile, opts) {

return Promise.resolve()
.then(function() {
if (expressionOrTree instanceof Array)
expressionOrTree = '[' + expressionOrTree.join('] + [') + ']';

if (typeof expressionOrTree != 'string')
if (typeof expressionOrTree != 'string' && !(expressionOrTree instanceof Array))
return expressionOrTree;

return setExternals(self, traceOpts.externals)
Expand Down Expand Up @@ -733,10 +730,7 @@ Builder.prototype.buildStatic = function(expressionOrTree, outFile, opts) {

return Promise.resolve()
.then(function() {
if (expressionOrTree instanceof Array)
expressionOrTree = '[' + expressionOrTree.join('] + [') + ']';

if (typeof expressionOrTree != 'string')
if (typeof expressionOrTree != 'string' && !(expressionOrTree instanceof Array))
return expressionOrTree;

return setExternals(self, traceOpts.externals)
Expand Down

0 comments on commit dc7e502

Please sign in to comment.