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

If we are generate small token set in different file from token set with reference, it will throwing error #957

Open nilesh0107 opened 1 year ago

nilesh0107 commented 1 year ago

Heyy, I have token.json file and I want to convert those token into css variable tokens with reference into different *.css token files, but getting error

Property Reference Errors: Reference doesn't exist:

my token.json is

{ "core":{ "color": { "yellow": { "value": "#ffcf01", "type": "color" } } }, "comp": { "color":{ "warning":{ "value": "{core.color.yellow}", "type": "color" } } } }

I am expecting two .css files as output with reference core.css comp.css core.css generate token correctly as expected and we expecting to generate comp tokens in comp.css file without core tokens

but actually it will throwing error while executing comp.css as different token file Reference doesn't exist: comp.color.warning.primary.value tries to reference core.color.yellow, which is not defined

How we can resolve this issue? Can you please provide a solution for same on urgent basis, because we are stuck at this level.

Thanks in advance!!

dbanksdesign commented 1 year ago

I created a StackBlitz project with your tokens and it works fine for me: https://stackblitz.com/edit/node-jyhijt?file=sd.config.js

Can you let me know what your configuration looks like? Or hopefully my example should solve your issue.

nilesh0107 commented 1 year ago

I created a StackBlitz project with your tokens and it works fine for me: https://stackblitz.com/edit/node-jyhijt?file=sd.config.js

Can you let me know what your configuration looks like? Or hopefully my example should solve your issue.

@dbanksdesign - Thanks for creating a example on above issue, but our requirement is to keep reference., so I have added

options: { outputReferences: true }

in configuration, which is throwing some errors

Can you please take a look on it?

Thanks in advance!!!.

dbanksdesign commented 1 year ago

Ah I see. That warning in the console is just a warning. It doesn't actually throw an error and the files should still build fine. I updated the StackBlitz example to use outputReferences and both files build as expected.