Browse Source

handle non-existent dir of import

rewrite
Rich-Harris 8 years ago
parent
commit
dab40ce0b9
  1. 14
      src/utils/defaults.js

14
src/utils/defaults.js

@ -7,11 +7,15 @@ export function load ( id ) {
} }
function addJsExtensionIfNecessary ( file ) { function addJsExtensionIfNecessary ( file ) {
const name = basename( file ); try {
const files = readdirSync( dirname( file ) ); const name = basename( file );
const files = readdirSync( dirname( file ) );
if ( ~files.indexOf( name ) && isFile( file ) ) return file;
if ( ~files.indexOf( `${name}.js` ) && isFile( `${file}.js` ) ) return `${file}.js`; if ( ~files.indexOf( name ) && isFile( file ) ) return file;
if ( ~files.indexOf( `${name}.js` ) && isFile( `${file}.js` ) ) return `${file}.js`;
} catch ( err ) {
// noop
}
return null; return null;
} }

Loading…
Cancel
Save