This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-07-24
Channels
- # announcements (5)
- # beginners (184)
- # calva (32)
- # cider (29)
- # clj-kondo (1)
- # cljdoc (29)
- # cljsrn (6)
- # clojure (44)
- # clojure-dev (36)
- # clojure-europe (9)
- # clojure-italy (18)
- # clojure-losangeles (1)
- # clojure-nl (3)
- # clojure-spec (7)
- # clojure-uk (30)
- # clojure-ukraine (1)
- # clojuredesign-podcast (8)
- # clojurescript (65)
- # code-reviews (21)
- # core-async (25)
- # cursive (51)
- # data-science (3)
- # datascript (2)
- # datomic (25)
- # emacs (14)
- # events (1)
- # figwheel-main (3)
- # fulcro (3)
- # graalvm (5)
- # jackdaw (17)
- # kaocha (14)
- # luminus (5)
- # off-topic (17)
- # pathom (7)
- # pedestal (2)
- # re-frame (71)
- # reagent (25)
- # shadow-cljs (83)
- # spacemacs (31)
- # sql (92)
- # tools-deps (23)
- # vim (102)
- # xtdb (5)
@thheller i looked for annotation docs and found some, but didn't find anything specifically mentioning just ^js -- do you happen to know of any?
the guide tells you to use "typed" annotations like ^js/Foo.Bar
but I decided to skip those in shadow-cljs
https://code.thheller.com/blog/shadow-cljs/2017/11/06/improved-externs-inference.html
> By using the ^js tag metadata we are just telling the compiler that this is a native JS value and we are going to need externs for it. In shadow-cljs the /Foo.Bar type info is optional. You can still use it if you like but shadow-cljs won’t bother you if you don’t.
What is the recommended workflow for developing node scripts? I'm using emacs w/ CIDER and I find it a bit clunky… I have to start the cljs repl myself and it crashes a lot (when requiring something that doesn't exist for example); my experience in the browser was waaaay smoother
Hm… it always shows the cljs-repl as pending if I do that, even though I can run code in the repl itself
What is correct way to import file ./src/infrastructure/config.js
from another (to be specific) ./src/api/client/schemas/login.js
file.
From the login.js
I tried to import the configuration via:
const config = require('../../../infrastructure/config.js')
But I'm receiving the undefinedWell it's still CLJS code, because it's then required by the api/client/core.cljs
via ["./schemas/login" :as login]
Project configuration:
;; shadow-cljs configuration
{:source-paths
["src"]
:dependencies
[[mount "0.1.16"]
[funcool/promesa "2.0.1"]]
:builds {:api {:target :node-script
:output-to "target/api.js"
:ns-regexp "^api.*"
:main api.server/main!
:devtools {:after-load api.server/reload!}}
:worker {:target :node-script
:output-to "target/worker.js"
:ns-regexp "^worker.*$"
:main worker.setup/main!
:devtools {:after-load worker.setup/reload!}}
:worker-test {:target :node-test
:output-to "target/worker-test.js"
:autotest true
:ns-regexp "^test.worker.*"}}}
Tree of the project
config.js
const providers = {
someProvider: {
scope: [{
name: "shopping-lists"
}]
}
}
const allowedProviders = Object.keys(providers)
export const configuration = {
...providers,
allowedProviders
}
@thheller I've just changed require to export import
Here is how ./src/api/client/schemas/login.js
looks like
import joi from '@hapi/joi'
import { configuration } from '../../../infrastructure/config.js'
console.log(configuration)
Error message: TypeError: Cannot read property 'configuration' of null@thheller Is it even possible to import one .js file from another .js file and then import it in cljs file? Or should I use webpack to join all js files together?
given that you are targetting node however you could just import the .js
files directly and not have shadow-cljs process them in any way
That's true. I will use nodejs.require then 🙂 Thanks for pointing me that 🙂
closure does very strict rewriting of ES6 type code that doesn't play well with hot-reload style dev builds currently
any of you folks happen to be (neo)vim & fireplace users? I'm trying to follow a tutorial that uses shadow-cljs and can no longer get my repl connected. I included cider/cider-nrepl
and cider/piggieback
as dependencies and get the following warnings when starting the repl: https://pastebin.com/LPrmeKmz
Can I just ignore those? When trying to actually connect vim to the running repl I get this warning and further stacktrace:
[2019-07-24 12:37:11 - SEVERE] Unhandled REPL handler exception processing message {:id ae40bfe8-e180-4ad0-33de-ceb5d15054f3, :op classpath}
java.lang.IllegalArgumentException: No implementation of method: :send of protocol: #'nrepl.transport/Transport found for class: clojure.tools.nrepl.transport.FnTransport
@karol.wojcik sorry for interrupting you, I see there's a crypt.cljs
in your screenshot. I'm searching for a library for doing AES in cljs, any sugeestions?
@chase-lambert no they changed the artifact id
thats the newer one https://clojars.org/nrepl/versions/0.6.0
@thheller Looks like I need some features like InitVector that goog not support. I found a library called "crypto-js", but looks like there's something not correct in cljs.
https://github.com/brix/crypto-js
this will not work, the error is
Cannot read property 'charAt' of undefined
(ns foo.bar
(:require ["crypto-js" :as CryptoJS]))
((.. CryptoJS -enc -Base64 -parse)
"aGVsbG8n")
This is the JS version
var CryptoJS = require('crypto-js');
var result = CryptoJS.enc.Base64.parse('aGVsbG8n');
console.log(result);
@thheller Am I do the correct translating? If it is, I think there's something wrong with shadow-cljs.
also there's a html version, to ensure it can be run on browser environment.
<!DOCTYPE html>
<html>
<head></head>
<body>
<script src="node_modules/crypto-js/crypto-js.js"></script>
<script>
var result = CryptoJS.enc.Base64.parse('aGVsbG8n');
console.log(result);
</script>
</body>
</html>
@doglooksgood It's not problem with shadow. Try this:
(.. crypto/enc -Base64 (parse "hello"))
@karol.wojcik so what's going on here, very strange
I can even confirm CryptoJS.enc.Base64.parse
and (.. CryptoJS -enc -Base64 -parse)
are totally equal. tried in the console and repl.
But calling in console with JavaScript will work, calling in repl with ClojureScript will fail, they are in one environment.
Did you try my example?
(.. crypto/enc -Base64 (parse "hello"))
I'm not 100% sure, but as I understand the property access does not makes the js function invokable.
hey @thheller, what's the latest with piggieback
and shadow-cljs
these days? Now that I can connect with clojure I'm having problems getting the cljs repl connected. I used to just put :Piggieback :app
and it worked. Shadow-cljs says it's watching build :app
I have the cider/piggieback dependency loaded in.
I think in this case, sometimes invokable. there're some functions works like CryptoJS.enc.Utf8.parse
https://lwhorton.github.io/2018/10/20/clojurescript-interop-with-javascript.html
@karol.wojcik It's not invokable, it's missing the context for this
. this post have a great explain.
Hi, i'm using shadow-cljs
, the live reloading works great, except when i create a new namespace inside a package (folder) and require it somewhere, where it says : The required namespace X is not available, it was required by Y
, so i need to kill the shadow-cljs server
and restart it, is there a better way to do this? i've tried shadow/stop-worker
and then shadow/watch
again but no luck
@doglooksgood nice catch. I think that is the issue. I have been used to intellij automatically saving files and sometimes don't save manually. I just tried saving the file manually before using it and it worked. I will keep an eye on it to see if not saving was the cause. @ichigo let us know if that fixed it for you or not
thanks @doglooksgood, @neupsh i'll try that :thumbsup:
I'm using Emacs, get an different error. But evaluating the namespace before you save that file(let shadow-cljs compile it) will cause problem.
so i've tried 2 things: 1. create a package with a namespace, define a function inside it, require it in another namespace, this didn't work, even after evaluating the namespace after. 2. same as before, but after creating the function i evaluated the namespace and then require it, this works 🎉
How are people handling watching other assets like CSS during development? Do you just start multiple processes, or is it possible to add this to the normal shadow-cljs commands with the hooks? (E.g., start webpack as the build is configured)
I use css-in-js on my current app but I think the other option is to run node-sass or whatever as a separate process
There was a way to specify shadow-cljs to build only one js file instead of injecting a lot of <script>
tags for node_modules in the html during development. Anyone remember how to do that?
@lilactown hm, how are you making css-in-js work with shadow?