Skip to content
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

Improve tree-shaking #65

Merged
merged 12 commits into from
Dec 11, 2021
Merged

Improve tree-shaking #65

merged 12 commits into from
Dec 11, 2021

Conversation

dcastil
Copy link
Owner

@dcastil dcastil commented Dec 11, 2021

Previously the entire tailwind-merge library was bundled into a single file. This has a few issues.

  • It's harder to debug library as a library user during development as everything is in one huge file
  • I rely on dead code elimination of the projects using the library to remove unused exports of tailwind-merge which should be fine for modern bundlers, but some bundlers don't do a good job with dead code elimination. It's better to rely on tree shaking with unused imports. A good example of this is Bundlephobia which reports that all exports of tailwind-merge use the entire bundle size which is not accurate.

Bundlephobias export analysis of tailwind-merge v1.0.0:

Screenshot 2021-12-11 at 16 10 25

The solution: Preserve the transpiled files (at least for the ESM bundle) and don't bundle them into a single file.

@github-actions github-actions bot added the feature Is new feature label Dec 11, 2021
@dcastil dcastil marked this pull request as ready for review December 11, 2021 15:54
@dcastil dcastil merged commit f2784bd into main Dec 11, 2021
@dcastil dcastil deleted the feature/improve-tree-shaking branch December 11, 2021 15:55
@dcastil dcastil added the context-v1 Related to tailwind-merge v1 label Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
context-v1 Related to tailwind-merge v1 feature Is new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant