Skip to content

Commit

Permalink
simplify + add return type
Browse files Browse the repository at this point in the history
  • Loading branch information
dnalborczyk committed Dec 22, 2021
1 parent 67e50cf commit e900adf
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/utils/resolveId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,12 @@ export async function resolveId(
);
}

function addJsExtensionIfNecessary(file: string, preserveSymlinks: boolean) {
let found = findFile(file, preserveSymlinks);
if (found) return found;
found = findFile(file + '.mjs', preserveSymlinks);
if (found) return found;
found = findFile(file + '.js', preserveSymlinks);
return found;
function addJsExtensionIfNecessary(file: string, preserveSymlinks: boolean): string | undefined {
return (
findFile(file, preserveSymlinks) ??
findFile(file + '.mjs', preserveSymlinks) ??
findFile(file + '.js', preserveSymlinks)
);
}

function findFile(file: string, preserveSymlinks: boolean): string | undefined {
Expand Down

0 comments on commit e900adf

Please sign in to comment.