This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-08
Channels
- # announcements (6)
- # atom-editor (1)
- # babashka (21)
- # beginners (70)
- # clerk (4)
- # clj-kondo (71)
- # clj-yaml (1)
- # clojure (54)
- # clojure-art (1)
- # clojure-denmark (1)
- # clojure-dev (1)
- # clojure-doc (1)
- # clojure-europe (31)
- # clojure-nl (1)
- # clojure-norway (41)
- # clojure-uk (15)
- # clojurescript (36)
- # conjure (1)
- # cursive (2)
- # datomic (14)
- # duct (10)
- # emacs (12)
- # etaoin (176)
- # gratitude (25)
- # hyperfiddle (17)
- # jobs (1)
- # juxt (5)
- # london-clojurians (1)
- # malli (3)
- # nbb (21)
- # off-topic (29)
- # reitit (12)
- # releases (2)
- # remote-jobs (7)
- # shadow-cljs (9)
- # testing (9)
I'm struggling to properly import antd into a shadow-cljs/reagent project without creating a huge bundle. How I created the project:
lein new reagent-frontend test-app
...
npm i antd
npx shadow-cljs release app
How I imported the component:
(ns test-app.core
(:require
[antd :refer (Button)]
[reagent.core :as r]
[reagent.dom :as d]))
;; -------------------------
;; Views
(defn home-page []
[:div (Button [:h2 "Welcome to Reagent"])])
Removing Button from this reduces the size of my bundle from antd
is huge when imported that way. check the build report for a detailed breakdown https://shadow-cljs.github.io/docs/UsersGuide.html#build-report
avoid importing the root antd
package. instead try (:require ["antd/lib/button" :as Button])
@U05224H0W The build report lists all antd components, like the icons and dependencies. I tried following your GitHub comment (https://github.com/thheller/shadow-cljs/issues/412#issuecomment-442002374) to only import the Button component, but I couldn't figure out a syntax. I will try your two suggestions
Just tried a fresh cra project and imported the button. It's about half the size as the shadow-cljs project
with lein new reagent-frontend test-app / shadow-cljs:
501K Mar 8 08:30 public/js/app.js
if you want better tree shaking for npm packages I suggest you stick with webpack as described here https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html#option-2-js-provider-external
@U05224H0W Thanks, I'll try the webpack approach and see if that gives me any extra juice
remember that cljs.core alone basically is something like immutable-js + lodash in one
so if you do comparisons with plain js consider added those to make the comparison fair
well considering the additional 116 KB of cljs/core, there's still an additional 154 KB being brought in from npm with shadow-cljs compared to the barebones Button example in basic create-react-app
There is also this wrapper that you can use or just to take a look the optimal way to import. https://gitlab.com/synqrinus/syn-antd
Hey, anyone using tick
? Docs say that one can reduce cljs build size by including smaller timezone packages from js-joda. But they don't say where these packages are available or how I actually use them. Any ideas? https://github.com/juxt/tick/blob/master/docs/cljs.adoc
Oh yeah, thanks!
hello, I'm having trouble using regexp unicode in cljs:
(re-matches #"(?u)\p{Alpha}" "a")
=> works
(re-matches #"(?u)\p{Hex_Digit}" "a")
=> error Unknown character property name {In/IsHex_Digit} near index 16
in the JS console: 'a'.match(/\p{Hex_Digit}/u)
=> works
anyone knows what I'm missing ?
CLJ-hosted CLJS compiler first reads all CLJS forms and then converts them into JS code.
That means that the #"..."
dispatch macro will first be read by a CLJ reader and not a CLJS one. So that RegEx will be read as java.util.regex.Pattern
. And that's exactly the class that spits that error - it doesn't support Hex_Digit
.
You can move pattern preparation to runtime by calling re-pattern
on a plain string instead. It will avoid Java's Pattern
altogether.
What's a good, recent, bare bones (cljs+nrepl) cljs project template? No figwheel, no bells. I'm trying to get a cljs+nrepl+calva combo working nicely and kinda failing.
I guess shadow-cljs can be considered bells. 😃 But Calva has a Getting Started REPL for cljs, which creates a very small project and jacks in to it. This project is created in a temp directory. It's being downloaded from here: https://github.com/BetterThanTomorrow/dram/tree/published/drams