rescript-lang / rescript-compiler

The compiler for ReScript.
https://rescript-lang.org
Other
6.64k stars 441 forks source link

Pinned and Dev dependencies interacting #6679

Open CarlOlson opened 5 months ago

CarlOlson commented 5 months ago

This is hard to explain, so here is a reproducible example. The names of workspaces and modules were chosen to somewhat reflect the project I discovered this in. This was confirmed on version 10.1.2 and 11.0.1.

If you have 3 workspaces W_root, W_a, and W_b. W_root adds the two others as pinned dependencies. W_a and W_b both contain a dev directory with some module M. If W_a includes W_b as a dev dependency, then opens W_b, then W_b.M will collide with W_a.M when used.

Snippet from the example repo's output:

FAILED: test/MainTest-SrcHelpers.cmj

  We've found a bug for you!
  <removed>/rescript-shadow-test/src-helpers/test/MainTest.res:4:14-23

  2 │
  3 │ let _ = Helper.setup()
  4 │ let config = Config.get()
  5 │

  The module or file Config can't be found.
  - If it's a third-party dependency:
    - Did you add it to the "bs-dependencies" or "bs-dev-dependencies" in bsconfig.json?
  - Did you include the file's directory to the "sources" in bsconfig.json?

  Hint: Did you mean Config or Config?

What do I expect?

zth commented 5 months ago

@CarlOlson thanks for the detailed report and reproduction! 🙏

There's some ongoing work related to this "behind the scenes" currently. Hopefully this and more things related to pinned dependencies will clear up a lot in the not too distant future.

Maybe one of our monorepo users has some insight already. Cc @tsnobip @fhammerschmidt