Fork me on GitHub
#shadow-cljs
<
2021-11-24
>
mauricio.szabo04:11:04

Hi - is there a way for shadow-cljs to produce import ... instead of require ... in the resulting JS? The reason for that is that I have to interface with some libs that only use import in node.js, and I would like to not have to use an external bundler (to not loose the power of the REPL for development, for example)

thheller07:11:30

@hoertlehner deps.cljs files just need to be on the classpath, it doesn't matter whether thats in a jar or just a directory. combining them when building a jar is something you need to do as a jar can only contain one

henryw37409:11:35

I'm trying to use https://github.com/JedWatson/react-select in a build and shadow is complaining that the required dependency "process" is not available There is no declared dependency on process but I can see in the code there is if (typeof process !== 'undefined' so it's basically doing a polyfill. I can see why shadow has flagged it, but is there any opt to get shadow to let this kind of thing through?

thheller09:11:32

@henryw374 I'm guessing you don't have shadow-cljs npm package installed in the project. which means you are also missing the polyfills that provides. basically just npm install shadow-cljs

henryw37409:11:17

I don't. will try adding that now.

henryw37410:11:35

installing that worked, thanks @thheller. I can add shadow-cljs to my deps.cljs file, but that necessarily means putting the required shadow-cljs version there and also in deps.edn for the shadow-cljs maven lib.

thheller16:11:29

I don't understand. this is about polyfills so you should most definitely never add shadow-cljs to your deps.cljs file?

henryw37417:11:12

to work around the original problem I needed the npm shadow-cljs package. currently my deps.edn file has shadow mvn dep in it, so then if I'm also adding npm shadow, I need to ensure its version matches the mvn version

henryw37417:11:01

to get the shadow-cljs npm dep I add it to my project's deps.cljs file, but that's just my preference rather than just putting it in package.json

thheller17:11:59

you MUST have it in package.json as well as you MUST keep your package-lock.json in version control. not doing this is NOT an option in the JS world, unless you like pain of course

thheller17:11:37

if you really must put this in deps.cljs then put node-libs-browser there, not shadow-cljs

henryw37417:11:32

sure, it ends up in package.json anyway and they get committed. but at least in deps.cljs i can have comments etc. ok thanks i will try that lib instead

thheller17:11:34

yeah I'm just saying that due to the extensive use of version ranges in the npm world you really must keep a lock file and therefore maintain a package.json as well

thheller17:11:52

otherwise you basically get random results when installing stuff which is never good

henryw37417:11:39

yeah I get it - we do check in lock file as well. thanks

thheller17:11:39

I know a few people that tried to use npm as if it didn't exist and ignored package.json and lockfiles and so on

thheller17:11:49

I don't know a single one that didn't end up regretting that 😛

roman01la12:11:24

👋 Is it possible to trigger shadow’s heads up view to display an error message thrown during macro expansion time?

Stephen Wiseman16:11:02

It it possible to still use leiningen, but defer to shadow to manage cljs build + dependencies? Our current dev workflow is to start a repl using lein, then leverage component lifecycles to start/stop the different components of the app (both backend and frontend components). For the front-end component, we call the shadow api to start a shadow server and a shadow watch. The subsequent build always seems to use the lein dependencies. In contrast, if I test by simply starting a watch using the shadow cli, it will use the dependencies in shadow-cljs.edn, which is what I’m going for.

thheller16:11:59

@roman01la I don't understand the question. they should already show up?

roman01la18:11:24

hm, not really, for me assertion errors are not showing up, instead shadow’s hot reload icon keeps spinning in a browser, but the error is indeed printed in the terminal

roman01la18:11:37

on the other hand NPEs are showing up

roman01la18:11:42

could be a bug?

thheller19:11:38

what kind of assertion errors? just assert?

thheller19:11:06

shows up as expected for me

roman01la22:11:42

hm, could be something with my setup then

thheller16:11:23

@swiseman108 dependencies are managed when starting the JVM since they are JVM dependencies. so however you started the JVM will decide which dependencies shadow-cljs sees. so I guess the answer is no?

Stephen Wiseman19:11:13

Thanks. I was thinking this was the case. Thanks again for bearing with me and my questions!