Posted On: Jan 6, 2022

AWS Lambda functions using the Node.js 14 runtime now support code packaged as ECMAScript modules, allowing Lambda customers to consume a wider range of JavaScript packages in their Lambda functions. In addition, Lambda customers can now take advantage of ‘top-level await’, a Node.js 14 language feature. When used with Provisioned Concurrency, this improves cold-start performance for functions with asynchronous initialization tasks. For more information, see the blog post Using Node.JS ES Modules and Top-Level Await in AWS Lambda.

ECMAScript (ES) modules are a packaging format for JavaScript code, used to publish JavaScript code libraries so they can be imported and re-used in other applications. Until now, Lambda’s Node.js runtimes only supported code using the earlier CommonJS packaging format. With this release, customers can use the ES module format for both their function handler and any code they import.

With this release, customers can also use ‘top-level await’, a Node.js 14 language feature, to wait for asynchronous initialization tasks to complete during the function initialization phase. This capability is especially useful for functions configured with Provisioned Concurrency, which creates runtime environments ahead of time. This is designed to reduce cold start latency, resulting in more responsive applications.

Customers can use ES modules and top-level await with all Lambda functions using the Node.js 14 runtime (and subsequent releases of newer Node.js runtimes). They are available in all Regions where Lambda is available, except for China Regions. Visit our product page for more information about AWS Lambda or sign in to the AWS Lambda console to get started.