Huge size of zip files

When I deploy my stack or any functions in it, the size of the zip file is 1000 times the size of the actual code:

  • Size of the actual code files: 300o
  • Size of the zip files: 47Mo !

image

All the zip files looks seems to have the same size too:

image

  • Node version: 16
  • Serverless version:
  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              12.22.12
     Framework Version:         2.72.3
     Plugin Version:            5.5.4
     SDK Version:               4.3.2
     Components Version:        3.18.2
  • Number of function in yml: 92
  • Plugins in yml:
  - serverless-webpack
  - serverless-offline
  - serverless-domain-manager
  - serverless-api-gateway-caching
  - serverless-plugin-aws-alerts
  - serverless-plugin-split-stacks
  • Webpack config:
module.exports = {
  entry: slsw.lib.entries,
  target: 'node',
  externals: [nodeExternals({ whitelist: ['aws-xray-sdk-core'] })],
  mode: slsw.lib.webpack.isLocal ? 'development' : 'production',
  devtool: 'source-map',
  optimization: {
    minimize: false,
  },
  module: {
    rules: [
      {
        test: /\.ts$/,
        use: 'ts-loader',
        exclude: /node_modules/,
      },
    ],
  },
  resolve: {
    extensions: ['.ts', '.js'],
  },
  plugins: [{
    apply: (compiler) => {
      if (Object.keys(compiler.options.entry)[0] === 'authorizer') {
        new CopyWebpackPlugin(['GeoLite2-Country.mmdb']).apply(compiler);
      }
    },
  }],
};

This issue is slowing greatly deployment time (compilation and upload)

I don’t know if it could help:

package:
  individually: true

The option is already set !

It looks like the node_modules is huge and contain lost of lib that is doesn’t used by the code of the function.

Try uninstalling serverless-offline…