Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

serverless-esm-layer

luisdemarchi5.3kBSD-3-Clause-Clear1.2.0

A serverless plugin that will fix the problem of AWS-Layers not working with ES Modules (ESM .mjs)

serverless, aws-layer, aws-lambda, esm, es-modules

readme

Serverless plugin to support AWS Layers using ES Module

serverless

In early 2022, AWS released ES Module (ESM .mjs) support for the the Node.js 14.x Lambda Runtime and surprisingly, ESM support was released without "support" for AWS Layers. This plugin fixed the problem.

Note: This plugin was based on the vibe/aws-esm-layer-support repository that details the problem and shows the implemented solution.

Requirements:

  • Serverless v2.x or higher.
  • AWS provider and nodejs14.x/16.x runtimes

Setup

Install via npm:

npm install serverless-esm-layer --save-dev
  • Add the plugin to the plugins array in your Serverless serverless.yml:
plugins:
  - serverless-esm-layer

All done! When running SLS deploy your lambdas will have the correct configuration to work layers with ES Module. No extra configuration is needed.

Contribute

Help us making this plugin better and future proof.

  • Clone the code
  • Install the dependencies with npm install
  • Create a feature branch git checkout -b new_feature
  • Lint with standard npm run lint

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[1.2.0] - 2023-04-17

feat

  • support deployment of a single function with "serverless deploy function -f functionName"

[1.1.0] - 2022-11-15

feat

  • editing all files simultaneously

[1.0.5 .. 6] - 2022-10-25

fix

  • sync of functions

[1.0.3 .. 4] - 2022-09-18

fix

  • path for temporary files

[1.0.2] - 2022-09-18

chore

  • added repository url in package
  • Added link with problem description

[1.0.0] - 2022-09-18

feat

  • first fully functional version