rescript-lang / rescript-compiler

The compiler for ReScript.

Home Page:https://rescript-lang.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pinned and Dev dependencies interacting

CarlOlson opened this issue · comments

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?

  • I expect the modules in a "type": "dev" directory to never collide when building a different project.
  • I expect the error message to be more helpful. Perhaps the hint should use the full module path: Hint: Did you mean SrcHelpers.Config or TestHelpers.Config? (this wouldn't fix the problem, but would have made discovering the cause easier)

@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