style-dictionary icon indicating copy to clipboard operation
style-dictionary copied to clipboard

Reference doesn't exist: X tries to reference Y, which is not defined

Open LoadJulz opened this issue 2 years ago • 4 comments

I have a problem with resolving references in my figma token file. Our figma token file is organized as follows: [Light/Dark/Global]/Fontfamilies. When I define my fonts in Figma and use the fontFamily of the global theme, a relative reference is created that does not include the source (global) of the reference, i.e. the reference "{fontFamilies.body}" should be "{global.fontFamilies.body}" for it to work. Here is an excerpt from my token file.

"global": { "fontFamilies": { "heading": { "value": "Montserrat", "type": "fontFamilies" }, "body": { "value": "Montserrat", "type": "fontFamilies" } }, "paragraph": { "xs": { "value": { "fontFamily": "{fontFamilies.body}", "lineHeight": "{lineHeights.paragraph}", "fontWeight": "{fontWeights.regular}", "fontSize": "{fontSizes.xs}", "letterSpacing": "{letterSpacings.default}" }, "type": "typography" } } }

Does anybody has an workaround to still be able to convert this token file into a style_directory? Renaming all the references is no possible solution because the token file has around 1500 lines.

LoadJulz avatar Dec 09 '22 09:12 LoadJulz

Not sure if this would help you... :pray:

How are you exporting your tokens file? If you're using Tokens studio for Figma, while exporting you could see a setting as Include parent key which is turned on by default. Disable that before exporting the file.

image

vishrayne avatar Jan 05 '23 23:01 vishrayne

Hello, I have the same issue and basically, I don't want to loose the parent key, because I'm using it to filtering tokens.

Is there a better way to solve this issue?

sebazelonka avatar Jun 22 '23 19:06 sebazelonka

+1

mavo-pfizer avatar Sep 14 '23 21:09 mavo-pfizer

Just ran into this as well while testing a tool chain of Tokens Studio and Style Dictionary. We use global tokens as a base layer that should not be used directly but are referenced by alias tokens.

henriksonnergard avatar Sep 18 '23 06:09 henriksonnergard