Registry / devops / rollup-plugin-deassert

rollup-plugin-deassert

JSON →
library1.3.0jsnpmunverified

Rollup plugin to remove assert, invariant, and similar statements from production bundles. Current stable version: 1.3.2 (2024-08-23). Release cadence: active development with frequent updates. Key differentiator: supports both ESM and CJS, ships TypeScript definitions, and handles conditional expressions. Unlike alternatives, it integrates naturally with Rollup's plugin system and respects source maps. Peer dependencies: acorn ^8.12.1 and rollup ^4.20.0.

npm install rollup-plugin-deassert
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-DEAS
R
rollup-plugin-deassert
devopsjavascriptv1.3.0
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.

deassert (rollupPlugin)
import { rollupPlugin as deassert } from 'rollup-plugin-deassert'
const deassert = require('rollup-plugin-deassert')
Package exports ESM primarily; named export 'rollupPlugin' must be aliased per documentation. CJS require may not work in some environments.
deassert (default)
import deassert from 'rollup-plugin-deassert'
import { default as deassert } from 'rollup-plugin-deassert'
The package also has a default export, but the README uses the named export pattern. Both are valid.
type DeassertOptions
import type { DeassertOptions } from 'rollup-plugin-deassert'
import { DeassertOptions } from 'rollup-plugin-deassert'
TypeScript types are bundled; use 'import type' for compile-time only usage to avoid runtime errors.

Example of using rollup-plugin-deassert in a Rollup config to strip assert statements from TypeScript files.

// rollup.config.js import { rollupPlugin as deassert } from 'rollup-plugin-deassert'; export default { input: 'src/index.ts', output: { file: 'dist/bundle.js', format: 'cjs' }, plugins: [ deassert({ include: ['**/*.ts'], sourcemap: true }) ] };
Debug
Known issues
gotchaDefault export may be removed in future versions; use named export 'rollupPlugin' for stability.
fix
Replace default import { deassert } from 'rollup-plugin-deassert' with named import { rollupPlugin as deassert } from 'rollup-plugin-deassert'.
affects: >=1.0.0
breakingVersion 1.3.0 introduced support for conditional expressions; previous versions would ignore assert inside ternary/if conditions.
fix
Upgrade to >=1.3.0 to handle conditional expressions.
affects: <1.3.0
gotchaIf using TypeScript, you must explicitly set include: ['**/*.ts'] in options; otherwise the plugin only processes JavaScript files.
fix
Add include: ['**/*.ts'] or appropriate glob to deassert() options.
affects: >=1.0.0
deprecatedThe package 'rollup-plugin-deassert' is deprecated in favor of the unified 'deassert' package that supports multiple bundlers.
fix
Consider migrating to the 'deassert' package for cross-bundler compatibility.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'rollup-plugin-deassert'
Package not installed or named incorrectly.
fix
Run 'npm install -D rollup-plugin-deassert' or check package.json for correct name.
TypeError: deassert is not a function
Using default import incorrectly or wrong import path.
fix
Use 'import { rollupPlugin as deassert } from 'rollup-plugin-deassert'' instead of 'import deassert from ...'.
Error: The plugin deassert does not exist or is not a function.
Incorrect import or plugin not added to rollup config.
fix
Ensure the import is correct and the plugin is included in the plugins array: plugins: [deassert()].
AssertionError [ERR_ASSERTION]: false == true
The plugin didn't remove the assert statement (e.g., when include option is missing for TypeScript).
fix
Add 'include: ["**/*.ts"]' to deassert options if using TypeScript files.
Upgrade
Version history
1.3.0latest on npm
Audit
Dependencies
acornrequiredRequired for parsing JavaScript/TypeScript AST to locate assert calls
rolluprequiredPeer dependency — plugin runs within Rollup's build pipeline
Agent activity
12 hits · last 30 days
node
10
Amazon
1
Resources
rollup-plugin-deassert — npm install rollup-plugin-deassert · libregistry