Registry / testing / unassert-rollup-plugin

unassert-rollup-plugin

JSON →
library2.0.0jsnpmunverified

A Rollup plugin to remove assertion calls from production bundles using Unassert. Current stable version is 2.0.0, released with Unassert 2.0.0. Release cadence is low; v1 used Unassert 1.6.0. It strips assert, power-assert, and custom assertion statements, reducing bundle size and avoiding runtime assertions in production. Key differentiator: integrates Unassert's removal logic directly into the Rollup build pipeline, supporting include/exclude patterns, sourcemaps, and custom assertion patterns.

npm install unassert-rollup-plugin
INSTALL
IMPORT
SIG · UNASSERT-ROLLUP-PL
U
unassert-rollup-plugin
testingjavascriptv2.0.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.

unassert
import { unassert } from 'unassert-rollup-plugin';
import unassert from 'unassert-rollup-plugin';
The plugin exports a named function `unassert`. Default import is incorrect and will result in undefined.
unassert (as default)
import unassert from 'unassert-rollup-plugin';
import { unassert } from 'unassert-rollup-plugin';
In v2.0.0, the plugin also supports a default export (the same function). The README shows both patterns. Both work.
require()
const { unassert } = require('unassert-rollup-plugin');
const unassert = require('unassert-rollup-plugin');
CommonJS require must use destructuring to get the named export. Using require without destructuring yields an object containing the unassert function.

Rollup configuration using unassert plugin to remove assertion calls, with inclusion/exclusion patterns and sourcemap support.

import { unassert } from 'unassert-rollup-plugin'; export default { input: 'src/index.js', output: { file: 'dist/bundle.js', format: 'esm' }, plugins: [ unassert({ include: ['**/*.js'], exclude: ['test/**'], sourcemap: true, assertionPatterns: ['assert(value)', 'assert.ok(value)', 'assert.equal(actual, expected)'] }) ] };
Debug
Known issues
breakingv2.0.0 upgraded to Unassert 2.0.0, which may have different behavior regarding assertion pattern matching.
fix
Review Unassert 2.0.0 changelog for changes to assertion patterns and require/import handling.
affects: >=2.0.0
gotchaThe plugin only processes JavaScript files by default. For TypeScript or other file types, you must specify the 'include' option.
fix
Set 'include' to '**/*.ts' or similar if using TypeScript.
affects: >=1.0.0
deprecatedDefault export is deprecated in v2? The README shows both named and default exports, but the TypeScript types may only export named. Default import may stop working in future releases.
fix
Always use named import: import { unassert } from 'unassert-rollup-plugin';
affects: =2.0.0
gotchaSetting sourcemap: false removes assert calls from the output but also suppresses sourcemaps for the transformed code, making debugging harder.
fix
Keep sourcemap: true (default) to maintain debug ability.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: unassert is not a function
Using default import when the plugin exports a named function.
fix
Change to: import { unassert } from 'unassert-rollup-plugin';
Error: Could not resolve 'unassert-rollup-plugin'
Missing installation or incorrect import path.
fix
Run: npm install -D unassert-rollup-plugin
Upgrade
Version history
2.0.0latest on npm
Audit
Dependencies
unassertrequiredCore module that removes assertion calls; this plugin invokes unassert on each file.
Agent activity
10 hits · last 30 days
node
10
Resources
unassert-rollup-plugin — npm install unassert-rollup-plugin · libregistry