Skip to content

Commit 2610c1c

Browse files
author
James Halliday
committed
fixes for implicit and explicit extensions
1 parent dec0145 commit 2610c1c

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

index.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ function find_shims_in_package(pkgJson, cur_path, shims, browser) {
7070
}
7171
shims[key] = val;
7272
});
73+
74+
[ '.js', '.json' ].forEach(function (ext) {
75+
Object.keys(shims).forEach(function (key) {
76+
if (!shims[key + ext]) {
77+
shims[key + ext] = shims[key];
78+
}
79+
});
80+
});
7381
}
7482

7583
// paths is mutated
@@ -229,14 +237,18 @@ function resolve(id, opts, cb) {
229237
return cb(err);
230238
}
231239

232-
if (shims[id]) {
240+
var resid = path.resolve(opts.basedir || path.dirname(opts.filename), id)
241+
if (shims[id] || shims[resid]) {
242+
var xid = shims[id] ? id : resid
233243
// if the shim was is an absolute path, it was fully resolved
234-
if (shims[id][0] === '/') {
235-
return cb(null, shims[id], opts.package);
244+
if (shims[xid][0] === '/') {
245+
return resv(shims[xid], build_resolve_opts(opts, base), function(err, full, pkg) {
246+
cb(null, full, pkg);
247+
});
236248
}
237249

238250
// module -> alt-module shims
239-
id = shims[id];
251+
id = shims[xid];
240252
}
241253

242254
var modules = opts.modules || Object.create(null);

0 commit comments

Comments
 (0)