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
Fixup JSON AST conversion #1488
Conversation
|
c50d685
to
d013915
Compare
Should that function also delete the |
Yeap. Send PR. I will release it. |
d013915
to
8a4ae33
Compare
Are we ready to release it? |
I've just tested this in my project and it seems to work now |
BTW, why do you need JSON AST rehydration? |
For Parcel, I want to send ASTs across worker threads/cache them to disk. Thanks you so much for the fast process! |
Released in 8.2.1 |
I've found two problems related to
Input
:1std and 2nd commit: I missed that all nodes have a
source
property, not just the root (this caused stringification to fail)3rd commit: More of an optimization: because of 1), the source contents & map would be stored once for every node (!). This has something like a quadratic memory usage because larger CSS files have more files, so with 10x more rules, the CSS source is about 10x larger and is stored 10x times.
I've instead deduplicated these inputs objects by replacing
node.source.input
with a number in thetoJSON
output and including a_inputs
array which maps number to input object (because most of these are===
-equal). This is then reversed in fromJSON. This breaks a buch ofpostcss-parser-tests
tests at the moment though. What do you think of this approach? (Before I try to adjust the parser test runner to accept this version...)