This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-08-14
Channels
- # atom-editor (5)
- # babashka (6)
- # beginners (29)
- # calva (16)
- # cider (1)
- # clj-kondo (20)
- # cljs-dev (44)
- # clojure (29)
- # clojure-europe (19)
- # clojure-nl (8)
- # clojure-norway (7)
- # clojure-spec (2)
- # clojure-sweden (1)
- # clojure-uk (56)
- # clojurescript (32)
- # code-reviews (30)
- # conjure (24)
- # cursive (49)
- # datomic (4)
- # fulcro (31)
- # helix (3)
- # instaparse (4)
- # kaocha (100)
- # lambdaisland (2)
- # mid-cities-meetup (1)
- # monads (1)
- # off-topic (42)
- # pathom (13)
- # pedestal (6)
- # portal (5)
- # re-frame (6)
- # reagent (9)
- # reitit (11)
- # remote-jobs (1)
- # rewrite-clj (11)
- # shadow-cljs (44)
- # sql (22)
- # tools-deps (13)
- # uncomplicate (1)
- # xtdb (15)
If I want to compile some tests for puppeteer or similar, to be ran both with watch and a single test with return 0 if tests pass, which build target is the best? After 2 days of trying everything and nothing working out, I am inclined to believe that I should either use jvm (i.e. etaoin) or none of the -test builds, but node-script. Is this correct?
One thing I am really confused about is that it seems the process exists before the go blocks finish running.
well you need to use the async test helper. otherwise the tests finish without waiting for async stuff and exit the process.
Ok, that sounds reasonable but I am looking here https://shadow-cljs.github.io/docs/UsersGuide.html#target-node-test and I am not really sure what would be the 'helper' that you refer to. The whole page doesn't have this word on it : )
Hello, I'm trying to get a test build working with devcards test. My working devcards build has a option
:build-options {:ns-aliases {devcards-marked cljsjs.marked, devcards-syntax-highlighter cljsjs.highlight}}
specified. The problem is that this :build-options
key is not available when setting up a :test
build. So any files in devcards which match the -test$
regex will try to compile with this test build, but they will also end up including devcard.core
leading to the marked
issue.@smchugh230395 I'm not sure what you mean by :build-options key is not available ...
{:test
{:target :node-test
:output-to "out/node-tests.js"
:ns-regexp "-spec$"
:autorun true
:main optional}}}
This is the list of config options according to the docs. It does not list :build-options
as a valid config option. I thought maybe it is valid, but unlisted in the docs, so I tried including it in the test config options. This did not solve the issue though as opposed to my :mycards
build which works fine.:build-options
can be used in any build, the docs just don't mention it. just like :compiler-options
and :js-options
.
That was indeed my suspicion. When I ran previously I was still getting the same issues with regards to "devcards-marked" but now it's compiling. I must have made an error when compiling. Sorry about that. Thanks for the help.
Hello, I'm currently building a cljs electron app. I'm finding some difficulty accessing node.js APIs from renderer
application namespaces. For instance, I can access fs
fine from main
, but not from the application code. I can access npm
modules fine from the application as well, such as @material-ui/icons
. Most of my code is based off of https://github.com/ahonn/shadow-electron-starter, and I have enabled nodeIntegration
.
Interestingly, when I add (:require ["electron" :as elec :refer [ipcRenderer]])
to the top of a renderer file, and print elec
, it is an empty js object.
Verified: from the electron console, module$node_modules$electron$index
returns an empty object
Whoo. I'm able to (js/require "fs")
. I need to understand the difference between :require
and js/require
...
Appears that js/require
is commonJS require('')
whereas :require
is fancy ES6 import * from ""
https://clojureverse.org/t/guide-on-how-to-use-import-npm-modules-packages-in-clojurescript/2298
I wonder if this has something to do with :target :browser
for the renderer code. Perhaps shadow-cljs doesn't expect this code to also have node.js access in the case of electron?
@thheller So the strange error with incorrect UTF-8 start byte started occuring to me again:
Exception in thread "XNIO-1 I/O-3" java.lang.RuntimeException: com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 start byte 0xf8
at [Source: java.io.ByteArrayInputStream@21c7c0c2; line: 1, column: 92]
at com.cognitect.transit.impl.ReaderFactory$ReaderImpl.read(ReaderFactory.java:114)
at cognitect.transit$read.invokeStatic(transit.clj:319)
at cognitect.transit$read.invoke(transit.clj:315)
at shadow.cljs.devtools.server.common$fn__14808$fn__14809.invoke(common.clj:47)
at clojure.core$map$fn__5862$fn__5863.invoke(core.clj:2742)
at clojure.core.async.impl.channels$chan$fn__872.invoke(channels.clj:300)
at clojure.core.async.impl.channels.ManyToManyChannel.put_BANG_(channels.clj:83)
at clojure.core.async$put_BANG_.invokeStatic(async.clj:199)
at clojure.core.async$put_BANG_.invoke(async.clj:187)
at shadow.undertow$fn$reify__16240$handler_fn__16241.invoke(undertow.clj:314)
at shadow.undertow.WsTextReceiver.onFullTextMessage(WsTextReceiver.java:20)
at io.undertow.websockets.core.AbstractReceiveListener$2.complete(AbstractReceiveListener.java:156)
at io.undertow.websockets.core.AbstractReceiveListener$2.complete(AbstractReceiveListener.java:152)
at io.undertow.websockets.core.BufferedTextMessage.read(BufferedTextMessage.java:105)
at io.undertow.websockets.core.AbstractReceiveListener.readBufferedText(AbstractReceiveListener.java:152)
at io.undertow.websockets.core.AbstractReceiveListener.bufferFullMessage(AbstractReceiveListener.java:90)
at io.undertow.websockets.core.AbstractReceiveListener.onText(AbstractReceiveListener.java:70)
at io.undertow.websockets.core.AbstractReceiveListener.handleEvent(AbstractReceiveListener.java:44)
at io.undertow.websockets.core.AbstractReceiveListener.handleEvent(AbstractReceiveListener.java:33)
at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
at io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener.handleEvent(AbstractFramedChannel.java:952)
at io.undertow.server.protocol.framed.AbstractFramedChannel$FrameReadListener.handleEvent(AbstractFramedChannel.java:932)
at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92)
at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66)
at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89)
at org.xnio.nio.WorkerThread.run(WorkerThread.java:591)
Caused by: com.fasterxml.jackson.core.JsonParseException: Invalid UTF-8 start byte 0xf8
at [Source: java.io.ByteArrayInputStream@21c7c0c2; line: 1, column: 92]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1702)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:558)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._reportInvalidInitial(UTF8StreamJsonParser.java:3544)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._reportInvalidChar(UTF8StreamJsonParser.java:3538)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._finishString2(UTF8StreamJsonParser.java:2543)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._finishAndReturnString(UTF8StreamJsonParser.java:2469)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.getText(UTF8StreamJsonParser.java:315)
at com.cognitect.transit.impl.JsonParser.parseVal(JsonParser.java:60)
at com.cognitect.transit.impl.JsonParser.parseMap(JsonParser.java:112)
at com.cognitect.transit.impl.JsonParser.parseArray(JsonParser.java:128)
at com.cognitect.transit.impl.JsonParser.parseVal(JsonParser.java:56)
at com.cognitect.transit.impl.JsonParser.parse(JsonParser.java:46)
at com.cognitect.transit.impl.ReaderFactory$ReaderImpl.read(ReaderFactory.java:112)
... 25 more
So I was digging little bit through my data and I found that the problem is with using non-ascii characters in strings. Evaluating the following form in REPL will throw the error:
"Křápová"
Was something changed recently in using transit in Shadow-cljs? My version is 10.18.@pavel.klavik works fine for me
s$ shadow-cljs node-repl
shadow-cljs - config: /mnt/c/Users/thheller/code/shadow-cljs/shadow-cljs.edn
shadow-cljs - connected to server
cljs.user=> "Křápová"
"Křápová"
cljs.user=>
@tangj1122 :browser
by default will try to bundle all js requires which isn't what you want in case of electron. so you can either set :js-options {:js-provider :require}
or :js-options {:keep-as-require #{"fs" ...}}
:require
will make everything go through require
(so via nodeIntegration). :keep-as-require
lets you select whichever packages but defaults to bundling all others
so it works with node-repl
and I tested everything from scretch and I get the same error with this output in REPL:
Connecting to remote nREPL server...
Clojure 1.10.1
"Křápová"
=> "Křápová"
(shadow/repl :client)
To quit, type: :cljs/quit
=> [:selected :client]
"Křápová"
also works fine over nrepl
(shadow/repl :browser)
To quit, type: :cljs/quit
=> [:selected :browser]
"Křápová"
=> "Křápová"
no idea, but it is broken in both firefox and chrome
maybe something in my shadow-cljs.edn?
{:source-paths ["src"]
:dependencies [[reagent "0.10.0"]
[reagent-utils "0.3.3"]
[re-frame "0.12.0"]
[com.cognitect/transit-cljs "0.8.264"]
[day8.re-frame/http-fx "v0.2.0"]
[hickory "0.7.1"]
[binaryage/devtools "0.9.10"]
[bidi "2.1.6"]
[com.taoensso/sente "1.15.0"]
[venantius/accountant "0.2.5"]
[com.cemerick/url "0.1.2-SNAPSHOT"]
[com.taoensso/timbre "4.10.0"]
[cljc.java-time "0.1.8"]
[bouncer "1.0.1"]
[orgpad/volcano "0.1.2"]
[macchiato/core "0.2.17"]
[macchiato/env "0.0.6"]
[mount "0.1.16"]]
:nrepl {:port 9000}
:builds {:client {:target :browser
:output-dir "resources/public/js/compiled"
:asset-path "/js/compiled"
:modules {:shared {:entries []}
:main {:init-fn orgpad.client.core/init
:depends-on #{:shared}}
:layout {:entries [orgpad.client.layout.webworker.core]
:depends-on #{:shared}
:web-worker true}}
:compiler-options {:infer-externs :auto
:output-feature-set :es6}
:devtools {:after-load orgpad.client.core/mount-root
:before-load orgpad.client.core/stop-web-workers
:watch-dir "resources/public"
:browser-inject :main
:loader-mode :script}}
:landing {:target :browser
:output-dir "landing/resources/js"
:asset-path "/js"
:modules {:main {:init-fn orgpad.landing.dev/init}}
:devtools {:http-root "landing/resources"
:http-port 3500
:after-load orgpad.landing.dev/mount-root
:watch-dir "landing/resources"
:browser-inject :main}}
:emails {:target :browser
:output-dir "emails/js"
:asset-path "/js"
:modules {:main {:init-fn orgpad.server.email.dev/init}}
:devtools {:http-root "emails"
:http-port 3600
:after-load orgpad.server.email.dev/mount-root
:watch-dir "emails"
:browser-inject :main}}
:screenshot {:target :node-script
:main orgpad.screenshot.core/main
:output-to "screenshot/screenshot.js"
:devtools {:autoload true}
:compiler-options {:optimizations :simple}}}}
it fails in client project
can't think of anything that would affect this in shadow-cljs. maybe a bad charset encoding in your editor/terminal? should be utf-8
I am using Cursive nREPL
how can I access REPL from terminal?
try <meta charset="utf-8">
if its not in your HTML. wouldn't be the first time this fixed something.
it works fine from cljs-repl from terminal
maybe weird encoding in cursive then? I don't have a clue, the nrepl I tested was also in cursive.
I have this in my HTML:
<meta charset='utf-8'>
I will try to update Cursive to see whether it won't fix it