Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ES Modules #29

Open
appsforartists opened this issue Nov 2, 2017 · 0 comments
Open

Support ES Modules #29

appsforartists opened this issue Nov 2, 2017 · 0 comments

Comments

@appsforartists
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant