Skip to content

Commit

Permalink
Merge pull request #2805 from lpsinger/esbuild-if-metafile
Browse files Browse the repository at this point in the history
Gracefully handle build errors in esbuild script
  • Loading branch information
dakota002 authored Dec 16, 2024
2 parents def8c76 + 8117a76 commit 960827a
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,35 @@ const options = {
{
name: 'copy Node API modules to output directories',
setup(build) {
build.onEnd(async ({ metafile: { outputs } }) => {
await Promise.all(
Object.entries(outputs).flatMap(([entryPoint, { inputs }]) =>
Object.keys(inputs)
.filter((input) => extname(input) === '.node')
.map((input) =>
copyFile(input, join(dirname(entryPoint), basename(input)))
)
build.onEnd(async ({ metafile }) => {
if (metafile) {
await Promise.all(
Object.entries(metafile.outputs).flatMap(
([entryPoint, { inputs }]) =>
Object.keys(inputs)
.filter((input) => extname(input) === '.node')
.map((input) =>
copyFile(
input,
join(dirname(entryPoint), basename(input))
)
)
)
)
)
}
})
},
},
{
name: 'write metafile to output directory',
setup(build) {
build.onEnd(async ({ metafile }) => {
await writeFile(
join(build.initialOptions.outdir, 'metafile.lambda.json'),
JSON.stringify(metafile)
)
if (metafile) {
await writeFile(
join(build.initialOptions.outdir, 'metafile.lambda.json'),
JSON.stringify(metafile)
)
}
})
},
},
Expand Down

0 comments on commit 960827a

Please sign in to comment.