Fork me on GitHub
#shadow-cljs
<
2022-01-05
>
kennytilton00:01:00

I am trying to figure out why a dependency did not get pulled into a shadow build. I am weak on CLJS builds I will confess. FWIW, I started from the coolio Helix todo-mvc project: https://github.com/lilactown/helix-todo-mvc, That just does npm i and npm start to get things running: { "private": true, "scripts": { "start": "npx shadow-cljs watch app" <===================== }, "dependencies": { "react": "^16.13.1", "react-dom": "^16.13.1", "react-refresh": "^0.8.1", "react-router-dom": "^5.1.2", "react-slider": "^1.3.1", "shadow-cljs": "^2.8.94", "todomvc-app-css": "^2.4.1", "todomvc-common": "^1.0.5" } } My deps.edn is

{:paths ["src" "src/demo" "src/mxreact"]
 :deps {lilactown/helix {:mvn/version "0.1.1"}
        binaryage/devtools {:mvn/version "0.9.7"}
        thheller/shadow-cljs {:mvn/version "2.15.1"}
        tiltontec/matrix {:mvn/version "4.1.7-SNAPSHOT"}
        cljs-http/cljs-http {:mvn/version "0.1.46"}}}
The dependency not retrieved by the build is Matrix. The build then complains about a Matrix namespace not being found. Inspection of .m2 confirms the deficit. If I execute clojure -P the dependency is pulled from Clojars and the build succeeds. Yay. My shadow-cljs.edn is :
;; shadow-cljs configuration
{:deps true
 :builds
 {:app {:target :browser
        :output-dir "js"
        :asset-path "/js"
        :modules {:app {:entries [app.core]}}
        :devtools {:http-root    "."
                   :http-port    8888
                   :reload-strategy :full
                   :preloads     [devtools.preload
                                  demo.dev]}}}}
My app.core NS is:
(ns app.core
  (:require
    [tiltontec.model.core :as md]
    [react]
    [mxreact.mxreact :as mxr]
    ["react-dom" :as rdom]
    [demo.demo :as dmo]
    ["react-slider" :default ReactSlider]
    [tutorial.x100-hello-world.lesson :as app]
    ))
Can anyone see why clojure -P was needed to get the dependency downloaded? Or is that just part of the drill when new dependencies are added? Thx! 🙏

thheller06:01:40

@hiskennyness shadow-cljs does not control what clojure does. if you set :deps true when running shadow-cljs watch app it will call clojure -M -m shadow.cljs.devtools.cli watch app and let clojure handle all dependency resolution and classpath creation. shadow-cljs will not attempt to download anything itself in that case. I do not know why it may not download something. In general I'd stay very far away from SNAPSHOT dependencies and instead use :local/root or :git/url if you can

thheller06:01:47

did you maybe not restart shadow-cljs after adding the dependency? modifying deps.edn does require a shadow-cljs restart. just leaving the watch running won't work.

coetry07:01:32

Good morning folks, I'm looking to set up a workflow where i have a shadow-cljs build running on a remote server and I connect to it from my local Emacs + Cider. Has anyone tried this?

Franklin09:01:45

hello đź‘‹ I'm getting this error while trying to import an npm package

shared.js:1552 TypeError: Super expression must either be null or a function, not undefined
    at eval (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:35)
    at eval (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:35)
    at Object.eval (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:44)
    at r (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:2)
    at Object.eval (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:32)
    at r (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:2)
    at eval (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:4)
    at eval (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:4)
    at eval (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:1)
    at Object.shadow$provide.module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min (module$node_modules$react_leaflet_vectorgrid$dist$react_leaflet_vectorgrid_min.js:2)
Here's how the import statement looks like ["react-leaflet-vectorgrid" :default VectorGrid]

Franklin09:01:13

here's how it's imported in JS `

import VectorGrid from 'react-leaflet-vectorgrid';
https://www.npmjs.com/package/react-leaflet-vectorgrid

thheller09:01:34

which react version do you use?

Franklin09:01:52

"react": "^17.0.2"

thheller09:01:18

sorry. dunno never seen that error before. might be something to do with transpilation/polyfills

Franklin09:01:28

cool, thanks

thheller09:01:34

try :compiler-options {:output-feature-set :es-next} in your build config

thheller09:01:02

might also be a dependency version conflict on something

thheller09:01:16

if you setup a reproducible repo I can take a look

đź‘Ť 1
witek10:01:59

Hello. How do I access a custom value provided in :compiler-options inside of (defmacro ...)? Say, I have {:compiler-options {:xyz "23"}}. What is the path to "23" in &env?

thheller10:01:37

@cljs.env/*compiler* :options is basically :compiler-options from your build config

kennytilton10:01:52

No, @thheller, I did not have a watch running. The npm start command indirectly starts a watch, but I control-c'ed it each time, once it announced the missing dependency. Yes, I have :deps true in my shadow-cljs.edn, I am surprised to hear SNAPSHOT is a bad idea. Is that not a standard part of the ecosystem? I have noticed they do not work as dynamically as is really needed for iterative devlopment.This could be a breakthru! 🙂 I never heard of :local/root or :git/url options. To what are those options? I'll look around. I will also see what the clojure CLI crew has to say about dependency resolution. Thx!

thheller10:01:07

both :local/root and :git/url are tools.deps options

🙏 1
thheller10:01:25

note that running npm start does not imply that there is not a previous running server

thheller10:01:44

eg. having it running twice in separate terminals for examples

kennytilton13:01:52

Yeah, I am always careful to run just one (and check there is just one if things seem broken). Thank god for terminal (on OS X anyway) putting a bullet next to any terminals with a running process.

thheller10:01:57

so make sure that on startup it doesn't say "connected to server"

đź‘Ť 1
thheller10:01:10

if it does that you do have an active server running

Chase21:01:46

I am getting a "required namespace is not available error" when starting up shadow-cljs. I created a project with a hyphen in it's name but then my main function is contact-book.core/main which I can't call in my index.html script because js does not allow hyphens. Am I understanding that correctly? Wherever my main function is should not have a hyphenated namespace or am I doing something else wrong?

thheller05:01:19

contact-book.core/main will become contact_book.core.main in JS

thheller05:01:16

define "required namespace is not available error". if you follow the rules everything should be fine. see https://code.thheller.com/blog/shadow-cljs/2021/05/13/paths-paths-paths.html

Ben Hammond21:01:03

Can 'dev-http' start up an https server? https://shadow-cljs.github.io/docs/UsersGuide.html#dev-http seems to imply that it is, but when I try

:dev-http {8081 "resources/public"
            8444 {:root "resources/public"
                  :ssl true}}
I just get two http endpoints I would expect to have to supply a jks keystore too...

Ben Hammond21:01:45

I would like a dev https server to get my head around some secure cookie stuff

Ben Hammond22:01:07

:dev-http {8081 {:root "resources/public"
                  :ssl-port 8444
                  :ssl true}}
doesn't seem to work either

Ben Hammond22:01:30

I am running

npx shadow-cljs watch foo
perhaps watch is not leveraging dev-http...?

lilactown23:01:37

it looks like you're missing the :ssl config in the top level? https://shadow-cljs.github.io/docs/UsersGuide.html#_ssl

đź‘Ť 1
lilactown23:01:00

:ssl true I don't see that documented anywhere in the user guide

thheller05:01:46

to get ssl you need to setup ssl globally as linked above

thheller05:01:30

there is really only :ssl false for :dev-http where you can opt out of ssl for specific servers

đź‘Ť 1