Replies: 1 comment
-
We had some discussion about providing a TS API that would "transpile" to Prolog: #1276. No concrete work though. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First off, I want to make it clear that this is a question / suggestion and not a complaint. I love how Yarn is constantly innovating.
I learned about Constraints yesterday and my initial reaction was "wow this is super complicated and I have no idea how Prolog works". The Prolog-based constraints system seems powerful and elegant but very hard to approach for the average JavaScript developer.
I'm sure I could learn Prolog given enough time, but ideally you shouldn't have to learn a new programming language to use Yarn constraints (especially when that programming language is very different from traditional programming languages.)
I was wondering if Yarn constraints could be configured using a simpler and more familiar syntax. Yarn could either handle the simple syntax directly, or compile the simple syntax to the more powerful Prolog syntax. Yarn could continue to support the Prolog syntax for people who need really complex constraints, but the idea is that the majority of developers would use the simple syntax.
Some options for the simple syntax
Yarn could support ONE of the following formats for configuring constraints:
Common use cases
The simple syntax should support the all common use cases but would not need to support every use case. Here are some guesses at common use cases for constraints. (Using TypeScript, jQuery, and React as examples — it could be any package.)
typescript@~4.0.0
and package2 depends ontypescript@^4.4.3
.)typescript
. (This constraint is not met if package1 depends ontypescript@^4.0.0
and package2 depends ontypescript@^4.1.0
and Yarn resolves these semver ranges to different versions.)typescript
use version >= 4.0.0.typescript
use version >= 4.0.0 and < 5.0.0.@react-navigation/*
use version >= 6.0.0. (Using the wildcard character to refer to multiple packages with similar names.)jquery
.react
also depend onreact-dom
.typescript
, if referenced, is indevDependencies
and not independencies
.workspace:
....and probably more that I haven't thought of.
Idea: Each of these bullet points could be thought of as a "rule", similar to a rule in ESLint.
Proposal for simple syntax
The question is, what would this simple syntax actually look like? I think that's outside the scope of this post but I'm happy to come up with something if this idea gains traction.
Lastly, feel free to ignore this suggestion if it doesn't make sense. 😂
Beta Was this translation helpful? Give feedback.
All reactions