Zip size is much larger on cdci than locally

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

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,
        },
      },
    ],
  },
}

Fixed with https://github.com/serverless/serverless/pull/8505

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.

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 Showbox Tutuapp

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 because it’s clearly adding that to package.json that balloons the size.

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