8000 Reduce CLJS compiled bundle size by alexander-yakushev · Pull Request #1211 · metosin/malli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Reduce CLJS compiled bundle size #1211

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

Merged
merged 1 commit into from
Jun 7, 2025

Conversation

alexander-yakushev
Copy link
Contributor
@alexander-yakushev alexander-yakushev commented Jun 5, 2025

When the Clojurescript compiler encounters a call to resolve or a var macro, it inlines the whole metadata right at the callsite. This produces a lot of unnecessary code in the compiled output.

My proposal here is to rewrite predicate-schemas function to avoid using #' quoting. With these changes, I was able to reduce the compiled Malli size (with advanced optimizations) by 14 KB uncompressed (4KB gzipped).

@ikitommi
Copy link
Member
ikitommi commented Jun 5, 2025

Change welcome.

@alexander-yakushev
Copy link
Contributor Author

Hm, I'm actually struggling to make it work on CLJS with all the macro action that is going on. Will you accept a PR that spells out all pairs of symbols and function values explicitly? I know it's more error prone this way, but I'm not sure I can make this work in the way I wanted from the beginning.

@alexander-yakushev
Copy link
Contributor Author
alexander-yakushev commented Jun 5, 2025

Alright, managed to get it to work by extracting the code-expanding macro into another namespace. I'm not sure why it couldn't work within the same namespace, I don't have that much experience with CLJS.

@ikitommi ikitommi merged commit 9cfa7d2 into metosin:master Jun 7, 2025
14 checks passed
@ikitommi
Copy link
Member
ikitommi commented Jun 7, 2025

Great, thanks! If you want smaller cljs bundles, there is also the compiler option to omit the default registry: https://github.com/metosin/malli?tab=readme-ov-file#dce-and-schemas

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.

2 participants
0