serverless-bundle icon indicating copy to clipboard operation
serverless-bundle copied to clipboard

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

Open bjesus opened this issue 4 years ago • 5 comments

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!

bjesus avatar Jul 23 '20 17:07 bjesus

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?

jayair avatar Aug 17 '20 00:08 jayair

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.

bjesus avatar Aug 20 '20 19:08 bjesus

Sounds good!

jayair avatar Sep 07 '20 18:09 jayair

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

mpaccione avatar Sep 23 '21 22:09 mpaccione

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

nuwan-swivel avatar Dec 12 '22 07:12 nuwan-swivel