Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/parser/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export default async function build(
});
return;
}
const tokens = resolver.apply(params.input ?? {});
const token = tokens[id]!;
if (!token) {
logger.error({ group: 'plugin', label: plugin.name, message: `No token "${id}"` });
Expand Down
46 changes: 46 additions & 0 deletions packages/parser/test/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,52 @@ describe('Plugin API', () => {
}
});

it('can setTransform for token missing in default input', async () => {
const config = defineConfig(
{
plugins: [
{
name: 'my-plugin',
async transform({ setTransform }) {
setTransform('token', { format: 'my-format', value: '1', input: { test: 'present' } });
},
async build({ getTransforms, outputFile }) {
outputFile(
'file.txt',
String(getTransforms({ id: 'token', format: 'my-format', input: { test: 'present' } })?.[0]?.value),
);
},
},
],
},
{ cwd: new URL('file:///') },
);
const { sources, tokens, resolver } = await parse(
[
{
src: JSON.stringify({
name: 'Resolver',
version: '2025.10',
resolutionOrder: [{ $ref: '#/modifiers/test' }],
modifiers: {
test: {
default: 'empty',
contexts: { empty: [{}], present: [{ token: { $type: 'number', $value: 1 } }] },
},
},
}),
filename: new URL('file:///'),
},
],
{ config },
);

const { outputFiles } = await build(tokens, { config, resolver, sources });
expect(outputFiles[0]).toEqual(
expect.objectContaining({ filename: 'file.txt', contents: '1', plugin: 'my-plugin' }),
);
});

