reasonml / reason-react

Reason bindings for ReactJS
https://reasonml.github.io/reason-react/
MIT License
3.25k stars 349 forks source link

Wrap the React Library #770

Closed anmonteiro closed 1 year ago

anmonteiro commented 1 year ago

reason-react exposes too many toplevel modules. These could be nested under React, e.g.:

davesnx commented 1 year ago

I would like to rethink this and keep the toplevel equal to the library names:

We could unwrap and keep the minimum toplevels but those match the packages installed from npm 1 to 1.

The benefits of this are:

anmonteiro commented 1 year ago

I don't think that's a good idea. Why is it so important that our library structure matches the JS package names / sub-paths?

I actually think that the current wrapped design is quite elegant and there's a nice sub-module for everything that you can access.

davesnx commented 1 year ago

I don't think that's a good idea. Why is it so important that our library structure matches the JS package names / sub-paths?

First for discoverability and second to have the minimum amount of subjectivity on the names of the structure. People don't read the documentation to use a module/function, they often use autocomplete.

anmonteiro commented 1 year ago

I don't think it's very discoverable having to add (libraries react react.dom react.dom-server) in order to have those modules appear in your editor. It's a much better API to have (libraries reason-react) and React.DOM etc. don't you think?

davesnx commented 1 year ago

What I'm proposing is to have libraries reason-react which exposes react, reactdom, etc. and not fall into the trap what we had before so, React.Event, ReactDOM.Style, ReactDOM.Server etc still remains wrapped.

anmonteiro commented 1 year ago

how do you expose those multiple toplevel modules from:

  1. a single library reason-react
  2. without exposing all?
davesnx commented 1 year ago

wrapped false, one module per toplevel, the rest either inlined or private libraries

anmonteiro commented 1 year ago

That actually sounds pretty nice if you can make it work. I'm in favor of it, if we can manage to hide the internal modules.