I'm still digging into it a bit: https://github.com/thheller/shadow-cljs/issues/841
Is it expected that shadow won't infer an extern and won't produce a warning? I'm seeing a renamed JS property slipped into release build
@roman01la you need to be a bit more specific. it entirely depends on the code whether externs are generated or not.
I see, here's more context code
(defn get-x []
^js/LibraryX @lib-x)
(let [x (get-x)]
(.methodA x)
(.methodB x))
manual externs
LibraryX.prototype.methodA = function() {}
for the above setup methodB
gets renamed in release build and there's no compiler warning emitted
(defn get-x ^js []
@lib-x)
now when I remove manual externs and hint those values with ^js
inference seems to work fine in release
but you should be getting warnings in this case. or automatic externs inference
unfortunately I didn't get any
I’m running a watch like so:
shadow-cljs watch app
But in the browser app, I’m getting two errors:
Connection closed
and
Stale client
How to fix this error?
There are warnings but no errors in the shadow command linewhy does ^js
work but more specific ^js/Lib
doesn't?
Now I’m only getting Connection closed
@roman01la both are the same as far as shadow-cljs is concerned. I'm just not sure that the typehint directly on the defer properly propagates to the function return value.
@ps that means the JS that is being loaded was not produced by the watch
you started. that can either happen if you have 2 shadow-cljs isntances running in the same project. or you changed the paths somewhere but still access the "old" JS
how to close all shadow-cljs instances?
i might have been running two
I’ve tried shadow-cljs stop
> both are the same as far as shadow-cljs is concerned. I'm just not sure that the typehint directly on the defer properly propagates to the function return value.
interesting, so there two things going on
1. shadow doesn't emit a warning
2. switching to ^js
solves the problem, externs inferred correctly
odd
@ps stop will only stop the latest one. if you somehow started another you need to kill it manually. you can use the java tools to find the process. just jps
or jcmd
@thheller I can verify that adding return type hint solves the above problem, however it doesn't exist in plain cljs
what does? shadow-cljs doesn't do anything special in that regard?
I mean that in plain cljs property renaming doesn't happen, but in shadow it does happen, even though shadow doesn't emit infer warning
you need to be more precise. I do not have enough information to know what you are referring to. for example the renaming may not happen in regular CLJS because you have some CLJSJS externs that happen to handle it, they are often over-generated so it might even be from a different package or so.
I'm happy to take a look at reproducible sample code any time (and fix it if there are actual issues)
good point about third party externs, I'll put a minimal repro once I manage to reduce the scope of the problem
in general shadow-cljs does more externs inference, not less so I'd be very surprised if thats the cause
yeah that's why it seemed weird to me
another interesting case I just hit is that during dev shadow emits an inferring warning, but release build doesn't emit the warning and generated JS looks correct
this is not a problem, since adding a hint to silence the compiler in dev is fine, but still interesting inconsistency
can't say anything without reproducible examples
I’m trying to run the shadow repl on cursive
this is my repl configuration
But I’m getting this error:
EOF while trying to sync input stream.
when clicking run
can you see the warning on the bottom? pretty sure you need to add "localhost" to the Host field
and also select nREPL above, then also select "use port from nrepl file"
like this
@thheller it’s stuck on: Connecting to remote nREPL server...
is shadow-cljs running? did you actually configure that port? is it actually running on localhost?
please use the above setting. you really should not be hardcoding the port ever.
this is the beginning of the shadow output:
shadow-cljs - HTTP server available at <http://localhost:8021>
shadow-cljs - server version: 2.8.93 running at <http://localhost:9630>
shadow-cljs - nREPL server started on port 7002
shadow-cljs - watching build
seems fine then. maybe your firewall is blocking the port?
how to fix that?
sorry I cannot help you with macOS questions and note the "maybe". I don't have a clue if that is the cause
also I still see shadow-cljs connection closed
This is the output from jcmd
51168 clojure.main -i /private/var/folders/96/df02xppj77g7dx698gtmwmrw0000gn/T/form-init5834689007742471668.clj
53409 clojure.main -i /private/var/folders/96/df02xppj77g7dx698gtmwmrw0000gn/T/form-init6184901872508431686.clj
52882 clojure.main -m leiningen.core.main run -m shadow.cljs.devtools.cli --npm watch app
52885 clojure.main -i /private/var/folders/96/df02xppj77g7dx698gtmwmrw0000gn/T/form-init2867749071698962093.clj
51910
53993 sun.tools.jcmd.JCmd
ok that is one shadow-cljs process. the others are lein processes. not sure if you mean to have those.
i mean to have one lein process that’s running my app’s server
ok. but you did not start shadow-cljs in those processes? meaning there is no lein-shadow
in your project.clj
?
I’m not sure:
(defproject vendo "0.1.0"
:description "Main Page. Vendomarch."
:url "<http://vendomarch.com/>"
:dependencies [[ch.qos.logback/logback-classic "1.2.3"]
[cheshire "5.10.0"]
[cljs-ajax "0.8.0"]
[clojure.java-time "0.3.2"]
[com.cognitect/transit-clj "1.0.324"]
[com.fasterxml.jackson.core/jackson-core "2.11.0"]
[com.fasterxml.jackson.core/jackson-databind "2.11.0"]
[com.google.javascript/closure-compiler-unshaded "v20200504" :scope "provided"]
[cprop "0.1.17"]
[day8.re-frame/http-fx "0.1.6"]
[expound "0.8.4"]
[funcool/struct "1.4.0"]
[luminus-aleph "0.1.6"]
[luminus-transit "0.1.2"]
[luminus/ring-ttl-session "0.3.3"]
[markdown-clj "1.10.4"]
[metosin/jsonista "0.2.6"]
[metosin/muuntaja "0.6.7"]
[metosin/reitit "0.5.2"]
[metosin/ring-http-response "0.9.1"]
[mount "0.1.16"]
[nrepl "0.7.0"]
[org.clojure/clojure "1.10.1"]
[org.clojure/clojurescript "1.10.764" :scope "provided"]
[org.clojure/core.async "1.1.582"]
[org.clojure/google-closure-library "0.0-20191016-6ae1f72f" :scope "provided"]
[org.clojure/google-closure-library-third-party "0.0-20191016-6ae1f72f" :scope "provided"]
[org.clojure/tools.cli "1.0.194"]
[org.clojure/tools.logging "1.1.0"]
[org.webjars.npm/bulma "0.8.2"]
[org.webjars.npm/material-icons "0.3.1"]
[org.webjars/webjars-locator "0.40"]
[re-frame "0.12.0"]
[reagent "1.0.0-alpha2"]
[ring-webjars "0.2.0"]
[ring/ring-core "1.8.1"]
[ring/ring-defaults "0.3.2"]
[selmer "1.12.27"]
[thheller/shadow-cljs "2.8.93" :scope "provided"]
;; non-default dependencies
[com.novemberain/monger "3.1.0"]
[clj-http "3.10.1"]
[org.mongodb/mongo-java-driver "3.12.1"]
[com.cemerick/url "0.1.1"]
[com.draines/postal "2.0.3"]
[digest "1.4.9"]
;; cljs
[rgm/tailwind-cljs "0.1.0"]
[cljs-bean "1.5.0"]
[clojurewerkz/elephant "1.0.0-beta18"]
]
:min-lein-version "2.0.0"
:source-paths ["src/clj" "src/cljs" "src/cljc"]
:test-paths ["test/clj" "test/cljs"]
:resource-paths ["resources" "target/cljsbuild"]
:target-path "target/%s/"
:main ^:skip-aot vendo.core
:plugins [[lein-shadow "0.2.0"]]
:clean-targets ^{:protect false}
[:target-path "target/cljsbuild"]
:shadow-cljs
{:nrepl {:port 7002}
:builds
{:app
{:target :browser
:output-dir "target/cljsbuild/public/js"
:asset-path "/js"
:modules {:app {:entries [<http://vendo.app|vendo.app>]}}
:devtools
{:watch-dir "resources/public" :preloads [re-frisk.preload]}
:dev
{:closure-defines {"re_frame.trace.trace_enabled_QMARK_" true}}}
:test
{:target :browser-test;;:node-test
:test-dir "resources/public/js/test"
:autorun true
:ns-regexp ".*"
:devtools {:http-port 8021
:http-root "resources/public/js/test"}
}
:node-test
{
:target :node-test
:output-to "target/test/test.js"
}
:ci
{
:target :karma
:output-to "target/ci.js"
:ns-regexp ".*"
}
}}
:npm-deps [[shadow-cljs "2.8.93"]
[create-react-class "15.6.3"]
[react "16.13.0"]
[react-dom "16.13.0"]]
:npm-dev-deps [[xmlhttprequest "1.8.0"]]
:profiles
{:uberjar {:omit-source true
:prep-tasks ["compile" ["shadow" "release" "app"]]
:aot :all
:uberjar-name "vendo.jar"
:source-paths ["env/prod/clj" "env/prod/cljs" ]
:resource-paths ["env/prod/resources"]}
:dev [:project/dev :profiles/dev]
:test [:project/dev :project/test :profiles/test]
:project/dev {:jvm-opts ["-Dconf=dev-config.edn" ]
:dependencies [[binaryage/devtools "1.0.0"]
[cider/piggieback "0.5.0"]
[pjstadig/humane-test-output "0.10.0"]
[prone "2020-01-17"]
[re-frisk "1.3.2"]
[ring/ring-devel "1.8.1"]
[ring/ring-mock "0.4.0"]]
:plugins [[com.jakemccrary/lein-test-refresh "0.24.1"]
[jonase/eastwood "0.3.5"]]
:source-paths ["env/dev/clj" "env/dev/cljs" "test/cljs" ]
:resource-paths ["env/dev/resources"]
:repl-options {:init-ns user
:timeout 120000}
:injections [(require 'pjstadig.humane-test-output)
(pjstadig.humane-test-output/activate!)]}
:project/test {:jvm-opts ["-Dconf=test-config.edn" ]
:resource-paths ["env/test/resources"]
}
:profiles/dev {}
:profiles/test {}})
ok, sorry cannot help you with lein-shadow
related issues
what if I remove the lein-shadow plugin?
yes, you should do that
basically what you want is EITHER running everything directly via lein OR running the server parts with lein and the CLJS parts with shadow-cljs
NOT both. it appears to me that you currently try to do both and them interfering with each other
I do recommend running things separately always
so in one process you run lein repl
or whatever the command there is and in another process you run shadow-cljs watch app
(I have also never used luminus so I'm not sure how all that works)