This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-08-29
Channels
- # aws (1)
- # beginners (78)
- # boot (27)
- # cider (16)
- # clara (15)
- # cljs-dev (84)
- # cljsjs (13)
- # cljsrn (19)
- # clojure (65)
- # clojure-france (10)
- # clojure-italy (8)
- # clojure-russia (35)
- # clojure-spec (34)
- # clojure-uk (124)
- # clojurescript (50)
- # clojutre (3)
- # core-async (16)
- # data-science (18)
- # datascript (1)
- # datomic (9)
- # emacs (2)
- # flambo (3)
- # fulcro (55)
- # graphql (3)
- # hoplon (4)
- # jobs (2)
- # juxt (21)
- # keechma (6)
- # lumo (73)
- # off-topic (4)
- # om (10)
- # onyx (5)
- # parinfer (1)
- # pedestal (3)
- # re-frame (60)
- # reagent (19)
- # specter (24)
So say I want to use fabric through cljsjs. I've put [cljsjs/fabric "1.5.0-1"]
in the dependencies vector of project.clj
. But after restarting leiningen/figwheel I'm told that "there's no such namespace cljsjs/fabric" when running (ns fab-test.core (:require cljsjs/fabric))
.
What am I doing wrong?
@rovanion The foreign-lib ("namespace") names don't use /
, the correct name is cljsjs.fabric
Sorry, that was a pretty obvious typo. But I'm back to the error message I had previously today: That cljsjs is not defined.
Though it is loaded into the browser, I can access fabric.Canvas in the console and js/fabric.Canvas
in cljs.
(ns fab5.core
(:require [cljsjs.fabric :as fab]))
(prn js/fabric.Canvas) ; => #object[klass]
(prn fab/Canvas) ; => #object[ReferenceError ReferenceError: cljsjs is not defined]
@rovanion Fabric package doesn't support :global-exports
so you can't use :as
alias with it, you need to access it through the global
Ahh, thank you @juhoteperi!
If you want, you could add
{:file "cljsjs/fabric/development/fabric.inc.js",
:provides ["cljsjs.fabric"],
:global-exports {cljsjs.fabric Fabric}
:file-min "cljsjs/fabric/production/fabric.min.inc.js"}
To :foreign-libs
in compiler-options to use global-exports (remember to quote symbols in global-exports depending where you set this)Reagent changelog and alpha upgrade guide might be the best resources related to this, for now: https://github.com/reagent-project/reagent/blob/master/docs/0.8-upgrade.md
In my project.clj or (based on some googling) in a src/deps.cljs file in the cljsjs package?
you can overwrite the deps.cljs options from cljsjs packages, in your own cljs compiler-options, e.g. in your project.clj, when using lein
Though you can use global-exports like this, it might be best to just use the old way (access through the global object) until the new features are ironed out 🙂