tokens-studio / sd-transforms

Custom transforms for Style-Dictionary, to work with Design Tokens that are exported from Tokens Studio
MIT License
175 stars 27 forks source link

[Bug]: Is this package compatible with style-dictionary 4.0.0-prerelease.27 ? #277

Closed hadrien-xbto closed 2 months ago

hadrien-xbto commented 2 months ago

What happened?

Running a very basic script to test if everything works, yields the following error.

your package.json specifies "style-dictionary": "^4.0.0-prerelease.22" but it seems that the ^ is misleading and that there are too many breaking changes between prereleasses for your package to stay compatible with each upgrade, right ?

Script :

import StyleDictionary from 'style-dictionary'
import {registerTransforms} from "@tokens-studio/sd-transforms";
registerTransforms(StyleDictionary)
const sd = new StyleDictionary({
        source: ['src/*.json'],
        platforms: {}
    });

Error : if (typeof transformFn !== 'function') throw new Error('transform must be a function');

Without the registerTransforms, the script goes through fine.

Reproduction

package.json : "dependencies": { "@tokens-studio/sd-transforms": "0.15.2", "style-dictionary": "^4.0.0-prerelease.27" }

Expected output

No response

Version

0.15.2

jorenbroekema commented 2 months ago

style-dictionary is only a dev dependency of this package which I use to do some integration tests.

I will create a compatibility table for sd-transforms <-> style-dictionary versions!

jorenbroekema commented 2 months ago

Ah my mistake, style-dictionary is actually a direct dependency due to this package using its reference utils directly in the expand logic.

NPM will usually dedupe dependencies if they are compatible with regards to semver, but my guess is that with prereleases it will never dedupe them because they can always contain breaking changes? So yeah indeed the ^ is a little confusing if it doesn't actually do anything, I'm guessing it behaves as if you put a fixed version?

Either way, I added a compatibility table in the README now and upgraded this package to 0.16.0 to be compatible with the latest Style Dictionary prerelease (27), and I've added style-dictionary to peerDepedencies, meaning that if you were to install an incompatible Style Dictionary with this package, it should throw you an error from this version of sd-transforms onwards. https://github.com/tokens-studio/sd-transforms/pull/278