TypeScript and Lambda Serverless Project Limit
Recently, our project deployment met this exception while deploy
An error occurred: DevicePairingUpdatesLambdaFunction - Unzipped size must be smaller than 262144000 bytes (Service: AWSLambda; Status Code: 400; Error Code: InvalidParameterValueException; Request ID:xxxxxxx-11e8-81e6-xxxxxxx).
Look at the limitation for lambda in detail here
https://docs.aws.amazon.com/lambda/latest/dg/limits.html#limits-list
Lambda function deployment package size (compressed .zip/.jar file). 50MB
Size of code/dependencies that you can zip into a deployment package (uncompressed .zip/.jar size). 250
Currently, our projects are packaged and deployed in 2 different ways.
#1 serverless-plugin-typescript plugin
No webpack, no compress map file generated
Run the command >sls package and check the directory .serverless, there will be a zip file, unzip that, the structure will be as follow:
drwxr-xr-x 168 hluo staff 5376 Sep 6 16:36 node_modules
-rw-r--r-- 1 hluo staff 1017 Dec 31 1979 package.json
drwxr-xr-x 6 hluo staff 192 Sep 6 16:37 src
The good part for this plugin is that, all the shared dependencies will be under node_modules, the source codes in src directory are all small
-rw-r--r-- 1 hluo staff 2329 Dec 31 1979 accessToken.js
-rw-r--r-- 1 hluo staff 4686 Dec 31 1979 getVCSettings.js
-rw-r--r-- 1 hluo staff 2208 Dec 31 1979 handler.js
-rw-r--r-- 1 hluo staff 4413 Dec 31 1979 utils.js
So in this case, if you have 20 lambda in this serverless.yaml together, you will have all shared dependencies in node_modules, all lambda codes in src directory.
The bad side for this is that all these javascript files are normal files, no compress.
#2 serverless-webpack plugin
Compress map file generated for each lambda functions
Run the command >sls package and check the directory .serverless, there will be a zip file, unzip that, the structure will be as follow:
-rw-r--r-- 1 hluo staff 4.1M Jan 1 1980 handler.js
-rw-r--r-- 1 hluo staff 5.6M Jan 1 1980 handler.js.map
In this way, there is no node_modules, all related javascript dependencies will be compressed and packaged into the lambda js and js.map files.
The good thing is the files are compressed, so it is smaller than #1 comparing per lambda. But the downside for this plugin is you have no where to share dependencies. So if you have 20 lambda with similar dependencies in one serverless.yaml, you will have 20 bigger js and js.map files, that is why my size get over 50MB.
For example
-rw-r--r-- 1 hluo staff 7.3M Jan 1 1980 deleteDevicePairing.js
-rw-r--r-- 1 hluo staff 10M Jan 1 1980 deleteDevicePairing.js.map
-rw-r--r-- 1 hluo staff 7.3M Jan 1 1980 getPairedDevices.js
-rw-r--r-- 1 hluo staff 10M Jan 1 1980 getPairedDevices.js.map
-rw-r--r-- 1 hluo staff 7.3M Jan 1 1980 updateDevicePairing.js
-rw-r--r-- 1 hluo staff 10M Jan 1 1980 updateDevicePairing.js.map
-rw-r--r-- 1 hluo staff 7.3M Jan 1 1980 updateDeviceSystemName.js
-rw-r--r-- 1 hluo staff 10M Jan 1 1980 updateDeviceSystemName.js.map
I do not know if there are other solutions or plugins, but this is what I found in current situations.
References:
https://docs.aws.amazon.com/lambda/latest/dg/limits.html#limits-list
分享到:
相关推荐
serverless-plugin-typescript, 无服务器插件,支持零配置 serverless-plugin-typescript 无服务器插件,支持零配置特性零配置:不需要安装任何其他编译器或者插件就可以使用这个框支持ES2015语法 特性( export,...
Typescript-lambda-bundle 此示例说明了如何将打字稿lambda及其依赖项打包并捆绑到单个javascript文件中,从而使AWS Lambda的部署变得更加轻松和快捷。 打字稿 由于lambda处理程序本身是用Typescript编写的,因此...
TypeScript
Building Web Components with TypeScript and Angular 4 by Matthew Scarpino English | 10 Jun. 2017 | ASIN: B071K4HWMT | 603 Pages | AZW3 | 2.11 MB Angular is Google's foremost framework for developing ...
使用Webpack生成优化的Lambda软件包 在处理程序函数中使用ES6或TypeScript 在本地运行API网关使用serverless offline start 支持单元测试运行npm test以运行测试 正确错误消息的源映射 错误消息显示正确的行号 ...
Malagu 是基于 TypeScript 的 Serverless First、组件化、平台无关的渐进式应用框架
详细介绍用EC6+构建Apps,使用React开发SPA应用,用create-react-app安装项目、Redux、React Router、TypeScript, Node用Express和GraphQL开发WEB服务等内容。
Building Web Components with TypeScript and Angular 4 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自...
$ npm install -g shibayu36/typescript-cli-project $ typescript-cli-project hoge hoge 如果要从本地安装cli,请执行以下命令。 $ git clone https://github.com/shibayu36/typescript-cli-project.git $ cd ...
本文将介绍如何使用TypeScript和Angular框架构建Web组件。在展开具体知识点之前,我们首先要了解一下TypeScript和Angular的基本概念以及Web组件的相关历史。 1. JavaScript的发展历史:TypeScript是JavaScript的一...
ORM for TypeScript and JavaScr
Building Web Components with TypeScript and Angular 4 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
支持具有转换限制的ESNext和TypeScript语法(请参阅Note ) 注意:默认JavaScript语法目标设置为ES2017 ,因此所有AWS Lambda Node.js运行时都将支持最终捆绑包。 如果您仍在使用旧的lambda运行时,并且必须遵循它...
该项目是一款采用Java、Vue、TypeScript及HTML技术栈的后台管理平台源码,包含132个文件,涵盖56个Java类、29个Vue组件、18个...该系统与project-code-generate工具配套使用,旨在提供高效的后台管理解决方案。
服务器cd进入服务器文件夹cd React - Typescript - GraphQL - Project / server 运行npm install npm install 要启动服务器(如果您有yarn install运行) yarn dev 或者npm run dev 您应该在终端上看到类似的内容[ ...
无服务器分析 :high_voltage: 一个Google Analytics(分析)个人跟踪网站访问者的示例项目和概念验证。 您可以在上了解有关进行更多信息… ...可以在serverless.yml配置文件中自定义所有设置。 您可以轻松更改Dyn
Advanced TypeScript Programming Projects: Build 9 different apps with TypeScript 3 and JavaScript frameworks such as Angular, React, and Vue Gain in-depth knowledge of TypeScript and the latest ...
【typescript_shop_project】是一个使用TypeScript构建的电商项目,展示了如何在实际开发中利用TypeScript的强大特性和静态类型检查来提升代码质量和可维护性。在这个项目中,TypeScript被用作主要的编程语言,用于...
serverless-bundle是一个插件,可以通过合理的默认值最佳地打包ES6或TypeScript Node.js Lambda函数,因此您不必维护自己的Webpack配置。 它在内部使用插件。 只有一个依赖 支持ES6和TypeScript 生成优化的软件包...