Skip to content

Commit aa64869

Browse files
committed
Merge pull request #83 from substack/unique-parent-obj
Ensure "resolve" gets its own copy of "parent"
2 parents 5650c1f + d2c1e10 commit aa64869

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

index.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ Deps.prototype.walk = function (id, parent, cb) {
332332
var ts = self.getTransforms(file, pkg);
333333
ts.pipe(concat(function (body) {
334334
rec.source = body.toString('utf8');
335-
fromSource(rec.source);
335+
fromSource(file, rec.source, pkg);
336336
}));
337337
return ts.end(rec.source);
338338
}
@@ -354,7 +354,7 @@ Deps.prototype.walk = function (id, parent, cb) {
354354
var ts = self.getTransforms(file, pkg);
355355
ts.pipe(concat(function (body) {
356356
rec.source = body.toString('utf8');
357-
fromSource(rec.source);
357+
fromSource(file, rec.source, pkg);
358358
}));
359359
return ts.end(rec.source);
360360
}
@@ -367,24 +367,18 @@ Deps.prototype.walk = function (id, parent, cb) {
367367
builtin: has(parent.modules, id)
368368
}))
369369
.pipe(concat(function (body) {
370-
fromSource(body.toString('utf8'));
370+
fromSource(file, body.toString('utf8'), pkg);
371371
}))
372372
;
373-
374-
function fromSource (src) {
375-
var deps = rec.noparse ? [] : self.parseDeps(file, src);
376-
if (deps) fromDeps(file, src, pkg, deps);
377-
}
378373
});
374+
375+
function fromSource (file, src, pkg) {
376+
var deps = rec.noparse ? [] : self.parseDeps(file, src);
377+
if (deps) fromDeps(file, src, pkg, deps);
378+
}
379379

380380
function fromDeps (file, src, pkg, deps) {
381381
var p = deps.length;
382-
var current = {
383-
id: file,
384-
filename: file,
385-
paths: self.paths,
386-
package: pkg
387-
};
388382
var resolved = {};
389383

390384
if (input) --self.inputPending;
@@ -397,6 +391,12 @@ Deps.prototype.walk = function (id, parent, cb) {
397391
if (--p === 0) done();
398392
return;
399393
}
394+
var current = {
395+
id: file,
396+
filename: file,
397+
paths: self.paths,
398+
package: pkg
399+
};
400400
self.walk(id, current, function (err, r) {
401401
resolved[id] = r;
402402
if (--p === 0) done();

0 commit comments

Comments
 (0)