Skip to content

Commit

Permalink
Resolve "module", "jsnext:main" and "browser" before "main" (#299)
Browse files Browse the repository at this point in the history
Fixes #298
  • Loading branch information
fathyb authored and devongovett committed Dec 20, 2017
1 parent 539ade1 commit 7fcae06
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Resolver.js
Expand Up @@ -46,6 +46,16 @@ class Resolver {
packageFilter(pkg, pkgfile) {
// Expose the path to the package.json file
pkg.pkgfile = pkgfile;

// npm libraries can specify alternative main fields in their package.json,
// we resolve the "module" and "jsnext:main" in priority of "browser" to get the full dependency tree.
// libraries like d3.js specifies node.js specific files in the "main" which breaks the build
const main = pkg.module || pkg['jsnext:main'] || pkg.browser;

if (main) {
pkg.main = main;
}

return pkg;
}
});
Expand Down

0 comments on commit 7fcae06

Please sign in to comment.