Fork me on GitHub

I am trying to use instaparse in a shadow-cljs project. I have the following in shadow-cljs.edn: :dependencies  [[instaparse "1.4.10"]] The instaparse-1.4.10.jar is present in the appropriate .m2 repository. But shadow-cljs is not finding it. What am I doing wrong?


Can you share the error that you're seeing?


I found the problem, thanks.

👍 1

it is not. cider-jack-in-clj&cljs attempts to use the same process to start two separate repls. This was possible with figwheel. Shadow is a separate process so you cannot start a single lein and then create two repls from it, one clj and one cljs

👌 1

hello, I'm relatively new to ClojureScript and I'm trying to set up tests for a ns that has a couple of functions. I'm using the recommended cljs.test setup from and I can run my tests fine from the REPL using cljs.test/run-tests. I also followed the instructions in but when I run shadow-cljs compile test on my terminal I get this exception:

shadow-cljs - connected to server
[:test] Compiling ...
NullPointerException: (node.clj:59) (node.clj:45) (node_script.clj:37)


looks like you don't have a :output-to configured in your build config?


The article at links to for a standalone example. But building the :bootstrap build with shadow-cljs 2.17.0 (where originally it was 2.11.7) fails with:

------ ERROR -------------------------------------------------------------------
 File: jar:file:/home/p-himik/.m2/repository/org/clojure/clojurescript/1.10.914/clojurescript-1.10.914.jar!/cljs/js.cljs:9:1
   6 | ;   the terms of this license.
   7 | ;   You must not remove this notice, or any other, from this software.
   8 | 
   9 | (ns cljs.js
The alias env is already used for namespace cljs.env.macros
  10 |   (:refer-clojure :exclude [require eval])
  11 |   (:require-macros [cljs.js :refer [dump-core]]
  12 |                    [cljs.env.macros :as env])
  13 |   (:require [clojure.string :as string]
Presumably because cljs/js.cljs has both [cljs.env.macros :as env] in its :require-macros and [cljs.env :as env] in its :require. Is there a way to fix this?


Huh, it actually works with 2.16.12 but breaks with 2.17.0.


uh yeah thats a bug

👍 1

I changed something in alias checks because of :as-alias

Joseph Winston18:02:10

Thanks for verifying the bug. I was chasing the same issue earlier.


hmm my check seems to be doing exactly what it is supposed to be doing? how is this ns form valid? it has env as alias for two different namespaces 😛


guess I have to relax that check a bit ...


should be fine in 2.17.1 again

🎉 1

Hi, any tips to debug this error?

shadow-cljs: reloading code but no :after-load hooks are configured! 


I do have the :after-load hook configured, and I can evaluate the function of the hook, but somehow nothing happens when I save a file. It's a :browser target, but with an Electron host


this is a warning not an error and you fix it exactly as linked above


where do you have :after-load configured? it is much easier to have ^:dev/after-load in the metadata of your code


code that needs to be included in the build naturally. so if you put it in some namespace that is not part of the build it won't trigger


I have in both metadata and in :devtools option. None worked


only one is needed


but as I said if the ns isn't included in the build they don't have any effect


is it included in the build?


needs to be required by something in the build (or added via :preloads)


This is the config:

{:target :browser
                 :output-dir "static"
                 :asset-path "."
                 :modules {:main {:init-fn cljs.atom.view/start!}}
                 :js-options {
                              :keep-native-requires true}
                              ;:js-provider :require}
                 :devtools {:before-load cljs.atom.view/start
                            :after-load cljs.atom.view/after-load}}


cljs.atom.view is in the config, and when I save the file, I see on Electron's console:

shadow-cljs: reloading code but no :after-load hooks are configured! 
browser.cljs:20 shadow-cljs: load JS cljs/atom/view.cljs


Both hooks point only to a (println "testing") for now...


they appear to be in the wrong order?


I mean it doesn't make sense to me triggering a start before loading new code?


helps if you show me the code?


oh wait ...


cljs.* is reserved. no hooks in those are discovered or used


Yep, that was it! Thanks again, as always! I'm doing something incredibly bizarre with ClojureScript, so I though it was something way more complicated than just the namespace name 😄


How do you deal with other watchers, doing some work outside of shadow-cljs? For example, I'm using postcss, and I have an npm script task to compile/watch. I can run it in another shell session, not a problem. But that has a minor annoyance - whenever I make style-related changes, they do not reflect in the browser without a manual refresh. And I think what's happening is that shadow-cljs picks up changes first (when .cljs files with hiccup modified), and npm script process always lagging behind. I thought about maybe using ^:dev/before-load-async, but that's in a file on the browser side. Can I have something similar but in clj, not cljs?


I use a setup using npm-run-all. as for example in this repo using postcss+tailwind


although I only use it to run postcss itself. I run shadow-cljs separately but you could easily run it there too


as for style related changes I added a new hook for that recently that is not in the docs yet


you may just be missing some watch related config if you just have css that isn't getting reloaded in the first place yet


@U05224H0W Hello Tomas, it works not only for css files, right? (I try to reload frontend after changes in .edn resources)


no, thats not supported


@U05224H0W But why? It's not possible in current implementation or needless feature or no time to implement this functionality?


mostly because there are limits to what shadow-cljs can reasonably do. There is no easy way to tell which files you are going to access and tracking all of them might get expensive. dunno what you are doing this code .edn files but maybe this already solves whatever it is


@U05224H0W Thanks for the answer. I use .edn files for translations (i18n) that's why I wanna reload frontend after some changes in them. I think it's a popular case. Isn't it? So you haven't any plans to extend this tracking?


I have no plans but if you setup a demo repo I might consider it


nobody else ever asked for this. so can't be that popular


Reading through the docs, perhaps I should look into the "build hooks"?


Yup, it does look exactly what I'm looking for. I apologize for the noise.