material-foundation / material-color-utilities

Color libraries for Material You
Apache License 2.0
1.57k stars 134 forks source link

TypeScript - Babel loader required for transpiling new ES syntax #106

Open mengX666 opened 1 year ago

mengX666 commented 1 year ago

Hey we'd like to use some of the functionalities in this library to generate color ramps in another npm package @atlaskit/tokens https://www.npmjs.com/package/@atlaskit/tokens.

We found out the compiled dependency has some ES20 syntaxes ?. and ?? which need to be transpiled with Babel plugins. It also means all the consumers of our package @atlaskit/tokens will need to transpile if their bundlers don't handle these syntaxes.

A workaround might be - the functions we are importing don't use these new ES syntaxes, so subpath import could work e.g. import { Hct } from "@material/material-color-utilities/hct"; and it requires an update in the exports field in package.json.

Another solution might be compiling the library with an older Babel plugin so that neither we nor our consumer has to transpile, but it might increase the bundle size.

Would love to hear your thoughts on this, thanks 🙏