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
feat(pkg-manifest): preserve comments in YAML manifests #6273
base: main
Are you sure you want to change the base?
Conversation
Following on from pnpm#2008 (comment) … Closes pnpm#2008.
💖 Thanks for opening this pull request! 💖 |
@@ -1,9 +1,24 @@ | |||
import gfs from '@pnpm/graceful-fs' | |||
import { type ProjectManifest } from '@pnpm/types' | |||
import YAML from 'yaml' |
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.
we use js-yaml
we shouldn't use 2 libraries for parsing yaml.
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.
@danielbayley, can you update the suggestion given by @zkochan?
I am desperate to preserve the comments in the pakcage.yaml
.
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.
we use
js-yaml
we shouldn't use 2 libraries for parsing yaml.
@zkochan I agree that 2 is not ideal… I suppose I’m proposing that we replace js-yaml
with eemeli.org/yaml
, because it retains comments very well, whereas js-yaml
does not, and instead just discards them. Did you take a look at my working implementation here? #2008 (comment)
can you update the suggestion given by @zkochan?
@gusbemacbe Unfortunately it isn’t a suggestion that helps with this implementation…
I am desperate to preserve the comments in the *
package.yaml
.
Same!
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.
With a bit more research, I'd also be in favor of a move to yaml
. It looks like js-yaml
hasn't had a release for a few years.
Switching to yaml
to avoid 2 libraries for parsing/serializing YAML files will take a bit of work though.
- Is there a performance difference? It'll be interesting to see a performance benchmark on serializing/deserializing a large
pnpm-lock.yaml
file betweenyaml
vsjs-yaml
. - There's patches to
js-yaml
that we'll need to replicate inyaml
. nodeca/js-yaml@master...pnpm:js-yaml:features-for-pnpm
@danielbayley Do you happen to have bandwidth for such an investigation? If not, we can spin up a different pull request investigating a switch from js-yaml
to yaml
that would merge before this PR.
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.
@danielbayley Do you happen to have bandwidth for such an investigation?
Unfortunately not, currently.
If not, we can spin up a different pull request investigating a switch from
js-yaml
toyaml
that would merge before this PR.
@gluxon Fully in favour of the switch… and definitely agree that should be a separate PR, preceding this one. I would be keen to pick up the baton after that to implement comment preservation…
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.
Sounds good! Thanks @danielbayley.
@zkochan, do you have to review this PR and to test, modifying a bit, to see if it will work? We are desperate to preserve the comments in the |
I think Zoltan's last review around avoiding 2 yaml libraries makes sense and still applies today. Would be curious for his thoughts on whether we should migrate in a separate PR though. |
Following on from the basic implementation outlined here in #2008—which works well—am I right in thinking that the
manifest: data
here (from here) containing the AST (including comments) getsnormalize
d, and therefore lost here?@zkochan I’m keen to get this feature merged, but could do with some pointers as to the best approach…
Closes #2008.