Registry / devops / rollup-plugin-cjs-check

rollup-plugin-cjs-check

JSON →
library1.0.3jsnpmunverified

A Rollup plugin that automatically verifies CommonJS output compatibility with Node.js's cjs-module-lexer. Currently at v1.0.3, with stable release cadence. It analyzes the generated CJS bundle and compares the exports detected by Rollup against those that cjs-module-lexer would detect, flagging mismatches that cause broken named imports in Node.js ESM. Unlike manual testing, this provides automated CI enforcement. Requires Rollup >=1.20.0 and Node >=14.0.0.

npm install rollup-plugin-cjs-check
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-CJS-
R
rollup-plugin-cjs-check
devopsjavascriptv1.0.3
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
import cjsCheck from 'rollup-plugin-cjs-check'
const { cjsCheck } = require('rollup-plugin-cjs-check')
Default export only; named export does not exist.
cjsCheck
import cjsCheck from 'rollup-plugin-cjs-check'
import { cjsCheck } from 'rollup-plugin-cjs-check'
This is the default import. Named import 'cjsCheck' is a common mistake.
type CjsCheckOptions
import type { CjsCheckOptions } from 'rollup-plugin-cjs-check'
TypeScript type exported for plugin options; not a runtime export.

Basic Rollup configuration using the cjs-check plugin to validate CJS exports.

// rollup.config.js import cjsCheck from 'rollup-plugin-cjs-check'; export default { input: 'src/index.js', output: { dir: 'output', format: 'cjs', }, plugins: [ cjsCheck(), ], };
Debug
Known issues
gotchaPlugin only works when output format is 'cjs'. Using with other formats silently skips checking.
fix
Ensure your Rollup output format is 'cjs'.
affects: >=1.0.0
gotchaPlugin does not fix mismatched exports; it only reports them. Manual adjustment of Rollup configuration or code may be needed.
fix
Review the reported mismatches and adjust named exports or use 'output.exports: 'named'' configuration.
affects: >=1.0.0
Errors
Common errors & fixes
RollupError: [rollup-plugin-cjs-check] Export 'MyExport' is not detected by cjs-module-lexer
Rollup detected an export that cjs-module-lexer cannot parse, likely due to dynamic export patterns or re-exports.
fix
Use static export syntax or output format 'es' for full ESM compatibility.
Error: Expected output format to be 'cjs' but got 'es'
Plugin was used with a non-CJS output format, causing the check to be skipped (but may warn).
fix
Ensure the Rollup configuration uses format: 'cjs'.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
rolluprequiredPeer dependency: plugin hooks into Rollup build process
Agent activity
7 hits · last 30 days
node
6
Resources
rollup-plugin-cjs-check — npm install rollup-plugin-cjs-check · libregistry