Skip to content

Commit 45f92b5

Browse files
authored
Fix esbuild treating warnings as errors (anomalyco#1167)
1 parent 0fa3409 commit 45f92b5

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
matrix:
1919
os: [ubuntu-latest, windows-latest]
20-
node-version: [14.x, 16.8]
20+
node-version: [12.x, 14.x, 16.8]
2121
runs-on: ${{ matrix.os }}
2222

2323
steps:

packages/core/src/runtime/handler/node.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,15 @@ export const NodeHandler: Definition<Bundle> = (opts) => {
139139
...config,
140140
plugins,
141141
})}
142-
esbuild.build({
143-
...config,
144-
plugins: config.plugins ? require(config.plugins) : undefined
145-
})
142+
try {
143+
await esbuild.build({
144+
...config,
145+
plugins: config.plugins ? require(config.plugins) : undefined
146+
})
147+
process.exit(0)
148+
} catch {
149+
process.exit(1)
150+
}
146151
}
147152
run()
148153
`;
@@ -153,11 +158,14 @@ export const NodeHandler: Definition<Bundle> = (opts) => {
153158
const result = spawn.sync("node", [builder], {
154159
stdio: "pipe",
155160
});
156-
const err = (result.stderr.toString() + result.stdout.toString()).trim();
157-
if (err)
161+
if (result.status !== 0) {
162+
const err = (
163+
result.stderr.toString() + result.stdout.toString()
164+
).trim();
158165
throw new Error(
159166
"There was a problem transpiling the Lambda handler: " + err
160167
);
168+
}
161169

162170
fs.removeSync(builder);
163171

0 commit comments

Comments
 (0)