This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-01
Channels
- # aleph (1)
- # architecture (7)
- # aws (1)
- # beginners (52)
- # boot (3)
- # cider (27)
- # cljs-dev (9)
- # cljsrn (16)
- # clojure (82)
- # clojure-dev (75)
- # clojure-italy (14)
- # clojure-nl (11)
- # clojure-spec (10)
- # clojure-uk (31)
- # clojurescript (49)
- # core-async (13)
- # datascript (11)
- # datomic (15)
- # duct (11)
- # emacs (8)
- # fulcro (46)
- # heroku (2)
- # jobs-discuss (27)
- # jobs_rus (1)
- # juxt (25)
- # keechma (1)
- # off-topic (59)
- # om (2)
- # pedestal (4)
- # portkey (113)
- # portland-or (1)
- # re-frame (14)
- # reagent (11)
- # shadow-cljs (278)
- # vim (2)
- # yada (2)
Is it possible to use Conditional Reading for web-worker contexts? For example, I'm using prosemirror in one of my files. Unfortunately, prosemirror expects a global document
variable, which is not available in web worker context. This makes it impossible to require the prosemirror namespace, because it throws an exception inside the webworker. I can definitely restructure the app into separate modules, but before doing that I just wanted to check because the Conditional Reading option would be much easier.
No worries, just solved it by patching the underlying prosemirror library.
@mjmeintjes no it only works per build. restructuring the modules is the way to go I think
I am trying to see if we can port Calva to Clojurescript one file at a time. But Iâm having troubles getting the require
to work for requiring JS files. I have structured the src directory the same way as under *Requiring JS* in the User Guide: https://shadow-cljs.github.io/docs/UsersGuide.html#_requiring_js
Trying to require a file utilities.js
at the root of the src/js
directory from a cljs
file in a subdirectory to src/main
. But whatever I type except for "utilities"
fails, Shadow says no:
The required JS dependency â../utilitiesâ is not available, it was required by ârepl/message.cljsâ.
I asked shadow-cljs to be verbose, but it doesnât give any more clues to this particular issue.
{:source-paths
["src/main"]
:dependencies
[[org.clojure/core.async "0.4.474"]
[cider/cider-nrepl "0.16.0"]
[org.clojure/tools.nrepl "0.2.12"]]
:builds
{:calva
{:target :node-library
:output-dir "out-cljs"
:output-to "src/js/main.js"
:exports {:message repl.message/message}
:modules {:main {:entries [repl.message]}}
:devtools {}}}}
repl.message/message
is a map with symbols from the module. I am hoping I can access that map from js code.
I just forked master https://github.com/PEZ/clojure4vscode
Thanks. The problem with where to output-to is that main
in package.json
must remain ./src/js/extension
for now.
Now I get this:
[:calva] Build failure:
NullPointerException:
shadow.build.classpath/find-js-resource (classpath.clj:1017)
shadow.build.classpath/find-js-resource (classpath.clj:998)
shadow.build.resolve/eval14123/fn--14126 (resolve.clj:192)
clojure.lang.MultiFn.invoke (MultiFn.java:243)
shadow.build.resolve/resolve-string-require (resolve.clj:227)
shadow.build.resolve/resolve-string-require (resolve.clj:210)
shadow.build.resolve/resolve-require (resolve.clj:393)
shadow.build.resolve/resolve-require (resolve.clj:386)
I just got it to compile fine with
{:source-paths
["src/cljs"
"src/js"]
:dependencies
[[org.clojure/core.async "0.4.474"]
[cider/cider-nrepl "0.16.0"]
[org.clojure/tools.nrepl "0.2.12"]]
:builds
{:calva
{:target :node-library
:output-to "dist/calva.js"
:exports {:message repl.message/message}
:modules {:main {:entries [repl.message]}}
:devtools {}}}}
Thatâs what I have too, except that I removed the :modules
map. Will try with putting it back.
yeah so the main problem you are going to run into the the use of require
and module.exports
the problem with your current approach is that shadow-cljs is building it but vscode is loading it differently
A minimal cljs main entry point which just uses the current extension.js
should maybe solve the problem with where to output-to
.
Anyway, if manualy I move the js file created by shadow to the root of where everything else lies (and use the main namespace calva
to avoid the NPE) then I get things to compile and the extension to load. But I access the exported map incorrectly atm.
I now pushed an update to the wip-cljs-toolchain
branch with these changes. If you want to try it, just move the generated dist/calva.js
to src/main/calva
before reloading the extension host.
Iâll be away from the computer for some hours now. Hoping Iâll be home in time so I can continue this tonight.
@pez, @thheller did this https://github.com/thheller/clojure4vscode/tree/migrate-to-es6/src/main/calva Itâs a little bit late here so once you get back I will be away
when initing a bootstrapped compiler env with (boot/init state {....
is it posible to pass options like in a regular build def
...
:my-build {...
:compiler-options {:my-flag true}
} ....
}
that will show in (get-in @cljs.env/*compiler* [:options])
?
looking at the source at shadow.cljs.bootstrap.browser
, but first time digging under the hood... đ
use case is :
expanding / implementing something like https://github.com/bhauman/devcards/blob/ae6d1a459b91cfbccb4594c0e6970b2de289a4b3/src/devcards/core.clj#L133 deftest macro that works across cljs/browser.@fj.abanses you are passing the state to init
(defonce c-state (cljs/empty-state))
(swap! c-state assoc-in [:options :my-option ] false)
(defonce _ (boot/init c-state
{:path "/js/bootstrap"
:load-on-init '#{b2repl.user}}
(fn []))
I did, it works. I wasnt sure it was the right way. ThanksGetting this with shadow-cljs check:
Failed reading cache for scratchpad.core: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input: expected close marker for Array (start marker at [Source: [email protected]; line: 1, column: 1028532])
at [Source: [email protected]; line: 1, column: 1033075]
Failed writing cache for scratchpad.core: java.lang.Exception: Not supported: class java.util.regex.Pattern
And shadow-cljs check
takes quite a while to finish, which may as well just be the Closure compiler, but if it's slow due to the cache failing for some reason, it'd be great if it could be sped up.
is this open source code? wonder where the pattern is coming from? probably somewhere in meta?
okay, watch
isn't complaining, release
is:
Failed writing cache for scratchpad.core: java.lang.Exception: Not supported: class java.util.regex.Pattern
just want to confirm that all phases complain. doesn't make sense for watch
not to complain
Failed writing cache for scratchpad.core: java.lang.Exception: Not supported: class java.util.regex.Pattern
Could it be relevant that 1. this a .cljc file with macros and reader conditionals and 2. I'm using the lein integration with shadow?
I'm also getting these:
WARNING: failed to inspect resource "jar:file:/[....]/scratchpad/core.cljc", it will not be available.
IF! you get WARNING: failed to inspect resource "jar:file:/[....]/scratchpad/core.cljc", it will not be available.
the file will not be available
⯠shadow-cljs compile scratchpad 1s 862ms
shadow-cljs - config: /Users/gnl/Code/re-frame-playground/shadow-cljs.edn version: 2.3.14
shadow-cljs - running: lein with-profile +shadow run -m shadow.cljs.devtools.cli --npm compile scratchpad
May 01, 2018 5:00:53 PM clojure.tools.logging$eval870$fn__874 invoke
WARNING: failed to inspect resource "jar:file:/Users/gnl/.m2/repository/gnl/scratchpad/0.1.0-SNAPSHOT/scratchpad.1.0-SNAPSHOT.jar!/scratchpad/core.cljc", it will not be available.
May 01, 2018 5:00:53 PM clojure.tools.logging$eval870$fn__874 invoke
WARNING: failed to inspect resource "jar:file:/Users/gnl/.m2/repository/zprint/zprint/0.4.7/zprint-0.4.7.jar!/zprint/main.cljc", it will not be available.
[:scratchpad] Compiling ...
May 01, 2018 5:01:00 PM com.google.javascript.jscomp.LoggerErrorManager println
WARNING: node_modules/highlight.js/lib/languages/tp.js:14: WARNING - String continuations are not recommended. See
begin: '(AR|P|PAYLOAD|PR|R|SR|RSR|LBL|VR|UALM|MESSAGE|UTOOL|UFRAME|TIMER|\
^
May 01, 2018 5:01:00 PM com.google.javascript.jscomp.LoggerErrorManager printSummary
WARNING: 0 error(s), 1 warning(s)
------ WARNING #1 --------------------------------------------------------------
File: node_modules/highlight.js/lib/languages/tp.js:14:11
String continuations are not recommended. See
--------------------------------------------------------------------------------
nil
Failed writing cache for scratchpad.core: java.lang.Exception: Not supported: class java.util.regex.Pattern
[:scratchpad] Build completed. (602 files, 483 compiled, 0 warnings, 49.68s)
I assume you are working on scratchpad
so why is scratchpad.1.0-SNAPSHOT.jar
on the classpath?
the SNAPSHOT jar probably contains an older version which is then overwritten by your source files
I had the jar installed with lein install
because I was messing around with lein checkouts before shadow-cljs and now I'm directly referring the source-path of the current version
ok the jar is just outdated but not a problem since you have the sources directly available
spent an hour or so once debugging this. couldn't figure out how it could still load a file that I just deleted đ
Hah! Got it:
(s/def ::color (s/or :keyword keyword?
:literal (s/and string?
#(re-matches #"#[a-fA-F0-9]+" %)
#(or (= (count %) 7) (= (count %) 4)))))
That keyword ends up in some metadata and you mentioned something about metadata before, is that a good direction?
The caching working doesn't make any difference to how long shadow-cljs check
takes though, so apparently that's just the Closure compiler needing a while. Is there any way to speed this up, do you think? Somehow just recheck changed files or something or does it need to go over the whole project every time?
To describe the environment - it's a playground project with many dependencies one of which is the library that I'm currently working on.
Which makes sense in a way, but some sort of caching would be nice, I'd love to be able to do the type-checking at a similar speed as hot-reloading.
but the way the closure compiler does this means that you must provide all the sources and dependencies
just published [email protected]
. should fix the cache issue
Okay, this clears up a few things, thanks. I don't think a single-ns check will do the trick for my use case, but I'll let you know when I finish my thing, it'll be clearer what I have in mind and then we can brainstorm some more about how best to approach this if at all possible.
there's a great npm library https://github.com/gtanner/qrcode-terminal
Okay, so:
shadow-cljs check
[:scratchpad] Build completed. (161 files, 0 compiled, 0 warnings, 4.80s)
34s 786ms
shadow-cljs release
[:scratchpad] Build completed. (161 files, 130 compiled, 0 warnings, 41.58s)
55s 530m
What's the discrepancy between the time reported in build completed
and the actual time it took?
makes all commands a whole lot faster since you don't have to pay for the startup each time
probably takes 20sec to just start things and warm up before anything actually related to check
happens
Oh wow, clearly I've severly underestimated the startup time of the whole thing. (shadow/check ...)
in the REPL is done in 14seconds now.
hmm yeah. dunno if there are flags in the closure compiler I'm supposed to be setting
Maybe :closure-warnings makes a difference in that it doesn't only control reporting but actual checking?
Thanks for the help with migrating Calva imports/exports to ES6, @thheller! I have merged it into my wip branch now and it compiles and the extension loads. I pushed my branch with the changes. The extension doesnât quite work yet, commands die silently. I guess the message
module looked resonably simple to start the porting with, but it is also very central to most everything Calva does. đ
Hmm, I have made some little progress, but it seems that utilities.js
is sometimes not imported correctly, I get errors saying things like module$calva$utilities.X is not a function
from places like hover.js
and messages.cljs
. However shadow.js
seems to get a correct import, because it can use utilities.js
functions.
So you think I can get it working by fixing the imports manually? They look right to me. (I donât see any difference between the imports that works and those that donât.)
for some reason ES6 doesn't allow "partial" refers. either all or nothing. no idea why.
There. Now it seems most stuff works. Maybe all stuff. I am really too tired to figure that out right now. đ Anyway, pushed the changes to the wip branch for anyone who cares. Calva is on itâs way to be ported to Clojurescript, thanks to shadow-cljs!
I had to do a funny trick. The new message.cljs
module of course produces proper clojure maps. But the bencoder
(.js) module of course has none of that. So I made a small migrate.cljs
module that converts it back to a Javascript object. I use it from client.js
before giving the message to bencoder. If I can port client.js
to Clojurescript I will be able to remove this migration module, I think.
Off-topic - are you building an nRepl cljs server by any chance?
Rather an nrepl cljs client. Itâs an extension to VS Code, Calva. I am now curious why you asked? :face_with_cowboy_hat:
Because I was thinking at some point about writing a lumo nRepl-compatible server of some sort. I was actually wondering which bencode library to use on JS for instance...so I guess I will observe Calva closely đ
That would be wonderful. Then Calva could support Lumo, I think. Is it something unRepl can be used for?
Most of the client is still in JavaScript, though. The only part I have ported is the messages maps.
Hi. Every now and again I get the following error printed by shadow-cljs:
[2018-05-01 23:27:27 - SEVERE] Unhandled REPL handler exception processing message {:ns user, :op eval, :code (ns learning.web.web-worker.core
(:require [learning.web.module.core :as m]
[keechma.toolbox.pipeline.core :as pp]
[keechma.controller :as controller]
[learning.js-utils :as j]
[keechma.toolbox.pipeline.controller :as pp-controller]
[goog.object :as go]))
, :file /home/matthys/projects/personal/learning/src/learning/web/web_worker/core.cljs, :line 1, :column 1, :session 6e5b0609-56d9-4d5f-9b08-91f627139e22, :id 15}
java.lang.NoClassDefFoundError: Could not initialize class shadow.cljs.devtools.errors$user_friendly_error$fn__16179
at shadow.cljs.devtools.errors$user_friendly_error.invokeStatic(errors.clj:290)
at shadow.cljs.devtools.errors$user_friendly_error.invoke(errors.clj:289)
Is this something you've seen before? I can create an issue and try to figure out what's causing it, but it doesn't seem to do anything bad.@mjmeintjes I'm also trying to get setup for keechma development with shadow-cljs. Did you ever get your setup worked out?
Yeah, I've been using shadow-cljs and keechma for a couple of months now and it works great. Let me know if you have any questions.
do you have an example repo with the configs that you could share đ
also, I'm using Atom with protorepl, will that be ok?
just stalked you real quick and found this: https://github.com/mjmeintjes/shadow-cljs-keechma-node Let me know if you recommend other resources (tutorials/guides/etc.)!
That project should show you the basics, however it is a bit more complicated than needed because it also includes server side rendering using nodejs webserver. One of my goals for this month is to get a guide out on how to get started using shadow-cljs and keechma. For now your best bet is to have a look at https://github.com/gothinkster/clojurescript-keechma-realworld-example-app and keechma docs to get started with Keechma. Shadow-cljs is pretty straightforward - I'll extract my basic setup to a starter project and let you know. One important tip - have a look at https://github.com/keechma/keechma toolbox, especially datasource loaders and pipeline controllers. I know that sounds like a lot of jargon, but have a look and let me know if you have any questions. Ypu can also ask on the keechma channel, they are really helpful.
I haven't used Atom before, so can't help you there unfortunately.
Thank you so much @mjmeintjes ! Your help is greatly appreciated! Btw, you come highly recommended by the Keechma author himself :thumbsup: