tailwind-merge icon indicating copy to clipboard operation
tailwind-merge copied to clipboard

Transpile lib to more modern JS

Open dcastil opened this issue 1 year ago • 1 comments

Note If you are affected by this, please let me know in a comment.

Currently the library is transpiled with the default browserslist config which means it is transpiled to ES5.

I played around with some more modern configs like last 3 years and > 0.1%, maintained node versions and could reduce the minified library size by 1 kB and the gzipped size by 0.5 kB. Additionally, I expect some minor performance improvements because e.g. rest/spread isn't polyfilled anymore.

Transpiling to more modern JS could be a breaking change for some users of tailwind-merge, so this would need to go into a v2 release of tailwind-merge.

I could also provide an additional legacy build (import { twMerge } from 'tailwind-merge/legacy') which stays transpiled to ES5 since everything in tailwind-merge can be polyfilled. But I guess that's not necessary since devs who need to support ES5 probably transpile their dependencies anyway these days.

dcastil avatar Aug 13 '22 11:08 dcastil

Related: https://github.com/dcastil/tailwind-merge/issues/132

dcastil avatar Aug 20 '22 19:08 dcastil