This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-13
Channels
- # aleph (7)
- # announcements (3)
- # babashka (29)
- # beginners (70)
- # calva (5)
- # cider (14)
- # clara (3)
- # clj-kondo (25)
- # cljs-dev (2)
- # clojure (237)
- # clojure-conj (3)
- # clojure-europe (6)
- # clojure-italy (14)
- # clojure-nl (4)
- # clojure-uk (40)
- # clojurescript (29)
- # clojurex (1)
- # code-reviews (2)
- # cursive (3)
- # datascript (1)
- # fulcro (11)
- # graalvm (4)
- # graphql (12)
- # jackdaw (1)
- # jobs (1)
- # joker (22)
- # london-clojurians (1)
- # off-topic (132)
- # re-frame (38)
- # rewrite-clj (11)
- # shadow-cljs (200)
- # spacemacs (1)
- # sql (67)
- # tools-deps (15)
{:source-paths ["src/dev" "src/main" "src/functions" "src/tools" "src/test"] :dependencies [[binaryage/devtools "0.9.10"] [reagent "0.8.1" :exclusions [cljsjs/react]] [re-frame "0.10.9" :exclusions [cljsjs/react]] ; [day8.re-frame/http-fx "v0.2.0"] [secretary "1.2.3"] [cljs-bean "1.5.0"] ;;https://github.com/mfikes/cljs-bean [cider/cider-nrepl "0.22.4"] [testdouble/clojurescript.csv "0.4.5"] ] ; :nrepl {:port 8777} :builds {:app {:target :browser :output-dir "public/js" :asset-path "/js" :modules {:app {:init-fn project.core/init :preloads [devtools.preload]}} :devtools {:http-root "public" :http-port 8000}} :browser-test {:target :browser-test :ns-regexp "-test$" :runner-ns shadow.test.browser :test-dir "tests/browser-test" :devtools {:http-root "target/browser-test" :http-port 8290}} :karma-test {:target :karma :ns-regexp "-test$" :output-to "tests/karma-test.js"} :functions {:target :node-library :output-to "functions/cljs-libs.js" :exports-var project.cloud-functions/declaration} :tools {:target :node-script :output-to "tools/tools.js" :main project.tools/main}}}
@raf I'm not sure what is going on. can you please post a regular github issue so I don't forget looking into it?
When loading NPM packages the shadow way (i.e. (:require ["foo" :as foo])
) I’m getting a spec error trying to load it into a repl:
Syntax error macroexpanding clojure.core/ns at (src/workspaces/app/demo_ws.cljs:1:1).
-- Syntax error -------------------
(... (:require
[com.fulcrologic.fulcro.components :as fp]
[nubank.workspaces.core :as ws]
[nubank.workspaces.card-types.fulcro3 :as ct.fulcro]
[com.fulcrologic.fulcro.mutations :as fm]
[com.fulcrologic.fulcro.dom :as dom]
["reakit" :as rk]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
has extra input
-- Relevant specs -------
:clojure.core.specs.alpha/ns-form:
(clojure.spec.alpha/cat
:ns-name
clojure.core/simple-symbol?
:docstring
(clojure.spec.alpha/? clojure.core/string?)
:attr-map
(clojure.spec.alpha/? clojure.core/map?)
:ns-clauses
:clojure.core.specs.alpha/ns-clauses)
-------------------------
Detected 1 error
Ah thanks, I must have messed up repl state somewhere. Restarting everything and making sure i”m in cljs repl fixed it
how to require
import Storage from 'react-native-storage';
in cljs, i use [“react-native-storage” :default Storage], but the browser output
shadow-cljs - failed to load module$node_modules$react_native_storage$lib$storage_cjs
shadow.js.jsRequire @ js.js:74
shadow.js.require @ js.js:100
eval @ /js/compiled/cljs-runtime/core.js:6
goog.globalEval @ app.js:836
env.evalLoad @ app.js:2216
(anonymous) @ app.js:2901
what is the actual error though? this just tells you WHY failed to load, not why. the why is a different error?
(ns core
(:require [reagent.core :as r]
[starter.browser]
[utils.login]
["react-native-storage" :default Storage]
[pages.dashboard.questionnaire]))
(defn ^:export init
"auto init"
[]
(let []
(prn "thit is cljs init" ))
)
I can't remember how to fix that. need to include some "regenerator/runtime" package or so manually
@thheller there is of course nothing to be done for symbol resolution in cursive (or emacs) using shadow-style imports, correct? when people develop with js-land deps, there’s no code knowledge/goto/navigation?
probably not filtering events correctly. the ns form evaluated at the REPL has multiple effects
I can't seem to reload namespaces in the REPL in my clojurescript app. Here's what I do (after running (shadow/repl :app)
to enter in to the CLJS repl):
(use 'getfluentspanish.dom :reload)
Error in phase :compilation
Only [lib.ns :only (names)] and optionally `:rename {from to}` specs supported in :use / :use-macros; offending spec: [getfluentspanish.dom] at line 1 cljs/user.cljs
it seems like namespaces just work way differently in the cljs repl
*ns*
doesn't work either
is there a guide anywhere?
it doesn't error out now, but it doesn't seem to reload
like i add new code, i see that it compiles in the shadow watcher, but the new code isn't available
(require '[getfluentspanish.dom :as dom] :reload)
added a new function, it's just nil
in the repl after
in repl after reloading: dom/new-function
--> nil
not calling it, just evaluating the symbol
and it says it's nil
and changes to another existing function don't show up
i added some log lines and they only show up when i restart the terminal pane i have running lein shadow watch app
, refresh the browser tab and restart the repl
@thheller just found your post (https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html) and will definitely give this a read as well
well i don't have automatic reloading in the repl
my code recompiles
via lein shadow watch app
i.e. i make changes, the browser reloads my code automatically
but my repl has a stale version
(shadow/repl :app)
unfortunately that doesn't seem to be happening
let me take a look:
[thheller/shadow-cljs "2.8.39" :scope "provided"]
ok i'll try updating
i'll try bumping
bumped the version and still not seeing updates within the repl
it seems like it's only happening with some namespaces
this "dom" namespace is new - i hadn't actually included it elsewhere in the project
i was just manually playing with a new function in the REPL
but for example when i make changes to a namespace that contains a bunch of reagent components that are actually used on the website i'm developing, it: - is updated in the browser - automatically updates in the REPL
maybe it needs to be loaded by the browser to participate in the auto reload functionality?
@thheller that's the problem. once i included in a file loaded by the browser, it started to auto-reload
I was trying to use devcards with shadow-cljs and finding it a bit hard to find information about that...
in https://clojurians-log.clojureverse.org/shadow-cljs/2018-04-01 there's some messages from 2018 that say it's mostly just importing devcards with macros, and then set the devcards compiler option to true
from that starting point the compilation works, but at runtime there's a couple of console warnings and nothings shows on screen
main.js:2218 failed to load devcards.system.js ReferenceError: React is not defined
at eval (system.cljs:321)
at eval (system.cljs:321)
at eval (<anonymous>)
at Object.goog.globalEval (main.js:836)
at Object.env.evalLoad (main.js:2216)
at main.js:2413
env.evalLoad @ main.js:2218
(anonymous) @ main.js:2413
main.js:2218 failed to load devcards.core.js ReferenceError: React is not defined
at eval (core.cljs:117)
at eval (core.cljs:117)
at eval (<anonymous>)
at Object.goog.globalEval (main.js:836)
at Object.env.evalLoad (main.js:2216)
at main.js:2418
that namespace belongs to devcards, and points to this function
(define-react-class DevcardsRoot
(componentDidMount
[this]
(add-watch app-state :renderer-watch (fn [_ _ _ _] (.forceUpdate this))))
(render [this] (main-template app-state)))
@mike.a.mackenzie yes sorry, hot-reload only reloads sources actually used in the build. for the rest the regular REPL workflow should still work though.
@filipematossilva you can probably get away with importing cljsjs.react
. that will create the React
global
should I be using shadow-cljsjs
? I saw some references to it in https://github.com/bhauman/devcards/issues/156 but I couldn't figure out how I should use it
the problem you see is that devcards assumes there is a React
global, because it was always there when using cljsjs.react
shadow-cljs already depends on it, so it is always there. no need for you do do anything except add a cljsjs.react
require somewhere
doing so shows an error that seems similar
system.cljs:334 Uncaught ReferenceError: ReactDOM is not defined
at Object.devcards$system$renderer [as renderer] (system.cljs:334)
at eval (system.cljs:458)
ah I tried [cljsjs.react-dom]
and that failed, so that's it
you might want to try https://github.com/nubank/workspaces
I now see an UI with things that seem from devcards so it looks like it is loaded, will poke around more
thank you for your help
yeap, all well and good, uploaded it as https://github.com/filipesilva/shadow-cljs-devcards
hello, i'm trying to get going with shadow-cljs and Cursive. I'm trying to re-create my old figwheel config, where I had a run configuration that would start figwheel in a Cursive REPL - one click, all in. I've got two problems: 1. I can't figure out how to start a cljs REPL instead of a clj one 2. I can't figure out how to start shadow in my run configuration I'm hoping there's somebody here who uses Cursive and might be able to help?
I use a little script to kick everything off, by passing it in the parameters of a run configuration:
;;
(require '[figwheel.main.api :as fig])
(fig/start "app")
We do a lot of prototyping, which means changing deps. My goal is to restart a CLJS REPL in a single click
Currently, I'm only able to run shadow-cljs from a terminal, which means I have to go over there, kill the process, restart and so on
Sorry, I'm not sure I understand the question. I click the green Run arrow on my build configuration, and Cursive spins one up for me - compiling all the stuff on the way
(require '[shadow.cljs.devtools.server :as server])
(require '[shadow.cljs.devtools.cli]) ;; if you want to use the shadow-cljs command line tools
(require '[shadow.cljs.devtools.api :as api])
(server/start!)
(api/watch :app)
(api/repl :app)
I don't want to split out my frontend from my backend, and leiningen seems like the easiest way to keep it all together
yes, currently i've put them in the :dev
profile, although i actually wasn't sure about that
ok, it seems this works. i get a lot of :failed-to-compare
errors, but the build still completes successfully
windows is this: java version "1.8.0_202" Java(TM) SE Runtime Environment (build 1.8.0_202-b08) Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
it's possible that Intellij uses a built-in one, but it prints out that path at the start of the REPL output
i've always had trouble with clojure and later versions, maybe it's time to give it a bump
comparing npm package versions to spit out a small warning if they aren't what your packages expected