This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-20
Channels
- # aleph (12)
- # announcements (7)
- # aws (6)
- # babashka (36)
- # beginners (161)
- # boot (1)
- # calva (6)
- # cider (21)
- # clj-kondo (13)
- # cljs-dev (28)
- # cljsrn (1)
- # clojars (3)
- # clojure (13)
- # clojure-colombia (1)
- # clojure-europe (10)
- # clojure-spec (12)
- # clojure-uk (47)
- # clojuredesign-podcast (2)
- # clojurescript (67)
- # datascript (8)
- # datomic (21)
- # duct (3)
- # emacs (6)
- # events (1)
- # fulcro (6)
- # graalvm (98)
- # jobs (1)
- # kaocha (18)
- # luminus (1)
- # malli (7)
- # off-topic (56)
- # pathom (5)
- # re-frame (18)
- # reagent (3)
- # reitit (9)
- # remote-jobs (3)
- # rewrite-clj (10)
- # ring (1)
- # shadow-cljs (155)
- # spacemacs (2)
- # sql (5)
- # tools-deps (27)
- # vim (86)
- # xtdb (2)
read the manual from the beginning up to this section https://shadow-cljs.github.io/docs/UsersGuide.html#_hot_code_reload
@thheller When targetting :node-script, does shadow-cljs provides some way to bundle all the code (including all npm deps) into one js file (for easier distribution)?
@eliraz.kedmi https://code.thheller.com/blog/shadow-cljs/2019/08/25/hot-reload-in-clojurescript.html
I am using shadow-cljs in Gitlab enviroment where it is not possible to cache directories which are outside build directory (for example $HOME/.m2). What is the preferred way to set .m2 directory location?
assuming you are actually using shadow-cljs.edn and not project.clj/deps.edn you can set :maven {:local-repo "maven"}
or so in shadow-cljs.edn
Yes, this seems to work. Maybe this can be added to user guide as well because some one else may find the same problem as well
One more question. Do I understand correctly that --config-merge cannot be used to merge configuration to root level of shadow-cljs.edn but only inside :builds -> :build-name map?
I think that it might work because I can create that file in the build pipeline. I will try and see what happens.
Using 'shadow-loader' (or more accurate, shadow-lazy), can I set up so that modules are loaded from an absolute URL and not from the "current" origin?
ok, I'm calling release from Clojure, and I need to override the asset path. Should this work? (shadow/release :main {:asset-path "something"})
https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration
It's dynamic, yes -- we unfortunately have a couple of environments and a semi-complicated setup.
A lazy module that works well in development, fails to load in release mode. The error is something like shadow-cljs - failed to load – 329
, how to debug this? is this a case for pseudo-names?
ok, making some progress -- loading the module as a script, I get $jscomp is not defined
, which I see in the main module wrapped inside an IIFE, so that's probably the culprit
@thheller I seem to be hitting https://github.com/google/closure-compiler/issues/1138
@eliraz.kedmi are you using the built-in shadow http server or your own? That error is usually a stale cache problem.
I'm using the built-in.. maybe it's the way I'm using it? I simply jack-in using CIDER with nRepl
I'm not sure that's the proper way to activate the hot reload. however, when I change the code I do see the little CLJS logo spins and nothing changes
OK, and have you setup a function in your project to be called after load? i.e. something with ^:dev/after-load
metadata?
No, I have not. I don't know what that function suppose to do? I mean, what logic to put inside it?
Are you using reagent? If so you'd probably call (reagent/render ...)
, most probably the function you call to start your applicaiton.
Shadow doesn't know what to do when it reloads your code -- you might have changed component but shadow tries to be framework agnostic. So it will put the new code in the browser, but you somehow need to re-render the DOM yourself. That's where these build hooks come in.
(defonce EL (atom nil))
(defn ^:dev/after-load -render []
(when @EL
(react-dom/render
(hx/f [Main])
@EL)))
Regarding state of the app, that's a question of how you set it up. If it's global state that lives under a defonce
then yes. If it's local state (react hooks) it will be gone.
So I'm trying to figure out what's the deal with my $jscomp
issue -- I see a bunch of code in my lazy module that does things like $jscomp.arrayFromIterable
, $jscomp.makeIterator
and so on -- but no $jscomp
definition in it. The main module almost immediately starts with
(function(){
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl ....
So the docs say (https://shadow-cljs.github.io/docs/UsersGuide.html#output-wrapper): "When using multiple :modules (a.k.a code splitting) this is not enabled by default since each module must be able to access the variables created by the modules it depends on." -- but it seems that's not entirely true. If I turn set :output-wrapper false
then I get over my issue, $jscomp
is public and everything works again, with the downside of having a ton of global variables.
@orestis yeah what is an issue I've been meaning to look into. you can fix it by either :output-wrapper false
or :prepend-js "var $jscomp = {};"
in the base module to pull it into the global scope
for some reason when using output-wrapper the var $jscomp
just becomes $jscomp
that isn't exported
Are you sure about the :prepend-js
? It doesn't seem to work, and I don't see how it could since it would run through optimisations. I tried :prepend
to get it as a plain string but apparently due to JS scoping rules, the IIFE expression will still not "see it".
I'm not sure why this is necessary at all though. especially since :advanced should be renaming this but for some reason it doesn't
Made an issue here: https://github.com/thheller/shadow-cljs/issues/603 for Google's sake
anyone happen to know of an example usign shadow-cljs with klipse? when i require the klipse namespaces in my namespace, I get the following error:
The required namespace "cljsjs.codemirror.addon.edit.closebrackets" is not available, it was required by "klipse/ui/editors/editor.cljs".
The namespace was provided via :foreign-libs which is not supported.
Please refer to for more information.
I'm trying to shim that addon namespace as described in the shadow guide, but I'm having trouble figuring out the things i need to require and export. There's also a few more addons in that klipse namesace that will have to be shimmed.So I'm still having issues with source-maps not actually working with shadow-cljs. The sourceMappingURL
in a file appears to be a relative path, is that how's it supposed to work?
//# sourceURL=js/cljs-runtime/edu.unc.applab.clem.views.js
//# sourceMappingURL=edu.unc.applab.clem.views.js.map
@donyorm as I said before this is controlled by :asset-path
. if you set :asset-path "js"
then yes it will be a relative path
it should likely be /js
otherwise your paths won't resolve properly as you use any kind of "routing"
ie. if you load the page via /some/thing
then the browser will try to resolve /some/thing/js
Changing it to /js didn't seem to do much. Here's the source map part of the file:
//# sourceURL=/js/cljs-runtime/edu.unc.applab.clem.views.js
//# sourceMappingURL=edu.unc.applab.clem.views.js.map
The source map is at /js/cljs-runtime/edu.unc.applab.clem.views.js.map
Will that setup find it properly
Basically firefox isn't using source maps in error reporting (and presumably shadow-cljs/react/whatever is sending errors to the console) isn't using them either. Ex. I'll get the following stack-trace:
cljs$core$IFn$_invoke$arity$6 /js/cljs-runtime/cljs.core.js:13306
cljs$core$IFn$_invoke$arity$5 /js/cljs-runtime/cljs.core.js:13288
cljs$core$IFn$_invoke$arity$4 /js/cljs-runtime/cljs.core.js:13276
cljs$core$IFn$_invoke$arity$4 /js/cljs-runtime/cljs.core.js:13564
list_errors /js/cljs-runtime/edu.unc.applab.clem.views.js:102
res /js/cljs-runtime/reagent.impl.component.js:134
reagent$impl$component$wrap_render /js/cljs-runtime/reagent.impl.component.js:153
reagent$impl$component$do_render /js/cljs-runtime/reagent.impl.component.js:201
render /js/cljs-runtime/reagent.impl.component.js:227
Which doesn't give me much help in where to look in my own fileI think it's actually uncaught. I'll throw an exception in my own code just to be sure
"Error: omg
at new cljs$core$ExceptionInfo (/js/cljs-runtime/cljs.core.js:36930:10)
at Function.eval [as cljs$core$IFn$_invoke$arity$3] (/js/cljs-runtime/cljs.core.js:36991:9)
at Function.eval [as cljs$core$IFn$_invoke$arity$2] (/js/cljs-runtime/cljs.core.js:36987:26)
at eval (/js/cljs-runtime/demo.browser.js:19:29)"
Now I'm getting this error
Source map error: Error: request failed with status 404
Resource URL: line 827 > eval
Source Map URL: cljs.core.js.map
I wonder if my routing is messed up. Anyway for me to tell what url it's looking for the source-map at?The code frontend and backend are running on the same machine so I needed to have ring server it up
and you are accessing the page via http://localhost:3000?
That would do. Seems to be working fine for me, other than the fact that my server is not serving the proper mimetype for JS files. Guess I'll have to fix that
I'll try to figure out why it isn't loading the source maps anymore. It used to work fine the last time I tested in Firefox
@aisamu I'm not able to reproduce the goog.math.Long
error you ran into yesterday. is it possible you are including two separate builds using the closure library in some way?
I found one issue with :npm-module but I can't see how that possibly leads to your error
Would you like me to check for something in specific? (e.g. I'd expect multiple requires
to be de-duped by webpack, for example)
if anything they would be completely separate builds. can't see how it would include the same build twice
Still can't explain the failure, but noticed two major changes while diffing the failing js bundle: Some TLD's are now wrapped in a parenthesis
- cljs.core._STAR_print_newline_STAR_ = false;
+ (cljs.core._STAR_print_newline_STAR_ = false;)
goog.math.Lang
is wrapped/provided differently
;;;;;;;;;;;;;
;; Old
goog.provide("goog.math.Long");
...
goog.math.Long = function(low, high) { ...}
...
goog.math.Long.getMinValue = function() { ... }
;;;;;;;;;;;;;
;; New
goog.loadModule(function(exports) {
...
goog.module("goog.math.Long");
...
var Long = function(low, high) {...}
...
Long.getMinValue = function() { ... }
...
exports = Long;
return exports;
});
module.exports = goog.math.Long;
:man-shrugging:
Will keep digging....it works fine in the browser. maybe something weird going on for npm-module. it does work in node. I'll try to get a webpack test setup going
I got this funny experience where I can't compile tailwind in a shadow-cljs project.
npx tailwind build styles.css -o output.css
This command works normally but inside a folder that has a shadow-cljs project it doesn't??
It takes styles.css
which is
@import "tailwindcss/base";
@import "tailwindcss/components";
@import "tailwindcss/utilities";
and outputs the same content into output.css
It doesn't actually create the styles. I remember you saying you used it so I don't see how this is happening.
Oh yep
just a silly copy paste error
that's embarrasing haha