Babel plugin that removes assertion calls (assert, console.assert, power-assert) from production builds. Current stable version is 3.2.0, compatible with Babel 7. Release cadence is low, with major versions tied to Babel major versions. Key differentiator: allows full use of assertions during development without runtime overhead in production, with support for ES modules and power-assert integration. Alternative to manual conditional wrapping or dead-code elimination.
npm install babel-plugin-unassertVerified import paths — ran on the pinned version, not inferred.
Demonstrates using babel-plugin-unassert via Babel config to remove assertions in production. Shows conditional plugin addition based on NODE_ENV.
Use babel-plugin-unassert@2 for Babel 6, @1 for Babel <=5.
Use babel-plugin-unassert@1 for Babel 5 or lower.
Upgrade to v2 (Babel 6) or v3 (Babel 7) as per your Babel version.
Ensure your assertions use standard assert module or power-assert. Alternatively, ensure custom functions have no side effects.
Use require('babel-plugin-unassert') or import default. Never destructure as { unassert }.Run 'npm install --save-dev babel-plugin-unassert' and ensure it's in node_modules.
Install the plugin and ensure node_modules path is correct. Check for typos.
Use const plugin = require('babel-plugin-unassert'); not const { unassert } = require('babel-plugin-unassert');Add 'babel-plugin-unassert' to plugins array when NODE_ENV === 'production'. Verify Babel config applies during build.