dougmoscrop / serverless-plugin-include-dependencies

MIT License
184 stars 40 forks source link

Crashes when required file is not a module (like requiring a plain js) #82

Open pursual opened 1 year ago

pursual commented 1 year ago

/serverless-plugin-include-dependencies/get-dependency-list.js:82:66 const pathToModule = resolve.sync(path.join(moduleName, 'package.json'), { basedir }); throws an error that is uncaught, because moduleName is null:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received null
pursual commented 1 year ago

This basically makes it impossible to use when including custom code from a shared layer.

ianbale commented 12 months ago

I've not got the time to do a fix and PR, but if anyone wants to do so, or just fix your copy for now, you can do by by editing get-dependency-list.js.

Find the two calls to handle() and wrap that in an IF statement: if (dependency.substring(0,5) !== "/opt/")

Very rough and ready, bit it will get you going for now.