A Rsbuild plugin that configures your build for AWS Lambda deployment. This plugin automatically sets up the correct build configuration for AWS Lambda Node.js runtime compatibility.
# npm
npm install rsbuild-plugin-aws-lambda -D
# yarn
yarn add rsbuild-plugin-aws-lambda -D
# pnpm
pnpm add rsbuild-plugin-aws-lambda -D
Add the plugin to your Rsbuild config:
import { pluginAwsLambda } from 'rsbuild-plugin-aws-lambda';
export default {
plugins: [pluginAwsLambda()],
};This plugin will:
- Set the build target to
nodeby default - Configure the output library type as
commonjs2for AWS Lambda compatibility (AWS Lambda expects CommonJS modules by default)
After building your project, you can configure your Lambda function's handler using the format:
<filename>.<handler>
For example, if your entry file is src/index.js and exports a handler function:
// src/index.js
export const handler = async (event, context) => {
// Your Lambda function logic
return {
statusCode: 200,
body: JSON.stringify({ message: 'Success!' })
};
};Set your Lambda handler configuration to: index.handler
You can override the plugin behavior with options:
export default {
plugins: [
pluginAwsLambda({
override: {
target: 'node', // 'node' | 'web' | 'web-worker'
library: {
type: 'commonjs2',
// other library options...
},
},
}),
],
};- Type:
'node' | 'web' | 'web-worker' - Default:
'node' - Purpose: Specifies the build target environment. For AWS Lambda, this should typically remain as
'node'
- Type:
LibraryOptions - Default:
{ type: 'commonjs2' } - Purpose: Configures the output library format. The default
commonjs2setting ensures compatibility with AWS Lambda's Node.js runtime
MIT License