Skip to content

JS plugin does not expose metadata properties ($description, $extensions, aliases, etc.) even when requested #790

Description

@g12n

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions