Registry / devops / serverless-rollup-plugin

serverless-rollup-plugin

JSON →
library5.1.5jsnpmunverified

A plugin for the Serverless Framework that bundles AWS Lambda functions using Rollup. Version 5.1.5 requires Node.js ≥18 and supports Serverless Framework v1–4 and Rollup v2–4. It automatically wraps handlers with module installation and file copying, supports concurrent builds, custom rollup configs, and ESM or CJS output. Differentiators: dependency injection per function, source map support, and Yarn/npm integration. Releases are automated via semantic-release on GitHub.

npm install serverless-rollup-plugin
INSTALL
IMPORT
SIG · SERVERLESS-ROLLUP-
S
serverless-rollup-plugin
devopsjavascriptv5.1.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (plugin)
plugins: - serverless-rollup-plugin
plugins: - serverlessRollupPlugin
Plugin is referenced by its npm package name in serverless.yml. No JavaScript import needed.
Rollup config export
export default { /* rollup config */ }
module.exports = { /* rollup config */ }
Rollup configs can be ESM; the plugin uses rollup's loadConfigFile internally. CommonJS also works but ESM is recommended.
Function dependencies
testFunction: handler: src/handler.handler dependencies: - aws-xray-sdk-core
testFunction: handler: src/handler.handler include: - aws-xray-sdk-core
Use 'dependencies' key, not 'include'. The plugin installs these in the deployment package.

Minimal setup with serverless.yml and rollup.config.js for a Lambda function.

// Pre-requisites: Node.js >=18, serverless >=3.2, rollup installed // 1. Install the plugin // npm install --save-dev serverless-rollup-plugin // 2. serverless.yml plugins: - serverless-rollup-plugin custom: rollup: config: rollup.config.js concurrency: 5 functions: hello: handler: src/hello.handler dependencies: - source-map-support // 3. rollup.config.js (ESM) export default { input: 'src/hello.js', output: { format: 'cjs', sourcemap: true, banner: "require('source-map-support').install();" } }; // 4. Deploy // npx serverless deploy // The plugin will bundle src/hello.js, install source-map-support, and deploy to AWS Lambda.
Debug
Known issues
breakingThe plugin requires Node.js >=18 starting from version 5.0.0.
fix
Upgrade Node.js to 18+ or use an older version of the plugin (e.g., 4.x).
affects: >=5.0.0
breakingPeer dependency on Serverless Framework dropped support for v1.x in version 4.0.0? (Verify version boundary)
fix
Use Serverless >=2.0.0 or use plugin version 3.x.
affects: >=4.0.0
deprecatedThe 'installCommand' option is deprecated; use 'npm install' or 'yarn add' directly in custom.rollup.dependencies? Not deprecated. Actually note: custom.rollup.installCommand still works but is not recommended because it does not handle lockfiles.
fix
Instead of installCommand, manage dependencies with serverless's built-in package mechanism or use npm workspaces.
affects: >=5.0.0
gotchaIf output format is 'esm', the .mjs extension is used, but Lambda native ESM support requires Node.js 14+ and function configuration may need adjustments.
fix
Ensure Lambda runtime is Node.js 14 or higher and that your handler path ends with .mjs in serverless.yml.
affects: >=4.0.0
gotchaThe plugin does not support Rollup plugins that need to run after the bundle is written (e.g., writeBundle hooks) because it uses rollup.generate() instead of rollup.write().
fix
Use rollup.write() via custom script or use a different bundling approach for such plugins.
affects: *
Errors
Common errors & fixes
Error: ENOENT: no such file or directory, open '/path/to/rollup.config.js'
The plugin cannot find the Rollup config file. Default path is rollup.config.js in the project root.
fix
Create a rollup.config.js file or specify the path using custom.rollup.config in serverless.yml.
Error: Cannot find module 'rollup'
Rollup is not installed as a devDependency or is not in node_modules.
fix
Install rollup: npm install --save-dev rollup
Error: The Serverless Framework plugin "serverless-rollup-plugin" is not recognized
The plugin is not listed in plugins section, or it's misspelled.
fix
Add 'serverless-rollup-plugin' to the plugins array in serverless.yml.
Error: Requested concurrency 5 but only 1 available? (paraphrase) - Out of memory during concurrent builds
Too many concurrent rollup processes for available memory.
fix
Reduce custom.rollup.concurrency to a lower number (e.g., 2 or 3).
Upgrade
Version history
5.1.5latest on npm
Audit
Dependencies
rolluprequiredPeer dependency for bundling
serverlessrequiredPeer dependency - the Serverless Framework
Agent activity
16 hits · last 30 days
node
14
Resources
serverless-rollup-plugin — npm install serverless-rollup-plugin · libregistry