From 6920233ebbe3c03d2dac9c8a0caf7085fa991f57 Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Wed, 10 Jan 2018 20:40:11 +0000 Subject: [PATCH] fix: add guard for options.browser with no pkg.browser field --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 3c0824e..d9778e9 100644 --- a/src/index.js +++ b/src/index.js @@ -77,7 +77,7 @@ export default function nodeResolve ( options = {} ) { if (options.browser && typeof pkg[ 'browser' ] === 'string') { pkg[ 'main' ] = pkg[ 'browser' ]; - } else if (options.browser && pkg[ 'browser' ][ pkg[ 'main' ] ]) { + } else if (options.browser && typeof pkg[ 'browser' ] === 'object' && pkg[ 'browser' ][ pkg[ 'main' ] ]) { pkg[ 'main' ] = pkg[ 'browser' ][ pkg[ 'main' ] ]; } else if ( useModule && pkg[ 'module' ] ) { pkg[ 'main' ] = pkg[ 'module' ];