-
-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid using @babel/runtime
as a dependency
#421
Comments
Hey @theoludwig! 👋 tailwind-merge is bundled to be compatible with the browserslist query Do you have a use case where speed matters so much more than compatibility with enough browsers? The tradeoff with not transpiling at all to shave off a few bytes is that the code will break the app for some 10-20% of users. |
Hey @dcastil, thanks for your reply! I understand the desire to maintain broad compatibility, but I would like to present a case for why we should avoid including the
Maybe, but then, for 80-90% of users, they are downloading and executing more JavaScript, than necessary. As you said: "bundled to be compatible with the browserslist query", "which is the default for most apps.", that's exactly the point, it's not the library developer responsibility, but the app developer responsibility to bundle/polyfill/transpile accordingly to what browsers they want to target. Most frameworks for apps, already handle it, whether it is Vite.js, Next.js or others. For reference, some comments/articles, that discuss this:
ConclusionIn conclusion, while ensuring compatibility is important, it should not come at the cost of performance and maintainability for the majority of users. By not including Looking forward to your thoughts on this! |
That argument makes a lot of sense to me, thanks for bringing it up! I won't be able to stop transpiling the default bundle because that could break a lot of apps. But I could add another bundle, e.g. import { twMerge } from 'tailwind-merge/esnext' There is already a similar bundle like that for people that need the code to be ES5-compatible (#286, #344): import { twMerge } from 'tailwind-merge/es5' Would that be something that could work for you? |
Yes, possibly, a |
That bundle wouldn't use |
@theoludwig just checked the bundle and the normal tailwind-merge bundle doesn't even import |
But I can see how having |
This was addressed in release v2.4.0. |
Describe the bug
While it is expected that
tailwind-merge
increase bundle size (as said in the docs) and has a cost at runtime, we should minimze it nonetheless.We should be able to use modern JavaScript syntax and features, as supported by modern browsers, hence, I don't think adding
@babel/runtime
(for better compatibility? as I understand it) is worth it.To Reproduce
npm install tailwind-merge
Expected behavior
No dependencies.
Environment
tailwind-merge@2.3.0
The text was updated successfully, but these errors were encountered: