shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
Mr. Savy 2021-01-26T00:10:48.075600Z

yeah that's what I thought at first but after struggling for a few days I started reaching I guess. knowing it's just supposed to be js, I'm going to try targeting node next and see if that works, thank you for your input!

2021-01-26T00:51:25.076500Z

Hello, I get this error, when use shadow-cljs in WSL ubuntu on Windows, can anyone help? thanks. shadow-cljs - config: /home/kimim/workspace/vorstellung/shadow-cljs.edn shadow-cljs - updating dependencies shadow-cljs - dependencies updated Execution error (AssertionError) at shadow.build.classpath/process-root-contents (classpath.clj:593). Assert failed: (sequential? root-contents)

thheller 2021-01-26T01:01:15.077Z

@kimi.im my guess is that you don't have a :source-paths vector? maybe a set or map?

thheller 2021-01-26T01:02:24.077900Z

@ajsnow2012 you don't have to look at node either. unless you need some type of server of course. look literally for "static website"

2021-01-26T01:03:17.079Z

It is set correctly :source-paths ["src/cljs"] The same setting, works in Linux or windows environment. But WSL failed..

thheller 2021-01-26T01:04:39.079300Z

I use WSL too and never had an issue

thheller 2021-01-26T01:04:44.079600Z

what is the rest of the stacktrace?

2021-01-26T01:05:53.079700Z

Hello @thheller, the full error looks like this: {:clojure.main/message "Execution error (AssertionError) at shadow.build.classpath/process-root-contents (classpath.clj:593).\nAssert failed: (sequential? root-contents)\n", :clojure.main/triage {:clojure.error/class java.lang.AssertionError, :clojure.error/line 593, :clojure.error/cause "Assert failed: (sequential? root-contents)", :clojure.error/symbol shadow.build.classpath/process-root-contents, :clojure.error/source "classpath.clj", :clojure.error/phase :execution}, :clojure.main/trace {:via [{:type java.lang.AssertionError, :message "Assert failed: (sequential? root-contents)", :at [shadow.build.classpath$process_root_contents invokeStatic "classpath.clj" 593]}], :trace [[shadow.build.classpath$process_root_contents invokeStatic "classpath.clj" 593] [shadow.build.classpath$process_root_contents invoke "classpath.clj" 593] [shadow.build.classpath$find_jar_resources invokeStatic "classpath.clj" 670] [shadow.build.classpath$find_jar_resources invoke "classpath.clj" 638] [shadow.build.classpath$find_resources invokeStatic "classpath.clj" 767] [shadow.build.classpath$find_resources invoke "classpath.clj" 758] [shadow.build.classpath$index_path_STAR_ invokeStatic "classpath.clj" 997] [shadow.build.classpath$index_path_STAR_ invoke "classpath.clj" 994] [clojure.lang.PersistentVector reduce "PersistentVector.java" 343] [clojure.core$reduce invokeStatic "core.clj" 6827] [clojure.core$reduce invoke "core.clj" 6810] [shadow.build.classpath$index_classpath$fn__10836$fn__10837 invoke "classpath.clj" 1130] [clojure.lang.Atom swap "Atom.java" 37] [clojure.core$swap_BANG_ invokeStatic "core.clj" 2352] [clojure.core$swap_BANG_ invoke "core.clj" 2345] [shadow.build.classpath$index_classpath$fn__10836 invoke "classpath.clj" 1130] [shadow.build.classpath$index_classpath invokeStatic "classpath.clj" 1129] [shadow.build.classpath$index_classpath invoke "classpath.clj" 1124] [shadow.build.classpath$index_classpath invokeStatic "classpath.clj" 1126] [shadow.build.classpath$index_classpath invoke "classpath.clj" 1124] [shadow.cljs.devtools.server.common$fn__15586 invokeStatic "common.clj" 92] [shadow.cljs.devtools.server.common$fn__15586 invoke "common.clj" 90] [clojure.lang.AFn applyToHelper "AFn.java" 154] [clojure.lang.AFn applyTo "AFn.java" 144] [clojure.core$apply invokeStatic "core.clj" 665] [clojure.core$apply invoke "core.clj" 660] [shadow.runtime.services$start_one invokeStatic "services.clj" 98] [shadow.runtime.services$start_one invoke "services.clj" 87] [shadow.runtime.services$start_many$fn__9395 invoke "services.clj" 127] [shadow.runtime.services$start_many invokeStatic "services.clj" 126] [shadow.runtime.services$start_many invoke "services.clj" 105] [shadow.runtime.services$start_all invokeStatic "services.clj" 144] [shadow.runtime.services$start_all invoke "services.clj" 139] [shadow.cljs.devtools.server$start_system invokeStatic "server.clj" 340] [shadow.cljs.devtools.server$start_system invoke "server.clj" 202] [shadow.cljs.devtools.server$start_BANG_ invokeStatic "server.clj" 483] [shadow.cljs.devtools.server$start_BANG_ invoke "server.clj" 385] [shadow.cljs.devtools.server$start_BANG_ invokeStatic "server.clj" 388] [shadow.cljs.devtools.server$start_BANG_ invoke "server.clj" 385] [shadow.cljs.devtools.server$from_cli invokeStatic "server.clj" 615] [shadow.cljs.devtools.server$from_cli invoke "server.clj" 591] [clojure.lang.AFn applyToHelper "AFn.java" 160] [clojure.lang.AFn applyTo "AFn.java" 144] [clojure.lang.Var applyTo "Var.java" 705] [clojure.core$apply invokeStatic "core.clj" 665] [clojure.core$apply invoke "core.clj" 660] [shadow.cljs.devtools.cli_actual$lazy_invoke invokeStatic "cli_actual.clj" 23] [shadow.cljs.devtools.cli_actual$lazy_invoke doInvoke "cli_actual.clj" 20] [clojure.lang.RestFn invoke "RestFn.java" 460] [shadow.cljs.devtools.cli_actual$blocking_action invokeStatic "cli_actual.clj" 129] [shadow.cljs.devtools.cli_actual$blocking_action invoke "cli_actual.clj" 116] [shadow.cljs.devtools.cli_actual$main invokeStatic "cli_actual.clj" 177] [shadow.cljs.devtools.cli_actual$main doInvoke "cli_actual.clj" 132] [clojure.lang.RestFn applyTo "RestFn.java" 137] [clojure.core$apply invokeStatic "core.clj" 669] [clojure.core$apply invoke "core.clj" 660] [shadow.cljs.devtools.cli_actual$_main invokeStatic "cli_actual.clj" 219] [shadow.cljs.devtools.cli_actual$_main doInvoke "cli_actual.clj" 217] [clojure.lang.RestFn applyTo "RestFn.java" 137] [clojure.lang.Var applyTo "Var.java" 705] [clojure.core$apply invokeStatic "core.clj" 665] [clojure.core$apply invoke "core.clj" 660] [shadow.cljs.devtools.cli$_main invokeStatic "cli.clj" 75] [shadow.cljs.devtools.cli$_main doInvoke "cli.clj" 67] [clojure.lang.RestFn applyTo "RestFn.java" 137] [clojure.lang.Var applyTo "Var.java" 705] [clojure.core$apply invokeStatic "core.clj" 665] [clojure.main$main_opt invokeStatic "main.clj" 514] [clojure.main$main_opt invoke "main.clj" 510] [clojure.main$main invokeStatic "main.clj" 664] [clojure.main$main doInvoke "main.clj" 616] [clojure.lang.RestFn applyTo "RestFn.java" 137] [clojure.lang.Var applyTo "Var.java" 705] [clojure.main main "main.java" 40]], :cause "Assert failed: (sequential? root-contents)"}}

thheller 2021-01-26T01:06:34.080Z

which java version?

thheller 2021-01-26T01:08:07.080300Z

yeah its a bad .jar file on the classpath causing this

thheller 2021-01-26T01:08:22.080600Z

something that pretends to be a .jar but isn't

thheller 2021-01-26T01:08:34.080800Z

most likely from your java dist

2021-01-26T01:09:26.081Z

openjdk 11.0.10 2021-01-19 OpenJDK Runtime Environment GraalVM CE 21.0.0 (build 11.0.10+8-jvmci-21.0-b06) OpenJDK 64-Bit Server VM GraalVM CE 21.0.0 (build 11.0.10+8-jvmci-21.0-b06, mixed mode, sharing)

