{"id":21947,"library":"rollup-plugin-cjs-check","title":"rollup-plugin-cjs-check","description":"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.","status":"active","version":"1.0.3","language":"javascript","source_language":"en","source_url":"https://github.com/0no-co/rollup-plugin-cjs-check","tags":["javascript","typescript"],"install":[{"cmd":"npm install rollup-plugin-cjs-check","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-cjs-check","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-cjs-check","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: plugin hooks into Rollup build process","package":"rollup","optional":false}],"imports":[{"note":"Default export only; named export does not exist.","wrong":"const { cjsCheck } = require('rollup-plugin-cjs-check')","symbol":"default","correct":"import cjsCheck from 'rollup-plugin-cjs-check'"},{"note":"This is the default import. Named import 'cjsCheck' is a common mistake.","wrong":"import { cjsCheck } from 'rollup-plugin-cjs-check'","symbol":"cjsCheck","correct":"import cjsCheck from 'rollup-plugin-cjs-check'"},{"note":"TypeScript type exported for plugin options; not a runtime export.","wrong":null,"symbol":"type CjsCheckOptions","correct":"import type { CjsCheckOptions } from 'rollup-plugin-cjs-check'"}],"quickstart":{"code":"// rollup.config.js\nimport cjsCheck from 'rollup-plugin-cjs-check';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    dir: 'output',\n    format: 'cjs',\n  },\n  plugins: [\n    cjsCheck(),\n  ],\n};\n","lang":"javascript","description":"Basic Rollup configuration using the cjs-check plugin to validate CJS exports."},"warnings":[{"fix":"Ensure your Rollup output format is 'cjs'.","message":"Plugin only works when output format is 'cjs'. Using with other formats silently skips checking.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Review the reported mismatches and adjust named exports or use 'output.exports: 'named'' configuration.","message":"Plugin does not fix mismatched exports; it only reports them. Manual adjustment of Rollup configuration or code may be needed.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use static export syntax or output format 'es' for full ESM compatibility.","cause":"Rollup detected an export that cjs-module-lexer cannot parse, likely due to dynamic export patterns or re-exports.","error":"RollupError: [rollup-plugin-cjs-check] Export 'MyExport' is not detected by cjs-module-lexer"},{"fix":"Ensure the Rollup configuration uses format: 'cjs'.","cause":"Plugin was used with a non-CJS output format, causing the check to be skipped (but may warn).","error":"Error: Expected output format to be 'cjs' but got 'es'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}