Serverless Framework project fails to deploy because of archive size
See original GitHub issueBug description
Generated bundle of the Serverless project has too big size and exceeds allowed by AWS Lambda 250 MB.
It happens because of big sizes of downloaded @prisma/client, which, for some reasons, downloads engines folder that has unzipped size of 96 MB. And the other big files are connected to generated using command prisma generate
schema.
Dependency versions
@prisma/client: “^2.20.0” prisma (dev) : “^2.20.1” serverless (dev): “^2.32.1” serverless-webpack: “^5.4.0” webpack: “^5.11.0” @types/webpack: “^4.41.25”
Webpack config
import nodeExternals from 'webpack-node-externals';
import slsw from 'serverless-webpack';
import { TsconfigPathsPlugin } from 'tsconfig-paths-webpack-plugin';
import CopyPlugin from 'copy-webpack-plugin';
const isOffline = !!slsw.lib.webpack.isLocal;
if (isOffline) {
// eslint-disable-next-line no-console
console.log('Offline mode detected!');
}
// Add plugins for the offline mode here
const offlinePlugins: NonNullable<Configuration['plugins']> = [];
const config: Configuration = {
target: 'node',
entry: slsw.lib.entries,
externals: [nodeExternals()],
mode: isOffline ? 'development' : 'production',
devtool: 'source-map',
module: {
rules: [
{
test: /\.ts$/,
use: [
'source-map-loader',
{
loader: 'ts-loader',
options: {
onlyCompileBundledFiles: true,
},
},
],
},
{
test: /\.graphql$/,
use: ['raw-loader'],
},
],
},
plugins: [
...(isOffline ? offlinePlugins : []),
new CopyPlugin({
patterns: [
{ from: './src/database/prisma/schema.prisma', to: './schema.prisma' },
],
})],
resolve: {
plugins: [
new TsconfigPathsPlugin(),
],
extensions: ['.ts', '.js'],
},
optimization: {
minimize: !isOffline,
},
stats: 'minimal',
};
export = config;
Serverless webpack options
webpackConfig: webpack.config.ts
includeModules: true
packager: npm
packagerOptions:
scripts:
- prisma generate
Environment
& setup
- OS: Mac OS Big Sur 11.1
- Database: PostgreSQL
- Node.js version: 12
- Prisma version: 2.20.1
Background
This is on the first deploy of Prisma to our existing Lambda stack. We have not been able to get Lambda working yet. We bundle our functions through webpack before deploying.
I have looked at the webpack bundle and confirm that @prisma/client is being bundled with the lambda function before deploying.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:6
- Comments:55 (28 by maintainers)
Top GitHub Comments
@janpio I created a minimum repro at https://github.com/jsw/prisma-issue-6644
Also, I fixed part of the issue by moving the
packages.patterns
from function scope to file scope, though both are supposed to work if I’m correctly following the serverless docs. Take a look at myserverless.yml
. And@prisma/engines
andprisma
are still included unless your workaround above is applied.Quick update: I can confirm that we upload both binaries, the native and the
rhel
one, in standard Serverless Framework projects. No Webpack required even. If your own application code is big, this can of course lead to upload (50MB limit) or unpack (150MB limit) problems. I’ll look for a solution and let you know again.