deprecated: use babel-plugin-dev-expression instead.
Invariant assertions implemented as babel-plugin-macros macro.
# npm
npm install @vasiliicuhar/invariant.macro
# yarn
yarn add @vasiliicuhar/invariant.macro
import invariant from "@vasiliicuhar/invariant.macro"
let sum = 2 + 3
invariant(sum === 4, `expected 4, got ${sum}`)
// throws new InvariantError('Invariant failed: expected 4, got 5')
In production error messages are stripped from resulting bundle
invariant(condition, `error message ${prettyPrint(obj)}`)
// is transpiled to
invariant(condition)
invariant(condition, "invariant failed", { env: "development" })