digitalmaas / serverless-plugin-browserifier

Reduce the size and speed up your Node.js based lambda's using browserify.
Other
27 stars 3 forks source link

Plugin fails when used with serverless that contains ECR (Elastic Container Repository) with lambdas in Python and NodeJS #39

Closed henriquef-cit closed 3 years ago

henriquef-cit commented 3 years ago

I have one serverless.yaml to deploy Lambda Functions in Python with ECR (Elastic Container Repository) and Lambda Functions in NodeJs, Everything works fine without the plugin, but when I add it, I get the error below

NodeJS 14.15.5 npm 6.14.11 Serverless Framework 2.23

sls package --stage dev -v --service name-of-service
.
.
.
.

Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir
Serverless: Invoke warmup:addWarmers
Serverless: WarmUp: Skipping warmer "default" creation. No functions to warm up.
Serverless: Browserifier: Service runtime is not nodejs...
Serverless: Browserifier: Service not set to package individually...
Serverless: Browserifier: Computing global config...
Serverless: Browserifier: Using browserify@17.0.0
Serverless: Browserifier: Using browserify "node" option...
Serverless: Browserifier: Computed globalBrowserifyConfig: {"disable":false,"exclude":[],"include":[],"external":[],"ignore":[],"basedir":"/home/xxxxxxx/repos/name-of-the-service","entries":[],"bare":true,"standalone":"lambda","ignoreMissing":true,"detectGlobals":true,"debug":true,"node":true}
Serverless: Browserifier: Preparing 1 function(s)...
Serverless: Browserifier: Preparing "name_of_function"...
Serverless: Browserifier: functionObject for name_of_function: {"description":"commit:  branch: ","image":{"name":"name_of_image"},"memorySize":10240,"environment":{"STAGE":"dev","SNS_TOPIC_NAME":"xxx-yyy-zzz","SNS_ARN":"arn:aws:sns:us-east-1:xxx:xxx-yyy-zzz","SNS_JSON_BUCKET":"xxx-yyyy-zzz","SNS_AB_TEST_TOGGLE":"False"},"events":[],"name":"name-of-service-stage-function"}
Serverless: Browserifier: Unexpected failure detected!

 Type Error ----------------------------------------------

  TypeError: Cannot read property 'split' of undefined
nolde commented 3 years ago

Hi @henriquef-cit ,

As stated in the documentation, this plugin requires package individually to be set to true, which the plugin is actually telling you that it is incorrectly set on the logs you've pasted.

Furthermore, you logs have the function configuration in there, but there is no handler in that function, which is needed for browserify to determine the entrypoint. It also has an "image" configuration, which is used to deploy a pre-packaged image to be executed in lambda, which makes browserifying it in this step completely impossible.

Therefore, it doesn't seem like it would be ever possible for the plugin to work, given the configuration provided.

nolde commented 3 years ago

As you didn't reply, I will consider this a non-issue. Closing.