Fork me on GitHub

i have this INFO warning with one module, i haven't noticed issues in my app so far but what could be the consequences of such an "invalid-required"

node: v11.13.0
shadow-cljs - server version: 2.8.51 running at 
shadow-cljs - nREPL server started on port 52448
[2020-03-24 11:42:40.454 - INFO] - {:resource-name "node_modules/eth-lib/lib/bytes.js", :requires [{:line 9, :column 193}]}


typically thats some kind of dynamic require in JS, so that would always fail


got it, dynamic require, interesting line in that library 😅

if (typeof window !== "undefined" && window.crypto && window.crypto.getRandomValues) rnd = window.crypto.getRandomValues(new Uint8Array(bytes));else if (typeof require !== "undefined") rnd = require("c" + "rypto").randomBytes(bytes);else throw "Safe random numbers not available.";


yeah thats specifically to stop bundlers from bundling the crypto package since dynamic requires are still pretty much an unsolved problem


make sense - thanks!

Ben Hammond14:03:35

I have a cljs/React front end that I have been hosting with the shadow-cljs :dev-http I have a clojure backend running on pedestal/jetty I am now at the point where I would like to establish a websocket connection between the two; Ideally I would like to serve the front-end from Pedestal server AND connect a shadow-cljs repl to this session; When I serve the html pages from pedestal however, I cannot get the cljs repl started; I get > No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code. I can see that shadow-cljs :run-dev somehow injects

into the webpage and I can see that Pedestal server does not do this and I presume that this is why it does not make a repl connection; Where does this repl websocket get injected? How can I get Pedestal server to do the same thing?


@ben.hammond you don't need to configure pedestal in any way. the websocket connection is made to the shadow-cljs server which is completely separate


this also has nothing to do with :dev-http. that is strictly serving static files only.

Ben Hammond14:03:11

oh so the REPL ws connection should be identical wherever the cljs files are server from


the .js files can be served by pedestal as they are just files


the websocket connection is made to the shadow-cljs server which is running on port 9630

👍 4
Ben Hammond14:03:27

ah right I see I see thanks!


Hope everyone is well. I’m working with Higcharts using and things are going fine until I want to use the “Sankey” style chart ( This is provided in a separate JS file ( The Highchart fiddle just shows adding the sankey.js to your html and it works. Except it doesn’t since I’m using the npm package. I can’t figure out how to get the react component to find this extra code/module. I added the sankey.js to the html and even tried, but that package doesn’t seen to include Sankey. I keep getting “Error: Highcharts error #17: missingModuleFor: sankey” Has anyone figured out how to get this to work?


@wasser you probably can import it from the highcharts npm module. check if you can find a sankey file in node_modules/highcharts


dunno about the react parts though


Hi, I'm trying to use a node module on Shadow-CLJS, but it's not raising the error: '"module$node_modules$nrepl_client$src$nrepl_client is not defined"' The node module is nrepl-client, I'm trying to require it with ["nrepl-client" :as nrepl], shadow-cljs target is node-library


If I use js/require it works correctly


I’m having trouble with my production build (targeting the browser). When loading index.html in the browser I get an error in the JavaScript console: ReferenceError: Can't find variable foo where my init-function is foo.core/init . In development mode everything works find…


In shadow-cljs.edn I tried:

:modules    {:main {:init-fn foo.core/init}}
:modules    {:main {:entries [foo.core]}}
my index.html looks like this:
<html lang="en">
	<!-- ... -->
    <script src="/js/compiled/main.js"></script>
    <div id="app"></div>


… and in foo/core.cljs I have:


(defn ^:export init []


do you get any JS errors during load?


like any others I mean?


Yes, it happens during load…

TypeError: undefined is not an object (evaluating '$')
	iO — main.js:1126:113
	cN — main.js:1128:348
	(anonymous function) — main.js:1061:406
	(anonymous function) — main.js:1061:441
	Global Code — main.js:1800
ReferenceError: Can't find variable: foo
	Global Code — 
where `
where line 18 of index.html is:


Solved. I used the --debug option when compiling my production code and it turned out that there was some debug code using cljs.pprint/pprint without explicitly requiring it. So shadow-cljs release foo --debug did the trick and produced some useful output to the JavaScript console in the browser to track down the problem. Instead of (evaluating '$') in the logs above I got some hints to hat it was related to pprint

👍 4

@thheller I found a sankey.js file in node_modules/highcharts/modules so tried adding ‘[“highcharts/modules/sankey.js”]’ to the namespace, but I still get the “error 17, missing module for sankey”. Do I need to add the dependency somewhere else?


I have no idea sorry. maybe you need to initialize it somehow. highcharts probably has some docs for that?


Thanks anyway. Maybe someone else has stubbled into this and got it sorted.

David Pham21:03:22

Did you try to put the file somewhere else?

David Pham21:03:48

Like where you have your usual highcharts dependency?

David Pham21:03:14

What about removing the .js at the end of your import?


None of those (putting the js file someplace, adding it to the html, dropping the .js) worked - stil getting “Error 17”. I found another react lib to try which apparently includes the sankey stuff directly so I don’t get the “Error 17", but if fails in a different way: “undefined is not an object (evaluating ‘t.chart’)” Now I’m trying to get some source-maps, so I have a chance of figuring out what this issue really is (shadow-cljs noob).


the issue likely doesn't have anything to do with shadow-cljs. I suspect that you just have to initialize the sankey module somehow. I can't tell you how though. the highcharts docs probably mention it with an example for npm. that you'd just need to translate.


@thheller - right you are! pawing theough the docs for react-jsx-highcharts I found the all important call: [“highcharts/modules/sankey” :as addSankeyModule] ... (addSankeyModule Highcharts)

👍 4