This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-01-08
Channels
- # alda (1)
- # announcements (18)
- # babashka (101)
- # beginners (110)
- # calva (17)
- # cider (53)
- # clara (18)
- # clj-kondo (26)
- # cljdoc (6)
- # clojure (152)
- # clojure-europe (9)
- # clojure-portugal (4)
- # clojure-spec (20)
- # clojure-survey (7)
- # clojure-sweden (10)
- # clojure-uk (10)
- # clojured (1)
- # clojurescript (29)
- # core-async (7)
- # cursive (4)
- # datomic (11)
- # defnpodcast (2)
- # dirac (1)
- # emacs (13)
- # events (2)
- # figwheel-main (1)
- # fulcro (1)
- # jobs (14)
- # jobs-discuss (17)
- # leiningen (2)
- # malli (1)
- # off-topic (74)
- # overtone (1)
- # pedestal (4)
- # planck (2)
- # re-frame (7)
- # reitit (4)
- # remote-jobs (4)
- # shadow-cljs (78)
- # slack-help (3)
- # spacemacs (56)
- # test-check (3)
- # tools-deps (6)
This might be more of a CLJS question so I can take it there if appropriate -- I'd like to access a property from some JavaScript namespaces in the CLJS layer. The JavaScript code to do this is supposed to be this:
import Constants from 'expo-constants';
const { version } = Constants.manifest;
On the CLJS side, I wrote my namespace declaration like this:
(:require ["expo-constants" :as expo-constants])
But when I try to access (.-Constants expo-constants)
, it just returns nil
.
I can run (type expo-constants)
and it comes up as #object[Object]
so it's something, but struggling to figure out how to access it further. Anyone have tips or troubleshooting ideas?Good morning, I'm having issues with deps.edn + shadow-cljs. I followed the official docs to figure out which alias to use for shadow-cljs :
:aliases {:shadow-cljs {:extra-deps {thheller/shadow-cljs {:mvn/version "2.8.83"}
:main-opts ["-m" "shadow.cljs.devtools.cli"]}}}
When I try to execute the alias:
clj -A:shadow-cljs watch app
I get the following error:
Error building classpath. Coordinate type not loaded for library :main-opts in coordinate ["-m" "shadow.cljs.devtools.cli"]
Has anyone ran into similar issues?I'll look into it further after work.
@quest see https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages. it likely is (:require ["expo-constants" :default expo-contants])
Dead on as usual, thanks @thheller. Properties such as (.-manifest expo-constants)
became immediately accessible after using :default
@jarvinenemil is your intent to use clj
? you can just run with shadow-cljs watch app
if you configure :deps {:aliases [:shadow-cljs]}
but dunno about that error otherwise. comes from clj
, not shadow-cljs. looks ok to me .. maybe ask in #tools-deps
@jarvinenemil I see it now ... you :main-opts
is listed as part of the :extra-deps
map. its a misplaced }
.
The problem with rising up very early in the morning and trying to do things 😄. Thanks a lot @thheller ⭐
might be worth reporting to #tools-deps regardless. the error message could probably be clearer. it just confused me at first.
I think i had some other issues, when I was not using aliases No such var: ana/unwrap-quote
im gonna continue this evening.
I've upgraded a project to a newer version of shadow-cljs a while back and had some issues with the namespace wrt directory structure, at the time I solved it for shadow-cljs watch
but now shadow-cljs release
is giving me issues. I have two modules with :web-worker true, but I was getting this error:
[:main] Build failure:
Module Entry "shadow.cljs.devtools.client.worker" was moved out of module ":fetch-worker".
It was moved to ":shared" and used by #{:filter-worker :fetch-worker}.
I tried to move :web-worker into :worker-shared, and that builds, but I get "SHADOW_ENV is not defined" when it runs.My whole modules:
:modules {:shared {:entries []}
:web-shared {:entries []
:depends-on #{:shared}}
:worker-shared {:entries []
:depends-on #{:shared}
:web-worker true}
:app {:entries [main.gsv.client]
:depends-on #{:web-shared :shared}}
:fetch-worker {:entries [main.gsv.fetch-worker]
:depends-on #{:worker-shared :shared}
}
:filter-worker {:entries [main.gsv.filter-worker]
:depends-on #{:worker-shared :shared}
}}
@bbss oh I didn't consider 2 separate workers in the current setup. I enabled REPL/hot-reload inside workers. you can disable that for now by setting :devtools {:worker-inject false}
hmm wait nevermind. you are not actually setting :web-worker true
on the workers. I think your entire setup isn't actually supported right now
I was setting web-worker true on the workers, but then I got the "was moved out of module" warnings.
right yeah only actual workers can have :web-worker true because they get some extra boilerplate
but yeah you probably need to disable the worker-inject for now. didn't consider 2 workers for that
so :devtools {:worker-inject false}
and :web-worker true
for both the workers but not the shared
I'm giving an ignite presentation tonight to evangelize shadow-cljs and cljs. would love feedback in #off-topic from anyone with an opinion and 5 minutes to spare
npx create-cljs-project app
will take care of creating generic boilerplate and some config
oh never seen create-cljs-project. i mention create-cljs-app
but it gets a bit heavy with the headless browser it brings along
its been in the readme for a while now https://github.com/thheller/shadow-cljs#quick-start
Getting
inspect_client.cljc:279 Uncaught ReferenceError: document is not defined
at $fulcrologic$fulcro$inspect$inspect_client$install
Removed the inspect preload and now getting
browser.cljs:430 Uncaught ReferenceError: window is not defined
at browser.cljs:430
minor "semantic" issue (.setAppElement Modal "#app")
should not be run at the top level, as it will re-execute on every hot-reload. stuff like that goes into the init
fn .. which you confusingly called main
😉
probably not an issue in this case but in general that stuff goes into the init fn
@bbss then you also need to set :devtools {:browser-inject :web-shared :worker-inject false}
I really need to figure out a way to make this config cleaner now that devtools in workers are supported. makes things slightly more complicated 😛
thanks for the feedback so far. deployed those changes to the presentation and the site
Workers load with that, but now I'm getting a bunch of warnings that are actually errors I expect:
shared.js:3199 failed to load goog.async.throttle.js TypeError: Cannot read property 'prototype' of undefined
env.evalLoad @ shared.js:3199
(anonymous) @ app.js:1482
shared.js:3199 failed to load goog.crypt.base64.js TypeError: Cannot read property 'SAFARI' of undefined
etc..
that might be a bad closure-library version? if you use deps.edn/project.clj thats a "common" conflict nowadays ...
you should have these versions or newer, but not older
[com.google.javascript/closure-compiler-unshaded "v20191027"]
[org.clojure/google-closure-library "0.0-20191016-6ae1f72f"]
[org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f"]
Added that and still have the warnings that sound like errors, they happen for the started workers too. But the application is working again! had to remove a bunch of code that was not warning or erroring but referring a missing library in the project.clj dependencies (I think that was what's wrong?)
shared.js:3199 failed to load goog.async.throttle.js TypeError: Cannot read property 'prototype' of undefined
at Object.goog.inherits (shared.js:1931)
at eval (throttle.js:76)
at eval (<anonymous>)
at Object.goog.globalEval (shared.js:1817)
at Object.env.evalLoad (shared.js:3197)
at app.js:936
env.evalLoad @ shared.js:3199
(anonymous) @ app.js:936
shared.js:3199 failed to load fulcro.client.network.js TypeError: Cannot read property 'ErrorCode' of undefined
at eval (network.cljc:24)
at eval (<anonymous>)
at Object.goog.globalEval (shared.js:1817)
at Object.env.evalLoad (shared.js:3197)
at app.js:960
env.evalLoad @ shared.js:3199
(anonymous) @ app.js:960
shared.js:3199 failed to load fulcro.client.primitives.js TypeError: goog.async.Throttle.base is not a function
etc..
are there more errors? seems like a cascading error to me where one problem causes all the others
There are more errors, but I think it's maybe in code I'm not using anymore. Making big cuts in the codebase after refactoring.
when using release I'm getting
shared.js:2 Uncaught ReferenceError: $jscomp is not defined
at shared.js:2
at shared.js:1
Which I think is warned about with:
File: /Users/baruchberger/work/gsv/src/main/gsv/api/createIterable.js:89:8
--------------------------------------------------------------------------------
86 | if (prop === 'length') {
87 | return length;
88 | }
89 | if (prop === Symbol.iterator) {
--------------^-----------------------------------------------------------------
variable $jscomp is undeclared
--------------------------------------------------------------------------------
90 | return iterator;
91 | }
92 | return source[prop];
93 | }
--------------------------------------------------------------------------------
another option is adding :web-shared {... :prepend-js "window.$jscomp = {};"}
.. there is an option issue about this I think. still need to dig into the closure compiler to figure out why this happens
I made a short demo with plain shadow-cljs today (no backend at all, no lein etc.). The repl always complained about unused vars, whenever I accessed any vars defined in the source. I don't remember seeing that before, and googling didn't show anything. Any ideas what's up with that?
@thheller Thanks. Looks like the :output-feature-set :es6 + :prepend worked. Next issue is my js/window
seems to be undefined. So many errors compared to earlier, did the closure compiler suddenly get a lot more strict or something?