serverless-bundle
serverless-bundle copied to clipboard
Source maps make build fail when including source from outside the directory
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!
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?
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.
Sounds good!
I'd like to know as well I am experiencing the same issue!
Any update on this? Having the same issue when importing functions from outside the directory