Skip to content

Change in package/exclude usage? #3869

Closed

Description

@sbstjn

Have there been changes in how to exclude paths from being included in the package? I see different archive sizes (22kb compared to 6.7mb) when using 1.15.3 and 1.16.1:

Config

package:
  exclude:
    - node_modules/**

Based on the docs it should work like this.

Using 1.15.3

Archive is ~22kb.

$ > yarn add [email protected]
$ > $(npm bin)/sls version && \
    $(npm bin)/sls package && \
    ls -ahl .serverless/sls-example.zip

1.15.3

Serverless: Packaging service...

-rw-r--r--  1 sbstjn  staff    22K Jun 27 21:58 .serverless/sls-example.zip

Using 1.16.1

Archive is ~7mb

$ > yarn add [email protected]
$ > $(npm bin)/sls version && \
    $(npm bin)/sls package && \
    ls -ahl .serverless/sls-example.zip

1.16.1

Serverless: Packaging service...

-rw-r--r--  1 sbstjn  staff   6.7M Jun 27 22:00 .serverless/sls-example.zip

NPM Dependencies

After moving the serverless package from dependencies to devDependencies in my package.json, the archive has 22kb using 1.16.1 as well.

22kb

{
  "devDependencies": {
    "serverless": "1.16.1"
  }
}

7mb

{
  "dependencies": {
    "serverless": "1.16.1"
  }
}

Expectation

I expected it does not matter if packages are in dependencies or devDependecies when using package/exclude in my configuration to exclude the node_modules folder.

Activity

  1. pmuens commented on Jun 28, 2017

    @pmuens
    Contributor

    Nice catch @sbstjn! 👍

    I'm pretty sure that this is related to #3737.

    Could be that the exclusion patterns for the Node.js dev dependencies overwrite the ones which are set by package.exclude. 🤔

  2. added this to the 1.18 milestone on Jun 28, 2017
  3. pmuens commented on Jul 4, 2017

    @pmuens
    Contributor

    Thanks again for reporting @sbstjn 👍

    We've just started a PR which will include a fix for this (will be updated frequently).

    It can be found here: #3889.

  4. ajkerr commented on Jul 4, 2017

    @ajkerr

    After upgrading to 1.16.1 from 1.14.0, I also noticed this ballooning in size of our zip files. It turns out that every node_modules directory in my service is being included in the zip file for every single function.

    Our global package settings are set like so:

    package:
      individually: true
      exclude:
        - '**/*'
    

    Each function then re-includes its code.

    With 1.16.1, all node_modules directories from every function in my service is being included in every zip file, despite the exclude filter above, and the fact that we are trying to package functions individually.

    I tried setting excludeDevDependencies to false, but this didn't appear to have any effect.

  5. pmuens commented on Jul 5, 2017

    @pmuens
    Contributor

    Thanks for commenting @ajkerr 👍

    We're currently working on a bug fix in #3889. We'll do a patch release once fixed.

    The excludeDevDependencies config will be added in v1.17 which we're about to release today. That should give you a way to opt-out of this until it's fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions