{"id":22512,"library":"unassert-rollup-plugin","title":"unassert-rollup-plugin","description":"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.","status":"active","version":"2.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/birkskyum/unassert-rollup-plugin","tags":["javascript","plugin","rollup","unassert","typescript"],"install":[{"cmd":"npm install unassert-rollup-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add unassert-rollup-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add unassert-rollup-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core module that removes assertion calls; this plugin invokes unassert on each file.","package":"unassert","optional":false}],"imports":[{"note":"The plugin exports a named function `unassert`. Default import is incorrect and will result in undefined.","wrong":"import unassert from 'unassert-rollup-plugin';","symbol":"unassert","correct":"import { unassert } from 'unassert-rollup-plugin';"},{"note":"In v2.0.0, the plugin also supports a default export (the same function). The README shows both patterns. Both work.","wrong":"import { unassert } from 'unassert-rollup-plugin';","symbol":"unassert (as default)","correct":"import unassert from 'unassert-rollup-plugin';"},{"note":"CommonJS require must use destructuring to get the named export. Using require without destructuring yields an object containing the unassert function.","wrong":"const unassert = require('unassert-rollup-plugin');","symbol":"require()","correct":"const { unassert } = require('unassert-rollup-plugin');"}],"quickstart":{"code":"import { unassert } from 'unassert-rollup-plugin';\n\nexport default {\n  input: 'src/index.js',\n  output: {\n    file: 'dist/bundle.js',\n    format: 'esm'\n  },\n  plugins: [\n    unassert({\n      include: ['**/*.js'],\n      exclude: ['test/**'],\n      sourcemap: true,\n      assertionPatterns: ['assert(value)', 'assert.ok(value)', 'assert.equal(actual, expected)']\n    })\n  ]\n};","lang":"typescript","description":"Rollup configuration using unassert plugin to remove assertion calls, with inclusion/exclusion patterns and sourcemap support."},"warnings":[{"fix":"Review Unassert 2.0.0 changelog for changes to assertion patterns and require/import handling.","message":"v2.0.0 upgraded to Unassert 2.0.0, which may have different behavior regarding assertion pattern matching.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Set 'include' to '**/*.ts' or similar if using TypeScript.","message":"The plugin only processes JavaScript files by default. For TypeScript or other file types, you must specify the 'include' option.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always use named import: import { unassert } from 'unassert-rollup-plugin';","message":"Default 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.","severity":"deprecated","affected_versions":"=2.0.0"},{"fix":"Keep sourcemap: true (default) to maintain debug ability.","message":"Setting sourcemap: false removes assert calls from the output but also suppresses sourcemaps for the transformed code, making debugging harder.","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":"Change to: import { unassert } from 'unassert-rollup-plugin';","cause":"Using default import when the plugin exports a named function.","error":"TypeError: unassert is not a function"},{"fix":"Run: npm install -D unassert-rollup-plugin","cause":"Missing installation or incorrect import path.","error":"Error: Could not resolve 'unassert-rollup-plugin'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}