shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
Mr. Savy 2020-09-11T04:32:46.229200Z

has anyone dealt with a stale client? I'm not sure why it decided to start doing this. I've tried restarting everything.

2020-09-11T05:04:54.229700Z

@ajsnow2012 usually this means the browser has an old version

2020-09-11T05:05:14.230200Z

are you sure the cache of your browser is disabled?

2020-09-11T05:05:43.230800Z

i.e. devtools > network tab > disabled cache ticked (don't worry, it will only be disabled while, devtools are open)

Mr. Savy 2020-09-12T18:45:59.279600Z

I will try this, thanks!

Misha Bohdan 2020-09-11T07:39:16.236200Z

Hello! I'm new to cljs and trying to start a clean project from re-frame-template. I'm constantly getting the same error while jack-in: websocket.cljs:12 WebSocket connection to '<ws://127.0.0.1:9630/api/remote-relay?server-token=1f29b682-7f54-413e-84da-7388b53919df>' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED . How can I solve it? REPL is not working too in VS Code, but for Clojure (not a script one) it's working fine. Tried both Chromium and Firefox.

thheller 2020-09-11T08:23:54.238100Z

@ajsnow2012 did you maybe change your :output-dir or :modules {:main ...} to :modules {:app ...} or so? anything that affects where the output goes basically but did not update your HTML to load that code and instead still load the old stuff?

2020-09-11T08:24:12.238600Z

Anyone using shadow-cljs with Cursive on Windows?

thheller 2020-09-11T08:24:38.239200Z

@bohdan.mikhail looks like shadow-cljs isn't running? or running on a different port but not having compiled yet?

👍 1
thheller 2020-09-11T08:24:46.239500Z

@info902 I am 😉

2020-09-11T08:26:01.241600Z

Ok then there is hope for me. I couldn’t get it working yesterday. But that are some of my first steps in ClojureScript anyway , before only Clojure

Misha Bohdan 2020-09-11T08:26:37.242900Z

@thheller VSCode says that all should works fine, according to logs

shadow-cljs - HTTP server available at <http://localhost:8280>
shadow-cljs - server version: 2.11.0 running at <http://localhost:9630>
shadow-cljs - nREPL server started on port 8777

2020-09-11T08:26:42.243100Z

I tried to get @jacek.schae project working in Cursive

Misha Bohdan 2020-09-11T08:28:23.244Z

Can it be caused by running under WSL?

2020-09-11T08:29:23.246500Z

I use WSL2 but since today I do all coding directly in Windows

2020-09-11T08:29:26.246600Z

Anyone have any insight about what the correct value for :asset-path is for a :bootstrap build is? If I try to do advanced compilation, I get errors about goog not found from the bootstrap stuff in particular.

thheller 2020-09-11T08:29:28.246700Z

@bohdan.mikhail if you run under WSL2 then you must use the IP of that virtual machine to connect since it is not running under localhost anymore

thheller 2020-09-11T08:30:07.247600Z

(or forward the port from windows)

2020-09-11T08:30:11.247800Z

Sorry mixed up with your discussion 😆

2020-09-11T08:31:07.248300Z

(maybe :advanced doesn't work with bootstrap, who knows?)

thheller 2020-09-11T08:31:10.248400Z

@pmooser :bootstrap does not have that setting at all. :advanced is not compatible with bootstrap, must use :simple

2020-09-11T08:31:57.249400Z

Ok, thanks. I will give it a try. Does that mean both of my builds have to be :simple ? (ie both the app and bootstrap builds)

thheller 2020-09-11T08:32:04.249600Z

yes

2020-09-11T08:32:35.250Z

That appears not to work at all for me, but thanks for the info.

thheller 2020-09-11T08:34:53.251300Z

@info902 whats your issue then? most of the time I run my stuff directly under windows, sometimes under WSL1. WSL2 is kinda annoying because of the IP but easy enough if you just use a hostname for that machine vs an IP

2020-09-11T08:37:50.256300Z

Well I opened the ReFrame Pro project in IntelliJ and as its a Shadow-cljs project / no Leiningen .... I couldn’t get the repl connected to the started project . I tried all kind of things to get the Cursive repl working. Calva worked fine

Misha Bohdan 2020-09-11T08:38:13.256700Z

@thheller it's a little bit confusing, because the web page opens like it's at the localhost but a ws connection should be port-forwarded. Don't they work in the same manner?

Misha Bohdan 2020-09-12T19:33:45.280900Z

I found that the VS Code or maybe Windows itself performing port forwarding on opening link step (clicking to it in the editor) because typing in the browser is not working without explicit forwarding

2020-09-11T08:38:39.257800Z

Must be a beginner problem 😐

2020-09-11T08:39:03.258400Z

@thheller Is the fact that :advanced doesn't work with :bootstrap a shadow-cljs limitation, or a fundamental self-hosted cljs limitation?

thheller 2020-09-11T08:45:05.258800Z

fundamental, it cannot work ever anywhere.

thheller 2020-09-11T08:46:35.259500Z

@info902 well what DID you try? do you have a hardcoded :nrepl {:port 9000} or so in your shadow-cljs.edn?

thheller 2020-09-11T08:50:06.259700Z

also see https://shadow-cljs.github.io/docs/UsersGuide.html#_cursive

2020-09-11T08:54:35.261100Z

@thheller Ok, I'm trying to use :simple for both my :app and :bootstrap targets ... and when I try to load the page, I get some shadow-cljs logs that say "failed to load 8" "failed to load 16" and "failed to load 23" each of those is a jsRequire call of some sort ... can you provide any hints about debugging what might be causing this?

2020-09-11T09:00:14.262Z

Yeap / :nrepl {:port 333} and npm run dev starts up

2020-09-11T09:02:00.263400Z

Damn, I just deleted the whole .idea project and recreated it new. This time directly with the pom.xml

2020-09-11T09:02:18.263900Z

Looks better now with Cursive

thheller 2020-09-11T09:17:53.264Z

hmm how do you access the webpage?

mauricio.szabo 2020-09-11T12:45:06.265200Z

Hi, I'm having some trouble with some node.js requires, when I require then using :js-provider :shadow (requiring then on the ns form). For example, jsdom have the following code somewhere:

exports.Canvas = null;
let canvasInstalled = false;
try {
  require.resolve("canvas");
  canvasInstalled = true;
} catch (e) {
  // canvas is not installed
}
if (canvasInstalled) {
  const Canvas = require("canvas");
  if (typeof Canvas.createCanvas === "function") {
    // In browserify, the require will succeed but return an empty object
    exports.Canvas = Canvas;
  }
}

mauricio.szabo 2020-09-11T12:45:46.266100Z

This makes shadow-cljs expects to have canvas installed. Is there a workaround, or should I use the default :js-provider and use something else to bundle my js file?

thheller 2020-09-11T12:53:40.266300Z

this pattern isn't supported (ie. require.resolve)

thheller 2020-09-11T12:54:40.266900Z

you can set :js-options {:resolve {"canvas" false}} so it won't bundle it

thheller 2020-09-11T12:55:16.267400Z

that might kind of work but is rather horrid thing to do

Alexis Vincent 2020-09-11T14:56:57.268600Z

@thheller Hi there, I’m trying to get either npm-module or :esm to pop me a repl in the browser. Cljs being imported from javascript in nextjs. Want a way to use cljs libs from nextjs applications.

Alexis Vincent 2020-09-11T14:57:38.269400Z

But neither is connecting back to the shadow watcher

Alexis Vincent 2020-09-11T14:58:35.269700Z

Do they support repl in the browser?

thheller 2020-09-11T15:04:47.270400Z

don't use :esm when embedding into other targets. thats needs a lot more work before that becomes practical.

Alexis Vincent 2020-09-11T15:05:14.271300Z

Would you suggest using :browser?

thheller 2020-09-11T15:05:15.271400Z

:npm-module should work fine *BUT* you need to ensure the REPL ns is loaded from JS

Alexis Vincent 2020-09-11T15:05:30.271900Z

right, which ns is this?

thheller 2020-09-11T15:05:39.272200Z

so wherever you do (require "./cljs/whatever.your.ns")

thheller 2020-09-11T15:05:58.272800Z

the ns is shadow.cljs.devtools.client.browser

thheller 2020-09-11T15:06:22.273400Z

you can if if (process.env.NODE_ENV === "development") { require ... } in the JS

thheller 2020-09-11T15:06:31.273900Z

don't know what your JS looks like

Alexis Vincent 2020-09-11T15:06:36.274Z

cool. So in dev, load shadow.cljs.devtools.client.browser

Alexis Vincent 2020-09-11T15:06:38.274200Z

perfect

Alexis Vincent 2020-09-11T15:06:42.274400Z

got you

Alexis Vincent 2020-09-11T15:07:39.275500Z

Would be interesting to have a discussion about esm sometime. I have a large interest in getting seamless TS and cljs interop. But don’t always control the bundling experience

Alexis Vincent 2020-09-11T15:09:20.277200Z

What are the options for shipping cljs core in an npm package, and then having cljs compile in place (same directory), but with a require on cljs? Not sure if I made sense here.

Alexis Vincent 2020-09-11T15:09:47.277400Z

Thanks for the help!

thheller 2020-09-11T15:11:39.278100Z

cljs.core as npm package to be included in other CLJS builds is pretty much a no go

thheller 2020-09-11T15:11:49.278400Z

or rather not something I'm interested in working on or supporting

thheller 2020-09-11T15:11:59.278700Z

just goes completely against what :advanced is supposed to do