This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-02-23
Channels
- # announcements (2)
- # atom-editor (3)
- # babashka (49)
- # beginners (100)
- # biff (9)
- # calva (78)
- # clj-kondo (18)
- # clojure (143)
- # clojure-europe (13)
- # clojure-germany (1)
- # clojure-nl (2)
- # clojure-spec (5)
- # clojure-sweden (2)
- # clojure-uk (4)
- # clojurescript (58)
- # conjure (1)
- # cursive (4)
- # datascript (11)
- # datomic (63)
- # docker (7)
- # emacs (18)
- # events (1)
- # fulcro (18)
- # graalvm (5)
- # helix (4)
- # improve-getting-started (13)
- # jobs (4)
- # jobs-discuss (3)
- # lsp (15)
- # malli (90)
- # membrane (14)
- # off-topic (12)
- # other-languages (5)
- # pedestal (7)
- # polylith (53)
- # re-frame (15)
- # reitit (23)
- # releases (4)
- # remote-jobs (9)
- # ring (11)
- # shadow-cljs (90)
- # specter (2)
- # testing (3)
- # tools-build (63)
- # vim (2)
- # xtdb (8)
@rahx1t just forgot to git push. updated now. I did bump the closure compiler version in 2.17.4 but I'm not aware of any problems related to that. I do use module lazy loading myself and have no issues?
how do you load the modules? is this maybe a cache issue? ie. having modules from different builds loaded? you cannot mix modules from different builds or different versions of builds. this can happen easily if your cache settings are not set properly and the browser caches too much by default. if you are not using :module-hash-names
that is. works fine without too, just requires telling the server to send proper headers so cache is validated properly
I'm loading the modules via a combination of shadow.lazy
and shadow.loadable
and specifying the modules in shadow-cljs.edn
Our main client.js
bundle is cachebusted via appending a client.js?<GIT_SHA>
, but the lazy-loaded modules are referenced by only their <module_name>.cljs
without a hash. Based on what you described above, the issue could've been a result of the updated client.cljs?<GIT_SHA>
bundle loading cached, out-of-date modules (due to browser cache). Is that right?
I don't think we're currently setting any cache-related headers. Sounds like we can either modify those or utilize :module-hash-names
. Thanks!
:module-hash-names
is the safest option yeah. you should look into setting proper headers as well though. never hurts, especially with :module-hash-names
you only get the full benefit with proper headers
Say a client has loaded version A of the app, and we deploy/release version B. We replace the module hash names on the server with those from version B. We prompt the user to update their version of the app by refreshing the page -- however, they sometimes ignore this If they continue browsing with version A of the app, version A continues to attempt to load A-bundled modules. Since we've replaced those files in the server, would you expect requests for version A hashed modules to fail? Since the hashes are contained in the file names themselves, rather than appended as a query string parameter, those resources for A need to exist, otherwise those requests will fail. Am I understanding that right? How do folks usually work around this? Do they keep older deployed versions of files on the server? Am I missing something fundamental about caching?
this is much better than the alternative of ending up with 2 separate versions of builds loaded at the same time. there is a very slim chance they are actually compatible
Is there an option that tells shadow-cljs to append module-hash-names
builds but not delete them? I recall the build process replacing the files each time, but I will double-check this
Probably it'll have to replace the manifest each time but want to keep keep the module-hash-names files themselves
We recently started seeing this error on our console:
react_devtools_backend.js:4061 shadow-cljs - failed to load module$node_modules$react_popper$lib$cjs$index
<snip>
react_devtools_backend.js:4061 TypeError: Cannot redefine property: Popper
at Function.defineProperty (<anonymous>)
at Object.shadow$provide.module$node_modules$react_popper$lib$cjs$index (VM20697 module$node_modules$react_popper$lib$cjs$index.js:1:165)
at Object.shadow.js.jsRequire (js.js:66:18)
at Object.shadow.js.require (js.js:113:20)
at eval (VM20698 nosco.ui.popup.js:7:62)
at eval (<anonymous>)
at Object.goog.globalEval (base.js:503:11)
at Object.env.evalLoad (base.js:1564:12)
at eval (VM20252 main.js:45:12)
at eval (<anonymous>)
It was working but we changed the order of some imports and now we're seeing this. We unfortunately have two version of Popper in our node_modules (v1, v2), they use a different npm artifact. But it seems that if you load them in one order, they work, but not in another order. Other than scouring our deps and removing the old version, could there be any other way to troubleshoot/fix this?hmm not sure. reproducible example would help. don't have enough information otherwise. dunno why it would be redefining the property. this is only in watch
I assume? not release
I'm scouring our generated code and I see a reference to global.Popper
and also a reference to Object.defineProperty(exports, "Popper", function()...)
This looks like internal shadow-cljs error:
[2022-02-23 08:42:12.108 - WARNING] :shadow.cljs.devtools.server/nrepl-ex
Note: The following stack trace applies to the reader or compiler, your code was not executed.
CompilerException Syntax error compiling at (clojure/tools/reader/edn.clj:75:9). #:clojure.error{:phase :compile-syntax-check, :line 75, :column 9, :source "clojure/tools/reader/edn.clj"}
clojure.lang.Compiler.analyze (Compiler.java:6812)
clojure.lang.Compiler.analyze (Compiler.java:6749)
clojure.lang.Compiler$InvokeExpr.parse (Compiler.java:3824)
clojure.lang.Compiler.analyzeSeq (Compiler.java:7113)
clojure.lang.Compiler.analyze (Compiler.java:6793)
clojure.lang.Compiler.analyze (Compiler.java:6749)
clojure.lang.Compiler$IfExpr$Parser.parse (Compiler.java:2841)
clojure.lang.Compiler.analyzeSeq (Compiler.java:7111)
clojure.lang.Compiler.analyze (Compiler.java:6793)
clojure.lang.Compiler.analyze (Compiler.java:6749)
clojure.lang.Compiler$BodyExpr$Parser.parse (Compiler.java:6124)
clojure.lang.Compiler$LetExpr$Parser.parse (Compiler.java:6440)
Caused by:
RuntimeException No such var: err/throw-no-dispatch
clojure.lang.Util.runtimeException (Util.java:221)
clojure.lang.Compiler.resolveIn (Compiler.java:7392)
clojure.lang.Compiler.resolve (Compiler.java:7362)
clojure.lang.Compiler.analyzeSymbol (Compiler.java:7323)
clojure.lang.Compiler.analyze (Compiler.java:6772)
clojure.lang.Compiler.analyze (Compiler.java:6749)
08:42:18.498 [main] INFO io.undertow - starting server: Undertow - 2.2.4.Final
Shadow-Cljs 2.17.4
Yeah, as always you're right.
Hi. Trying to update an old figwheel/lein project to shadow. What could be the reason for shadow working from the npx command line fine, but not from inside lein run?
$ lein run -m shadow.cljs.devtools.cli compile app
WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.core.typed.contract-utils, being replaced by: #'clojure.core.typed.contract-utils/boolean?
2022-02-23 16:28:48,959 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
[:app] Compiling ...
The required namespace "project.core" is not available.
"project/core.clj" was found on the classpath. Should this be a .cljs file?
but from command line:
$ npx shadow-cljs compile app
shadow-cljs - config: /path/to/project/shadow-cljs.edn
WARNING: boolean? already refers to: #'clojure.core/boolean? in namespace: clojure.core.typed.contract-utils, being replaced by: #'clojure.core.typed.contract-utils/boolean?
16:20:38.929 [main] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Slf4jLoggerProvider
[:app] Compiling ...
[:app] Build completed. (340 files, 6 compiled, 13 warnings, 6.31s)
Im not using any lein-shadow, Im just trying to run it as a lein target (so I can hook it into the uberjar build)
if you use lein project.clj then :source-paths
or :dependencies
in shadow-cljs.edn do not apply
so they need to be configured in project.clj. likely your :source-paths
are just incorrect or missing
hi, i have this build that's working properly in dev mode and then when i build it for release, when the compiled js is loaded i get a console error:
Uncaught SyntaxError: Unexpected identifier
i've tried a simple or whitespace compilation, i've tried to release with -debug, i've tried to check externs... but i'm really stuck now and don't know where to look... what can i do to get more info about this error?Do you have
:source-map true
added to your build's compiler options? That might help w/ producing a useful stack trace and/or pointing you to the code that's getting mangledhttps://shadow-cljs.github.io/docs/UsersGuide.html#compiler-options
Ah actually that shouldn't be an issue if you're only using whitespace and simple optimization
i tried source map but that doesn't point me to soemthing useful
just to be sure the whitespace optim, i add the :release {:compiler-options {:optimizations :whitespace}}
right?
Unexpected identifier is not a externs issue. seems like there is something wrong with the output
are you sure compilation completed successfully? sometimes some CI systems kill the shadow-cljs JVM during :advanced
for using too much memory or so
[:app] Build completed. (1896 files, 0 compiled, 0 warnings, 11.17s)
i'm getting that at the end
I'm assuming this is a :browser
build? are you maybe testing in a really old browser?
Thinking back on this... I've intermittently seen this issue altho not in a while (would sometimes occur after installing an npm
dep).
Back then, I would rm -rf .shadow-cljs
, then run the build again to get an entirely fresh build
that's the full error trace, i'm on latest chrome macOS
are you maybe not actually loading the JS? just some webserver serving something else? like html?
yes there is but it's a long line ... source map not giving anything
which shadow-cljs version is this? did you set a custom :output-feature-set
? it doesn't seem to like the yield
yeah i though it could be yield but it should be supported everywhere, and the dev build is not giving an error
can i add you to the repo maybe?
could be the closure compiler transpiling away the function* which would make yield invalid
ah i see
so should i set a :output-feature-set?
but you can try :compiler-options {:output-feature-set :es-next}
in the build config
i do it
seems to be working now :shocked_face_with_exploding_head:
issue now that some browser might not like it...
i see -- so the issue was the transpiling for yield
not giving correct js?
(thanks a lot for that faster-than-typing live debugging!!)
ok i had 2.12.5
i'll bump up and then try without the es-next
shadow updated but still need a output-feature-set
es2020 is fine
i wouldn't be surprised that one of this library is just using weirdly generators, so that's tricking the compiler...
default output-set is which one?
:thumbsup:
Does the error only appear with :advanced? Try turning setting :pseudo-names true
in the compiler options, that may help locate the problem. @teawaterwire
it appears with advanced yes, i tried with simple and whitespace and it appeared as well... which is weird so i'm questioning if i was actually setting properly the optimization
hello! Is there a way to disable what are, I presume, shadow-specific compiler errors? Here is what I鈥檓 seeing:
cljs.user=> (require '[sicmutils.env :refer [+ ->infix]])
nil
cljs.user=> (let [f +] (->infix (f 'x 'x)))
"x + x"
cljs.user=> (->infix (+ 'x 'x))
------ WARNING - :invalid-arithmetic -------------------------------------------
Resource: <eval>:1:10
cljs.core/+, all arguments must be numbers, got [cljs.core/Symbol cljs.core/Symbol] instead
--------------------------------------------------------------------------------