-
Notifications
You must be signed in to change notification settings - Fork 17
genType support #102
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
Comments
Any idea what needs to happen to support genType? Is it an extra PPX that implicitly needs to be called or something? |
I poked around a bit and it seems that during compilation rescript invokes the compiler like this:
whereas rewatch does it like this (I added the -bs-gentype flag)
|
Rewatch is awesome! But I definitely need gentype support in order to be able to use it at my company. I tried making this change and building my project, and it didn't produce gentype files:
Of course we wouldn't want to always add the flag like that, it'd be based on the Also I'm not sure how extra configs related to gentype in the bsconfig are supposed to get passed in, such as shims, output file extension etc. If anyone with more knowledge of the compiler api knows what needs to happen in order to produce gentype files, it'd enable us to use rewatch 🔥 and I'd be more than happy to make a PR for it if someone points me in the right direction |
|
Probably. |
I think gentype reads the config file by itself. @adnelson so the fix you did there should work. Not clear why it doesn't. And adding proper support to rewatch should be a matter of checking whether the config file has a prop |
Exactly. In the near future, gentype will emit for all or no files by config. |
@cristianoc @zth The files are not generated because rewatch passes the path to the |
Sounds like something that should be fixed in the compiler so that gentype does handle absolute paths..? |
To confirm, assuming this is true: Then yes, gentype should behave like the rest of the compiler. |
@Bushuo a PR that fixes it would be amazing 💯 of course, having to call bsc twice for each file is definitely not ideal, but could be omitted once the gentype compiler is fixed to work with absolute paths (which is strange that it doesn't). I wonder if alternatively rewatch could be configured to pass in relative paths instead of absolute paths, again until absolute paths work. I don't know what the advantages/disadvantages are for that. |
@adnelson I tried using my implementation in a larger project that was already set up with Rewatch, but unfortunately, it didn’t work. Apologies for that. It seems like this needs to be handled at the compiler level. The issue with the paths stems from how Rewatch organizes its files in a flat structure under lib/ocaml, whereas bsb structures the compilation artifacts under lib/bs to mirror the source folder's hierarchy. At least, that’s what I’ve gathered from my investigation so far. |
@Bushuo no worries. Presumably it should be possible to make gentype work with absolute paths, but unfortunately I've spent the last few hours trying to get the compiler built on my macbook to no avail :\ so I can't really hack on the compiler side of things. |
Around here might be a good place to start looking: https://github.com./rescript-lang/rescript-compiler/blob/master/compiler/gentype/Paths.ml#L41-L45 |
Ah right. This is definitely something we could backport to 11.1.x and release so you don't need to go to v12 for it. |
I'm still on v10 :\ there's more that I'll need to do in order to get v11 working with our app. But hopefully whatever you @Bushuo got working with v11, will also work with v10 (or close). |
This has now been implemented for v11 (will ship in |
I'm using
@genType
in one of my projects. Rewatch doesn't seem to be able to generate*.gen.tsx
yet, is there any plan to support it?The text was updated successfully, but these errors were encountered: