Skip to content
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

Tokens passed to include that contain an isSource property are treated as source files #1007

Open
dstaley opened this issue Aug 10, 2023 · 1 comment
Labels

Comments

@dstaley
Copy link

dstaley commented Aug 10, 2023

When passing tokens via include that contain the property isSource: true, the included tokens are indistinguishable from actual source tokens, resulting in the inability to distinguish during a filter.

Reproduction

Expected result: build/figma/figma.tokens.json contains only the blue-500 token since it's defined in tokens/color.js

Actual result: output contains tokens from both tokens/color.js and include/tokens.json

According to the v3 migration guide:

isSource: A boolean representing if this file was defined as ‘source’ in the configuration as opposed to ‘include’ (or directly setting the ‘properties’ object). This can also help filtering tokens from output files you don't want to include.

Since the default json formatter includes the isSource property, I think it would make sense to give it special treatment when it's seen in a file coming from include and manually override it to false.

@jorenbroekema jorenbroekema added bug and removed bug labels May 1, 2024
@jorenbroekema
Copy link
Collaborator

I'm not sure I understand why your "include" tokens source files contain design tokens that already contain the metadata props that style-dictionary is supposed to fill out for you. That said, I will file this as a bug because style-dictionary is supposed to set the isSource property itself whether it's already been prefilled or not.

I think we also need to have a discussion on how metadata properties should be handled in general.
According to the DTCG spec, you'd put it either in property names starting with $ prefix, or you'd put it into the $extensions under the unique namespace of your tool (e.g. style-dictionary). If I'm not mistaken, $metada props are something that belong to the token authors territory, and $extensions is where tools can put their stuff, so I'm leaning towards refactoring everything to scope and read metadata from that $extensions['com.styledictionary'] namespace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants