Skip to content

Commit

Permalink
Reimplement getBabelConfigFile to be simpler
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Aug 30, 2023
1 parent 2fa63b9 commit 0740b99
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions packages/next/src/build/get-babel-config-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@ const BABEL_CONFIG_FILES = [
export async function getBabelConfigFile(
dir: string
): Promise<string | undefined> {
const babelConfigFile = await BABEL_CONFIG_FILES.reduce(
async (memo: Promise<string | undefined>, filename) => {
const configFilePath = join(dir, filename)
return (
(await memo) ||
((await fileExists(configFilePath)) ? configFilePath : undefined)
)
},
Promise.resolve(undefined)
)
return babelConfigFile
for (const filename of BABEL_CONFIG_FILES) {
const configFilePath = join(dir, filename)
const exists = await fileExists(configFilePath)
if (!exists) {
continue
}
return configFilePath
}
}

0 comments on commit 0740b99

Please sign in to comment.