Versions
- @terrazzo/cli: 2.4.0
- @terrazzo/plugin-js: 2.4.0
Node.js version
25.9.0
OS + version
macOS Version 26.4.1 (25E253)
Description
The JS plugin currently does not retun several token metadata properties in its output, even when they are explicitly requested via the properties option. According to the documentation of the plugIn the $description attribute should be active by default and other properties are opt in.
During discussion on Discord @unpunnyfuns traced the issue to the parser.
$type and $value are hardcoded as the only return values from the parser. so plugins never get1em
|
node[localID] = { $type: token.$type, $value: token.$value }; |
Reproduction
bright.tokens.json
{
"color": {
"brand": {
"$type": "color",
"$description": "Basic Brand Color to enjoy a day at flamingo beach",
"$value": {
"colorSpace": "srgb",
"components": [1, 0.078431, 0.57647],
"alpha": 1,
"hex": "#FF1493"
},
"$extensions": {
"com.figma.variableId": "VariableID:2001:24",
"com.figma.scopes": ["ALL_SCOPES"]
}
}
},
"headline": {
"font-color": {
"$type": "color",
"$value": "{color.brand}",
"$extensions": {
"com.figma.variableId": "VariableID:2001:25",
"com.figma.scopes": ["ALL_SCOPES"]
}
}
},
"$extensions": {
"com.figma.modeName": "bright"
}
}
terrazzo.config.ts
import { defineConfig } from "@terrazzo/cli";
import js from "@terrazzo/plugin-js";
export default defineConfig({
tokens: ["bright.tokens.json"],
plugins: [
js({
filename: "tokens.js",
properties: [
"id",
"$description",
"$extensions",
"$deprecated",
"aliasOf",
"aliasChain",
"aliasedBy",
],
}),
],
outDir: "./dist/",
});
Generated output:
/** ------------------------------------------
* Autogenerated by ⛋ Terrazzo. DO NOT EDIT!
* ------------------------------------------- */
export const PERMUTATIONS = {
"{\"tzMode\":\".\"}": {
"color.brand":{"id":"color.brand"},
"headline.font-color":{"id":"headline.font-color"},
},
};
const INPUT_DEFAULTS = {"tzMode":"."};
/** Produce a token set from a given input. */
export const resolver = {
apply(userInput) {
if (!userInput || typeof userInput !== "object") {
throw new Error(`invalid input: ${userInput}`);
}
const input = { ...INPUT_DEFAULTS, ...userInput };
const inputKey = JSON.stringify(Object.fromEntries(Object.entries(input).sort((a, b) => a[0].localeCompare(b[0], "en-us", { numeric: true }))));
return PERMUTATIONS[inputKey];
},
listPermutations() {
return [{"tzMode":"."}];
},
};
The following properties are missing from the generated output:
$description
$extensions
$deprecated
aliasOf
aliasChain
aliasedBy
Expected result
The generated should contain information about "id", "$description", "$extensions", and the alias related properties.
Extra
Versions
Node.js version
25.9.0
OS + version
macOS Version 26.4.1 (25E253)
Description
The JS plugin currently does not retun several token metadata properties in its output, even when they are explicitly requested via the
propertiesoption. According to the documentation of the plugIn the$descriptionattribute should be active by default and other properties are opt in.During discussion on Discord @unpunnyfuns traced the issue to the parser.
terrazzo/packages/parser/src/resolver/create-synthetic-resolver.ts
Line 74 in 7a7fd2b
Reproduction
bright.tokens.json{ "color": { "brand": { "$type": "color", "$description": "Basic Brand Color to enjoy a day at flamingo beach", "$value": { "colorSpace": "srgb", "components": [1, 0.078431, 0.57647], "alpha": 1, "hex": "#FF1493" }, "$extensions": { "com.figma.variableId": "VariableID:2001:24", "com.figma.scopes": ["ALL_SCOPES"] } } }, "headline": { "font-color": { "$type": "color", "$value": "{color.brand}", "$extensions": { "com.figma.variableId": "VariableID:2001:25", "com.figma.scopes": ["ALL_SCOPES"] } } }, "$extensions": { "com.figma.modeName": "bright" } }terrazzo.config.tsGenerated output:
The following properties are missing from the generated output:
$description$extensions$deprecatedaliasOfaliasChainaliasedByExpected result
The generated should contain information about "id", "$description", "$extensions", and the alias related properties.
Extra