serverless: Package individually at the function level is broken

Bug Report

Description

Set package individually at a function level but not at the service level. This actually works if I set package individually to true at the service level

  1. What happened?

The function was package individually:

myFunc:
  package:
    individually: true
    exclude:
      - '**'
    include:
      - 'myFolder/**'

However, all the services files are included in the generated bundle.

I expected that only the files in myFolder would have been added.

The problem seems to be at https://github.com/serverless/serverless/blob/master/lib/plugins/package/lib/packageService.js#L21

this.serverless.service.package.include should be empty since it’s not defined at the service level instead of containing all the files in the project. But I can’t find where it’s being populated. Or is there any other way to achieve this that I’m missing?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 5
  • Comments: 15 (8 by maintainers)

Most upvoted comments

I’m going to close this issue, as there’s no reproduction case provided, and as I checked the posted examples all works as expected.

In my case, I was using

handler: index.main 
module: hello 

but it needed to be

handler: hello/index.main

Add configValidationMode: error to your serverless.yml (same indentation as service: xyz) to avoid these mistakes.

@stevematdavies you have an error in your configuration. Are you relying on latest version of Framework? Note that latest version will clearly communicate this error with Configuration warning

@stevematdavies can you prepare as simple as possible test case that reproduces the issue?