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 29, 2023
1 parent 115f42d commit 0e2322c
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 0e2322c

Please sign in to comment.