reasonml-editor / atom-ide-reason

ReasonML/OCaml language support for Atom-IDE, using ocaml-language-server under the hood.
MIT License
34 stars 8 forks source link

Generating interface files inside a monorepo (multiple bsconfig.json) #25

Closed kgoggin closed 6 years ago

kgoggin commented 6 years ago

First off, thanks for this awesome package! I love using Atom with Reason!

The project I'm currently working on uses a monorepo and as such has a few different sub-packages, each with it's own bsconfig.json. When I try to auto-generate an interface file, it tries to do it relative to the project/monorepo root instead of the package's root and fails.

I'm not all that familiar with Atom's API for packages, but after a little poking around it'd seem like you'd need a way to change the default behavior of basing all the path's off of the project root. I wonder if there'd be a way to recursively search up the file structure from the location of where the action was invoked and search for a lib folder and/or bsconfig and then stop there? I know Babel has logic like that for finding a .babelrc file. Or maybe there's another approach that'd work better?

I'd be up for giving it shot with a little direction about the preferred approach because I'd love to be able to use this feature! Thanks again.

alex35mil commented 6 years ago

Hey, AFAIR the main reason I implemented it this way is b/c (on my machine) toolchain doesn’t work w/ bsconfig.json being not in the root anyway. So I open all monorepo projects as a workspace that includes a number of sub-projects, e.g. atom ./client ./server .. Does toolchain works for you when you open monorepo w/ bs configs being in sub-folders?

kgoggin commented 6 years ago

Yeah, in general everything seems to work just fine for me. I've got a monorepo where the frontend code is nested a couple of levels deep from the repo root and has the bsconfig.json and I've not had any issues with that setup.

alex35mil commented 6 years ago

I previously had issues w/ OLS & bsconfig.json in subfolders but w/ RLS it works w/o issues so 👍 for updating lookup logic. Also, we can get rid of config for interface generator in this case.

I would take the path to the current file then recursively check for bsconfig.json up to the project's root. If it's found, then use FOUND_DIR/node_modules/bs-platform/lib/bsc.exe binary and FOUND_DIR/lib/bs/.../*.cmi. If nothing is found then give up w/ warning.

@kgoggin @zaaack

kgoggin commented 6 years ago

Just upgraded to 1.0 and this works like a charm! Thanks so much!

alex35mil commented 6 years ago

FYI There is still an issue w/ interface generator for lerna / yarn workspaces users, I'll fix it soon.