Closed askoufis closed 5 months ago
Latest commit: d844d57e1f356ed850a0af062c0b2fd3edaf191b
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Support
invariant
function andtiny-invariant
librarytiny-invariant
is a small, 0 dependency assertion library. The standard way of importing its assertion function is to name itinvariant
, which is why I added it to thevariables
config forbabel-plugin-unassert
.Why should we support
tiny-invariant
?For dev-time assertions in the browser, usually we'd reach for the
assert
library. This is what Braid uses. However, it has an unnecessarily large dependency graph for an assertion library.Hopefully we can eventually replace
assert
withtiny-invariant
within Braid. Part of that involves supporting an alternative assertion library in sku. Not sure when the change in Braid will happen, as it depends on consumers using a version of sku that supportstiny-invariant
(i.e. whatever version this change is released in).Tradeoffs between
assert
andtiny-invariant
assert
supports checking non-primitive values, has more useful error messages, and offers various assertion functions.tiny-invariant
just asserts on a user-provided condition, throwing an error if it fails. That's it. This is likely suitable for most use cases, and will probably work just fine in Braid and most front-end apps/libraries.Meme
Show
![drug eyes polyfills meme](https://github.com/seek-oss/sku/assets/5663042/90194631-73c2-459c-b28a-55719d5c5fab)