Open abritinthebay opened 1 year ago
This seems like a good change. If you would be up for writing a PR to modify the existing function and add some documentation about the new option, we can get this in.
Since we have outputReferences
and outputReferencesFallback
already, it might make sense to go to this API:
{
"outputReferences": {
"enabled": true,
"fallbacks": true,
"recursive": true
}
}
Which would be a breaking change but I'm happy to pull this topic into v4 major, I think outputReferences in general could do with a bit of redesign anyways.
Can I try it?
Can I try it?
https://github.com/amzn/style-dictionary/issues/1032 Might make sense to follow this issue, I expanded a little bit more on this there. I haven't started on trying to implement this yet because I first want to have a chat with the other maintainers since it's quite a big restructure, which is hopefully tomorrow.
Feel free to reach out to us in our Slack -> style-dictionary-v4 channel! This is also where I announce any new prereleases or ask for feedback, so it's a good one to follow the progress.
Use case: I'd love to use the property formatter, but I want full resolution (to avoid duplication) for my custom format. Unfortunately it's not possible without rolling my own version of createPropertyFormatter.
Simply put - a chain of..
will mean that resolving the
a.d.value
reference will get youa.c.value
nota.b.value
. I can absolutely see this use case--especially with CSS variable scoping--but given that resolving the value would get you1
it's odd to not be able to do the reverse at all.Wanting this behavior but not having it in the default
createPropertyFormatter
means having to write my own exact copy... just with a simple addition of recursion of the reference resolution (I pulled out the code into a localresolveReferences
function) inside therefs.forEach
Obviously you could also modify in place, etc. Lots of options, but the point is to make it possible to recursively resolve the references up the chain. Given the current behavior is certainly wanted, likely as a default, putting this behind an option flag like
recursiveReferences
or something would make sense.