tokens-studio/sd-transforms

[Bug]: registerTransforms outputs false error for missing references. Transforms still work

Closed this issue · 1 comments

What happened?

While transforming a set of input files, I receive an error:

Error: Reference doesn't exist: tries to reference font-weight.regular, which is not defined.
    at file:///C:/Users/ANONYMOUS/source/repos/ANONYMOUS/node_modules/.pnpm/@tokens-studio+sd-transforms@0.13.4_quill-delta@5.1.0_rxjs@7.8.1_tslib@2.6.2/node_modules/@tokens-studio/sd-transforms/dist/bundled_CJS_deps/style-dictionary/lib/utils/references/resolveReferences.js:182:15
    at String.replace (<anonymous>)
    at _resolveReferences (file:///C:/Users/ANONYMOUS/source/repos/ANONYMOUS/node_modules/.pnpm/@tokens-studio+sd-transforms@0.13.4_quill-delta@5.1.0_rxjs@7.8.1_tslib@2.6.2/node_modules/@tokens-studio/sd-transforms/dist/bundled_CJS_deps/style-dictionary/lib/utils/references/resolveReferences.js:85:9)
    at resolveReferences (file:///C:/Users/ANONYMOUS/source/repos/ANONYMOUS/node_modules/.pnpm/@tokens-studio+sd-transforms@0.13.4_quill-delta@5.1.0_rxjs@7.8.1_tslib@2.6.2/node_modules/@tokens-studio/sd-transforms/dist/bundled_CJS_deps/style-dictionary/lib/utils/references/resolveReferences.js:40:10)
    at recurse (file:///C:/Users/ANONYMOUS/source/repos/ANONYMOUS/node_modules/.pnpm/@tokens-studio+sd-transforms@0.13.4_quill-delta@5.1.0_rxjs@7.8.1_tslib@2.6.2/node_modules/@tokens-studio/sd-transforms/dist/src/parsers/add-font-styles.js:20:38)
    at recurse (file:///C:/Users/ANONYMOUS/source/repos/ANONYMOUS/node_modules/.pnpm/@tokens-studio+sd-transforms@0.13.4_quill-delta@5.1.0_rxjs@7.8.1_tslib@2.6.2/node_modules/@tokens-studio/sd-transforms/dist/src/parsers/add-font-styles.js:50:13)
    at addFontStyles (file:///C:/Users/ANONYMOUS/source/repos/ANONYMOUS/node_modules/.pnpm/@tokens-studio+sd-transforms@0.13.4_quill-delta@5.1.0_rxjs@7.8.1_tslib@2.6.2/node_modules/@tokens-studio/sd-transforms/dist/src/parsers/add-font-styles.js:56:5)
    at parseTokens (file:///C:/Users/ANONYMOUS/source/repos/ANONYMOUS/node_modules/.pnpm/@tokens-studio+sd-transforms@0.13.4_quill-delta@5.1.0_rxjs@7.8.1_tslib@2.6.2/node_modules/@tokens-studio/sd-transforms/dist/src/parsers/parse-tokens.js:7:28)
    at parse (file:///C:/Users/ANONYMOUS/source/repos/ANONYMOUS/node_modules/.pnpm/@tokens-studio+sd-transforms@0.13.4_quill-delta@5.1.0_rxjs@7.8.1_tslib@2.6.2/node_modules/@tokens-studio/sd-transforms/dist/src/registerTransforms.js:57:28)
    at C:\Users\ANONYMOUS\source\repos\ANONYMOUS\node_modules\.pnpm\style-dictionary@3.9.2\node_modules\style-dictionary\lib\utils\combineJSON.js:68:26

However, the transformation seems to be complete and the output seems correct.

Reproduction

Here's a zip file containing a minimal reproduction. Unzip, run npm i then node build-tokens.js

repro.zip

Expected output

Expecting the build to complete without emitting errors, since the reference should in fact be defined

Version

0.13.4

Hey, yes that's this bug #217 , fixed in v0.13.0 and above of this package, and only if you're also using style-dictionary v4.0.0-prerelease.2

Unfortunately I could not fix this issue in style-dictionary v3, so you'd have to migrate to the v4 prereleases to get this fixed