thheller 2021-01-26T01:10:38.081500Z

you can set :log {:level :debug} in your shadow-cljs.edn. that should then log which one causes the trouble

đź‘Ť 1
2021-01-26T01:15:35.082300Z

Thanks. It says one deps jar is empty: [2021-01-26 09:14:44.403 - FINE] :shadow.build.classpath/bad-jar - {:file #object[http://java.io.File 0x7b8bf5c0 "/home/kimim/.m2/repository/commons-io/commons-io/2.6/commons-io-2.6.jar"]} ZipException zip file is empty

thheller 2021-01-26T01:16:20.082500Z

just delete it

thheller 2021-01-26T01:16:24.082700Z

redownload probably fixes it

2021-01-26T01:16:51.083Z

It works now. Thanks.

đź‘Ť 1
zimablue 2021-01-26T08:40:07.084800Z

hey, I'm getting an issue using node when I try to require a cljs file which itself requires a string path javascript file, but I don't really get a stack trace, just "failed to import" and then "SHADOW ERROR" and the path

zimablue 2021-01-26T08:40:22.085Z

sorry SHADOW import error

zimablue 2021-01-26T08:48:05.085700Z

I made progress, that file is in my output watch artifact, I manually modified it to log the error, which told me the problem was another missing module: Module not provided: shadow.js.shim.module$chai, however this module is in the root node_modules

thheller 2021-01-26T09:11:19.086600Z

@zimablue I don't understand what you mean by however this module is in the root node_modules. what is your build config and how are you running it?

zimablue 2021-01-26T10:16:45.090100Z

hi Mr Heller, the overall purpose is to try and test datascript which I am consuming through javascript, so in my actual project I use datascript though javascript which works fine but can't debug it, I was trying to jam part of my javascript project in as a datascript-repl dependency so I could use clojure debugging and understand the Clojure project, To that end I am connecting calva to a node-library build, the repl works and I can import datascript modules. I then just dumped my javascript node_modules and output lib into a subdirectory of the datascript project. It works to some extent but fails to resolve when one javascript file imports another, my build looks like this:

zimablue 2021-01-26T10:17:01.090400Z

builds {:node {:target :node-library ;; :main {:entries [test_node.js]} :js-options {:js-package-dirs ["vscodelib", "node_modules"] ;; :js-provider :require } :output-to "./lib" :exports {:dunno datascript.js/keywordize}}

zimablue 2021-01-26T10:17:20.090800Z

and the error I get after I manually overwrite my output artifact to print the error is:

zimablue 2021-01-26T10:17:39.091200Z

(in node)

zimablue 2021-01-26T10:17:41.091300Z

shadow-cljs - failed to load module$vscodelib$test$databasespec SHADOW import error /home/zimablue/projects/readlib/datascript/.shadow-cljs/builds/node/dev/out/cljs-runtime/marc.js Module not provided: shadow.js.shim.module$chai

zimablue 2021-01-26T10:18:06.091700Z

Chai being a javascript dependency of the javascript file which I am importing

zimablue 2021-01-26T10:18:24.092200Z

sorry, please don't waste any time on this since I am very new so it's certainly a failure of my understanding

zimablue 2021-01-26T10:18:35.092600Z

but if you can immediately guess the problem that would be cool also

thheller 2021-01-26T10:29:17.093800Z

yeah sorry I can't help much. it seems like you are trying to do something weird but I don't understand what

thheller 2021-01-26T10:29:47.094400Z

cljs-runtime/marc.js suggests you have a (ns marc) which I don't see in your config so no clue

thheller 2021-01-26T10:33:10.094800Z

:js-package-dirs ["vscodelib", "node_modules"] this is also suspect. why are you doing this?

thheller 2021-01-26T10:34:25.095800Z

no clue how chai plays into all of this. datascript doesn't use it.

thheller 2021-01-26T10:43:06.097Z

"dumped my javascript node_modules and output lib into a subdirectory" this will definitely not work and is not supposed to

zimablue 2021-01-26T11:30:52.097800Z

what is the recommended alternative approach for consuming js code? it has to be formatted as npm packages?

thheller 2021-01-26T11:31:36.098800Z

it sounds to me like you want the opposite route? consume the CLJS code in a JS build? if your code is mostly JS?

zimablue 2021-01-26T11:32:09.099700Z

I'm doing that successfully, the reason for this reversal is for development, so that I can debug a clojurescript library using clojurescript repl/tooling

thheller 2021-01-26T11:32:41.100100Z

debug "where"?

thheller 2021-01-26T11:32:48.100300Z

I mean where is the final JS running?

thheller 2021-01-26T11:33:08.100900Z

:node-library isn't really meant to be re-bundled. it is meant to be used in node directly. (as the name implies 🙂)

zimablue 2021-01-26T11:33:31.101400Z

the final js is intended to run as you said, consuming the clojurescript, this is just intended to run in my repl/run tests so I can poke around the clojurescript dependencies

zimablue 2021-01-26T11:33:46.101800Z

(this alternative setup)

zimablue 2021-01-26T11:34:21.102500Z

since it's hard to use javascript tools to understand what clojurescript libraries are doing with your datastructures I tried to set up a version of the reverse setup to enable me to use cljs tooling

thheller 2021-01-26T11:34:48.102800Z

ok. what kind of JS code do you have? plain standard ES6+ code or some kind of other dialect? JSX? etc?

zimablue 2021-01-26T11:35:05.103200Z

it's typescript which has been compiled to es5 modules

zimablue 2021-01-26T11:35:28.103700Z

I think

thheller 2021-01-26T11:35:31.103900Z

ok, did you follow https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js

zimablue 2021-01-26T11:35:39.104300Z

I'm certain that's what happens, but not sure that my description is useful

thheller 2021-01-26T11:35:39.104400Z

better to compile to es8 or so but es5 isok

zimablue 2021-01-26T11:36:07.104900Z

thanks, I have looked at this document but not read every line, I will reread this section

zimablue 2021-01-26T11:36:09.105100Z

thank you for your help

thheller 2021-01-26T11:38:00.107800Z

you may also try :npm-module which will might work better for your use-case

zimablue 2021-01-26T11:38:03.108Z

ah yes I read this section, then by trial and error made it work by requiring in my cljs like this: (ns marc (:require ["/vscodelib/test/databasespec.js" :as foo])) That call works, but when databasespec.js has a further dependency (require("chai")), that's when I get the error I pasted

zimablue 2021-01-26T11:38:11.108200Z

I will try npm-module

zimablue 2021-01-26T11:38:43.109100Z

I started to read the shadow-cljs source code but it seems fairly complex

thheller 2021-01-26T11:38:47.109300Z

so you have :source-paths ["src"] and src/vscodelib? the :js-package-dirs is misleading here and probably causing issue

zimablue 2021-01-26T11:39:23.110200Z

yes I have both of those, I think that was what worked (or at least gave me a new error message) by trial and error

thheller 2021-01-26T11:39:38.110500Z

ideally the code you use this way uses ESM syntax so not require("chai") but import Foo from "chai"

zimablue 2021-01-26T11:40:12.110700Z

(ns marc (:require ["/vscodelib/test/databasespec.js" :as foo]))

thheller 2021-01-26T11:40:34.111100Z

what is your :source-paths?

zimablue 2021-01-26T11:40:53.111500Z

sorry wrong paste

thheller 2021-01-26T11:41:01.111800Z

vscodelib makes me suspicious. is this running as a vscode plugin of some kind?

zimablue 2021-01-26T11:41:13.112Z

{ :verbose true :log {:level :debug} :source-paths [ "src" ] :dependencies [[persistent-sorted-set "0.1.2"]] :builds {:node {:target :node-library ;; :main {:entries [test_node.js]} :js-options {:js-package-dirs ["vscodelib", "node_modules"] ;; :js-provider :require } :output-to "./lib" :exports {:dunno datascript.js/keywordize}}}}

thheller 2021-01-26T11:41:31.112400Z

ok so the above would look for src/vscodelib/test/databasespec.js

zimablue 2021-01-26T11:41:39.112700Z

yes which is where it is

zimablue 2021-01-26T11:41:51.113Z

that part I believe works, it's the next dependency resolution, js=>js

thheller 2021-01-26T11:42:22.113300Z

so that JS file has a require("chai")?

zimablue 2021-01-26T11:42:33.113600Z

yes

zimablue 2021-01-26T11:42:46.113900Z

which I think is the result of a typescript compilation with target "es5"

thheller 2021-01-26T11:43:39.114700Z

well it should not have require at all. it should have import

thheller 2021-01-26T11:43:54.114900Z

but require should also work

thheller 2021-01-26T11:44:00.115100Z

how are you running any of this?

zimablue 2021-01-26T11:44:43.115800Z

I start shadow-cljs server, shadow-cljs watch node, npm=>import "./lib" and then finally through calva connect to the running repl

zimablue 2021-01-26T11:45:00.116300Z

sorry if that's a pedantic description as you can tell I'm new to this ecosystem

thheller 2021-01-26T11:45:02.116400Z

npm=>import "./lib" what does that mean?

zimablue 2021-01-26T11:45:08.116700Z

sorry

zimablue 2021-01-26T11:45:14.117200Z

• "node => import lib"

zimablue 2021-01-26T11:45:23.117700Z

i start node in a terminal then import the output artifact

zimablue 2021-01-26T11:45:33.118Z

which provides the runtime (?)

thheller 2021-01-26T11:46:00.118900Z

please post what exactly you are doing. you are forcing me to guess which helps noone.

zimablue 2021-01-26T11:46:03.119100Z

as in (calva) <=> (shadow-cljs watch) <=> (node with loaded code)

zimablue 2021-01-26T11:46:14.119600Z

I was trying to be precise

thheller 2021-01-26T11:46:20.120Z

you are literally running node and then import lib? that is invalid?

zimablue 2021-01-26T11:46:41.120400Z

no I run node and then "require("lib")

zimablue 2021-01-26T11:46:46.120700Z

sorry I got the verbs confused

thheller 2021-01-26T11:47:08.121100Z

please be more precise

thheller 2021-01-26T11:47:25.121500Z

require("lib") this would be looking for node_modules/lib? which no output is going to

thheller 2021-01-26T11:47:48.122500Z

I need to understand what you are doing to provide any kind of help

zimablue 2021-01-26T11:47:58.122700Z

lib is where the node watch process outputs the javascript artifact

zimablue 2021-01-26T11:48:13.123Z

this line in my shadow-cljs.edn: :output-to "./lib"

zimablue 2021-01-26T11:48:17.123200Z

I believe configures that

thheller 2021-01-26T11:48:32.123600Z

yes. but require("lib") will NOT look for that output at least not with the default node configuration

zimablue 2021-01-26T11:48:48.123900Z

it's require ("./lib")

zimablue 2021-01-26T11:48:51.124100Z

sorry

thheller 2021-01-26T11:48:59.124300Z

ok thanks

thheller 2021-01-26T11:49:13.124600Z

ok first of all why are you doing this at all?

thheller 2021-01-26T11:49:27.125100Z

why not just shadow-cljs node-repl or that via Calva?

thheller 2021-01-26T11:50:16.126600Z

but ok, lets try to make this work

zimablue 2021-01-26T11:50:25.127100Z

I think I tried that and it didn't work, so I tried to run the individual commands

thheller 2021-01-26T11:50:32.127600Z

you open node. you run require("./lib"). what happens next?

zimablue 2021-01-26T11:50:38.127800Z

to at least vaguely understand what what happening

zimablue 2021-01-26T11:50:56.128200Z

then I go to calva and do "connect to running repl", some magic happens and I can communicate with that process

thheller 2021-01-26T11:51:05.128600Z

no. what happens in the node process

thheller 2021-01-26T11:51:11.128800Z

not interested in calva at this time

zimablue 2021-01-26T11:51:31.129200Z

I get this output

zimablue 2021-01-26T11:51:44.129500Z

> require("./lib") { dunno: [Getter] } > shadow-cljs - #6 ready!

thheller 2021-01-26T11:51:57.129700Z

ok that appears to work fine then

thheller 2021-01-26T11:52:18.130400Z

now please run shadow-cljs cljs-repl node

thheller 2021-01-26T11:52:23.130600Z

no calva

thheller 2021-01-26T11:52:43.130900Z

then eval something like :foo just to verify the connection works

zimablue 2021-01-26T11:53:40.131500Z

the shadow-cljs cljs-repl node gives "shadow-cljs: command not found"

thheller 2021-01-26T11:54:03.131800Z

ok if you don't have the global install run npx shadow-cljs cljs-repl node instead

zimablue 2021-01-26T11:54:20.132200Z

yes sorry I see I was using npx for the others

zimablue 2021-01-26T11:54:39.132500Z

it connects and runs simple commands

thheller 2021-01-26T11:54:51.132800Z

ok and what command did you run to "break" things?

zimablue 2021-01-26T11:55:09.133Z

(require 'marc)

thheller 2021-01-26T11:55:33.133400Z

ok and that still breaks things now? trying to take calva out of the equation here

zimablue 2021-01-26T11:55:42.133600Z

yes

thheller 2021-01-26T11:55:59.134Z

with what error? the above Module not provided I assume?

zimablue 2021-01-26T11:57:55.135400Z

same problem: shadow-cljs - failed to load module$vscodelib$test$databasespec SHADOW import error /home/zimablue/projects/readlib/datascript/.shadow-cljs/builds/node/dev/out/cljs-runtime/marc.js now before I had gotten more information about the error by modifying the output "lib" artifact and adding a line which logs the error

thheller 2021-01-26T11:57:56.135700Z

remove :exports {:dunno datascript.js/keywordize}} from your build config and instead use :exports {:dunno marc/foo}}

zimablue 2021-01-26T11:57:59.135900Z

and if I repeat that I get

zimablue 2021-01-26T11:58:00.136Z

shadow-cljs - failed to load module$vscodelib$test$databasespec SHADOW import error /home/zimablue/projects/readlib/datascript/.shadow-cljs/builds/node/dev/out/cljs-runtime/marc.js Module not provided: shadow.js.shim.module$chai /home/zimablue/projects/readlib/datascript/.shadow-cljs/builds/node/dev/out/cljs-runtime/marc.js

zimablue 2021-01-26T11:58:11.136400Z

referring to the js=> js import

zimablue 2021-01-26T11:58:18.136600Z

ok

thheller 2021-01-26T11:58:56.137300Z

need to have an actual def in that ns though. you can use any you already have or just add (def foo 3)

thheller 2021-01-26T11:59:16.137700Z

point is getting that ns into the initial build so we can get to the error "earlier", ie. trigger it on build or on load, not the REPL

thheller 2021-01-26T12:00:48.138100Z

also remove :js-options completely

zimablue 2021-01-26T12:01:38.138800Z

before i removed js-options, you are right this moved the error from the repl stage to the node require("./lib") stage

zimablue 2021-01-26T12:01:40.139100Z

same error

zimablue 2021-01-26T12:01:47.139400Z

trying without js-options

thheller 2021-01-26T12:02:08.139800Z

ok, I'm guessing you are running into a variant of this https://github.com/thheller/shadow-cljs/issues/832

thheller 2021-01-26T12:02:37.140800Z

so, try node then global.shadow$provide = {}; then require("./lib")

zimablue 2021-01-26T12:02:42.140900Z

same result without js-options

thheller 2021-01-26T12:03:43.141300Z

also I don't understand why you are not getting that error

thheller 2021-01-26T12:03:58.141700Z

can you share this file src/vscodelib/test/databasespec.js?

zimablue 2021-01-26T12:04:13.142100Z

without js-options and with the suggested node argument I get the same error

zimablue 2021-01-26T12:06:40.142400Z

here:

thheller 2021-01-26T12:08:40.143200Z

ok var datascript_1 = require("datascript"); this is a problem and probably causing all the rest

thheller 2021-01-26T12:08:54.143500Z

that will include the npm datascript package. not the one compiled by shadow-cljs you are doing all this for

roelof 2021-01-26T12:09:32.144100Z

any shadow-expert who can help me with this How to solve this one :

cljs꞉cljs.user꞉&gt;  @state/orders
nil
; No available JS runtime.
clj꞉cljs.user꞉&gt;  @state
shadow-cljs.edn
{:source-paths ["src"]

 :dependencies [[binaryage/devtools "0.9.10"]
                [proto-repl "0.3.1"]
                [reagent "0.8.0"]]

 :nrepl        {:port 3333}

 :builds
 {:app {:target :browser
        :output-dir "public/js"
        :asset-path "/js"

        :modules
        {:main
         {:entries [giggin.core]}}

        :devtools
        {:after-load  giggin.core/main
         :http-root   "public"
         :http-port   3000}}}}

thheller 2021-01-26T12:10:21.145Z

@roelof open <http://localhost:3000> in the browser. see https://shadow-cljs.github.io/docs/UsersGuide.html#repl-troubleshooting

roelof 2021-01-26T12:10:36.145200Z

that one is open

thheller 2021-01-26T12:10:46.145500Z

what does the browser console say?

zimablue 2021-01-26T12:12:57.147Z

@thheller, I see - I think this problem might be separate, since the chai importation is direct in this file not through datascript. What should that import look like and do you have any idea how I nudge typescript to compile it so that it requires correctly?

zendevil 2021-01-26T12:14:31.148Z

I get a warning in my react-native app: the shadow-cljs websocket was disconnected.

zendevil 2021-01-26T12:14:43.148500Z

Do you know what’s the cause?

zendevil 2021-01-27T16:51:09.198400Z

it seems like it’s connected successfully since the app correctly loads.

thheller 2021-01-27T17:22:24.198800Z

no that doesn't mean anything. the websocket is injected by shadow-cljs to provide the hot-reload and REPL. it does not effect the app loading part.

thheller 2021-01-27T17:22:42.199Z

but it may fail to connect if it picked the wrong IP or so

thheller 2021-01-27T17:22:47.199200Z

but without more info I cannot help you

zendevil 2021-01-28T05:58:35.212400Z

I’m not exactly sure what info to provide

roelof 2021-01-26T12:14:55.148900Z

I see two messages

Warning: The tag &lt;orders&gt; is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter.

CLJS DevTools: some custom formatters were not rendered.

roelof 2021-01-26T12:15:14.149400Z

I see the posted message on repl of VS Code

thheller 2021-01-26T12:15:50.149500Z

no. did it ever connect successfully?

thheller 2021-01-26T12:16:26.149700Z

well there isn't really any way to do this

thheller 2021-01-26T12:16:52.149900Z

since the datascript npm package is bundled differently and not by shadow-cljs

thheller 2021-01-26T12:17:51.150100Z

yeah I really don't think the way you are trying this is going to work

zimablue 2021-01-26T12:19:39.150300Z

I see, thanks for all your help I learned something hopefully

zimablue 2021-01-26T12:19:57.150500Z

is a better approach to try and bundle the javascript into an npm package shape, whatever that is

zimablue 2021-01-26T12:20:04.150700Z

since shadow-cljs knows how to consume that?

roelof 2021-01-26T12:20:45.151300Z

I want to show the contents of this :

(ns giggin.state
  (:require [reagent.core :as r]))

(def orders (r/atom {}))

thheller 2021-01-26T12:25:22.153700Z

@roelof this ; No available JS runtime. means that the browser has not connected back to shadow-cljs. that is the only issue you need to solve. the code does not matter. I cannot solve this for you without more info. the build config you provided will have generated a public/js/main.js. I assume you have a public/index.html file with a &lt;script src="/js/main.js"&gt;?

thheller 2021-01-26T12:25:35.153800Z

no that won't do anything

roelof 2021-01-26T12:26:11.154100Z

yes

thheller 2021-01-26T12:26:13.154300Z

the issue is getting JS->CLJS->JS->JS working

roelof 2021-01-26T12:27:03.155500Z

and I tried also (js/alert "test") and then I saw a popup so it seems there is a js runtime

thheller 2021-01-26T12:27:15.155800Z

and you don't get a shadow-cljs ready message in the browser console?

thheller 2021-01-26T12:27:25.156Z

wait now there is a runtime?

roelof 2021-01-26T12:27:45.156400Z

if I do the alert there seems to be a runtime

thheller 2021-01-26T12:28:20.157200Z

and what do you get via giggin.state/order?

roelof 2021-01-26T12:28:26.157400Z

yes, I see this message : `shadow-cljs: #7 ready!`

thheller 2021-01-26T12:28:33.157600Z

ok. that is your runtime

thheller 2021-01-26T12:28:48.157900Z

did you try the REPL stuff before opening the page?

roelof 2021-01-26T12:29:08.158100Z

then it seems to work

roelof 2021-01-26T12:29:15.158300Z

`cljs꞉cljs.user꞉> giggin.state/orders #<Atom: {}>`

roelof 2021-01-26T12:29:54.158600Z

yep, then everything works then

roelof 2021-01-26T12:30:15.158800Z

thanks

zimablue 2021-01-26T12:30:51.158900Z

that's not strictly necessary, I'm only trying to test some isolated pieces, I don't need to go datascript=>js=>datascript, I just commented those parts. I also rearranged to check and all the inter-project direct imports work, it's just anything that assumes it's going to see a node_modules and does like that unqualified import like var ramda = require("ramda")

zimablue 2021-01-26T12:31:21.159100Z

so if I can just go datascript => js => (assumed node_modules import) I will have enough to do the poking that I was hoping for

zimablue 2021-01-26T12:31:47.159300Z

thanks so much, do you have any simple menial task I could do as compensation for your help?

zimablue 2021-01-26T12:31:55.159500Z

(help so far)

2021-01-26T14:19:24.161100Z

Hi, this may be a question for graal js but thought I'd give it a go. Has anyone managed to get shadow-cljs to output js that can be loaded via graal context?

2021-01-26T14:19:55.161900Z

Currently I'm playing with :target :esm which has got me further than I have been...

thheller 2021-01-26T14:30:20.162500Z

there is an undocument :target :graaljs which sort of works for most stuff

2021-01-26T14:31:33.163500Z

Cheers, I'll give that a blast and have a look at the source.

thheller 2021-01-26T14:32:23.164Z

just :entries [whatever.ns] :output-to "foo/bar.js"

thheller 2021-01-26T14:32:39.164400Z

it has no support for running graaljs context or so. that you have to do yourself.

1
thheller 2021-01-26T14:33:28.165400Z

no REPL or hot-reload either since the default context doesn't support it. I can show some code to sort of get it but its pretty specific to how you create and use the graal context

2021-01-26T14:36:29.166400Z

If you have some example code it would be great. I'm currently going off nothing so anything is helpful.

thheller 2021-01-26T14:43:02.166700Z

well what do you intend to do with graal?

2021-01-26T14:48:06.167100Z

Using it for ssr a reagent app.

2021-01-26T14:50:13.168700Z

I started using shadow a couple of years back because of the great npm support but now have to get that app ssr'ing, graal because of the performance uplift.

thheller 2021-01-26T14:50:40.169200Z

performance is generally a lot worse than node

thheller 2021-01-26T14:50:43.169400Z

startup time is horrible

thheller 2021-01-26T14:51:37.169700Z

and no support for async whatsoever is rather limiting

thheller 2021-01-26T14:53:25.171200Z

they have since moved to shadow-cljs and I implemented the :target :graaljs for them as well as some custom code so they get some hot-reload

2021-01-26T14:57:21.172500Z

Looks like it would be wise to go back to ol' fashioned jvm

zendevil 2021-01-26T15:39:36.172700Z

i don’t know what the websocket is

GGfpc 2021-01-26T19:22:53.173700Z

How can I start a repl that I can tap into with (shadow/repl) but without reloading the server on every change?

GGfpc 2021-01-26T19:23:26.174300Z

I want to write some code in the repl but don't want to lose state on every change

Malik Kennedy 2021-01-27T17:12:44.198600Z

def's get re-evaluated and overwritten, running shadow-cljs watch , if I have state that I don't want to get re-initialized and re at the def form, there's defonce .

GGfpc 2021-01-26T19:24:03.174900Z

I tried the browser repl but I can't connect via Cursive because it returns this error

(shadow/repl :app)
Execution error (ExceptionInfo) at shadow.cljs.devtools.server.nrepl-impl/repl-init (nrepl_impl.clj:28).
watch for build not running

2021-01-26T19:28:43.175Z

“watch for build not running”. Have you tried (shadow/watch :app) first?

thheller 2021-01-26T19:30:16.175300Z

> ... but don't want to lose state on every change

thheller 2021-01-26T19:31:16.176500Z

that is your code losing the state. you can fix that. you can also run (shadow/watch :app {:autobuild false}) so it doesn't automatically recompile if thats what you are asking

thheller 2021-01-26T19:32:36.176800Z

also just (shadow/node-repl) is usually good enough if you just want a repl