Skip to content

v2.5.0 — token exports resolve variables from other libraries

Choose a tag to compare

@tpitre tpitre released this 30 Nov 06:40
· 3 commits to main since this release

Added

  • Token exports resolve variables from other libraries. When a file's variables alias another library (a theme on top of a shared primitives library), figma_export_tokens and the Token Browser's downloads read those library variables through the Desktop Bridge: the ones the file's variables reference, and the ones those alias in turn. It's read-only; nothing is imported into the file. Without the Desktop Bridge, or if the read fails, the export falls back to the previous behavior and says so.
    • DTCG includes the library collections as their own sets, flagged in $extensions["figma-console-mcp"].library, and its references point into them. Each library set's name carries a short tag from its collection key (palette/light (a1b2c3)), so a token's name is the same on every export, whichever other collections were read (the tag is the key's first 6 characters, longer when those have no digit or when two libraries' collections share both a name and those characters), and never clashes with a local collection.
    • DTCG split by mode or by collection keeps the opaque {__library:<id>} references as before, so each file stands on its own (a theme file imported alone, or a per-mode file that can't hold a library's own modes).
    • CSS, SCSS, Tailwind, TypeScript, JSON, Style Dictionary and Tokens Studio write the referenced value per mode instead of skipping the token. In each library collection the value comes from the mode with the same name as the mode it's reached from (the token's own, or the previous collection's along a chain of aliases), ignoring case, or else the collection's first mode. Matching mode names is a convention (a theme's Dark reads a palette's Dark): in Figma, a layer that sets a mode for the library collection, or the collection's default where none is set, decides what's shown, which a token file can't express. Primer's CSS export went from 3,425 skipped tokens to none, Carbon's from 2,007. That also removes broken references: a token that aliased a skipped token pointed at a variable the file never defined (166 var()s in Carbon's CSS). A value that still can't be resolved (a library variable Figma can't return, a color whose opacity can't be read, or any library reference with libraryTokens: "skip") is skipped with a comment (as is an alias to a deleted variable), and so is every token that aliases it, so no format references a token skipped this way. A color with opacity whose part can't be resolved is written as the color Figma resolved for it, where Figma could. The export's warnings count the skipped values per format.
    • figma_import_tokens (DTCG) never creates or changes library collections or variables. It compares references into libraries by the library variable they point at, so re-importing an unchanged DTCG export plans no changes, whether it was made by this version, with splitByMode, with collectionIds, with libraryTokens: "skip", or by an earlier release. Alias writes into a library use the library variable's own ID. Tokens added inside a file's library sets, or whose value differs from the one recorded at export, are reported, not imported (they belong to their own library).
    • The skip rule also covers aliases to variables deleted from the file: a token that aliases one is skipped with it, where formats used to reference a variable they didn't define.
    • A modes filter doesn't apply to library collections' own modes, and a collection's own values are read only for the exported modes (a variable reached through an alias is followed in every mode). libraryTokens: "skip" keeps the previous behavior, except that tokens aliasing a skipped token are now skipped too, instead of referencing a token the output doesn't define.

Fixed

  • The Token Browser's download message said references to other libraries were "kept as-is"; CSS and the other formats actually skipped those tokens. It now says how many library variables were read, how many stayed unresolved, and how many values were skipped.