{"id":22356,"library":"serverless-rollup-plugin","title":"Serverless Rollup Plugin","description":"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.","status":"active","version":"5.1.5","language":"javascript","source_language":"en","source_url":"https://github.com/theBenForce/serverless-rollup-plugin","tags":["javascript"],"install":[{"cmd":"npm install serverless-rollup-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add serverless-rollup-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add serverless-rollup-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for bundling","package":"rollup","optional":false},{"reason":"Peer dependency - the Serverless Framework","package":"serverless","optional":false}],"imports":[{"note":"Plugin is referenced by its npm package name in serverless.yml. No JavaScript import needed.","wrong":"plugins:\n  - serverlessRollupPlugin","symbol":"default (plugin)","correct":"plugins:\n  - serverless-rollup-plugin"},{"note":"Rollup configs can be ESM; the plugin uses rollup's loadConfigFile internally. CommonJS also works but ESM is recommended.","wrong":"module.exports = { /* rollup config */ }","symbol":"Rollup config export","correct":"export default { /* rollup config */ }"},{"note":"Use 'dependencies' key, not 'include'. The plugin installs these in the deployment package.","wrong":"testFunction:\n  handler: src/handler.handler\n  include:\n    - aws-xray-sdk-core","symbol":"Function dependencies","correct":"testFunction:\n  handler: src/handler.handler\n  dependencies:\n    - aws-xray-sdk-core"}],"quickstart":{"code":"// Pre-requisites: Node.js >=18, serverless >=3.2, rollup installed\n// 1. Install the plugin\n// npm install --save-dev serverless-rollup-plugin\n\n// 2. serverless.yml\nplugins:\n  - serverless-rollup-plugin\n\ncustom:\n  rollup:\n    config: rollup.config.js\n    concurrency: 5\n\nfunctions:\n  hello:\n    handler: src/hello.handler\n    dependencies:\n      - source-map-support\n\n// 3. rollup.config.js (ESM)\nexport default {\n  input: 'src/hello.js',\n  output: {\n    format: 'cjs',\n    sourcemap: true,\n    banner: \"require('source-map-support').install();\"\n  }\n};\n\n// 4. Deploy\n// npx serverless deploy\n\n// The plugin will bundle src/hello.js, install source-map-support, and deploy to AWS Lambda.","lang":"yaml","description":"Minimal setup with serverless.yml and rollup.config.js for a Lambda function."},"warnings":[{"fix":"Upgrade Node.js to 18+ or use an older version of the plugin (e.g., 4.x).","message":"The plugin requires Node.js >=18 starting from version 5.0.0.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Use Serverless >=2.0.0 or use plugin version 3.x.","message":"Peer dependency on Serverless Framework dropped support for v1.x in version 4.0.0? (Verify version boundary)","severity":"breaking","affected_versions":">=4.0.0"},{"fix":"Instead of installCommand, manage dependencies with serverless's built-in package mechanism or use npm workspaces.","message":"The '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.","severity":"deprecated","affected_versions":">=5.0.0"},{"fix":"Ensure Lambda runtime is Node.js 14 or higher and that your handler path ends with .mjs in serverless.yml.","message":"If output format is 'esm', the .mjs extension is used, but Lambda native ESM support requires Node.js 14+ and function configuration may need adjustments.","severity":"gotcha","affected_versions":">=4.0.0"},{"fix":"Use rollup.write() via custom script or use a different bundling approach for such plugins.","message":"The 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().","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Create a rollup.config.js file or specify the path using custom.rollup.config in serverless.yml.","cause":"The plugin cannot find the Rollup config file. Default path is rollup.config.js in the project root.","error":"Error: ENOENT: no such file or directory, open '/path/to/rollup.config.js'"},{"fix":"Install rollup: npm install --save-dev rollup","cause":"Rollup is not installed as a devDependency or is not in node_modules.","error":"Error: Cannot find module 'rollup'"},{"fix":"Add 'serverless-rollup-plugin' to the plugins array in serverless.yml.","cause":"The plugin is not listed in plugins section, or it's misspelled.","error":"Error: The Serverless Framework plugin \"serverless-rollup-plugin\" is not recognized"},{"fix":"Reduce custom.rollup.concurrency to a lower number (e.g., 2 or 3).","cause":"Too many concurrent rollup processes for available memory.","error":"Error: Requested concurrency 5 but only 1 available? (paraphrase) - Out of memory during concurrent builds"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}