alexreardon / tiny-invariant

A tiny invariant function

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

consider adding `warning` as well?

ianstormtaylor opened this issue · comments

Hey, thanks for this awesome library!

I was wondering if you'd consider adding the warning (source) counterpart to Facebook's invariant that logs warnings instead of throwing errors? It would be awesome to be able to use a single, tiny library for this like:

import { invariant, warning } from 'tiny-invariant'

Or maybe it would be in another?

import invariant from 'tiny-invariant'
import warning from 'tiny-warning'

They're both super useful for reducing build sizes I've found.

Thanks!

I think named export could make this package safer since bundler will check its existence in the package. Default export is blindly named by user and he can make a mistake and prevent babel plugin from processing. /cc @alexreardon

However this package has a specific name and should not have another behaviour to not confuse users. It's better to create tiny-warning package. I think it will be quite useful in libraries like jss and material-ui.

I can create one if we will agree with Alex about api.

you can now use tiny-warning 👍

Amazing, @alexreardon! A link for future folks: https://github.com/alexreardon/tiny-warning

Thank you!