rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

Suggestion: Pinned dependencies should be transitive

Open LoganGrier opened this issue 3 years ago • 3 comments

I'm not sure whether this is a bug. I'm wording this issue like a feature request instead of a bug report since transitivity isn't specified in the pinned-dependency docs.

Current Behavior

Right now, pinned dependencies are not transitive: if c is a pinned dependency of b and b is a pinned dependency of a, then c is not necessarily a pinned dependency of a. This means that if c is not explicitly marked as a pinned dependency of a, then when a is rebuilt, all dev files in c are deleted.

Suggested Behavior

When a is built, dev files in c should also be build since c is a transitive pinned dependency of a through b.

Motivation

  1. Non-transitivity is unintuitive. Dependencies, including the dependencies and dev-dependencies in bsconfig and package.json, are almost always transitive.
  2. Non-transitivity makes building and testing code more complicated. When testing packages in a mono-repo, its common to build and test all packages in the repo using commands like yarn workspaces foreach run build && yarn workspaces foreach --parallel run test. For those not familiar with yarn, the command yarn workspaces foreach run [script] runs the given script on each project in a workspace in arbitrary order. To build and test a monorepo that uses rescript, you have two options:
    1. Build projects in topological order (yarn workspaces foreach --topological-dev run build-test). Since rescript build isn't thread-safe, the command above can't be run with the --parallel option.
    2. Create a phony project that depends on all other projects and build it before testing (cd phony-project && yarn build && cd top && yarn workspaces foreach --parallel run test). This approach becomes more complicated when non-ReScript packages are in the same monorepo as ReScript packages.

LoganGrier avatar Sep 25 '22 18:09 LoganGrier

You can take a look at the logic around here

https://github.com/rescript-lang/rescript-compiler/blob/master/jscomp/bsb/bsb_config_parse.ml#L305

cristianoc avatar Sep 26 '22 02:09 cristianoc

did you find any solution here ? i am facing the same.

PlabanJr avatar May 24 '24 14:05 PlabanJr

Did you try https://github.com/teamwalnut/rewatch?

DZakh avatar May 24 '24 14:05 DZakh

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar May 20 '25 02:05 github-actions[bot]

I believe Rewatch, the new build system, solves this. Feel free to reopen if not.

zth avatar May 20 '25 16:05 zth