Closed romaindutartre closed 2 years ago
@romaindutartre thanks for report.
Problem is that by pointing node_modules/object-mapper
in include
section, you've indicated that you want all modules that are there. In this case reducer assumes that you also want node_modules/object-mapper/test/test.js
module and hence crashes when not able to resolve it's dependencies.
I think you can easily fix it by putting node_modules/object-mapper/index.js
file into include
and not whole node_modules/object-mapper
folder.
Other question is, why do you actually need to list object-mapper
in include
section. Wouldn't it be resolved automatically?
The thing is by default we want to exclude every packages because we are using a shared AWS Layer to load all common packages inside our Lambda function but some library we have to manually add to the serverless package like object-mapper
, that's why I put it in the include
section. I tried removing it from the include
section and packaging but the compressed zip doesn't include object-mapper
in the node_modules, probably because of the exclude
all policy.
Putting node_modules/object-mapper/index.js
in the include
section oddly only include this specific file in the zip file and doesn't seem to follow the module.exports = require('./src/object-mapper');
.
and doesn't seem to follow the module.exports = require('./src/object-mapper');.
Hmm.. I think the case is that reducer currently supports include
instruction only at function level and not at global package level. That definitely should be improved
Workaround you may use, is to put include
at function level instead for now.
Having similar issue here as well... my function just needs aws-sdk and nothing else.
+ ./node_modules/.bin/sls deploy --stage dev
Serverless: Packaging service...
Error --------------------------------------------------
Error: Could not resolve "tape" module, required in "./serverless/eb-restart-app/node_modules/isarray/test.js"
at ./serverless/eb-restart-app/node_modules/serverless-plugin-reducer/node_modules/ncjsm/get-dependencies.js:33:12
#... and then sometimes it spits out another module...
Error: Could not resolve "benchmark" module, required in "./serverless/eb-restart-app/node_modules/jmespath/perf.js"
at ./serverless/eb-restart-app/node_modules/serverless-plugin-reducer/node_modules/ncjsm/get-dependencies.js:33:12
I also got this while trying to npm i, not exactly sure what this means...
npm WARN serverless-plugin-reducer@3.2.3 requires a peer of serverless@^1.21 but none is installed. You must install peer dependencies yourself.
Serverless.yml snippet:
package:
individually: true
excludeDevDependencies: false
custom:
includeDependencies:
enableCaching: true
plugins:
- serverless-plugin-reducer
- serverless-plugin-common-excludes
- serverless-plugin-include-dependencies
functions:
hello:
handler: handler.hello
name: eb-restart-app
description: EB restart app
runtime: nodejs12.x
memorySize: "128"
timeout: 300
# where handler.hello requires('aws-sdk') and thats it
For the time being and without digging in too much, im taking out serverless-plugin-reducer
.
I also got this while trying to npm i, not exactly sure what this means...
Plugin didn't delcare support for v2 of Serverless Framework. I've just fixed that (published with v3.2.4)
Concerning other errors, it doesn't seem to be related to issue in question (you do not have includes
rules per function).
It looks a if a test files of some package (isarray
) are required, and they require dev dependencies to be installed, which obviously are not.
Fixed with https://github.com/medikoo/serverless-plugin-reducer/commit/ae68aada3cc826a32415f4f2227642c0ccba2af0 and released with v4.0.0
Hi,
I've come across what I think is a bug in this library. In my serverless project I'm using the
object-mapper
library and I'm getting an error when packaging the project usingserverless package
. I believeserverless-plugin-reducer
should check whether the required modules are insidedevDependencies
in order not to . I could just add thistape
library to the dependencies of my project and indeed it works but I'm not sure that's the way to go.The error in question:
Regards, Romain
Relevant parts of relevant files
serverless.yml
package.json (from my project)
object-mapper/package.json
object-mapper/test/test.js