Skip to content

Conversation

philipp-spiess
Copy link
Member

@philipp-spiess philipp-spiess commented Sep 17, 2025

Summary

Removes lodash dependencies (lodash.merge, lodash.castarray, lodash.isplainobject) and replaces them with inline implementations to reduce bundle size and eliminate external dependencies.

This addresses concerns raised in the community about lodash dependencies bloating bundle sizes (referenced from this discussion).

Copy link

vercel bot commented Sep 17, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
tailwindcss-typography Ready Ready Preview Comment Sep 17, 2025 1:59pm

Replace lodash.merge, lodash.castarray, and lodash.isplainobject with inline implementations to reduce bundle size and eliminate external dependencies. The merge function maintains full compatibility with lodash behavior, including recursive merging of nested objects within arrays.

- Remove lodash.merge, lodash.castarray, lodash.isplainobject from dependencies
- Add inline implementations in src/utils.js with identical behavior
- Update src/index.js to import utilities from utils module
- Maintain backward compatibility and all existing functionality

Fixes bundle size concerns raised in community discussions about lodash dependencies.
}

return merge(target, ...sources)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code that uses merge could probably be simplified to not need it at all tbh

}

function castArray(value) {
return Array.isArray(value) ? value : [value]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we simplified that code and dropped the entries -> fromEntries dance we could inline this too

Copy link
Contributor

@thecrypticace thecrypticace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments but don't actually need to simplify those things unless you feel like it 🤷‍♂️

Copy link
Member

@RobinMalfait RobinMalfait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this handles all the cases that lodash handled, but I also don't think we need to have support for all of that (old) JS stuff anyway.

This should be enough for our use cases. I would even argue that this is already too complex for what we need. But it's much simpler / smaller already.

@philipp-spiess
Copy link
Member Author

@RobinMalfait @thecrypticace Yeah I was going for least changes possible to avoid any breakage. Can definitely be cleaned up but we'd want to invest time in the CSS-only branch if we do that instead. Let me add changelog and land it 👍

@philipp-spiess
Copy link
Member Author

@RobinMalfait @thecrypticace thanks for whoever of you fixed the Vercel thing :D

@philipp-spiess philipp-spiess merged commit ecb7d5c into main Sep 17, 2025
4 checks passed
@philipp-spiess philipp-spiess deleted the remove-lodash branch September 17, 2025 14:02
philipp-spiess added a commit that referenced this pull request Sep 19, 2025
* Remove lodash dependencies

Replace lodash.merge, lodash.castarray, and lodash.isplainobject with inline implementations to reduce bundle size and eliminate external dependencies. The merge function maintains full compatibility with lodash behavior, including recursive merging of nested objects within arrays.

- Remove lodash.merge, lodash.castarray, lodash.isplainobject from dependencies
- Add inline implementations in src/utils.js with identical behavior
- Update src/index.js to import utilities from utils module
- Maintain backward compatibility and all existing functionality

Fixes bundle size concerns raised in community discussions about lodash dependencies.

* Add changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants