Skip to content

Commit

Permalink
Merge branch 'fix-1365' of https://github.com/chrisirhc/module-deps i…
Browse files Browse the repository at this point in the history
…nto streams3
  • Loading branch information
James Halliday committed Oct 16, 2015
2 parents 2014f51 + fc7695a commit 7a98124
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions index.js
Expand Up @@ -157,7 +157,7 @@ Deps.prototype.resolve = function (id, parent, cb) {
if (opts.extensions) parent.extensions = opts.extensions;
if (opts.modules) parent.modules = opts.modules;

self.resolver(id, parent, function onresolve (err, file, pkg) {
self.resolver(id, parent, function onresolve (err, file, pkg, fakePath) {
if (err) return cb(err);
if (!file) return cb(new Error(
'module not found: "' + id + '" from file '
Expand All @@ -171,11 +171,12 @@ Deps.prototype.resolve = function (id, parent, cb) {
if (!p.__dirname) p.__dirname = path.dirname(file);
self.pkgCache[file] = p;
onresolve(err, file, opts.packageFilter
? opts.packageFilter(p, p.__dirname) : p
? opts.packageFilter(p, p.__dirname) : p,
fakePath
);
});
}
else cb(err, file, pkg);
else cb(err, file, pkg, fakePath);
});
};

Expand All @@ -194,6 +195,7 @@ Deps.prototype.readFile = function (file, id, pkg) {
};

Deps.prototype.getTransforms = function (file, pkg, opts) {
// TODO: Needs FAKE path here.
if (!opts) opts = {};
var self = this;

Expand Down Expand Up @@ -308,7 +310,7 @@ Deps.prototype.walk = function (id, parent, cb) {
this.inputPending ++;
}

self.resolve(id, parent, function (err, file, pkg) {
self.resolve(id, parent, function (err, file, pkg, fakePath) {
if (rec.expose) {
// Set options.expose to make the resolved pathname available to the
// caller. They may or may not have requested it, but it's harmless
Expand Down Expand Up @@ -363,7 +365,7 @@ Deps.prototype.walk = function (id, parent, cb) {
if (c) return fromDeps(file, c.source, c.package, Object.keys(c.deps));

self.readFile(file, id, pkg)
.pipe(self.getTransforms(file, pkg, {
.pipe(self.getTransforms(fakePath || file, pkg, {
builtin: has(parent.modules, id)
}))
.pipe(concat(function (body) {
Expand Down

0 comments on commit 7a98124

Please sign in to comment.