Skip to content

v4.0.0-prerelease.15

Pre-release
Pre-release
Compare
Choose a tag to compare
@github-actions github-actions released this 23 Feb 13:26
· 37 commits to main since this release
d5d7a8e

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'
        );
      },
    });