[英]How do you bundle aws-sdk-js into a Serverless Framework optimized package?
AWS SDK for node.js can not be run through browserify due to how the SDK is loaded由于SDK 的加载方式, AWS SDK for node.js 无法通过browserify运行
I want to included a newer version of the AWS SDK for node then what is included in lambda but I also want to optimize (via browserify) my lambda node.js code.我想包含一个较新版本的 AWS SDK for node 然后包含在 lambda 中,但我也想优化(通过 browserify)我的 lambda node.js 代码。
How do I pull this off?我该如何解决这个问题?
The JAWS AWS Module system (aka awsm) allows for this functionality via an attribute in the awsm.json metadata file that specifies how the lambda code is packaged. JAWS AWS 模块系统(又名 awsm)通过 awsm.json 元数据文件中的一个属性来实现此功能,该属性指定了 lambda 代码的打包方式。
Specifically the lambda.package.optimize.exclude
and lambda.package.optimize.includePaths
defined in the lambda configuration options section of the awsm.json spec.特别是lambda.package.optimize.exclude
规范的lambda 配置选项部分中定义的lambda.package.optimize.exclude
和lambda.package.optimize.includePaths
。
The exclude
attribute specifies node modules that should be excluded from the optimization process (under the covers it is just using browserify exclude ). exclude
属性指定应该从优化过程中排除的节点模块(在幕后,它只是使用browserify exclude )。 In the exclude
attribute you simply specify ['aws-sdk']
.在exclude
属性中,您只需指定['aws-sdk']
。 You must then tell JAWS to include aws-sdk
in the zip by putting its path in includePaths
.然后,您必须通过将其路径放在includePaths
来告诉 JAWS 将aws-sdk
包含在 zip 中。
The includePaths
attribute is a list of paths relative to the back
directory that are pulled in as-is into the zip file before deployment. includePaths
属性是相对于back
目录的路径列表,这些路径在部署之前按原样拉入 zip 文件。
For a complete example see the awsm sample有关完整示例,请参阅awsm 示例
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.