Skip to content

Commit

Permalink
only check for index file when no export pattern is defined, package …
Browse files Browse the repository at this point in the history
…is cjs
  • Loading branch information
bumblehead committed Aug 19, 2022
1 parent 9555024 commit ab99e2d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions resolvewithplus.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,6 @@ export default (o => {
return indexval;
};

o.getpackagepath = (jsonfile, opts) => (
o.isfilesync(jsonfile) && (jsonfile = require(jsonfile)) &&
(o.gettargetindex(jsonfile, opts) || jsonfile.main));

// https://nodejs.org/api/modules.html#modules_module_require_id
//
// LOAD_AS_FILE(X)
Expand Down Expand Up @@ -181,8 +177,10 @@ export default (o => {
let filepath = null;
let relpath;
let json = path.join(d, packagejson);

if ((relpath = o.getpackagepath(json, opts))) {
let jsonobj = o.isfilesync(json) && require(json);
if ((relpath = o.gettargetindex(jsonobj, opts))) {
filepath = o.getasfilesync(path.join(d, relpath))
} else if ((relpath = jsonobj.main)) {
filepath = o.getasfilesync(path.join(d, relpath))
|| o.getasfilesync(path.join(d, path.join(relpath, 'index')));
} else {
Expand Down

0 comments on commit ab99e2d

Please sign in to comment.