This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
ModuleManager has a registerCallback
fn that lets you add a callback for errors, but this is only called after it has attempted to load a script a few times, and doesn’t pass you the actual error
well, found a way to listen for errors during module loading: https://gist-press.com/mhuebert/dfdf5dd94bbb944e995dc475c4421f4c I think it’s kind of crazy that ModuleManager’s default is to silently swallow errors. (I saw a comment in the source where they wonder if they should throw, so they have been thinking about this)
goog.log.warning(
this.logger, 'Loaded incomplete code for module(s): ' + moduleIds, e);
etcIt wasn’t obvious to me how to actually use it. I enabled debug mode in one of the namespaces but it didn’t have an effect
I’d also want these errors to be observed in production, maybe that’s also possible with the logging setup
so, following plexus’s nice post (https://lambdaisland.com/blog) I found the four lines of code necessary to get goog logging to work
FWIW
(ns ...
(:require [goog.debug.Console :as Console])
(:import [goog.debug Console]))
(.setCapturing (Console.) true)
(Console/autoInstall)
here is a reasonable default w glog:
(:require [goog.debug.Logger.Level :as Level]
[goog.log :as glog])
(:import [goog.debug Console])
(.setCapturing (Console.) true)
(.setLevel (glog/getLogger "") Level/WARNING)
i’ll also add that to the gist… it adds 1.5kb but presumably may be useful for other errors cropping up from goog stuff
when connecting on shadow nrepl port i am getting the clj repl. how do I start cljS repl from it these days?
how you start the watch is up to you. either from the command line or from the CLJ REPL via (shadow.cljs.devtools.api/watch :the-build-id)
it's started, but..
cljs.user=>
[:selected :app]
1
No application has connected to the REPL server. Make sure your JS environment has loaded your compiled ClojureScript code.
yes. what build do you have? if its :target :browser
you need to open the browser and load your JS
if you just want a REPL to play with you can just run (shadow.cljs.devtools.api/browser-repl)
or (shadow.cljs.devtools.api/node-repl)
the build is node
:builds {:app {:target :node-library
:exports {:handler server.main/handler}
:output-dir "target"
:output-to "target/main.js"}}}
how do i point to something local for a dependency?
or a specific github commit?
thanks i'll have a look
hmm i'm getting
Exception in thread "main" java.io.FileNotFoundException: Could not locate shadow/cljs/devtools/cli__init.class, shadow/cljs/devtools/cli.clj or shadow/cljs/devtools/cli.cljc on classpath.
@thheller in addition to or instead of npm install?
shadow-cljs is two parts. the JS parts that do the CLI stuff and the JVM parts that do the actual compilation
I don't see it explicitly mentioned in the User Guide, but is the :dump-core
compiler option supposed to work in cljs builds? I'm finding that even when setting that to true
, cljs.js/dump-core
still returns nil
:dump-core
is not supported. if you need self-hosted support you should follow this https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html
I can’t get npx shadow-cljs watch ...
with :http-root
to work on any version of shadow-cljs later than 2.6.x. I tried a personal project, the re-frame example[1], and the quickstart browser example[2]. Every time I run them everything other the than index (js,css,etc) fails to load with a 404. I tried changing to the new format suggested by issue 436[3] and got the same behavior. There are no sym-links involved in any of this. I am on mac. I tried node versions 8 and 10, with no difference in behavior.
The index.html is loading and making changes to it are reflect, but no other resources are loaded (in same directory or otherwise). Serving that folder with something like simple-http works perfectly fine.
I am on mac os catalina, so that could be the issue. I can’t really follow the code for the dev server. I do know based on adding print statements to my personal project that the js and css files are ultimately making their way to the push state handler[4], where they are then turned in 404s.
If there is any way I can help debug this issue I’d be happy to. I wanted to check on here first to make sure I’m not missing something obvious.
[1] https://github.com/shadow-cljs/examples/tree/master/re-frame
[2] https://github.com/shadow-cljs/quickstart-browser
[3] https://github.com/thheller/shadow-cljs/issues/436
[4] https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/http/push_state.clj
@jimmy what is your actual config? which version are you on? there are no issues I know of related to the dev http servers
All I did was take the quickstart above clone it and change the version to the latest. I then tried the last 5 or so versions. Tried 2.7.0. Still didn't work. Tried 2.6.0 and it worked.
@jimmy I cloned the shadow-cljs/examples repo, and ran the following commands:
cd shadow-examples/re-frame
npm i
npm i -D shadow-cljs # currently installs 2.8.40
npm run watch # shadow-cljs watch app
After letting the build complete, I am able to load both the compiled code and CSSfor clarity, I am able to see the build files loaded by going to http://localhost:8280
it looks like there may have been one or more changes to the dev server between 2.6 and 2.7. @jimmy could you try some of the intermediate versions?
it looks like a lot of changes occurred between 2.6.14 and 2.6.24 so you might start between those two versions
well, found a way to listen for errors during module loading: https://gist-press.com/mhuebert/dfdf5dd94bbb944e995dc475c4421f4c I think it’s kind of crazy that ModuleManager’s default is to silently swallow errors. (I saw a comment in the source where they wonder if they should throw, so they have been thinking about this)