Releases: amzn/style-dictionary
v4.0.0-prerelease.8
v4.0.0-prerelease.7
Minor Changes
- 0410295: Improve and test the error handling of standalone usage of reference utilities.
v4.0.0-prerelease.6
Patch Changes
- 1dd828c: Fix issue in browser-bundled glob, bump.
v4.0.0-prerelease.5
Major Changes
-
6cc7f31: BREAKING:
-
usesReference
util function is nowusesReferences
to be consistent plural form like the other reference util functions. -
getReferences
first and second parameters have been swapped to be consistent withresolveReferences
, so value first, then the full token object (instead of the entire dictionary instance). -
getReferences
accepts a third options parameter which can be used to set reference Regex options as well as an unfilteredTokens object which can be used as a fallback when references are made to tokens that have been filtered out. There will be warnings logged for this. -
format.formatter
removed old function signature of(dictionary, platform, file)
in favor of({ dictionary, platform, options, file })
. -
Types changes:
- Style Dictionary is entirely strictly typed now, and there will be
.d.ts
files published next to every file, this means that if you import from one of Style Dictionary's entrypoints, you automatically get the types implicitly with it. This is a big win for people using TypeScript, as the majority of the codebase now has much better types, with much fewerany
s. - There is no more hand-written Style Dictionary module
index.d.ts
anymore that exposes all type interfaces on itself. This means that you can no longer grab types that aren't members of the Style Dictionary class directly from the default export of the main entrypoint. External types such asParser
,Transform
,DesignTokens
, etc. can be imported from the newly added types entrypoint:
import type { DesignTokens, Transform, Parser } from 'style-dictionary/types';
Please raise an issue if you find anything missing or suddenly broken.
Matcher
,Transformer
,Formatter
, etc. are still available, although no longer directly but rather as properties on their parents, soFilter['matcher']
,Transform['transformer']
,Format['formatter']
- Style Dictionary is entirely strictly typed now, and there will be
-
Patch Changes
- e859036: Fix Windows support by using a Linux/Windows + Node/Browser compatible path utility. Upgrade to latest Glob version. Apply posix: true to prevent breaking change glob update.
v4.0.0-prerelease.4
Minor Changes
-
122c8f6: Expose a new utility called resolveReferences which takes a value containing references, the dictionary object, and resolves the value's references for you.
import StyleDictionary from 'style-dictionary'; import { resolveReferences } from 'style-dictionary/utils'; const sd = new StyleDictionary({ tokens: { foo: { value: 'foo' }, bar: { value: '{foo}' }, qux: { value: '{bar}' }, }, }); console.log(resolveReferences(sd.tokens.qux.value, sd.tokens)); // 'foo'
-
122c8f6: BREAKING: expose getReferences and usesReference utilities as standalone utils rather than requiring them to be bound to dictionary object. This makes it easier to use.
Patch Changes
- 044123c: Patch StyleDictionary main type file to export default instead of "export =" which does not work in ESM.
v4.0.0-prerelease.3
Patch Changes
- 8d2f6d8: Make sure fs-node.js file is published to NPM.
v4.0.0-prerelease.2
Major Changes
-
a4542f4: BREAKING: StyleDictionaryInstance.properties & .allProperties have been removed. They were deprecated in v3 in favor of .tokens and .allTokens.
-
a4542f4: BREAKING: StyleDictionary to be initialized with a new API and have async methods. Use:
import StyleDictionary from 'style-dictionary'; /** * old: * const sd = StyleDictionary.extend({ source: ['tokens.json'], platforms: {} }); * sd.buildAllPlatforms(); */ const sd = new StyleDictionary({ source: ['tokens.json'], platforms: {} }); await sd.buildAllPlatforms();
You can still extend a dictionary instance with an extended config, but
.extend()
is only used for this, it is no longer used to initialize the first instance:import StyleDictionary from 'style-dictionary'; const sd = new StyleDictionary({ source: ['tokens.json'], platforms: {} }); const extended = await sd.extend({ fileHeader: { myFileHeader: (defaultMessage) => { return [...defaultMessage, 'hello, world!']; }, }, });
To ensure your initialized StyleDictionary instance is fully ready and has imported all your tokens, you can await
hasInitialized
:import StyleDictionary from 'style-dictionary'; const sd = new StyleDictionary({ source: ['tokens.json'], platforms: {} }); await sd.hasInitialized; console.log(sd.allTokens);
For error handling and testing purposes, you can also manually initialize the style-dictionary config:
import StyleDictionary from 'style-dictionary'; const sd = new StyleDictionary({ source: ['tokens.js'], platforms: {} }, { init: false }); try { await sd.init(); } catch (e) { // handle error, e.g. when tokens.js file has syntax errors and cannot be imported } console.log(sd.allTokens);
The main reason for an initialize step after class instantiation is that async constructors are not a thing in JavaScript, and if you return a promise from a constructor to "hack it", TypeScript will eventually trip over it.
Due to being able to dynamically (asynchronously) import ES Modules rather than synchronously require CommonJS modules, we had to make the APIs asynchronous, so the following methods are now async:
- extend
- exportPlatform
- buildAllPlatforms & buildPlatform
- cleanAllPlatforms & cleanPlatform
In a future release, most other methods will be made async or support async as well, such as parsers, transforms, formats etc.
Minor Changes
- cedf8a0: Preprocessors are a new feature added to style-dictionary, which allows you to do any type of processing of the token dictionary after parsing, before resolving and transforming.
See preprocessor docs for more information. - a4542f4: options.log to be respected in all error logging, including platform specific logs.
v4.0.0-prerelease.1
Patch Changes
-
c1dd5ec: Allow overriding CSS formatting with commentStyle and commentPosition props.
For commentStyle, options are 'short' or 'long'.
For commentPosition, options are 'above' or 'inline'.We also ensure that the right defaults are picked for CSS, SASS/SCSS, Stylus and Less.
This also contains a fix for ensuring that multi-line comments are automatically put "above" rather than "inline".
-
6fb81ad: Allow falsy token values for outputReferences, e.g.
0
. -
24d41c3: Allow outputReferences to work on non-string values.
v4.0.0-prerelease.0
Major Changes
- dcbe2fb:
- The project has been fully converted to ESM format, which is also the format that the browser uses.
For users, this means you'll have to either use Style-Dictionary in ESM JavaScript code, or dynamically import it into your CommonJS code. Style-Dictionary.extend()
method is now asynchronous, which means it returnsPromise<StyleDictionary.Core>
instead ofStyleDictionary.Core
.allProperties
/properties
was deprecated in v3, and is now removed fromStyleDictionary.Core
, useallTokens
andtokens
instead.- Templates and the method
registerTemplate
were deprecated in v3, now removed. Use Formats instead. - The package now uses package entrypoints, which means that what is importable from the package is locked down to just the specified entrypoints:
style-dictionary
&style-dictionary/fs
. If more is needed, please raise an issue explaining which file you were importing and why you need it to be public API.
- The project has been fully converted to ESM format, which is also the format that the browser uses.
Minor Changes
-
dcbe2fb: FileSystem that is used by Style-Dictionary can now be customized:
import { setFs } from 'style-dictionary/fs'; setFs(myFileSystemShim);
By default, it uses an in-memory filesystem shim
@bundled-es-modules/memfs
in browser context,node:fs
built-in module in Node context.
All notable changes to this project will be documented in this file. See standard-version for commit guidelines.
v3.8.0
What's Changed
- Add options.outputStringLiterals to typescript/es6-declarations by @isaac-y-baron in #857
- JSON syntax highlighting on README by @coliff in #911
- Compose object imports by @giovannimartusciello in #874
- fix-918: add correct return types for sortByReference by @kwittkowsky in #919
- chore(deps): bump json5 by @dbanksdesign in #912
- docs: update JSDoc param names to match argument names by @jessicalynch in #939
- fix(transforms): consistent usage of 'token' instead of 'prop' by @julien-deramond in #934
- feat(formats) Use TSDoc comment format for typescript/es6-declarations by @christianvuerings in #950
- Fix doc about destination config being optional by @rivajunior in #938
- Add missing className file format documentation for ios-swift classes by @gsouquet in #931
- fix(types): loosening the Platform type to allow for extension by @dbanksdesign in #926
- chore(deps): bump http-cache-semantics from 4.1.0 to 4.1.1 by @dependabot in #930
- fix(formats): added missing EOL before EOF for some formats by @AugustinasVainius in #963
- fix(docs): formatting for
options.import
at compose/object by @lucoel in #958
New Contributors
- @isaac-y-baron made their first contribution in #857
- @giovannimartusciello made their first contribution in #874
- @kwittkowsky made their first contribution in #919
- @jessicalynch made their first contribution in #939
- @julien-deramond made their first contribution in #934
- @christianvuerings made their first contribution in #950
- @rivajunior made their first contribution in #938
- @gsouquet made their first contribution in #931
- @AugustinasVainius made their first contribution in #963
- @lucoel made their first contribution in #958
Full Changelog: v3.7.2...v3.8.0