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

es5 support for Map/Set #437

Merged
merged 3 commits into from
Oct 22, 2019
Merged

es5 support for Map/Set #437

merged 3 commits into from
Oct 22, 2019

Conversation

runnez
Copy link
Collaborator

@runnez runnez commented Oct 4, 2019

Hi guys! This is a draft solution for es5 map support. What do you think about this approach?
It should works with babel preset, also it may works in IE11 ;)

Now map draft tests passes and I'm planning to add Set support, patches, etc

@runnez
Copy link
Collaborator Author

runnez commented Oct 4, 2019

Hmm, CI failed, I guess according this 017de43

@runnez runnez changed the title map es5 support draft concept map es5 support draft Oct 5, 2019
@runnez runnez mentioned this pull request Oct 5, 2019
2 tasks
@mweststrate
Copy link
Collaborator

Awesome! I'll hope to review in detail hopefully somewhere next week

@mweststrate mweststrate self-requested a review October 10, 2019 23:34
@runnez runnez changed the title map es5 support draft map/set es5 support draft Oct 14, 2019
@runnez
Copy link
Collaborator Author

runnez commented Oct 16, 2019

Need to decide

  • Should it work in environment without Map and Set?
    If yes, I need to add a checking
  • Should it work in IE11 without babel?
    IE11 has partial support without iteration methods and difference between Map.set method and does not support new Map(iterable)

And I have doubts about a lot of copy-paste between implementations proxy and es5

@mweststrate
Copy link
Collaborator

  1. No, as they can be polyfilled, which is the responsibility of the consumer of this package. A nice error message about the need of this would be great though.
  2. I think it is fine sticking to the normal web api's, and if something doesn't work on any browser, it is up to the host to set up some polyfill. So I'd write the code as if it is targetting a modern browser.
  3. I can imagine that having only an ES5 implementation might work, that is, a class based approach, and use that one in the Proxy case as well? I mean, the fact that Proxies are available, doesn't mean that we must use them :). I'd opt for code-base maintainability here.

@runnez
Copy link
Collaborator Author

runnez commented Oct 21, 2019

No, as they can be polyfilled, which is the responsibility of the consumer of this package. A nice error message about the need of this would be great though.

We have some checking here
https://github.com/immerjs/immer/pull/437/files#diff-de99f837249e5adf62716789c7b9e80eR40
Imagine, some consumer no uses Map or Set if he updates Immer, it will fail in ES5 browsers without Map and Set

@runnez runnez changed the title map/set es5 support draft es5 support for Map/Set Oct 21, 2019
@runnez
Copy link
Collaborator Author

runnez commented Oct 21, 2019

@mweststrate I think I've done. But I don't understand one thing. Should I update markChangesRecursively? It skips Map and Set, should skipping be explicit?

@mweststrate
Copy link
Collaborator

mweststrate commented Oct 21, 2019 via email

@mweststrate
Copy link
Collaborator

Superficially this looks great! I'll merge it into the v4 branch, and to further local investigation there. I'll also send a maintainer invite. That will allow you to directly commit to that branch, which avoids the whole song-and-dance of maintaining your own fork :)

@mweststrate mweststrate merged commit 85656cb into immerjs:v4 Oct 22, 2019
@runnez
Copy link
Collaborator Author

runnez commented Oct 22, 2019

@mweststrate Glad to hear that! Thanks a lot for invitation!

@aleclarson
Copy link
Member

🎉 This PR is included in version 5.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

3 participants