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

Commit 077f7ae

Browse files
mislavlukastaegert
authored andcommitted
Handle .node extension when resolving browser entries
1 parent 1895d73 commit 077f7ae

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import fs from 'fs';
66

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

1011
export default function nodeResolve ( options = {} ) {
1112
const useModule = options.module !== false;
@@ -76,7 +77,12 @@ export default function nodeResolve ( options = {} ) {
7677
if ( key[0] === '.' ) {
7778
const absoluteKey = resolve( pkgRoot, key );
7879
browser[ absoluteKey ] = resolved;
79-
if (!extname(key)) browser[ absoluteKey + '.js'] = browser[ absoluteKey+ '.json' ] = browser[ key ];
80+
if ( !extname(key) ) {
81+
exts.reduce( ( browser, ext ) => {
82+
browser[ absoluteKey + ext ] = browser[ key ];
83+
return browser;
84+
}, browser );
85+
}
8086
}
8187
return browser;
8288
}, {});

0 commit comments

Comments
 (0)