Skip to content

Commit

Permalink
docs: add in why we dropped CJS
Browse files Browse the repository at this point in the history
  • Loading branch information
willfarrell committed Dec 3, 2023
1 parent bbdaf58 commit 7c4cc52
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions website/docs/upgrade/4-5.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ Version 5.x of Middy no longer supports Node.js versions 16.x. You are highly en
- Update all errors to be consistent `new Error('message', { cause: { package:'@middy/***', data:*** } })`
- If using multiple `http-*-body-parsers` on the same endpoint you'll need to set `disableContentTypeError:true`

## Why we deprecated CJS

1. ESM has been well supported in Lambda for almost 2 years now
2. ESM is almost 2x faster than CJS at p95 [Using Node.js ES modules and top-level await in AWS Lambda](https://aws.amazon.com/blogs/compute/using-node-js-es-modules-and-top-level-await-in-aws-lambda/)
3. Maintainability; Maintaining a package to work with every transpilers and build tools that are constantly changing over time is hard and time consuming.

If you're not able to upgrade your codebase to using ESM yet, that's okay, v4.x is super stable and support CJS.

## Core

- Updated `plugin.timeoutEarlyResponse(...)` to throw new error with name `TimeoutError` to match new `AbortSignal.timeout()`.
Expand Down

0 comments on commit 7c4cc52

Please sign in to comment.