Skip to content

Commit

Permalink
fix: look for exports.require in package.json in addition to `mai…
Browse files Browse the repository at this point in the history
…n` when patching `require` (#378)
  • Loading branch information
dylannil committed Sep 25, 2023
1 parent 4fc41ce commit 411b791
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/patchRequire.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ export default function patchRequire(vol, unixifyPaths = false, Module = require

let pkg;
try {
pkg = packageMainCache[requestPath] = JSON.parse(json).main;
const pkgJson = JSON.parse(json);
pkg = packageMainCache[requestPath] = pkgJson.exports && pkgJson.exports.require || pkgJson.main;
} catch (e) {
e.path = jsonPath;
e.message = 'Error parsing ' + jsonPath + ': ' + e.message;
Expand Down

0 comments on commit 411b791

Please sign in to comment.