Closed anthony-nhs closed 2 weeks ago
Thanks for reporting @anthony-nhs. We're aware of the issue and will prioritize a fix. In the meantime, if anyone is having this issue, as a workaround, you can either
--packages=bundle
flag under the function metadataThis breaking change has now been reverted in the latest version of esbuild.
https://github.com/evanw/esbuild/releases/tag/v0.23.0
For the purposes of AWS SAM CLI, refrain from using esbuild version 0.22.0
and things should work as expected.
Description
esbuild 0.22.0 (https://github.com/evanw/esbuild/releases/tag/v0.22.0) changes the default behavior for packages so that dependencies are no longer bundled. You can overwrite this by specifying
--packages=bundle
. This should be the default for packages compiled with esbuild as specified it in Metadata properties of AWS::Serverless::Function and deployed through SAM so that dependencies are available in the deployed lambdaSteps to reproduce:
Install esbuild >0.22.0 Create a typescript lambda with a 3rd party dependency and deploy it using sam-cli using esbuild. Try executing the deployed lambda
Observed result:
Get error
Error: Cannot find module....
Expected result:
lambda executes
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: 1.120.0Add --debug flag to any SAM CLI commands you are running