Skip to content

Commit

Permalink
Merge pull request #1379 from Victorystick/simpler-resolveId
Browse files Browse the repository at this point in the history
Consolidate all non-null, `resolveId` return statements
  • Loading branch information
Rich-Harris committed Jun 3, 2017
2 parents b661e7e + 304c0be commit 48f3e82
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/utils/defaults.js
Expand Up @@ -36,16 +36,16 @@ export function resolveId ( importee, importer ) {
});
}

// absolute paths are left untouched
if ( isAbsolute( importee ) ) return addJsExtensionIfNecessary( resolve( importee ) );

// if this is the entry point, resolve against cwd
if ( importer === undefined ) return addJsExtensionIfNecessary( resolve( process.cwd(), importee ) );

// external modules are skipped at this stage
if ( importee[0] !== '.' ) return null;

return addJsExtensionIfNecessary( resolve( dirname( importer ), importee ) );
// external modules (non-entry modules that start with neither '.' or '/')
// are skipped at this stage.
if ( importer !== undefined && !isAbsolute( importee ) && importee[0] !== '.' ) return null;

// `resolve` processes paths from right to left, prepending them until an
// absolute path is created. Absolute importees therefore shortcircuit the
// resolve call and require no special handing on our part.
// See https://nodejs.org/api/path.html#path_path_resolve_paths
return addJsExtensionIfNecessary(
resolve( importer ? dirname( importer ) : resolve(), importee ) );
}


Expand Down

0 comments on commit 48f3e82

Please sign in to comment.