Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Commit

Permalink
Handle .node extension when resolving browser entries
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Feb 14, 2018
1 parent 398816d commit 3a63974
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import fs from 'fs';

const ES6_BROWSER_EMPTY = resolve( __dirname, '../src/empty.js' );
const CONSOLE_WARN = ( ...args ) => console.warn( ...args ); // eslint-disable-line no-console
const exts = [ '.js', '.json', '.node' ];

export default function nodeResolve ( options = {} ) {
const useModule = options.module !== false;
Expand Down Expand Up @@ -76,7 +77,12 @@ export default function nodeResolve ( options = {} ) {
if ( key[0] === '.' ) {
const absoluteKey = resolve( pkgRoot, key );
browser[ absoluteKey ] = resolved;
if (!extname(key)) browser[ absoluteKey + '.js'] = browser[ absoluteKey+ '.json' ] = browser[ key ];
if ( !extname(key) ) {
exts.reduce( ( browser, ext ) => {
browser[ absoluteKey + ext ] = browser[ key ];
return browser;
}, browser );
}
}
return browser;
}, {});
Expand Down

0 comments on commit 3a63974

Please sign in to comment.