Skip to content

Fix #355 - Diff showing on unchanged snapshot lines #356

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

Closed
wants to merge 4 commits into from

Conversation

fritz-c
Copy link
Contributor

@fritz-c fritz-c commented Feb 24, 2021

This PR is designed to fix #355

I am keeping this as a draft PR until the merging and release of reworkcss/css#151 , which is required for the fix to work.

@quantizor
Copy link
Contributor

@fritz-c unfortunately it doesn't seem like this is working with latest code. I'm interested in landing the change though if you can get it working again

@fritz-c
Copy link
Contributor Author

fritz-c commented Nov 22, 2021

@probablyup Unfortunately, while the branch with the fix in css did get merged several months ago, it has not been released as a new npm version yet. Afraid this fix is stalled until that happens, unless you could live with setting the css dependency version to the commit with the fix, or releasing your own npm package based on the current master branch.

@quantizor
Copy link
Contributor

I'm fine with that. Or if the code is small enough and the license allows we can just inline it.

@cincodenada
Copy link
Contributor

cincodenada commented Jul 26, 2022

Ha, I just made this same journey and had prepared basically the exact same fix. Thanks for all the work so far here! I put in a good word at css, and also found out there's also a fork at https://github.com/adobe/css-tools that integrates this fix, but it's a rewrite in TS and hasn't had a release yet. I've opened an issue there asking if they would be willing to do an interim 3.0.1 release in the meantime at their fork.

If we don't see movement on either of those soon, I think it's worth doing one of the other solutions above, or using something like patch-package to apply the change, which is just two lines of non-test changes.

For inlining: the lib itself is MIT licensed, so should be good there, and it's 1200 lines and 36K (24K if I count contents and not filesize, many files are the min of 4K on my system). The stringify bit (which could easily be inlined separately) is 700 lines and 13K, but since we don't need compression or sourcemap support, you'd only need to inline index.js, identity.js, and compiler.js, which is 500 lines and 6.6K altogether.

And heck, you could even monkeypatch if you want to get messy about it. It ain't pretty, but this fixed it for me - the class being patched is instantiated when serialize() is called, so it should be robust to ordering concerns even:

require('css/lib/stringify/identity').prototype.indent = function(level) {
  this.level = this.level || 1;

  if (null != level) {
    this.level += level;
    return '';
  }

  return Array(this.level).join(typeof this.indentation == 'string' ? this.indentation : '  ');
};

@holblin
Copy link
Contributor

holblin commented Aug 5, 2022

Do you think this will fix the issue? #416

@cincodenada
Copy link
Contributor

Do you think this will fix the issue? #416

Indeed it should! I somehow missed that the fork already had a release available, since it is I think that is the best option here. I'll double-check on Monday when I have my code at hand, but the fix does appear to be in 4.0, so that should fix the issue. Thanks for maintaining your fork, @holblin!

@quantizor
Copy link
Contributor

@fritz-c could you rebase and get this mergeable? Thanks!

@quantizor quantizor closed this Aug 9, 2022
@cincodenada cincodenada mentioned this pull request Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Diff showing on unchanged snapshot lines
4 participants