{"id":21984,"library":"rollup-plugin-deassert","title":"rollup-plugin-deassert","description":"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.","status":"active","version":"1.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/RebeccaStevens/deassert","tags":["javascript","assert","deassert","invariant","unassert","rollup","rollup-plugin","typescript"],"install":[{"cmd":"npm install rollup-plugin-deassert","lang":"bash","label":"npm"},{"cmd":"yarn add rollup-plugin-deassert","lang":"bash","label":"yarn"},{"cmd":"pnpm add rollup-plugin-deassert","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for parsing JavaScript/TypeScript AST to locate assert calls","package":"acorn","optional":false},{"reason":"Peer dependency — plugin runs within Rollup's build pipeline","package":"rollup","optional":false}],"imports":[{"note":"Package exports ESM primarily; named export 'rollupPlugin' must be aliased per documentation. CJS require may not work in some environments.","wrong":"const deassert = require('rollup-plugin-deassert')","symbol":"deassert (rollupPlugin)","correct":"import { rollupPlugin as deassert } from 'rollup-plugin-deassert'"},{"note":"The package also has a default export, but the README uses the named export pattern. Both are valid.","wrong":"import { default as deassert } from 'rollup-plugin-deassert'","symbol":"deassert (default)","correct":"import deassert from 'rollup-plugin-deassert'"},{"note":"TypeScript types are bundled; use 'import type' for compile-time only usage to avoid runtime errors.","wrong":"import { DeassertOptions } from 'rollup-plugin-deassert'","symbol":"type DeassertOptions","correct":"import type { DeassertOptions } from 'rollup-plugin-deassert'"}],"quickstart":{"code":"// rollup.config.js\nimport { rollupPlugin as deassert } from 'rollup-plugin-deassert';\n\nexport default {\n  input: 'src/index.ts',\n  output: {\n    file: 'dist/bundle.js',\n    format: 'cjs'\n  },\n  plugins: [\n    deassert({\n      include: ['**/*.ts'],\n      sourcemap: true\n    })\n  ]\n};","lang":"typescript","description":"Example of using rollup-plugin-deassert in a Rollup config to strip assert statements from TypeScript files."},"warnings":[{"fix":"Replace default import { deassert } from 'rollup-plugin-deassert' with named import { rollupPlugin as deassert } from 'rollup-plugin-deassert'.","message":"Default export may be removed in future versions; use named export 'rollupPlugin' for stability.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade to >=1.3.0 to handle conditional expressions.","message":"Version 1.3.0 introduced support for conditional expressions; previous versions would ignore assert inside ternary/if conditions.","severity":"breaking","affected_versions":"<1.3.0"},{"fix":"Add include: ['**/*.ts'] or appropriate glob to deassert() options.","message":"If using TypeScript, you must explicitly set include: ['**/*.ts'] in options; otherwise the plugin only processes JavaScript files.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider migrating to the 'deassert' package for cross-bundler compatibility.","message":"The package 'rollup-plugin-deassert' is deprecated in favor of the unified 'deassert' package that supports multiple bundlers.","severity":"deprecated","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":"Run 'npm install -D rollup-plugin-deassert' or check package.json for correct name.","cause":"Package not installed or named incorrectly.","error":"Error: Cannot find module 'rollup-plugin-deassert'"},{"fix":"Use 'import { rollupPlugin as deassert } from 'rollup-plugin-deassert'' instead of 'import deassert from ...'.","cause":"Using default import incorrectly or wrong import path.","error":"TypeError: deassert is not a function"},{"fix":"Ensure the import is correct and the plugin is included in the plugins array: plugins: [deassert()].","cause":"Incorrect import or plugin not added to rollup config.","error":"Error: The plugin deassert does not exist or is not a function."},{"fix":"Add 'include: [\"**/*.ts\"]' to deassert options if using TypeScript files.","cause":"The plugin didn't remove the assert statement (e.g., when include option is missing for TypeScript).","error":"AssertionError [ERR_ASSERTION]: false == true"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}