Fork me on GitHub
#shadow-cljs
<
2022-03-22
>
ingesol08:03:50

@thheller Right, thanks. I was just surprised that this was such an uncommon problem in the Node CLJS world. But I realized just now that we are probably requiring JS libraries that are mostly used in the browser, and that’s the bit that is uncommon.

thheller08:03:19

well it'll become more common once more packages are published as ESM only

thheller08:03:43

you can use :target :esm to generate ESM output which can consume those libs just fine

thheller08:03:02

but it may have other issues with commonjs in exchange 😛

pez08:03:51

When upgrading to latest shadow (from http://2.15.in a project, I get:

Syntax error compiling at (shadow/build/cljs_hacks.cljc:101:27).
No such var: ana/munge-goog-module-lib
What could be the culprit here? Even trying with 2.16.4 I get the same error.

pez09:03:57

A too old ClojureScript seems to have been the problem. This was then obscured by some of our sub projects depending on old versions of shadow-cljs. When I comment away those transitive deps, shadow suggested the ClojureScript dependency as a source of the problem. Which it was.

pez09:03:50

Now, I somehow suspect that the problem I was chasing (a lot of cider-nrepl ops unavailable) could have been caused by the transitive shadow-cljs dependencies. What's the recommended setup there? We have a lot of sub projects where we use shadow-cljs. Would excluding shadow-cljs when declaring the subproject dependencies in the main project help?

thheller10:03:54

the main project needs to declare its shadow-cljs dependency. that is pretty much the only thing you need.

thheller10:03:09

whether or not the sub projects do too should not matter then

thheller10:03:20

the project deps always win over any other

thheller10:03:52

just need to avoid the situation where you only have shadow-cljs declared but not clojurescript

thheller10:03:16

that way it can pick the new shadow-cljs but some old clojurescript somewhere out of the transitive deps if it doesn't find the one declared by shadow-cljs "first"

pez11:03:10

The main project is declaring its shadow-cljs dependency. Yet had a situation when a version from some sub project was used. Probably a misconfiguration, right?

pez11:03:04

With the original config it behaves like you say, main project wins. It was while fiddling around trying to understand that compile error that all of a sudden I saw yet another shadow version being used.

thheller17:03:35

hard to comment without knowing your particular setup. you can make pretty much everything happen if you want 😛

pez20:03:55

Yeah, sorry for rambling. I'm trying to digest the info you provided. 😃

chromalchemy12:03:43

I am having trouble getting cljs-devtools loading on a :target npm-module build. I tried different flavors of manual install, but nothing working. Any tips?

{:source-paths ["src"]
 :dependencies
   [[binaryage/devtools "1.0.5"]]

 :builds
   {:code
    {:target :npm-module
     :output-dir  "node_modules/shadow-cljs"
     :entries [gbo.mycljs]}}}
(ns gbo.mycljs
  (:require [devtools.core :as devtools])

(defn installCljsDevtools []
  (devtools/install!))
app.js
var clj = require("shadow-cljs/gbo.mycljs");
clj.installCljsDevtools();
I tried calling the devtools/install! from the html in a different script tag, but was unable to call it as a second namespace, exposed in the global html context. The resulting js is run through (an older) webpack build, could that be the issue? My dev server has to run on node 12.6. But i compile shadow-cljs with latest node, and other functions seem to run ok.

chromalchemy13:03:49

I reset my devtools to defualts, and now something is showing up. I am getting this even if I try to run with :optimizations :none

:builds
   {:code
    {:target :npm-module
     :output-dir  "node_modules/shadow-cljs"
     :entries [gbo.mycljs]
     :compiler-options {:optimizations :whitespace}}}

chromalchemy13:03:12

Maybe I need an explict :devtools config with things like

:watch-dir
:watch-path 
:before-load-async 
:after-load

chromalchemy13:03:51

I am not using the shadow-cljs server. I am running of a webpack build/reload codepase and using :npm-module to integrate cljs. But i am open to other suggestions. (Like is it easier to just use another build target?) I prefer to not disrupt the existing js codebase, just add some functions to it.

thheller17:03:55

you don't need any additional config for cljs-devtools but its kinda hard to tell what might be wrong without seeing the JS side of things

thheller17:03:10

webpack might be doing all sorts of stuff to the code

thheller17:03:40

maybe try including shadow-cljs watch or compile output. not release output?

Dmytro Bunin19:03:10

I am not sure if this question should go here or clojurescript but oh well. I have code like this

(fn [row-data]
  (. row-data -field))
And this function something on dev build but returns undefined in the release build. My guess is there is something going on in the optimization (obviously). I am curious why it breaks and how to make sure that it works consistently?

thheller19:03:17

do you not get inference warnings for this?

thheller19:03:44

but yes. this is an externs issue. can be fixed by using (fn [^js row-data] ...)

thheller19:03:03

you really should be getting a warning for this. unless you are on a really really old shadow-cljs version, or decided to ignore the warnings or turn them off 😛

Dmytro Bunin19:03:54

Oh, right, thanks!

Dmytro Bunin19:03:23

interesting why I’m not getting a warning :thinking_face:

thheller19:03:46

which shadow-cljs version do you use? in older versions this wasn't enabled be default

Dmytro Bunin20:03:44

thheller/shadow-cljs {:mvn/version "2.9.10"}

thheller20:03:01

yeah thats really old. wasn't enabled be default back then

Dmytro Bunin20:03:23

I will consider updating then 🙂 Thank you

thheller20:03:28

you can just enabled it. the link above tells you how

thheller20:03:46

but yeah upgrade works too 😉

genRaiy20:03:46

just checking something ... I'm trying to load my app using shadow and tools.deps - but I only seem to ever get the dashboard

genRaiy20:03:28

I read that clj does not support server-mode - so does that mean that I can't have the app served by shadow in this configuration?

genRaiy20:03:52

from the local file system I mean

thheller20:03:23

uhm the dashboard is served on its own server that has nothing to do with your apps code. that is a separate thing.

thheller20:03:39

has nothing to do with deps.edn or clj

thheller20:03:19

the dashboard runs on :9630 by default. for your app you can use :dev-http or any other webserver you want. https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http

genRaiy20:03:03

I tried the :dev-http but didn't get anywhere ... I'll RTFM again 🙂

genRaiy20:03:32

Ah - it's a top level keyword ... I had it in the :build

scarytom22:03:43

I have symlinked my node_modules directory somewhere outside my project (so that i can cache between runs in CI) and whilst npm is fine with this, shadow-cljs appears unhappy. I get

internal/modules/cjs/loader.js:818
  throw err;
  ^

Error: Cannot find module 'readline-sync'
is that a known issue?

thheller05:03:40

that is an error from node. not shadow-cljs.

scarytom15:03:21

fair point. I guess I have jumped to conclusions, but I was under the impression that npm was fine with a symlinked node_modules dir