mobx: "export 'default' (imported as 'mobx') was not found in 'mobx'

Installed version 3.1.14 and I get: "export 'default' (imported as 'mobx') was not found in 'mobx' whereas with 3.1.10 everything works fine.

I’m using https://github.com/timarney/react-app-rewired

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 22 (17 by maintainers)

Most upvoted comments

Mobx is a rather large library that provides many methods that work together, as opposed to being a single function or class with a single purpose. While one could make the case that observable is really the focus of the library, there isn’t really a single item that mobx exports that can be called “mobx”. This is the same reason that React doesn’t have a default export, nor does redux.

This is precisely the scenario that named exports are for, and maintaining both named and default exports for a library of mobx’s size is cumbersome (as demonstrated by @andykog’s PR above). It also removes the need for deciding “how do I want to import mobx today?”, as there will be only one way to do it. The trade-off cost of import * as mobx from 'mobx'; vs import mobx from 'mobx'; is minimal (4 characters to be precise).