Yeah, it’s how it works. I actually haven’t found value in the pinned-dependencies at all.
There are two options, you either treat shared as an actual package that should be developed separately. In this case, the solution will be to run rescript build -with-deps -w in the web and shared simultaneously.
Or instead of adding it as a dependency, you can set a path to shared in the bsconfig’s sources option. It has problems with artifact location and some other things, but it generally works.
After trying lerna, yarn, and pnpm workspaces earlier this year, we have also settled on pnpm. It gets weird sometimes with it’s lock file, but a fresh pnpm install fixes it easy
The workspace feature works pretty seamlessly, if you pnpm add something it’ll just link your workspace version if you have one
I plan on introducing rescript into our monorepo soon. Do you mean you treat each package as its own package that has it’s own build step? And intellisense/module resolution is self contained right?
ReScript will not rebuild any pinned-dependencies in watch mode! This is due to the complexity of file watching, so you’d need to set up your own file-watcher process that runs rescript build on specific file changes.
Looks like you need to use npx rescript clean before building if any of the dependent packages change, not sure if this is a bug or I misunderstand what pinned-dependencies is meant to do
So, as long as you run the watcher yourself, at least yarn v1 or npm workspace support is okay now. My subjective view is that the transitive pinned deps PR made it a bit better?
At least I have a real-world and open-source example now: the rescript-mui monorepo.
Needs watchexec binary to be installed. In the future, hopefully it will be possible to just write
npm run rewatch watch .
when rewatch supports all the different bsconfig configurations. Also rewatch aims to be more efficient with rebuilds.
I will actually try to dogfood rewatch into rescript-mui now.
Is this for watching for changes? I don’t mind the limitation there as I typically work on packages independently. What I’m running into is if package A has a dependency on package B and you change package B, package A does not pick up up on any of the changes even with pinned-dependencies and rescript build -with-deps
Sounds like this should be possible according to this documentation page: Pinned Dependencies | ReScript Language Manual, but whenever I try to run rescript build, my main app breaks and then my extension stops working. I always have to use a rescript clean and restart the extension.
There were several call to action for monorepo users in several discussions over several years.
Still waiting.
I apologize if I’m stepping on any toes here, I just started splitting a large project into manageable pieces and ran into what seemed like a bug with building. I searched the forums for “monorepo,” read through a few posts, and replied to the one that’s most similar to my case.
edit: I just actually looked into rewatch and see that it’s specific for rescript, will try to give it a try!
For the record: Yes, rewatch is for file watching rescript builds with support for npm workspaces. But actually it is a whole build system, since it replaces bsb.exe and calls the compiler (bsc.exe) directly.
@hellos3b: I am not sure if that documentation example is the way to go. Have a look at the aforementioned rescript-mui monorepo. It uses a root bsconfig and builds are started from there.
Hey, just checking, what is the “state of the art” with monorepos at the moment?
I tried rewatch today by copy-pasting the structure from rescript-mui and even got it running (with yarn, not with older npm). But I got stuck when vscode plugin didn’t really stay up to date with latest state of errors. I wonder if the plugin should even work with rewatch?
Edit: It seems allowing the vscode plugin to run its own build in addition to rewatch seems to keep the errors up to date. I’ll keep testing.
The errors should be up to date when you run rewatch. It’s not great to run two builds at the same time because it can cause inconsistencies. Make sure to run rewatch only in the project root.