amzn / style-dictionary

A build system for creating cross-platform styles.
https://styledictionary.com
Apache License 2.0
3.87k stars 543 forks source link

Consider async formatters support #999

Closed pascalduez closed 6 months ago

pascalduez commented 1 year ago

Hi,

as far as I can see, custom formatters have to be synchronous. This prevent the use of third parties that only ship asynchronous APIs in formatters.

I hit this while upgrading from Prettier 2 to 3 used to process the result of a custom formatter.

import { format } from 'prettier';

{
  name: 'something/something',
  formatter: async ({ dictionary, file, platform }) => {
    // Formatter logic here.
    // output = ...
    return await format(ouput, { ... });
 }

This is not currently possible.
Would that be something to consider?

ovidb commented 1 year ago

Plus one on this one. Having to rewrite everything using callbacks that return the registration. For now I think the path of least resistance is to downgrade prettier for us.

timsnadden commented 1 year ago

One workaround is to use the @prettier/sync package. https://github.com/prettier/prettier-synchronized

jorenbroekema commented 6 months ago

landed in v4 :)