Using esbuild in Your Serverless Framework Project

How to use esbuild to transpile and bundle your TypeScript Lambda functions in a Serverless Framework project — all without using any plugins!

Marco Lüthy
5 min readAug 31, 2021
Boy building blocks of legos — a play on the esbuild bundler
Building Lego bundles. My cover photo genius know no bounds! Photo by Kelly Sikkema. Thank you, Kelly!

esbuild is a JavaScript bundler written in Go by Evan Wallace which has risen in popularity recently due to its extremely fast speed, simplicity of use and, well, all-around better-ness when compared to older generation transpilers and bundlers like aging Webpack or Babel.

In this article, I’ll share a way to use esbuild to transpile, minify, and bundle your TypeScript (or, vanilla JavaScript) AWS Lambda function handlers before deploying them with the Serverless Framework — without using any Serverless plugins. Because we’re not using any plugins, the setup should work for other deployment tooling like AWS SAM as well.

Why not use a plugin? Yes, there are some esbuild plugins for the Serverless Framework. However, I find that most Serverless plugins are not well maintained and are often of dubious quality. Plugins can have access to your AWS credentials at deployment time, which, while often necessary for the plugin’s functionality, is kind of scary. Basically, I don’t trust most of them with access to my AWS account — and, as this article demonstrates, in most cases the…

--

--

Marco Lüthy
Marco Lüthy

Written by Marco Lüthy

Hi there! I’m Marco. I write mostly about software development, sometimes about books I’ve read, and occasionally something else to keep things interesting.

No responses yet