Skip to content

Commit

Permalink
require from patchRequire can now read exports.require info from pack…
Browse files Browse the repository at this point in the history
…age.json
  • Loading branch information
dylannil committed Sep 20, 2023
1 parent 81d58af commit de4061c
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 de4061c

Please sign in to comment.