# Zip size is much larger on cdci than locally

**URL:** <https://forum.serverless.com/t/zip-size-is-much-larger-on-cdci-than-locally/13158>\
**Category:** Serverless Framework\
**Tags:** aws, lambda, cicd\
**Created:** [November 19, 2020, 4:04pm UTC](https://forum.serverless.com/t/zip-size-is-much-larger-on-cdci-than-locally/13158 "2020-11-19T16:04:45Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrikelfstrom](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/patrikelfstrom/32/4737_2.png) [@patrikelfstrom](https://forum.serverless.com/u/patrikelfstrom)\
**Post date:** [November 19, 2020, 4:04pm UTC](https://forum.serverless.com/t/zip-size-is-much-larger-on-cdci-than-locally/13158/1 "2020-11-19T16:04:45Z")

</div>

I have an issue where the size of the zipped lambdas are much larger on the cdci (GitLab CE 11.8.0) than when running the package script locally.  
The lambdas are written in typescript and I use serverless-webpack to decrease the size as much as I can.  
I have not written the code so I don’t know why they are so large  
but still I think there should not really be that big of a difference between local and cdci packaging?

Am I missing something?  
Here is the build log: [https://pastebin.com/pcG7QaAg](https://pastebin.com/pcG7QaAg)

**Size when running `serverless package` locally:**  
getReport.zip: 28.6 MB  
push.zip: 25.8 MB  
alerts.zip: 25.8 MB  
reporting: 5 MB  
user.zip: 2.3 MB  
imageupload.zip: 90 KB

**Size when running `serverless deploy` on cdci:**  
getReport.zip: 168.76 MB  
push.zip: 92.91 MB  
alerts.zip: 92.91 MB  
reporting: 4.7 MB  
user.zip: 2.08 MB  
imageupload.zip: 55.68 KB

**serverless.yml:**  
plugins:  
- serverless-dotenv-plugin  
- serverless-offline  
- serverless-plugin-aws-alerts  
- serverless-plugin-info-json  
- serverless-webpack

```
package:
  individually: true
  exclude:
    - node_modules/aws-sdk/**

provider:
  name: aws
  region: eu-west-1
  runtime: nodejs10.x
  memorySize: 512
  timeout: 30
  versionFunctions: false
  stage: ${opt:stage, 'dev'}
  apiGateway:
    shouldStartNameWithService: true

custom:
  webpack:
    webpackConfig: ./webpack.config.js
    includeModules: true

```

**.gitlab-ci.yml:**

```
.deploy_to_aws:
  image: node:latest
  script:
    - npm i -g serverless
    - npm ci
    - serverless config credentials --provider aws --key $AWS_ACCESS_KEY_ID --secret $AWS_SECRET_ACCESS_KEY
    - serverless deploy --verbose --stage $STAGE --region $AWS_DEFAULT_REGION

```

**webpack.config.js**

```
const path = require("path")
const slsw = require("serverless-webpack")
const nodeExternals = require("webpack-node-externals")

module.exports = {
  context: __dirname,
  mode: slsw.lib.webpack.isLocal ? "development" : "production",
  entry: slsw.lib.entries,
  resolve: {
    extensions: [".ts"],
    symlinks: false,
    cacheWithContext: false,
  },
  output: {
    libraryTarget: "commonjs",
    path: path.join(__dirname, ".webpack"),
    filename: "[name].js",
  },
  target: "node",
  externals: [nodeExternals()],
  module: {
    rules: [
      {
        test: /\.(ts)$/,
        loader: "ts-loader",
        exclude: [
          [
            path.resolve(__dirname, "node_modules"),
            path.resolve(__dirname, ".serverless"),
            path.resolve(__dirname, ".webpack"),
          ],
        ],
        options: {
          transpileOnly: true,
          experimentalWatchApi: true,
        },
      },
    ],
  },
}
```

---

<div class="post-metadata">

**Author:** ![patrikelfstrom](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/patrikelfstrom/32/4737_2.png) [@patrikelfstrom](https://forum.serverless.com/u/patrikelfstrom)\
**Post date:** [November 24, 2020, 2:32pm UTC](https://forum.serverless.com/t/zip-size-is-much-larger-on-cdci-than-locally/13158/2 "2020-11-24T14:32:26Z")

</div>

Fixed with [https://github.com/serverless/serverless/pull/8505](https://github.com/serverless/serverless/pull/8505)

---

<div class="post-metadata">

**Author:** ![beenmeckel](https://avatars.discourse-cdn.com/v4/letter/b/8dc957/32.png) [@beenmeckel](https://forum.serverless.com/u/beenmeckel)\
**Post date:** [January 12, 2021, 10:17pm UTC](https://forum.serverless.com/t/zip-size-is-much-larger-on-cdci-than-locally/13158/3 "2021-01-12T22:17:55Z")

</div>

I can’t get module aliases working with serverless framework and a typescript lambda, i tried serverless-bundle and serverless-typescript plugins but none of them works and when i try to deploy it gives a module missing error. The same happen when using sls offline to test the lambda locally.

---

<div class="post-metadata">

**Author:** ![beenmeckel](https://avatars.discourse-cdn.com/v4/letter/b/8dc957/32.png) [@beenmeckel](https://forum.serverless.com/u/beenmeckel)\
**Post date:** [January 13, 2021, 10:29pm UTC](https://forum.serverless.com/t/zip-size-is-much-larger-on-cdci-than-locally/13158/4 "2021-01-13T22:29:23Z")

</div>

i tried serverless-bundle and serverless-typescript plugins but none of them works and when i try to deploy it gives a module missing error. The same happen when using sls offline to test the lambda locally.[9Apps](https://9apps.ooo/) [Showbox](https://showbox.kim/) [Tutuapp](https://tutuapp.uno/)

---

<div class="post-metadata">

**Author:** ![TomC](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/tomc/32/4002_2.png) [@TomC](https://forum.serverless.com/u/TomC)\
**Post date:** [April 8, 2022, 10:15am UTC](https://forum.serverless.com/t/zip-size-is-much-larger-on-cdci-than-locally/13158/5 "2022-04-08T10:15:10Z")

</div>

Same here, I’ve raised [Adding serverless-plugin-aws-alerts to a project adds ~40meg to package .zip size · Issue #218 · ACloudGuru/serverless-plugin-aws-alerts · GitHub](https://github.com/ACloudGuru/serverless-plugin-aws-alerts/issues/218) because it’s clearly adding that to package.json that balloons the size.

---

<div class="post-metadata">

**Author:** ![TomC](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/tomc/32/4002_2.png) [@TomC](https://forum.serverless.com/u/TomC)\
**Post date:** [April 8, 2022, 3:05pm UTC](https://forum.serverless.com/t/zip-size-is-much-larger-on-cdci-than-locally/13158/6 "2022-04-08T15:05:17Z")

</div>

Note, this happens for instance if you are pinned to an older plugin version, that declares a peer dependency on an older Serverless version, so Serverless brings itself and all it’s own dependencies into the project. You might be able to work around by excluding the extra node\_modules folders using the settings in serverless.yml
