amzn / style-dictionary

A build system for creating cross-platform styles.
https://styledictionary.com
Apache License 2.0
3.93k stars 557 forks source link

[QUESTION] Opportunity to resolve "Property Reference Errors"? #876

Open caoimghgin opened 2 years ago

caoimghgin commented 2 years ago

Using the 'outputReferences' feature in SD 3.0, could I programmatically attempt to resolve a Property Reference Error?

Property Reference Errors:
Reference doesn't exist: color.font.tertiary.value tries to reference color.base.grey.light.value, which is not defined

Here, color.font.tertiary attempts to link the value of original: { value: '{color.base.grey.light.value}' }, and I'd like the opportunity to search for original: { value: '{color.base.gray.light.value}' }, (The difference is 'grey' and 'gray').

This is a simple example.

Where there is little control over a designers (or multiple designers in multiple departments) deeply nested Figma structures and decide to output to tokens via a plug-in, then original: { value: '{rj-xxx.colors.palette.primary.400}' }, may be findable by reference after transforms by linking up to original: { value: '{color.palette.black}' },.

Though, I'm not a fan of overwriting the original, just a quick example to be clear.

dbanksdesign commented 2 years ago

You could use a custom parser to modify tokens before Style Dictionary tries to transform and resolve tokens. The custom parser would parse the JSON files and search for tokens with references to a list of known references you want to change and then update the token's value. Does that make sense?