Releases: amzn/style-dictionary
v4.0.0-prerelease.21
Minor Changes
-
8b6fff3: Fixes some noisy warnings still being outputted even when verbosity is set to default.
We also added log.warning "disabled" option for turning off warnings altogether, meaning you only get success logs and fatal errors.
This option can be used from the CLI as well using the--no-warn
flag.
Patch Changes
- 77ae35f: Fix scenario of passing absolute paths in Node env, do not remove leading slash in absolute paths.
v4.0.0-prerelease.20
Minor Changes
-
aff6646: Allow passing a custom FileSystem Volume to your Style-Dictionary instances, to ensure input/output files are read/written from/to that specific volume.
Useful in case you want multiple Style-Dictionary instances that are isolated from one another in terms of inputs/outputs.import { Volume } from 'memfs'; // You will need a bundler for memfs in browser... // Or use as a prebundled fork: import memfs from '@bundled-es-modules/memfs'; const { Volume } = memfs; const vol = new Volume(); const sd = new StyleDictionary( { tokens: { colors: { red: { value: '#FF0000', type: 'color', }, }, }, platforms: { css: { transformGroup: 'css', files: [ { destination: 'variables.css', format: 'css/variables', }, ], }, }, }, { volume: vol }, ); await sd.buildAllPlatforms(); vol.readFileSync('/variables.css'); /** * :root { * --colors-red: #FF0000; * } */
This also works when using extend:
const extendedSd = await sd.extend(cfg, { volume: vol });
v4.0.0-prerelease.19
Major Changes
-
79bb201: BREAKING: Logging has been redesigned a fair bit and is more configurable now.
Before:
{ "log": "error" // 'error' | 'warn' -> 'warn' is the default value }
After:
{ "log": { "warnings": "error", // 'error' | 'warn' -> 'warn' is the default value "verbosity": "verbose" // 'default' | 'verbose' | 'silent' -> 'default' is the default value } }
Log is now and object and the old "log" option is now "warnings".
This configures whether the following five warnings will be thrown as errors instead of being logged as warnings:
- Token value collisions (in the source)
- Token name collisions (when exporting)
- Missing "undo" function for Actions
- File not created because no tokens found, or all of them filtered out
- Broken references in file when using outputReferences, but referring to a token that's been filtered out
Verbosity configures whether the following warnings/errors should display in a verbose manner:
- Token collisions of both types (value & name)
- Broken references due to outputReferences & filters
- Token reference errors
And it also configures whether success/neutral logs should be logged at all.
Using "silent" (or --silent in the CLI) means no logs are shown apart from fatal errors. -
bcb5ef3: Remove reliance on CTI token structure across transforms, actions and formats.
Breaking changes:
- Token type will now be determined by "type" (or "$type") property on the token, rather than by checking its CTI attributes. This change has been reflected in all of the format templates as well as transform "matcher" functions that were previously checking
attributes.category
as the token type indicator. - Types are mostly aligned with DTCG spec types, although a few additional ones have been added for compatibility reasons:
- asset -> string type tokens where the value is a filepath to an asset
- icon -> content type string tokens where the content resembles an icon, e.g. for icon fonts like Microsoft codicons
- html -> HTML entity strings for unicode characters
- content -> regular string content e.g. text content which sometimes needs to be wrapped in quotes
- Built-in name transforms are now reliant only on the token path, and are renamed from
name/cti/casing
to justname/casing
.name/ti/camel
andname/ti/constant
have been removed. For examplename/cti/kebab
transform is nowname/kebab
. - Transform
content/icon
has been renamed tohtml/icon
since it targets HTML entity strings, not just any icon content. font/objC/literal
,font/swift/literal
andfont/flutter/literal
have been removed in favor offont/objC/literal
,font/swift/literal
andfont/flutter/literal
, as they do he exact same transformations.typescript/module-declarations
format to be updated with current DesignToken type interface.
Before:
{ "color": { "red": { "value": "#FF0000" } } }
After:
{ "color": { // <-- this no longer needs to be "color" in order for the tokens inside this group to be considered of type "color" "red": { "value": "#FF0000", "type": "color" } } }
- Token type will now be determined by "type" (or "$type") property on the token, rather than by checking its CTI attributes. This change has been reflected in all of the format templates as well as transform "matcher" functions that were previously checking
Patch Changes
- 8e297d6: Fix outputReferences for DTCG spec tokens, by using token.original.$value instead of token.original.value.
v4.0.0-prerelease.18
Patch Changes
- 738686b: Allow transformGroup to be combined with transforms, where standalone transforms will be added after the group's transforms.
v4.0.0-prerelease.17
Patch Changes
- 63681a6: Fix a couple of type imports issues in .d.ts files
v4.0.0-prerelease.16
v4.0.0-prerelease.15
Major Changes
-
502dbd1: BREAKING: All of our hooks, parsers, preprocessors, transforms, formats, actions, fileHeaders and filters, support async functions as well now. This means that the formatHelpers -> fileHeader helper method is now asynchronous, to support async fileheader functions.
import StyleDictionary from 'style-dictionary'; const { fileHeader } = StyleDictionary.formatHelpers; StyleDictionary.registerFormat({ name: 'custom/css', // this can be async now, usually it is if you use fileHeader format helper, since that now always returns a Promise formatter: async function ({ dictionary, file, options }) { const { outputReferences } = options; return ( // this helper is now async! because the user-passed file.fileHeader might be an async function (await fileHeader({ file })) + ':root {\n' + formattedVariables({ format: 'css', dictionary, outputReferences }) + '\n}\n' ); }, });
v4.0.0-prerelease.14
Minor Changes
- 606af51: Rename
typeW3CDelegate
utility function totypeDtcgDelegate
, as using "W3C" is highly discouraged when the standard isn't a W3C standard yet. - 606af51: Support the use of "value"/"type"/"description" as token names or token group names, at the sacrifice of now no longer being able to combine non-DTCG and DTCG syntax within the same token dictionary.
Patch Changes
- cd9f484: Escape double quotes for ts outputStringLiterals
v4.0.0-prerelease.13
Patch Changes
- 24584b4: Conditionally only run dev scripts when CWD is style-dictionary, so our consumers don't run it by accident
v4.0.0-prerelease.12
Patch Changes
- c2cbd1b: Publish the postinstall-dev script to NPM.