This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-07-16
Channels
- # beginners (48)
- # cider (21)
- # clara (6)
- # cljdoc (3)
- # cljs-dev (11)
- # cljsrn (5)
- # clojure (30)
- # clojure-canada (1)
- # clojure-dusseldorf (2)
- # clojure-italy (10)
- # clojure-losangeles (2)
- # clojure-nl (4)
- # clojure-russia (8)
- # clojure-spain (18)
- # clojure-uk (39)
- # clojurescript (84)
- # core-async (17)
- # cursive (22)
- # data-science (27)
- # datomic (27)
- # docker (3)
- # editors (5)
- # emacs (2)
- # figwheel-main (18)
- # fulcro (54)
- # hoplon (3)
- # hyperfiddle (2)
- # immutant (4)
- # jobs (1)
- # jobs-discuss (1)
- # lein-figwheel (7)
- # leiningen (3)
- # lumo (1)
- # onyx (5)
- # re-frame (64)
- # reagent (5)
- # reitit (7)
- # ring-swagger (6)
- # shadow-cljs (118)
- # specter (23)
- # tools-deps (38)
@thheller Hi. Do you have an example of how to call cljs from js with shadow-cljs? I created namespace and tried
import {foo} from 'goog:demo.foo';
it doesn’t work. I tried this example from documentation either:
import cljs, { keyword } from "goog:demo.foo";
cljs.array_map(keyword("foo"), "hello world");
In both cases javascript loader says:
Module not found: Can’t resolve ‘goog:demo.foo’ in ‘/Users/den/git/test/mhello-cljs/src’@denis_krivosheev this only works if the JS is compiled by shadow-cljs. I have some code for testing in the shadow-cljs repo. it looks like this https://github.com/thheller/shadow-cljs/blob/master/src/dev/demo/es6.js#L1
@tomi.hukkalainen_slac you still seem to be fighting with :foreign-libs
. I'm curious if you tried shadow-cljs and if you chose not to use it why?
I checked the docs to see how I could replace the current build with shadow without reworking too much, but got a bit stuck at the server side, again. I'm currently letting figwheel start the ring server for backend in dev mode. That works by simply telling figwheel where the ring handler is. At first I figured that shadow doesn't do that at all, only static files. Then I did get a pointer that there is a fallback handler config when client requests urls that aren't available as static, but that was... pretty sparsely documented. Just says that it's a function from req to response, without saying anything what the request or the response are
Surely I could have looked into source to figure it out, but once again I tried a different way to include libs that are not in cljsjs
I can't escape the feeling that moving to shadow would require significant refactoring of the way the backend and frontend are built and work together
thanks for the feedback though. I'll smooth over that part of the docs. shadow-cljs focus is on CLJS and I always run my own webserver when I need server side stuff.
@tomi.hukkalainen_slac FWIW the backend and the frontend work together exactly the same way. figwheel doesn't do anything to the backend and you can start the backend server by any other means. the only thing CLJS requires from the backend is that the generated JS files are served properly.
you can use run-server
with whatever you have specified as :ring-handler
in figwheel
I think an example showing the whole stack would go a long way, though of course what the stack is varies. I think that the compojure-api + reagent/re-frame is pretty usual
A question related to the :browser
target
Here is my shadow-cljs.edn file:
{:target :browser
:output-dir "resources/public/js/browser"
:devtools {:http-port 8025
:http-root "resources/public/js/browser"}
:modules {:main {:entries [audyx.app.init]}}}
I created an index.html
in resources/public/js/browser
with the following content:
<script src="main.js"></script>
but when I load localhost:8025/index.html
I get many console errors for all the js dependencies
For instance:
Not found
What is wrong with my configuration?
any reason why you don't use resources/public
as :http-root
though? typically you should avoid putting anything other than generated output into :output-dir
and then the :asset-path should be "js/browser". Right?
This is what I meant. I made a typo
that works
Now I am launching a REPL with shadow-cljs cljs-repl browser
@thheller The code doesn't seem to reload on code change.
I mean: I see in the browser a notification that the compilation started but the code changes don't take effect and the :before-load function is not triggered.
In my case, I have a couple of build warnings, so I set :ignore-warnings true
but it didn't help
what can I do?
https://github.com/shadow-cljs/quickstart-browser/blob/master/src/starter/browser.cljs#L3-L5
either like this in the code via metadata or :devtools {:after-load your.app/start}
in the config
I have tried both
but it didn't help
:browser
{:target :browser
:output-dir "resources/public/js/browser"
:asset-path "/js/browser/"
:ignore-warnings true
:devtools {:http-port 8025
:http-root "resources/public/"
:before-load audyx.app.init/before-load
:after-load audyx.app.init/start}
:modules {:main {:entries [audyx.app.init]}}}
shadow-cljs: WebSocket connected!
browser.cljs:27 shadow-cljs: REPL init successful
browser.cljs:121 BUILD-WARNING in audyx/audio/ambiences/calibration.cljs at [77:3]
Wrong number of args (1) passed to audyx.audio.ambiences.calibration/create-noise-node
shadow$cljs$devtools$client$browser$handle_build_complete @ browser.cljs:121
shadow$cljs$devtools$client$browser$handle_message @ browser.cljs:258
shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:148
(anonymous) @ browser.cljs:318
browser.cljs:121 BUILD-WARNING in audyx/audio/ambiences/transducer_calibration.cljs at [32:3]
Wrong number of args (3) passed to cljs.core/replace
shadow$cljs$devtools$client$browser$handle_build_complete @ browser.cljs:121
shadow$cljs$devtools$client$browser$handle_message @ browser.cljs:258
shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:148
(anonymous) @ browser.cljs:318
browser.cljs:121 BUILD-WARNING in audyx/audio/input.cljs at [35:13]
Use of undeclared Var audyx.audio.input/-Infinity
shadow$cljs$devtools$client$browser$handle_build_complete @ browser.cljs:121
shadow$cljs$devtools$client$browser$handle_message @ browser.cljs:258
shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:148
(anonymous) @ browser.cljs:318
browser.cljs:121 BUILD-WARNING in audyx/test/records/loop/volume.cljs at [29:1]
Bad method signature in protocol implementation, ILoop initial-index does not declare arity 3
shadow$cljs$devtools$client$browser$handle_build_complete @ browser.cljs:121
shadow$cljs$devtools$client$browser$handle_message @ browser.cljs:258
shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:148
(anonymous) @ browser.cljs:318
browser.cljs:121 BUILD-WARNING in audyx/test/records/loop/single.cljs at [10:1]
->Single already refers to: audyx.test.records.loop.single/->Single being replaced by: audyx.test.records.loop.single/->Single
shadow$cljs$devtools$client$browser$handle_build_complete @ browser.cljs:121
shadow$cljs$devtools$client$browser$handle_message @ browser.cljs:258
shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:148
(anonymous) @ browser.cljs:318
browser.cljs:121 BUILD-WARNING in audyx/graphs/vocalsnr_graph.cljs at [13:1]
Bad method signature in protocol implementation, Graph graph-definition does not declare arity 3
shadow$cljs$devtools$client$browser$handle_build_complete @ browser.cljs:121
shadow$cljs$devtools$client$browser$handle_message @ browser.cljs:258
shadow$cljs$devtools$client$env$process_ws_msg @ env.cljs:148
(anonymous) @ browser.cljs:318
I see the shadow-cljs icon rotating
nothing
Now I have exactly the same as figwheel. right?
Is there a way to have code completion in the shadow-cljs REPL?
Will try to connect emacs
what editor will you recomend on windows?
I have recently switched from Macos to Windows 10
Using WSL
I am having troubles installing leiningen on Windows
Trying to install shadow-cljs now
Meanwhile I was able to enjoy a shadow repl inside emacs (cider)
The instructions on the shadow doc are very clear
the only thing that was not 100% straightforward was that I had to configure [cider/cider-nrepl "0.17.0"]
according to my cider version: 0.18.0-SNAPSHOT
Maybe you can add a comment about that here: https://shadow-cljs.github.io/docs/UsersGuide.html#_dependencies_2
also, M-x cider-create-sibling-cljs-repl
is now: M-x cider-connect-sibling-cljs
if you use the built-in shadow-cljs support in cider you don't have to specify it at all I think
if you start shadow-cljs from emacs through CIDER it will insert the dependencies for you (I think)
@thheller now trying to configure Cursive
What context module should I provide in the Clojure remote REPL settings?
No idea. I don't know what is a context module?
I opened my project root folder
ok. trying it
whenever you change dependencies just call shadow-cljs pom
again and let cursive update it
you can also use project.clj
with lein
of course. cursive has a bit better integration with that.
What REPL should I create? A remote Clojure REPL?
I don't see an option for a Cljs REPL
Seems to work
Is there a way to call this code automatically?
Now I have a very weird issue in Cursive
I don't get a prompt in the REPL window
I can send commands to the REPL but I cannot type any command
sorry gotta go. Cursive has pretty extensive docs and should contain everything you need.
Thanks a lot
for your help
and for shadow-cljs
It really rocks!!!
I am having a warning at the beginning of the execution of compilation:
shadow-cljs - running: lein run -m shadow.cljs.devtools.cli --npm watch browser
Compiling ClojureScript...
Compiling ["public/clojurescript/dev/2ffae5ec-aa76-40ed-aadc-d3878fce327a.js"] from ["src/cljs/audyx" "resources"]...
module.js:549
throw err;
^
Error: Cannot find module '@cljs-oss/module-deps'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at [eval]:3:13
at ContextifyScript.Script.runInThisContext (vm.js:50:33)
at Object.runInThisContext (vm.js:139:38)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (module.js:652:30)
at evalScript (bootstrap_node.js:463:27)
After that the compilation completes successfully. But I'd prefer fixing this warning
Any idea?
some package.json contains a browser
key (e.g https://github.com/aws/aws-sdk-js/blob/master/package.json)
According to https://docs.npmjs.com/files/package.json#browser :
If your module is meant to be used client-side the browser field should be used instead of the main field. This is helpful to hint users that it might rely on primitives that aren't available in Node.js modules. (e.g. window)
Does shadow-cljs
behave like this when browser
key is present on a npm module imported?
Currently, I am not able to require aws-sdk in my shadow-cljs project
It seems like shadow-cljs ignores the browser
key
on :target :browser builds