-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
Steps to reproduce
- Create an empty serverless project for typescript: (after installing typescript, run
serverless create --template aws-nodejs-typescript --path aws-serverless-typescript-api - Install the package
- In the hello-world function created by the template, add the next code (with the required import):
validate('US', '12345') - Run the function (serverless offline)
- It will throw with the error:
Cannot find module '/Users/e10117069/Code/MS/address-management-purchase-api/.esbuild/.build/src/functions/helloWorld/formats/US.json'\nRequire stack:\n- /Users/e10117069/Code/MS/address-management-purchase-api/.esbuild/.build/src/functions/v1/helloWorld/handler.js\n- /Users/e10117069/Code/MS/address-management-purchase-api/node_modules/serverless-offline/src/lambda/handler-runner/in-process-runner/aws-lambda-ric/UserFunction.js
Problem
As serverless builds the required dependencies in just on output file and it tries to obtain the json files from the root folder of the output.
Workaround 1
- Add and configure webpack to add the json files to the root folder of the function.
Possible solution
Allowing to force using the format web (that adds the files with require, so they are included in the bundle). Added pull request: #78
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels