-
Notifications
You must be signed in to change notification settings - Fork 470
Made pinned dependencies transitive #5722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Made pinned dependencies transitive #5722
Conversation
LoganGrier
commented
Oct 3, 2022
- Made pinned dependencies transitive resolving this issue
- Moved extract_pinned_dependencies to from bsb_config_parse to bsb_build_util. This enables walk_all_deps to use extract_pinned_dependencies without creating a circular dependency
- Fixed a minor issue in the Troubleshoot a Broken Build section of Contributing.md
…s to bsb_build_util. Minor change to clean build script. Signed-Off-By: Logan Grier <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments
@@ -130,7 +130,7 @@ let ( |? ) m (key, cb) = m |> Ext_json.test key cb | |||
|
|||
type top = Expect_none | Expect_name of string | |||
|
|||
type package_context = { proj_dir : string; top : top } | |||
type package_context = { proj_dir : string; top : top; is_pinned: bool } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Transitive things are stored in dep_payload
, e.g. both package_specs
and jsx
mode have some transitive behaviour.
Not sure it's necessary to put this information in package context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A perhaps more to the point comment: pinned dependencies inherit package specs from the root project, so a bool is not enough. Assuming that's all that's tracked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way that Rescript handles pinned dependencies is pretty weird. In the existing code, pinned-dependencies
are just a set of strings. After finding all dependencies using Bsb_build_util.walk_all_deps
, the compiler iterates over the queue. All dependencies whose name is in that set is passed as a bsb_package_kind.Pinned_dependency
to bsb_ninja_regen.regenerate_ninja
. All other dependencies are passed as bsb_package_kind.Dependency
. Regardless of whether a dependency is passed as a Pinned_dependency
or a Dependency
, it is passed with the root project's package_specs
and jsx
. Any entry in pinned-dependencies
which is not the name of a dependency is ignored.
My PR just generalizes the pre-existing behavior. Firstly I've modified Bsb_build_util.walk_all_deps
so that it correctly traverses the new dependency graph. Secondly, since bsb_ninja_regen.regenerate_ninja
needs to know whether a dependency is pinned, and I already have to calculate that in Bsb_build_util.walk_all_deps
, I've modified Bsb_build_util.walk_all_deps
to return that information as well.
To address your comments specifically:
- While it's unnecessary to put
is_pinned
inpackage_context
, I chose to put it there because it makes the code simpler and reduces file reads. - A bool is enough because it isn't all that's tracked because pinned dependencies are weird.
…d-Off-By: Logan Grier <[email protected]>
…gned-Off-By: Logan Grier <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for doing this and for the explanation.
Would you update CHANGELOG.md as well?
Also, this seems to be safe enough to ship with 10.1 soon, rather than waiting for v11.
If you'd like to have this released sooner rather than later, would you base this on the 10.1 branch rather than master.
Separately, thanks for the comments on how the code for handling dependencies is structured. If you feel like opening a separate PR to clean that up, feel free to do so.
Strictly speaking, this PR is backwards incompatible with 10.0. Any project that assumes non-transitivity would be broken. While I can't think of a situation where someone would make this assumption, since non-transitivity is arguably not a bug, I think it makes sense to wait until the next major version. The workarounds listed in the original issue cover most use cases. Cleaning Up Pinned DependenciesI can't spare additional time right now to work on pinned dependencies. That said, I have a few thoughts on how they could be cleaned up. As I see it, there are two issues with the current system:
In a way, pinned dependencies are like dev dependencies in that pinned and dev are both traits that may apply to a dependency. Its natural then for both pinned and dev dependencies to be defined with similar syntax. I see two ways of doing this:
Here's what that looks like: Current Syntax
Proposal 1
Proposal 2
Arguments for proposal 1
Arguments for proposal 2
|
Thinking about this some more, the underlying problem that pinned dependencies solve is that compiling a project overwrites the compilation results of its dependencies. I see two ways of addressing this
While option 1 sounds simple, I can see potential complexity stemming from different compiler versions and configurations being used across different projects. Option 2 on the other hand seems pretty straightforward. The main advantage I see of option 1 over 2 is performance. |
Thanks. Merging now. |
* Made pinned dependencies transitive. Moved extract_pinned_dependencies to bsb_build_util. Minor change to clean build script. Signed-Off-By: Logan Grier <[email protected]> * Eliminated 'npm install' in transitive_pinned_dependency tests. Signed-Off-By: Logan Grier <[email protected]> * Deleted transitive pinned dependency test package-lock.json files. Signed-Off-By: Logan Grier <[email protected]> * Added entry in changelog. Signed-Off-By: Logan Grier <[email protected]>