rollup-plugin-unassert

raw JSON →
0.6.0 verified Mon Apr 27 auth: no javascript maintenance

Rollup plugin to remove assertion calls (e.g., assert, console.assert) from bundles using Unassert. Current stable version: 0.6.0. Low release cadence (last release 2020). Key differentiator: integrates Unassert into Rollup builds, removing debug assertions from production code, improving bundle size and performance. Alternatives like babel-plugin-unassert require Babel; this plugin is Rollup-native.

error Error: Cannot find module 'rollup-plugin-unassert'
cause Missing local installation or incorrect import path.
fix
npm install --save-dev rollup-plugin-unassert
error TypeError: unassert is not a function
cause Using named import instead of default import.
fix
Use import unassert from 'rollup-plugin-unassert' (without curly braces).
error ! RollupError: Could not resolve 'unassert' from ...
cause Unassert internal dependency not resolved; Rollup may fail if not installed.
fix
Ensure unassert is installed as a dependency: npm install unassert
gotcha The plugin removes assertion calls only in production builds; during development assertions remain. Ensure it is used in production config only.
fix Conditionally add plugin based on process.env.NODE_ENV or similar.
gotcha Sourcemap support: setting sourcemap: false hides assert calls when debugging. Leave as default true to keep sourcemaps accurate.
fix Do not set sourcemap: false unless you understand the debugging tradeoff.
deprecated Package is in maintenance mode; no active development. Consider using a more actively maintained alternative.
fix Evaluate alternatives like babel-plugin-unassert or manual removal.
npm install rollup-plugin-unassert
yarn add rollup-plugin-unassert
pnpm add rollup-plugin-unassert

Basic Rollup config with rollup-plugin-unassert to remove assertion calls from build output.

import unassert from 'rollup-plugin-unassert';

export default {
  input: 'src/index.js',
  output: {
    file: 'dist/bundle.js',
    format: 'esm'
  },
  plugins: [
    unassert()
  ]
};