Cypress Rollup Preprocessor
raw JSON → 1.2.0 verified Fri May 01 auth: no javascript
A Cypress preprocessor that bundles JavaScript test files using Rollup. Version 1.2.0, released 2022-06-18, is the latest stable release. The package is maintained with semantic versioning; breaking changes are documented in changelogs. It supports Cypress >=10 (ESM config) and <=9 (CJS config). Unlike alternatives like cy-rollup, this package closely follows the official Cypress preprocessor API and supports full Rollup input/output options, TypeScript configs, and watch mode. It requires Rollup 2.x as a peer dependency and ships TypeScript type definitions.
Common errors
error Cannot find module 'cypress-rollup-preprocessor' ↓
cause Package not installed or missing peer dependencies.
fix
Run
npm install cypress-rollup-preprocessor rollup@^2.0.0 --save-dev error Error: rollupOptions is not a function ↓
cause Option name changed in v0.7.0 from 'rollupOptions' to 'inputOptions'/'outputOptions'.
fix
Use
rollupPreprocessor({ inputOptions, outputOptions }) instead of rollupPreprocessor({ rollupOptions }) error TypeError: rollupPreprocessor is not a function ↓
cause Incorrect import or destructuring; default export not used correctly.
fix
Use
import rollupPreprocessor from 'cypress-rollup-preprocessor' (ESM) or const rollupPreprocessor = require('cypress-rollup-preprocessor') (CJS). Warnings
breaking In v0.7.0, the option 'rollupOptions' was renamed to 'inputOptions' and 'outputOptions'. Using 'rollupOptions' will cause a runtime error. ↓
fix Replace `rollupOptions` with `inputOptions` and `outputOptions` separately. Example: rollupPreprocessor({ inputOptions, outputOptions })
deprecated Cypress <=9 support is deprecated; newer versions may drop CJS require pattern. ↓
fix Migrate to Cypress >=10 and use ESM syntax: import rollupPreprocessor from 'cypress-rollup-preprocessor'
gotcha If you use TypeScript without 'esModuleInterop', default import may fail. Users incorrectly destructure the export. ↓
fix Use `import rollupPreprocessor from 'cypress-rollup-preprocessor'` with esModuleInterop, or use `const rollupPreprocessor = require('cypress-rollup-preprocessor')` in CJS.
gotcha The preprocessor only supports Rollup 2.x. Using Rollup 3.x or 4.x will cause incompatibility errors. ↓
fix Install rollup@2.x as a peer dependency: npm install rollup@^2.0.0 --save-dev
Install
npm install cypress-rollup-preprocessor yarn add cypress-rollup-preprocessor pnpm add cypress-rollup-preprocessor Imports
- default (rollupPreprocessor) wrong
const rollupPreprocessor = require('cypress-rollup-preprocessor').defaultcorrectimport rollupPreprocessor from 'cypress-rollup-preprocessor' - default (CJS require) wrong
const { rollupPreprocessor } = require('cypress-rollup-preprocessor')correctconst rollupPreprocessor = require('cypress-rollup-preprocessor') - TypeScript type imports wrong
import { CypressRollupPreprocessorOptions } from 'cypress-rollup-preprocessor'correctimport type { CypressRollupPreprocessorOptions } from 'cypress-rollup-preprocessor'
Quickstart
// cypress.config.ts (Cypress >=10)
import { defineConfig } from 'cypress'
import rollupPreprocessor from 'cypress-rollup-preprocessor'
export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
on('file:preprocessor', rollupPreprocessor())
},
},
})
// For custom Rollup options:
import rollupConfig from './rollup.config'
const { output: outputOptions, ...inputOptions } = rollupConfig
on('file:preprocessor', rollupPreprocessor({ inputOptions, outputOptions }))