Fork me on GitHub
#shadow-cljs
<
2019-07-16
>
Scot03:07:03

Hey, I noticed that cuerdas doesn't work with shadow-cljs. Cuerdas bundles xregexp.js as a resource, but shadow-cljs seems to be messing with it. Running npm install xregexp doesn't help, it then gives another error:

The required JS dependency "core-js/library/fn/array/is-array" is not available, it was required by "node_modules/@babel/runtime-corejs2/core-js/array/is-array.js".

Searched in:<my-project>/node_modules

You probably need to run:
  npm install core-js/library/fn/array/is-array
Neither this instruction, nor npm install core-js help. Has anyone else had success using cuerdas "2.2.0" on the client with shadow-cljs?

stefan13:07:09

Does npm install core-js@^2 work?

thheller15:07:21

core-js unfortunately has a bunch of incompatible versions

thheller15:07:17

it should be working normally but you might just have some version conflicts

ag07:07:31

Can someone explain how to use shadow with CIDER? I was able to get an absolute minimum with shadow-cljs.edn and a single :dev build targeted for :node-script, it works when I do shadow-cljs watch dev in one terminal window and node target/app.js in the other, but I just want to CIDER-jack-in. When I jack-in-cljs: - it first prompts me with the type of REPL, to which I say “shadow”, there’s also “shadow-select”, which I believe is the same thing. - then it prompts me again for a build, I choose :dev, - then it prompts me for the third time, asking if I want to launch a browser (wtf?). Anyway, it kinda works, but what bothers me - it doesn’t print anything, anywhere (unlike when I run the app like above). My :devtools {:after-load function, I can’t tell if it’s firing or not. I tried setting (enable-console-print!) and (node/enable-util-print!) - it’s not printing

ag07:07:05

I also tried setting up deps.edn with shadow-cljs - and failed at that as well. Anyway - my end goal is to run Puppeteer scripts, I believe I have to use :target :node-script for that. But why it’s not printing anything? prn doesn’t appear to be working, neither js/console.log. It’s not complaining, there’s simply no output anywhere

ag07:07:02

I probably can figure out how to set some elisp vars in .dir-locals.el so it doesn’t bother me with those silly prompts, but I can’t figure out how to print

thheller10:07:59

@ag I can't help with the cider side of things since I don't use it. as for the shadow-cljs side of things you should NEVER call any of the enable-print methods since that messes with the print methods shadow-cljs already sets up

thheller10:07:22

the print output is currently only available in the process in the launched node process

deadghost14:07:39

@ag https://www.blog.nodrama.io/shadow-cljs-cider/ I followed that and it seemed to be working ok (for browser target)

lilactown15:07:28

@ag when it prompts for the build, type dev not :dev

lilactown15:07:12

it prompts you to open a browser because most people are using CLJS in the browser.

lilactown15:07:34

you also still must run the node process in a terminal

lilactown15:07:11

@ag so the full steps should be: 1. Run cider-jack-in-clojurescript 2. Select shadow 3. Choose dev 4. Press n to not open a browser Once the build has completed once, in a terminal run the command: node target/app.js and you should see your console.log println etc. show up in the Node process terminal

Daw-Ran Liou22:07:25

Can dev http server redirect not just to index.html but also other files? Currently I have the below files under the public folder. There are both static pages (`index.html`, log-in.html, and sign-up.html) and my single page app (`app/index.html`). I want the single page app to handle all the routing under the path /app/*, for example /app/profile. However, when loading /app/profile, the dev server falls back to public/index.html. Any suggestion is welcome.

public/index.html
public/log-in.html
public/sign-up.html
public/app/index.html

alpox22:07:31

@dawranliou I didn't check it locally but did you try to set multiple roots?:

alpox22:07:11

I'd imagine the roots to be setup as ["public/app" "app"]

Daw-Ran Liou23:07:55

Thanks. I just gave it a try but it didn’t work because path /app/profile does not match any file under those two roots, and thus the default handler was called.

Daw-Ran Liou23:07:33

But I think you gave me a direction. The :push-state/index key might be the one I am looking for.

alpox23:07:34

Ah good. I hope it will work out with it.

Daw-Ran Liou23:07:58

This might not be exactly what I want but hope it’ll work. The right way to do it might be to write a custom handler:

Daw-Ran Liou23:07:20

Thanks again for helping out @alpox 🙂

alpox23:07:39

@dawranliou No problem. I'm sure you'll figure out something that works for you 🙂