mobx-state-tree icon indicating copy to clipboard operation
mobx-state-tree copied to clipboard

Include compiled es6 version in the package

Open andrey-ridge opened this issue 6 years ago • 5 comments

Bug report

  • [x] I've checked documentation and searched for existing issues
  • [x] I've made sure my project is based on the latest MST version
  • [ ] (not applicable) Fork this code sandbox or another minimal reproduction.

TypeScript project with compilerOptions.target: "es6" gives the error in MSTMap constructor:

Class constructor ObservableMap$$1 cannot be invoked without 'new'

MST npm package contains only ES5 code. MSTMap extends mobx.ObservableMap with old-fashioned way without class syntax.

function MSTMap(initialData) {
    return _super.call(this, initialData, mobx.observable.ref.enhancer) || this;
}

and this gives the error when mobx.es6.js used.

Temporary solution that worked for me - set compilerOptions.target to "es5". I suggest it's possible to include es6 version of MST in npm package (same way as mobx.es6.js).

andrey-ridge avatar Dec 06 '18 21:12 andrey-ridge

The same and it's still not resolved.

Also, for some reason I bumped to the issue of that all maps are undefined by default instead of empty Map objects, so it leads to error in values function which does not accept undefined as an argument

Carduelis avatar Nov 11 '19 12:11 Carduelis

all es5 should be valid es6 I'd expect. Please create a small repository that demonstrates the problem.

mweststrate avatar Nov 11 '19 19:11 mweststrate

Demo repo: https://github.com/andrey-ridge/mst-1101-demo

Please refer to README.md to build and run demo. Expected output should be like this:

Testing TodoMap with ES_VER=5...OK
Testing TodoMap with ES_VER=6...
TypeError: Class constructor ObservableMap cannot be invoked without 'new'

andrey-ridge avatar Nov 14 '19 11:11 andrey-ridge

@andrey-ridge Do you still need this??

The JS tools ecosystem has improved a lot as of now. If you still need this please comment.

@coolsoftwaretyler Do you think it's still relevant to fix this issue??

chakrihacker avatar Sep 06 '23 16:09 chakrihacker

@chakrihacker - I think we should leave this open. I'm seeing errors from the reproduction project, and I'd like to support this if we could.

It's been a while and not a ton of activity here, but that doesn't mean there aren't folks out there who might need it, and I'm guessing we can fix this with some kind of build config without actually changing library code?

coolsoftwaretyler avatar Sep 07 '23 04:09 coolsoftwaretyler