Skip to content

Commit

Permalink
V4 preprocessors (#235)
Browse files Browse the repository at this point in the history
* BREAKING: remove feature for auto grabbing SD instance

* BREAKING: use preprocessors if the passed SD is prerelease.2 or higher
  • Loading branch information
jorenbroekema authored Jan 9, 2024
1 parent d73d731 commit 6c95fe4
Show file tree
Hide file tree
Showing 27 changed files with 958 additions and 615 deletions.
5 changes: 5 additions & 0 deletions .changeset/fluffy-files-call.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tokens-studio/sd-transforms': minor
---

BREAKING: remove code that allowed user to not pass StyleDictionary instance to registerTransforms, and grabbed the locally installed StyleDictionary automatically. This seemed like a cool feature at first, but can cause hard to trace bugs if there are multiple installations of style-dictionary (due to incompatible semver).
5 changes: 5 additions & 0 deletions .changeset/six-kiwis-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tokens-studio/sd-transforms': minor
---

Will now use preprocessors instead of parsers when user Style-Dictionary is v4.0.0-prerelease.2 or higher. Fixes an issue with multi-file references not being resolvable when running composite token expansion or add font style utilities.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,12 @@ StyleDictionary.registerTransformGroup({
You can pass options to the `registerTransforms` function.

```js
registerTransforms({
registerTransforms(StyleDictionary, {
expand: {
composition: false,
typography: true,
// Note: when using Style-Dictionary v4.0.0-prerelease.2 or higher, filePath no longer gets passed
// as an argument, because preprocessors work on the full dictionary rather than per file (parsers)
border: (token, filePath) =>
token.value.width !== 0 && filePath.startsWith(path.resolve('tokens/core')),
shadow: false,
Expand Down
Loading

0 comments on commit 6c95fe4

Please sign in to comment.