Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package does not work depending how the consumer is bundled #79

Open
jose-garrido-martinez opened this issue Jan 30, 2023 · 1 comment

Comments

@jose-garrido-martinez
Copy link

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

@lightwave
Copy link

Same error when using Next.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants