This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-28
Channels
- # aws (1)
- # beginners (30)
- # boot (7)
- # cider (52)
- # clara (91)
- # cljs-dev (33)
- # cljsjs (1)
- # clojure (447)
- # clojure-brasil (3)
- # clojure-dev (16)
- # clojure-dusseldorf (5)
- # clojure-filipino (1)
- # clojure-italy (29)
- # clojure-sanfrancisco (5)
- # clojure-spec (62)
- # clojure-uk (37)
- # clojurescript (145)
- # clojurewerkz (1)
- # code-reviews (12)
- # community-development (157)
- # cursive (5)
- # datascript (1)
- # datomic (27)
- # editors (42)
- # emacs (5)
- # fulcro (31)
- # hoplon (2)
- # jobs (2)
- # keechma (1)
- # lumo (31)
- # off-topic (2)
- # om (1)
- # onyx (13)
- # parinfer (8)
- # re-frame (13)
- # reagent (32)
- # remote-jobs (4)
- # shadow-cljs (103)
- # spacemacs (15)
- # specter (10)
- # sql (1)
- # tools-deps (35)
- # unrepl (13)
@thheller sleepelss night for me, I tried the new closure. Was hopeing it would fix a Quill bug I had completly randomly, evening before launching a new webapp. So two post-compilation bugs I'm gettiing. But as these are both admin endpoints, then I'm actually running shadow-cljs watch
in production. Somehow build with optimizatioon :none
gave me an error, wait I can send it...
shadow-cljs release :admin ~/Documents/visitor
shadow-cljs - config: /home/hlolli/Documents/visitor/shadow-cljs.edn version: 2.2.20
shadow-cljs - connected to server
[:admin] Compiling ...
optimizations set to :none, can't optimize
{}
ExceptionInfo: optimizations set to :none, can't optimize
clojure.core/ex-info (core.clj:4739)
clojure.core/ex-info (core.clj:4739)
shadow.build.closure/optimize (closure.clj:1081)
shadow.build.closure/optimize (closure.clj:1074)
shadow.build.api/optimize (api.clj:182)
shadow.build.api/optimize (api.clj:176)
shadow.build/optimize (build.clj:318)
shadow.build/optimize (build.clj:310)
but can you say more about the quill thing? does it still not work with the latest closure?
(:require ["react-quill" :as Quill])
(defn component []
(let [quill-ref (atom nil)]
(r/create-class
{:reagent-render
(fn [] [:> Quill {:default-value ""
:ref (fn [el] (reset! quill-ref el))
:modules {:toolbar {:container [[{:header [1 2 3 4 5 false]}]
["bold" "italic" "underline" "strike" "blockquote"]
[{:list "ordered"} {:list "bullet"} {:indent "-1"} {:indent "+1"}]
["link" "image"]
["clean"]]
:handlers {:image (fn [_]
(let [editor (.getEditor @quill-ref)
selection (.getSelection editor)]
(.insertEmbed editor
selection.index "image"
(js/window.prompt "Please provide an image url")
"user")))}}}}])})))
headily elided, when clicking the image logo on the editor to provide img url, will work in :non the error otherwise is
admin.cljs:429 Uncaught TypeError: b.fi is not a function
at b.<anonymous> (admin.cljs:429)
at HTMLButtonElement.<anonymous> (quill.js:9393)
(anonymous) @ admin.cljs:429
(anonymous) @ quill.js:9393
For line number comparison then I'm running Quill Editor v1.3.6
one minor version above that which is declared in react-quill, same behaviour is in v1.3.5.definitely always turn on :compiler-options {:infer-externs :auto}
if you run into any issues
boom, it spotted something shade there now
431 | (.insertEmbed editor
---------------------------------------------------------------------------^----
Cannot infer target type in expression (. editor insertEmbed selection.index "image" (js/window.prompt "Hvað er URL á myndina?") "user")
excuse the foreign language used there 🙂you need to tell the compiler that editor
is a JS object and nothing that uses it should be renamed
https://code.thheller.com/blog/shadow-cljs/2017/10/15/externs-the-bane-of-every-release-build.html
but in CLJS we don't need classes so we only need to infer that the thing is a JS object or a CLJS object
Has anyone used shadow with devcards?
If so, any special caveats?
@jmckitrick we use shadow with devcards
we have a file like this:
(ns atlas-crm.cards
(:require
.... namespaces with cards
[devcards.core :as dc :refer-macros [start-devcard-ui!]]))
(start-devcard-ui!)
(defn refresh []) ;; Used for devcards live reload support
And a build like this:
:devcards {:target :browser
:asset-path "/js/devcards"
:output-dir "resources/public/js/devcards/"
:compiler-options {:devcards true :external-config {:fulcro.inspect/config {:launch-keystroke "ctrl-space"}}}
:modules {:devcards {:entries [atlas-crm.cards]}}
:devtools {:after-load atlas-crm.cards/refresh
:http-port 8600
:http-root "public" ;; We don't use this but our handler, but this makes shadow start a http server
:http-handler dev.test-handler/handler
:preloads [fulcro.inspect.preload]}}
Does anyone here know the command to get the page in shadow-cljs which shows how much space each dep or ns takes
@mitchelkuijpers (shadow.cljs.devtools.api/release-snapshot :the-build {})
then
Awesome thnx!
hmm, does this look like correct usage of rename-prefixing for closure? :compiler-options {:rename-prefix-namespace "App"}
i’m running into some collisions with other code on a page, using :advanced compilation, and it doesn’t seem to have an effect
@mhuebert this is not currently support because it needs special considerations for :modules
@thheller @lee.justin.m I was getting the same results even after I used NS requires. But after looking at the compiled output, I found a workaround. Closure was optimizing away the (.bind stmt)
call, probably because it was in a let with no binding of its results (even though it returns nil). When I bound the result Closure let it through:
(let [db ^js (:db @state)
stmt (.prepare db "SELECT * ...")
bound? (.bind stmt ids)])
The sql.js
namespace includes two JS "classes" (functions with prototype methods) of Database and Statement. I'm currently bringing them in as (ns my.app (:require ["sql.js" :as sql :refer [Database Statement]))
What's the best way to import them such that I can use them as namespaces like:
(let [
db ^Database (Database. dbBuffer)
stmt ^Statement (db/prepare sqlStr)
bound? (stmt/bind ids)])
Is that not what I'm doing here: (:require ["sql.js" :as sql :refer [Database Statement])
what you want to do is refer to the npm package name and then install the package in your repository using yarn or npm
https://www.npmjs.com/package/sql.js its the package name. so everything is correct
(ns my.app (:require ["sql.js" :as sql :refer [Database Statement]))
that should work just fine?
I thought javascript includes were optimized whereas npm includes just go through “simple”
(let [db ^js (:db @state)
stmt (.prepare db "SELECT * ...")
_ (.bind stmt ids)]) ;; this call got elided
@lee.justin.m I don't understand. what are you talking about? sql.js
is a normal npm
package so it gets treated like any other. so it goes through :simple
. but simple can also remove code.
sorry i guess i got confused. i though that if you include a raw js file then it was treated differently. please ignore me.
Oh, but this is in an electron app in the UI process which is being built with :target :browser
@lee.justin.m raw .js
file requires *always* start with either /
or ./
. anything that does not start with those is a npm
package.