This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-12-05
Channels
- # adventofcode (246)
- # aleph (5)
- # aws (7)
- # beginners (161)
- # boot (3)
- # calva (42)
- # cider (40)
- # clara (10)
- # cljdoc (7)
- # cljs-dev (40)
- # cljsrn (6)
- # clojure (170)
- # clojure-dev (8)
- # clojure-greece (2)
- # clojure-italy (15)
- # clojure-kc (2)
- # clojure-new-zealand (13)
- # clojure-nl (13)
- # clojure-russia (3)
- # clojure-spec (5)
- # clojure-uk (160)
- # clojurescript (72)
- # clojurex (1)
- # cursive (7)
- # data-science (9)
- # datascript (1)
- # datomic (120)
- # devcards (4)
- # emacs (18)
- # figwheel-main (10)
- # fulcro (34)
- # kaocha (3)
- # luminus (1)
- # lumo (6)
- # music (1)
- # nrepl (23)
- # off-topic (2)
- # pedestal (4)
- # re-frame (42)
- # reagent (36)
- # reitit (10)
- # ring-swagger (21)
- # shadow-cljs (124)
- # spacemacs (6)
- # tools-deps (14)
- # unrepl (3)
- # vim (2)
so before going all the way in depth on this I would like to get an opinion. I was a shadow-cljs.edn
with:
:release {:compiler-options {:optimizations :simple
:variable-renaming :off
:property-renaming :off
:pretty-print true
:elide-asserts false
:source-map true}
:autorun false}
it used to test some spec
(= {:problems
[{:path []
:pred 'cljs.core/keyword?
:val {:foo :bar}
:via []
:in []}]
:value {:foo :bar}
::error2/id :this-is-an-error-id}
(ex-data (error2/spec-ex-info :this-is-an-error-id spec body)))
So this is basically the original spec, sorry if messy. keyword?
is the spec (predicate only) and {:foo :bar}
the value. I will try to repro in core as well
the problem is, witch shadow-cljs watch
the above passes
with the :release
config above it does not
(not
(= {:problems
[{:path [], :pred cljs.core/keyword?, :val {:foo :bar}, :via [], :in []}],
:value {:foo :bar},
:laputa.tools.error2/id :this-is-an-error-id}
{:laputa.tools.error2/id :this-is-an-error-id,
:value {:foo :bar},
:problems [{:path [],
:pred :cljs.spec.alpha/unknown,
:val {:foo :bar},
:via [],
:in []}]}))
the problem above is in the :pred
, which is :cljs.spec.alpha/unknown
in :release
does it sound a thing worth an issue in shadow? or core?
@richiardiandrea spec
+ body
is missing from the code above so I can't say.
Sorry if messy. keyword?
is the spec (predicate only) and {:foo :bar}
the value. I will try to repro in core as well then
Would shadow be a good choice for writing a wrapper for a react based component framework?
@escherize I assume you mean writing a CLJS wrapper? for that you don't need a compiler at all since CLJS libraries are just uncompiled .cljs files
so you can use whatever. that being said shadow-cljs does not currently support publishing libs so you'd need lein or something else anyways đ
the challenge you'll face however is writing the library in a way that CLJS can access it
one of which is react - Not sure how to do the bundling / packaging of the libraries.
but it is probably going to require some tweaks for the other build tools since npm access is limited
@thheller is there some way I can run my npm module library such that the cljs repl can be used? I now tried starting a the simple demo http server code from the user guide (the node hot-reload section). I can start the server and browse to it, but shadow-cljs still doesnât count that as an app has connected.
I guess my question is: how would you do to be able to use the REPL with the npm module code, while developing it?
I asked that a couple days back, but haven't got the chance to test the proposed workaround
Like, you want shadow to rebuild every time node_modules changes?
Is it for running in node
or the browser
?
@clashthebunny Assuming you are asking me. đ I have some code Iâd like to share between some VS Code extensions and am repackaging that code as an NPM module. VS Code is built on Electron, so it is node
.
Today that code is built using target :node-library
and connects to the REPL when the extension starts. But this repackaging is really totally independent on VS Code or anything but node. And I canât figure out how to get it connected to the REPL.
You could check what party repl is doing: https://github.com/party-repl/clojure-party-repl#development
I'm doing the same with Chlorine, my package for Atom, with Shadow-CLJS too
They are developing an atom plugin with shadow-cljs.
@pez in your build config try :runtime :node
and then loading require("./path-to-output/shadow.cljs.devtools.client.node")
I just tried that, actually. Ran into the problems I had last time I tried to build with the :npm-module
target.
Lots of complaints when requiring the client. Then no eval. Which I tried to fix using this:
global["SHADOW_NODE_EVAL"] = function (js, smJson) {
if (smJson) {
js += "\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,";
js += Buffer.from(smJson).toString('base64');
}
//console.log(js);
return eval(js);
};
as always you could just use node-repl
outside all of this to work on the CLJS side of things
The complaints: It starts here:
var shadow = require('./calva_lib/shadow.cljs.devtools.client.node')
undefined
> failed to parse websocket message {:type :repl/init, :repl-state ...
There was, I was about to paste that too.
ReferenceError: SHADOW_IMPORTED is not defined
at Object.shadow$cljs$devtools$client$node$is_loaded_QMARK_ [as is_loaded_QMARK_] (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:64:24)
at Object.shadow$cljs$devtools$client$node$repl_init [as repl_init] (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:137:40)
at shadow$cljs$devtools$client$node$process_message (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:478:41)
at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.env.js:274:102)
at WebSocket.<anonymous> (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:535:44)
at WebSocket.emit (events.js:182:13)
at WebSocket.EventEmitter.emit (domain.js:460:23)
at Receiver._receiver.onmessage (/Users/pez/Projects/calva-lib/node_modules/ws/lib/WebSocket.js:141:47)
at Receiver.dataMessage (/Users/pez/Projects/calva-lib/node_modules/ws/lib/Receiver.js:389:14)
at Receiver.getData (/Users/pez/Projects/calva-lib/node_modules/ws/lib/Receiver.js:330:12)
https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/node.cljs
change this part https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/devtools/client/node.cljs#L29 to js/global.SHADOW_IMPORTED
it is connected to the shadow-cljs server using the node ws
module. so you are in node.
I restarted the node process after having replaced the is-loaded?
function and then I could require the client w/o complaints.
Getting the SHADOW_NODE_EVAL reference error still. âInstallingâ it per that code I pasted earlier gives some eval power back.
But trying to eval any of my code I get:
ReferenceError: calva is not defined
at eval (eval at global.SHADOW_NODE_EVAL (repl:7:16), <anonymous>:1:22)
at eval (eval at global.SHADOW_NODE_EVAL (repl:7:16), <anonymous>:4:3)
at global.SHADOW_NODE_EVAL (repl:7:16)
at Object.shadow$cljs$devtools$client$node$node_eval [as node_eval] (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:60:14)
at /Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:177:41
at Object.shadow$cljs$devtools$client$env$repl_call [as repl_call] (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.env.js:154:108)
at Object.shadow$cljs$devtools$client$node$repl_invoke [as repl_invoke] (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:175:92)
at shadow$cljs$devtools$client$node$process_message (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:482:41)
at Object.shadow$cljs$devtools$client$env$process_ws_msg [as process_ws_msg] (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.env.js:274:102)
at WebSocket.<anonymous> (/Users/pez/Projects/calva-lib/packages/calva_lib/shadow.cljs.devtools.client.node.js:535:44)
Yes, I probably am⊠Let me think about what is going on. I am really just executing node
inside the packages
folder and then requiring the node client like so: require('./calva_lib/shadow.cljs.devtools.client.node')
No, I have choosen to keep all that vscode stuff in TS. And building a library that only deals with data in CLJS. That is what I am trying to package as a npm module.
Cool. Iâll push this experiment to github so it is easier to look at what the heck it is I am doing.
Everything about this is new to me. Electron, VS Code. Node. CLJS. The list goes on. đ
Iâm not sure where electron enters the picture, but you seem to have doubts regardless?
there is no point in getting the node-repl to work in npm-module when you can just use shadow-cljs node-repl
instead?
oh yeah if you have the changed node.cljs
still in your sources thats now gonna break stuff
if you are connected to the CLJ nrepl part you simply call (shadow.cljs.devtools.api/node-repl)
Awesome. Iâll have to hack Calva to support this, then can continue to hack on Calva using it. đ
I checked the user guide and it says there are no builds involved using this repl. There are big chunks of shadow-cljs knowledge missing for me. I donât really understand what is different with this repl and the other one.
other REPLs runs as part of your build while your build is doing its thing, eg. rendering something using react when the page loads
node-repl is just a simple node-repl that doesn't do anything on its own until you tell it to do something