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 cjs and esm version for browser builds #1834

Merged
merged 1 commit into from
Dec 11, 2018

Conversation

mrtnbroder
Copy link
Contributor

@mrtnbroder mrtnbroder commented Dec 7, 2018

I've been running into issues with basic usage of mobx, where in a complete esm environment, a import * as mobx from 'mobx' webpack would still require the cjs version of mobx, though, a module entry is there and also defined within the package.json. This caused a lot of headache, as there was no reason to do so.

However, due to some weird behaviour, webpack 4 refuses to load the module version of mobx, until I've added the browser field to package.json.

Everything should still work correctly within a commonjs environment, as a require call to mobx within the browser still requires the cjs version. Thanks a lot to https://github.com/stereobooster/main-module-browser-test for the idea behind this.

This works reliable for me, so it would be great to get this merged in!

@coveralls
Copy link

Coverage Status

Coverage remained the same at 93.577% when pulling 72bdf6b on mrtnbroder:webpack-4-browser-field into d55c50a on mobxjs:master.

@mweststrate
Copy link
Member

Wow, ok, thanks for figuring out :)

@mweststrate mweststrate merged commit b115850 into mobxjs:master Dec 11, 2018
@mweststrate
Copy link
Member

released in 4.8.0 / 5.8.0

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

Successfully merging this pull request may close these issues.

4 participants