invariant
invariant copied to clipboard
Support ES Modules
invariant
only provides a CommonJS interface (exports = function()
). Unfortunately, this will fail if it is used in an ES Module environment (for instance, in jsxstyle
).
I don't know enough about how you mirror/bundle this package to provide a PR. A hacky (but probably functional) solution could be to create a default
property on invariant
and set it to the function:
function invariant() {}
module.exports = invariant;
invariant.default = invariant;
That would allow invariant to be used as an ES Module:
import invariant from 'invariant';
However, a proper ES Module would allow tools like webpack to better optimize bundle size.