it('simple transform', async () => {
const config = defineConfig(
{
Expand Down
156 changes: 78 additions & 78 deletions packages/plugin-css/test/__snapshots__/js.browser.test.ts.snap

Large diffs are not rendered by default.

78 changes: 39 additions & 39 deletions packages/plugin-css/test/fixtures/ds-figma-sds/sds.want.css
Original file line number Diff line number Diff line change
Expand Up @@ -466,67 +466,61 @@
--color-border-warning-secondary: var(--color-yellow-400);
--color-border-warning-tertiary: var(--color-yellow-600);
--color-brand-100: rgb(96.078% 96.078% 96.078%);
--color-icon-brand-on-brand: var(--color-brand-900);
--color-text-brand-on-brand: var(--color-brand-900);
--color-icon-brand: var(--color-brand-100);
--color-icon-brand-on-brand-secondary: var(--color-brand-100);
--color-icon-brand-on-brand-tertiary: var(--color-brand-100);
--color-text-brand: var(--color-brand-100);
--color-text-brand-on-brand-secondary: var(--color-brand-100);
--color-text-brand-on-brand-tertiary: var(--color-brand-100);
--color-brand-200: rgb(90.196% 90.196% 90.196%);
--color-brand-300: rgb(85.098% 85.098% 85.098%);
--color-icon-brand-secondary: var(--color-brand-300);
--color-text-brand-secondary: var(--color-brand-300);
--color-brand-400: rgb(70.196% 70.196% 70.196%);
--color-icon-disabled: var(--color-brand-500);
--color-icon-brand-tertiary: var(--color-brand-400);
--color-icon-disabled-on-disabled: var(--color-brand-400);
--color-text-disabled: var(--color-brand-500);
--color-text-brand-tertiary: var(--color-brand-400);
--color-text-disabled-on-disabled: var(--color-brand-400);
--color-brand-500: rgb(45.882% 45.882% 45.882%);
--color-icon-brand-tertiary: var(--color-brand-400);
--color-text-brand-tertiary: var(--color-brand-400);
--color-icon-disabled: var(--color-brand-500);
--color-text-disabled: var(--color-brand-500);
--color-brand-600: rgb(26.667% 26.667% 26.667%);
--color-icon-brand-secondary: var(--color-brand-300);
--color-text-brand-secondary: var(--color-brand-300);
--color-brand-700: rgb(21.961% 21.961% 21.961%);
--color-brand-800: rgb(17.255% 17.255% 17.255%);
--color-icon-brand: var(--color-brand-100);
--color-icon-brand-on-brand-tertiary: var(--color-brand-100);
--color-text-brand: var(--color-brand-100);
--color-text-brand-on-brand-tertiary: var(--color-brand-100);
--color-brand-900: rgb(11.765% 11.765% 11.765%);
--color-icon-brand-on-brand-secondary: var(--color-brand-100);
--color-text-brand-on-brand-secondary: var(--color-brand-100);
--color-icon-brand-on-brand: var(--color-brand-900);
--color-text-brand-on-brand: var(--color-brand-900);
--color-brand-1000: rgb(6.6667% 6.6667% 6.6667%);
--color-gray-100: rgb(96.078% 96.078% 96.078%);
--color-gray-200: rgb(90.196% 90.196% 90.196%);
--color-gray-300: rgb(85.098% 85.098% 85.098%);
--color-gray-400: rgb(70.196% 70.196% 70.196%);
--color-icon-default-tertiary: var(--color-white-400);
--color-text-default-tertiary: var(--color-white-400);
--color-gray-500: rgb(45.882% 45.882% 45.882%);
--color-icon-default-secondary: var(--color-white-500);
--color-text-default-secondary: var(--color-white-500);
--color-gray-600: rgb(26.667% 26.667% 26.667%);
--color-gray-700: rgb(21.961% 21.961% 21.961%);
--color-gray-800: rgb(17.255% 17.255% 17.255%);
--color-gray-900: rgb(11.765% 11.765% 11.765%);
--color-icon-default: var(--color-white-1000);
--color-text-default: var(--color-white-1000);
--color-gray-1000: rgb(6.6667% 6.6667% 6.6667%);
--color-green-100: rgb(92.157% 100% 93.333%);
--color-icon-positive-on-positive: var(--color-green-100);
--color-icon-positive-on-positive-secondary: var(--color-green-100);
--color-icon-positive-on-positive-tertiary: var(--color-green-100);
--color-text-positive-on-positive: var(--color-green-100);
--color-text-positive-on-positive-secondary: var(--color-green-100);
--color-text-positive-on-positive-tertiary: var(--color-green-100);
--color-green-200: rgb(81.176% 96.863% 82.745%);
--color-icon-positive: var(--color-green-200);
--color-text-positive: var(--color-green-200);
--color-green-300: rgb(68.627% 95.686% 77.647%);
--color-green-400: rgb(52.157% 87.843% 63.922%);
--color-icon-positive-secondary: var(--color-green-400);
--color-text-positive-secondary: var(--color-green-400);
--color-green-500: rgb(7.8431% 68.235% 36.078%);
--color-icon-positive-on-positive-tertiary: var(--color-green-100);
--color-green-600: rgb(0% 60% 31.765%);
--color-icon-positive-tertiary: var(--color-green-600);
--color-text-positive-tertiary: var(--color-green-600);
--color-green-600: rgb(0% 60% 31.765%);
--color-icon-positive-secondary: var(--color-green-400);
--color-text-positive-secondary: var(--color-green-400);
--color-green-700: rgb(0% 50.196% 26.275%);
--color-green-800: rgb(0.78431% 32.941% 17.647%);
--color-icon-positive: var(--color-green-200);
--color-icon-positive-on-positive-secondary: var(--color-green-100);
--color-text-positive: var(--color-green-200);
--color-text-positive-on-positive-secondary: var(--color-green-100);
--color-text-positive-on-positive-tertiary: var(--color-green-100);
--color-green-900: rgb(0.78431% 25.098% 13.725%);
--color-green-1000: rgb(2.3529% 17.647% 10.588%);
--color-icon-danger: var(--color-red-200);
Expand All @@ -535,6 +529,9 @@
--color-icon-danger-on-danger-tertiary: var(--color-red-100);
--color-icon-danger-secondary: var(--color-red-400);
--color-icon-danger-tertiary: var(--color-red-500);
--color-icon-default: var(--color-white-1000);
--color-icon-default-secondary: var(--color-white-500);
--color-icon-default-tertiary: var(--color-white-400);
--color-icon-neutral: var(--color-slate-200);
--color-icon-neutral-on-neutral: var(--color-slate-1000);
--color-icon-neutral-on-neutral-secondary: var(--color-slate-100);
Expand All @@ -559,36 +556,39 @@
--color-pink-1000: rgb(24.706% 8.2353% 21.176%);
--color-red-100: rgb(99.608% 91.373% 90.588%);
--color-text-danger-on-danger: var(--color-red-100);
--color-text-danger-on-danger-secondary: var(--color-red-100);
--color-text-danger-on-danger-tertiary: var(--color-red-100);
--color-red-200: rgb(99.216% 82.745% 81.569%);
--color-text-danger: var(--color-red-200);
--color-red-300: rgb(98.824% 70.196% 67.843%);
--color-red-400: rgb(95.686% 46.667% 41.569%);
--color-text-danger-secondary: var(--color-red-400);
--color-red-500: rgb(92.549% 13.333% 12.157%);
--color-text-danger-tertiary: var(--color-red-500);
--color-red-600: rgb(75.294% 5.8824% 4.7059%);
--color-text-danger-secondary: var(--color-red-400);
--color-red-700: rgb(56.471% 4.3137% 3.5294%);
--color-text-danger: var(--color-red-200);
--color-text-danger-on-danger-secondary: var(--color-red-100);
--color-text-danger-on-danger-tertiary: var(--color-red-100);
--color-red-800: rgb(41.176% 3.1373% 2.7451%);
--color-red-900: rgb(30.196% 4.3137% 3.9216%);
--color-red-1000: rgb(18.824% 2.3529% 1.1765%);
--color-slate-100: rgb(95.294% 95.294% 95.294%);
--color-text-neutral-on-neutral: var(--color-slate-1000);
--color-text-neutral-on-neutral-secondary: var(--color-slate-100);
--color-text-neutral-on-neutral-tertiary: var(--color-slate-100);
--color-slate-200: rgb(89.02% 89.02% 89.02%);
--color-text-neutral: var(--color-slate-200);
--color-slate-300: rgb(80.392% 80.392% 80.392%);
--color-text-neutral-secondary: var(--color-slate-300);
--color-slate-400: rgb(69.804% 69.804% 69.804%);
--color-text-neutral-tertiary: var(--color-slate-400);
--color-slate-500: rgb(58.039% 58.039% 58.039%);
--color-slate-600: rgb(46.275% 46.275% 46.275%);
--color-text-neutral-tertiary: var(--color-slate-400);
--color-slate-700: rgb(35.294% 35.294% 35.294%);
--color-text-neutral-secondary: var(--color-slate-300);
--color-slate-800: rgb(26.275% 26.275% 26.275%);
--color-text-neutral-on-neutral-tertiary: var(--color-slate-100);
--color-slate-900: rgb(18.824% 18.824% 18.824%);
--color-text-neutral: var(--color-slate-200);
--color-text-neutral-on-neutral-secondary: var(--color-slate-100);
--color-slate-1000: rgb(14.118% 14.118% 14.118%);
--color-text-neutral-on-neutral: var(--color-slate-1000);
--color-text-default: var(--color-white-1000);
--color-text-default-secondary: var(--color-white-500);
--color-text-default-tertiary: var(--color-white-400);
--color-text-warning: var(--color-yellow-200);
--color-text-warning-on-warning: var(--color-yellow-1000);
--color-text-warning-on-warning-secondary: var(--color-yellow-100);
Expand Down
Loading
Loading