AnomalyInnovations / serverless-bundle

Optimized packages for ES6 and TypeScript Node.js Lambda functions without any configuration.
https://serverless-stack.com/chapters/package-lambdas-with-serverless-bundle.html
MIT License
536 stars 157 forks source link

Source maps make build fail when including source from outside the directory #122

Open bjesus opened 4 years ago

bjesus commented 4 years ago

Hi! I'm trying out severless-bundle and it seems to do wonders! Thank you.

My Lambda includes a function from outside the Lambda folder, like so: const myForeignFunction = require("../library/index");

As long as I set sourcemaps: false, it all works like a charm. I can deploy the Lambda, and Webpack makes the foreign function available. But, if I want my sourcemaps enabled (which I do...), sls deploy fails with this error:

ERROR in /home/user/Projects/myproject/library/index.js
Module not found: Error: Can't resolve 'source-map-support/register' in '/home/user/Projects/myproject/library'

What am I doing wrong? Is this not the Right Way to include code from outside the Lambda directory?

Thank you!

jayair commented 4 years ago

Hmm that's interesting. If you don't include that foreign function it works?

When source maps are enabled, it will add that register function call. That package is included through serverless-bundle, so it's assuming that it can find it in the node modules. You might have to install it yourself in that foreign function?

bjesus commented 4 years ago

I'm unfortunately not working on that project anymore, so can't really test it this at the moment. Yes, if I don't include the foreign function it all worked again. Can't tell about installing source-map-support in the foreign function directory - didn't try that then... Hopefully I'll get back to working on that and then I'll report back again.

jayair commented 4 years ago

Sounds good!

mpaccione commented 3 years ago

I'd like to know as well I am experiencing the same issue!

nuwan-swivel commented 1 year ago

Any update on this? Having the same issue when importing functions from outside the directory