10000 Handle both missing pkg and missing main attr (#174) · lodash/babel-plugin-lodash@0c87f2a · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Sep 16, 2023. It is now read-only.

Commit 0c87f2a

Browse files
albertogasparinjdalton
authored andcommitted
Handle both missing pkg and missing main attr (#174)
1 parent d79d061 commit 0c87f2a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ModuleCache.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export default class ModuleCache extends MapCache {
1717
return;
1818
}
1919
const pkgPath = path.join(moduleRoot, 'package.json');
20-
const pkg = fs.existsSync(pkgPath) ? require(pkgPath) : { 'main': 'index.js' };
21-
const mainPath = normalizePath(path.dirname(path.resolve(moduleRoot, pkg.main)));
20+
const pkgMain = fs.existsSync(pkgPath) && require(pkgPath).main || 'index.js';
21+
const mainPath = normalizePath(path.dirname(path.resolve(moduleRoot, pkgMain)));
2222

2323
// Sort paths by the “main” entry first.
2424
const dirPaths = _.orderBy(glob.sync(path.join(moduleRoot, '**/'), {

0 commit comments

Comments
 (0)
0