shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
thheller 2020-10-25T07:37:39.119Z

@kevin842 no. the chances of that working are also extremely slim.

joshkh 2020-10-25T07:53:11.122300Z

i have a :node-library build, and i'm attaching a JS runtime by running node out/index.js . whenever an error is thrown in the REPL, say for example from node's http package, the NodeJS process quits and i have to go through the process of restarting/re-attaching everything. is there a way to avoid this?

thheller 2020-10-25T07:54:35.122900Z

> Warning: Using 'uncaughtException' correctly

thheller 2020-10-25T07:54:40.123100Z

is why it is not done by default

joshkh 2020-10-25T07:56:59.123800Z

> Attempting to resume normally after an uncaught exception can be similar to pulling out the power cord when upgrading a computer. Nine out of ten times, nothing happens. But the tenth time, the system becomes corrupted. i like this simile. thanks for pointing me to the docs.

thheller 2020-10-25T08:12:06.124400Z

btw if you just want a node-repl you can just use shadow-cljs node-repl. that manages the node process for you.

đź‘Ť 1
wombawomba 2020-10-25T14:26:24.128300Z

So I’m trying to include a JS react library in my CLJS project. Unfortunately the JS library includes a bunch of statements that import CSS files, which causes shadow-cljs to complain:

[:app] Compiling ...
[:app] Build failure:
Failed to inspect file
[;...]/foo.css

it was required from
[...]/foo.js

Errors encountered while trying to parse file
[...]/foo.css
  {:line 20, :column 1, :message "primary expression expected"}
Is there a way to get around this?

thheller 2020-10-25T14:27:10.128700Z

most likely the library expects to be bundled by webpack

thheller 2020-10-25T14:27:26.129100Z

if you can live without the css you can set :js-options {:ignore-asset-requires true} in your build config

wombawomba 2020-10-25T14:27:53.129600Z

Alright, I’ll try that as a first step 🙂 Thanks!

wombawomba 2020-10-25T15:05:43.132300Z

@thheller so the code compiles fine when I set :ignore-asset-requires. Unfortunately, it still won’t load in a browser, because the JS code contains statements like require('foo.css').use();. Maybe there’s some other way to get this working?

wombawomba 2020-10-25T15:09:04.132400Z

Like, perhaps I should be building the JS lib separately somehow instead?

wombawomba 2020-10-25T15:14:36.132600Z

…on second thought, I think I’ll just give up for now and run the whole thing from JS in an iframe instead. The library I’m trying to use is just too messy for me to be able to figure out how to call from CLJS.

wombawomba 2020-10-25T15:16:02.132800Z

I’d still be curious to hear if there’s a recommended workflow for building pesky JS libs separately though :)

wombawomba 2020-10-25T15:20:44.133Z

Alright, I found this which goes over what my options are: https://code.thheller.com/blog/shadow-cljs/2020/05/08/how-about-webpack-now.html

thheller 2020-10-25T15:20:58.133300Z

I don't know what kind of library you are using here. never heard of anything doing require('foo.css').use(); before

thheller 2020-10-25T15:21:27.133500Z

thats even uncommon for webpack

thheller 2020-10-25T15:24:21.134100Z

that looks like a standalone project and not a library you include?

wombawomba 2020-10-25T15:26:55.134300Z

Yeah pretty much. There’s some discussion on how to use it as a library here though: https://github.com/eclipse-theia/theia/issues/1045

wombawomba 2020-10-25T15:27:24.134700Z

So I wanted to give that a shot before moving on to other options