-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
support package.yaml format #1751
Comments
Please open this up at yarnpkg/rfcs. |
I know getting @whitecolor Were you planning to submit the associated RFC for this, or would you prefer someone else do it? |
@rmm5t I have no plans for this. |
@rmm5t please submit one 😊 |
This would be ammmmazzzing |
There is a somewhat lengthy discussion over at NPM about this and by looking at thumbs it's quite a popular feature request, but they basically forbid it because of personal preference. Would be nice if Yarn would be more open-minded on this. npm/npm#3336 One interesting quote from that issue by @tobia
@rmm5t I assume you haven't considered writing RFC? I don't feel for that either, we need some brave hero who can see some light in this... Personally, I love Yaml, even if was only about getting rid of those lame dangling commas, it would be a win, but comments and more concise syntax are great bonuses as well. |
@FredyC No, I don’t plan to write an RFC for this. While, I would very much prefer Yaml, after much thought, I don’t feel that this is something that Yarn can do solo. For example, most of my projects need to stay compatible with NPM, even though I only use Yarn. |
This may not be the correct bug to debate about this but having support for a .js file for the package definition would be much more useful than .yml in my opinion. Many other projects allow this type of programmatic config (node-config, serverless, webpack, etc) and I much prefer it. Being able to comment is only the tip of the iceberg. Imagine being able to run all of your favorite preprocessors on your package definition (i.e. eslint, prettier, jest). Imagine being able to require your shared repo which contains the definitions of all of your common package scripts and dependencies. This would solve one of the biggest pain points of using the multi-repo pattern. |
@fantapop I think it's a bad idea. Given that package.json file is more like a metafile used to control installation (and other) process, it might be rather an error-prone. The whole file would need to be executed before any operation could even happen. That would be probably slower than just parsing JSON/YAML file. Also, any package running arbitrary code before installation even begins is quite frankly terrifying. Btw, you can use Prettier on JSON, but I do not recommend it, because NPM/Yarn would overwrite your formatting eventually. |
JSON doesn't meet the most basic requirements for a configuration file (IMO) since it does not accept comments. What could be more basic than the ability to include comments as to why certain dependencies or versions are specified? Also json is unnecessarily noisy, loaded with unnecessary double quotes. I also don't think that backward compatibility is an issue, since any time someone needs the file in .json format it is trivial to convert. I also think setting an example would encourage npm to do the same, since after all, aren't they playing catch-up with yarn at this point? |
Maybe we could scrap backwards compatible and build yyarn (yaml-yarn), then the node community would have 3 package managers for node. Instead of having noisy configuration files, we would have a noisy experience figuring out what tool to choose for handling our packages, as if the Node community isn't already noisy when it comes to choosing tools. |
I just included the any-json module as a dev-dependency, added a json script that converts the package.yaml into package.json. So the package.json is derived, I only manually update the yaml file, and when I build it updates package.json. |
For people who came here like me and think "what a bunch of lazy developer who didn't listen to their user base"... After some thinking, I realized that this came with some serious technical challenge. The fact is that both JSON5 and YML parsing don't preserve the comments (by definition). This means that any action that change package file would remove the comments, or need complex text difference analysis to reinsert the comments into the new generated output. Definitely not something I would like to code, maintain and support. The nightmare when users start to complain the their comments don't stick with the correct line when adding new dependencies and the list got reordered... ew... When absolutely needing comments, because the script is absurdly complex, I use something like:
That's kind of wrong, can't be used everywhere in the file. But because it's still JSON data it can be preserved properly when using yarn commands. Or I use the readme file, or a page in our wiki... |
@fhewitt This unfortunately gets screwed up by sorting package.json, which is a highly encouraged practice. Furthermore, the lack of syntax highlighting renders it quite hackish and hard to recognize. https://eemeli.org/yaml does support parsing yaml with comments preserved. |
Pnpm supports package.yaml, if yarn would support it also, there would be critical mass. It just screwed up npm-runall and similar scripts that import an assumed package.yaml file, so I forked that one to use on pm's package.Jason/yaml resolution logic. I'm still hesitant to update package.jsons to yaml until another packager joins the club. |
Why not support yaml package files?
YAML
So that:
package.yaml
(orpackage.yml
) instead of jsonAnd npm wouldn't want to do this (as many other useful things)
npm/npm#3336
I've seen this issue:
#178
I wouldn't worry about interoperability with npm because it is already broken in many other cases, and json still will remain default option.
Also maybe option for custom package file name could be added.
The text was updated successfully, but these errors were encountered: