@daemianmack you can just run shadow-cljs watch build1 build2 build3
and then shadow-cljs cljs-repl build1
and so on (or nrepl) to talk to a specific REPL for a given build
you can have as many REPLs as you want but most editors don't do session management very well
hi, when upgrading from 2.9.2
to the latest version, there is an error on Android, but works fine on ios , react native project
and it seems work fine with hermes engine disabled
so something has been changed after 2.9.2 and it won't work in hermes engine
hmm no clue. would help to know what that statement was ๐
@thheller there is an instant crash with shadow-cljs on react-native when using the hermes engine "Property Long doesn't exist" related to goog.math.long.js . I bisected through shadow-cljs versions and it looks like 2.9.4 is clean, 2.9.5 is not on npm, and 2.9.6 has the bug
we are not using goog.math.long anywhere directly, but it looks like transit does indirectly
since it works fine in release I wonder if that could be related to this commit https://github.com/thheller/shadow-cljs/commit/c5ce449c5749c9a7dd7ed0f9d58ec5f78b826e03
or maybe even just the goog module hot-reload https://github.com/thheller/shadow-cljs/commit/659e6eb72f7ed0f2acaf57e5d4502bf24884646c
I don't have a clue. goog.math.Long
is used by cljs.core
. sounds like a bug in hermes to me though?
I assume you tested with 2.11.4 too?
It can't be a bug in hermes because there is no bug in shadow-cljs 2.9.4, and no bug in release
yes I tried 2.11.4 as well
any version above 2.9.4 has the bug
(2.9.5 is not on npm for some reason though)
just set :version "2.9.5"
in shadow-cljs.edn
(assuming you use neither project.clj nor deps.edn)
is there more to the "Property Long doesn't exist" error though? I can't do much without knowing what the actual code is that crashes
and how
I mean just run a shadow-cljs compile build
and load it
if it crashes the code should be easy to find
no compilation is fine as I said release works with any version
it might be a bug in hermes because of eval
release
builds don't eval
and the crash doesn't give much info
in the phone logs it's even less
run shadow-cljs compile build
then the app/index.js
is self-contained and won't connect to the REPL
you can edit that file
it will have a bunch of evalLoad
calls
env.evalLoad = function(name, code) {
goog.globalEval(code);
};
should be in the code somewhere in the beginning
yenda@desktop:~/clash-mobile$ shadow-cljs compile app
shadow-cljs - config: /home/yenda/clash-mobile/shadow-cljs.edn cli version: 2.8.76 node: v12.16.1
[:app] Compiling ...
Failed writing cache for taoensso.encore: java.lang.Exception: Not supported: class shadow.build.compiler$analyze$fn__11740
[:app] Build completed. (271 files, 270 compiled, 0 warnings, 11.07s)
maybe try adding console.log("loading", name, code)
or so
just to find the code that actually fails
when I run the code generated by shadow-cljs compile build I have no error
then do the same with a running watch
just don't make any other changes or your mod will be overwritten
also make sure to test with 2.11.4 please
no point in testing with 2.9.6
shadow-cljs - server version: 2.11.4 running at http://localhost:3449
the last statement I see in the log is loading goog.math.long.js goog.loadModule(function(exports) and then the whole module code
@thheller If you want more details:
<https://gist.github.com/yenda/4c73fb43ede8e7740bd6dbc6b7067659>
hmm
that file isn't rewritten at all?
ah hmm I guess the problem might be the :output-feature-set
that prevents it from rewriting the class Long
and that maybe confuses Hermes?
hmm although that should also fail in compile
builds
there is a SHADOW_ENV.evalLoad in the file
SHADOW_ENV.evalLoad("goog.math.long.js", "goog.loadModule(function(exports) {\n \x22use strict\x22;\n goog.module(\x22goog.math.Long\x22);\n goog.module.declareLegacyNamespace();\n const asserts \x3d goog.require(\x22goog.asserts\x22);\n const reflect \x3d goog.require(\x22goog.reflect\x22);\n class Long {\n constructor(low, high) {\n this.low_ \x3d low | 0;\n this.high_ \x3d high | 0;\n }\n toInt() {\n return this.low_;\n }\n toNumber() {\n return this.high_ * TWO_PWR_32_DBL_ + this.getLowBitsUnsigned();\n }\n isSafeInteger() {\n var top11Bits \x3d this.high_ \x3e\x3e 21;\n return top11Bits \x3d\x3d 0 || top11Bits \x3d\x3d -1 \x26\x26 !(this.low_ \x3d\x3d 0 \x26\x26 this.high_ \x3d\x3d (4292870144 | 0));\n }\n toString(opt_radix) {\n var radix \x3d opt_radix || 10;\n if (radix \x3c 2 || 36 \x3c radix) {\n throw new Error(\x22radix out of range: \x22 + radix);\n }\n if (this.isSafeInteger()) {\n var asNumber \x3d this.toNumber();\n return radix \x3d\x3d 10 ? \x22\x22 + asNumber : asNumber.toString(radix);\n }\n var safeDigits \x3d 14 - (radix \x3e\x3e 2);\n var radixPowSafeDigits \x3d Math.pow(radix, safeDigits);\n var radixToPower \x3d Long.fromBits(radixPowSafeDigits, radixPowSafeDigits / TWO_PWR_32_DBL_);\n var remDiv \x3d this.div(radixToPower);\n var val \x3d Math.abs(this.subtract(remDiv.multiply(radixToPower)).toNumber());\n var digits \x3d radix \x3d\x3d 10 ? \x22\x22 + val : val.toString(radix);\n if (digits.length \x3c safeDigits) {\n digits \x3d \x220000000000000\x22.substr(digits.length - safeDigits) + digits;\n }\n val \x3d remDiv.toNumber();\n return (radix \x3d\x3d 10 ? val : val.toString(radix)) + digits;\n }\n getHighBits() {\n return this.high_;\n }\n getLowBits() {\n return this.low_;\n }\n getLowBitsUnsigned() {\n return this.low_ \x3e\x3e\x3e 0;\n }\n getNumBitsAbs() {\n if (this.isNegative()) {\n if (this.equals(Long.getMinValue())) {\n return 64;\n } else {\n return this.negate().getNumBitsAbs();\n }\n } else {\n var val \x3d this.high_ !\x3d 0 ? this.high_ : this.low_;\n for (var bit \x3d 31; bit \x3e 0; bit--) {\n if ((val \x26 1 \x3c\x3c bit) !\x3d 0) {\n break;\n }\n ...
yeah all that looks exactly like it should
not a clue why it works in compile
but not watch
?
I mean watch loads more (and connects websocket) but all of that comes after goog.math.Long
with 2.9.4 https://gist.github.com/yenda/5f157d93164b856303574d547c33f632
(it loads the rest afterward)
@thheller if you look at the module it looks like they are not the same, not sure if that matters but for instance /** @constย */ var reflect
in 2.9.4 vs const reflect
in 2.11.4
so maybe you were write and it has something to do with feature set?
yes, if you set :output-feature-set :es5
that should change the rewriting
but again .. that sounds like a bug in hermes to me then
I'm not very familiar with these feature set so what changed between 2.9.4 and now?
Hermes is compiling js into bytecode
{:target :react-native
:init-fn app.core/init
:output-dir "app"
:dev {:devtools {
:autoload true
:reload-strategy :full
:after-load app.core/reload
:compiler-options {:source-map false
:output-feature-set :es5}}
:local-ip #shadow/env "SHADOW_HOST"}
:release {:compiler-options {:output-feature-set :es6
:warnings-as-errors true
:infer-externs :auto
:optimizations :advanced
:js-options {:js-provider :closure}}}}
I still have the error with this config
and the modules still have the const reflect
syntax in index.js
SHADOW_ENV.evalLoad("goog.math.long.js", "goog.loadModule(function(exports) {\n \x22use strict\x22;\n goog.module(\x22goog.math.Long\x22);\n goog.module.declareLegacyNamespace();\n const asserts \x3d goog.require(\x22goog.asserts\x22);\n const reflect \x3d goog.require(\x22goog.reflect\x22);\n class Long {\n constructor(low, high) {\n this.low_ \x3d low | 0;\n this.high_ \x3d high | 0;\n }\n toInt() {\n return this.low_;\n }\n toNumber() {\n return this.high_ * TWO_PWR_32_DBL_ + this.getLowBitsUnsigned();\n }\n isSafeInteger() {\n var top11Bits \x3d this.high_ \x3e\x3e 21;\n return top11Bits \x3d\x3d 0 || top11Bits \x3d\x3d -1 \x26\x26 !(this.low_ \x3d\x3d 0 \x26\x26 this.high_ \x3d\x3d (4292870144 | 0));\n }\n toString(opt_radix) {\n var radix \x3d opt_radix || 10;\n if (radix \x3c 2 || 36 \x3c radix) {\n throw new Error(\x22radix out of range: \x22 + radix);\n }\n if (this.isSafeInteger()) {\n var asNumber \x3d this.toNumber();\n return radix \x3d\x3d 10 ? \x22\x22 + asNumber : asNumber.toString(radix);\n }\n var safeDigits \x3d 14 - (radix \x3e\x3e 2);\n var radixPowSafeDigits \x3d Math.pow(radix, safeDigits);\n var radixToPower \x3d Long.fromBits(radixPowSafeDigits, radixPowSafeDigits / TWO_PWR_32_DBL_);\n var remDiv \x3d this.div(radixToPower);\n var val \x3d Math.abs(this.subtract(remDiv.multiply(radixToPower)).toNumber());\n var digits \x3d radix \x3d\x3d 10 ? \x22\x22 + val : val.toString(radix);\n if (digits.length \x3c safeDigits) {\n digits \x3d \x220000000000000\x22.substr(digits.length - safeDigits) + digits;\n }\n val \x3d remDiv.toNumber();\n return (radix \x3d\x3d 10 ? val : val.toString(radix)) + digits;\n }\n getHighBits() {\n return this.high_;\n }\n getLowBits() {\n return this.low_;\n }\n getLowBitsUnsigned() {\n
2.9.4:
SHADOW_ENV.evalLoad("goog.math.long.js", "goog.loadModule(function(exports) {\n \x22use strict\x22;\n goog.module(\x22goog.math.Long\x22);\n goog.module.declareLegacyNamespace();\n /** @const */ var asserts \x3d goog.require(\x22goog.asserts\x22);\n /** @const */ var reflect \x3d goog.require(\x22goog.reflect\x22);\n /** @final @constructor */ var Long \x3d function(low, high) {\n /** @private @const @type {number} */ this.low_ \x3d low | 0;\n /** @private @const @type {number} */ this.high_ \x3d high | 0;\n };\n /**\n * @return {number}\n */\n Long.prototype.toInt \x3d function() {\n return this.low_;\n };\n /**\n * @return {number}\n */\n Long.prototype.toNumber \x3d function() {\n return this.high_ * TWO_PWR_32_DBL_ + this.getLowBitsUnsigned();\n };\n /**\n * @return {boolean}\n */\n Long.prototype.isSafeInteger \x3d function() {\n var top11Bits \x3d this.high_ \x3e\x3e 21;\n return top11Bits \x3d\x3d 0 || top11Bits \x3d\x3d -1 \x26\x26 !(this.low_ \x3d\x3d 0 \x26\x26 this.high_ \x3d\x3d (4292870144 | 0));\n };\n /**\n * @param {number\x3d} opt_radix\n * @return {string}\n * @override\n */\n Long.prototype.toString \x3d function(opt_radix) {\n var radix \x3d opt_radix || 10;\n if (radix \x3c 2 || 36 \x3c radix) {\n throw new Error(\x22radix out of range: \x22 + radix);\n }\n if (this.isSafeInteger()) {\n var asNumber \x3d this.toNumber();\n return radix \x3d\x3d 10 ? \x22\x22 + asNumber : asNumber.toString(radix);\n }\n var safeDigits \x3d 14 - (radix \x3e\x3e 2);\n var radixPowSafeDigits \x3d Math.pow(radix, safeDigits);\n var radixToPower \x3d Long.fromBits(radixPowSafeDigits, radixPowSafeDigits / TWO_PWR_32_DBL_);\n var remDiv \x3d this.div(radixToPower);\n var val \x3d Math.abs(this.subtract(remDiv.multiply(radixToPower)).toNumber());\n var digits \x3d radix \x3d\x3d 10 ? \x22\x22 + val : val.toString(radix);\n if (digits.length \x3c safeDigits) {\n digits \x3d \x220000000000000\x22.substr(digits.length - safeDigits) + digits;\n }\n val \x3d remDiv.toNumber();\n return (radix \x3d\x3d 10 ? val : val.toString(radix)) + digits;\n };\n /**\n * @return {number}\n */\n Long.prototype.getHighBits \x3d function() {\n return this.high_;\n };\n /**\n * @return {number}\n */\n Long.prototype.getLowBits \x3d function() {\n return this.low_;\n };\n /**\n
@thheller ok looks like it works when I put compiler options at the top level of my build
so this line doesn't look into :dev and set es6 as default? https://github.com/thheller/shadow-cljs/commit/ad8ea9d4aefc5d1c0ab371613a9c96c17da3d447#diff-022dc5a1b7d0a256b0203406d97d8eb8R147
@thheller so the fix for now is to have :compiler-options {:output-feature-set :es5}
at the top level of your build config map when you want to use hermes on react-native target
Anyone have experience with doing the :target :karma
and it not launching the headless chrome when running npx karma start --single-run
?
Hello everyone! Seems when I sometimes reload my browser window, vim-fireplace is loosing the connection with the page and cannot re-establish it. Trying to send commands after this happens show the following error:
[2020-09-24 13:16:06.847 - WARNING] :shadow.cljs.devtools.server.util/handle-ex - {:msg {:op :cljs-load-sources, :sources [[:shadow.build.classpath/resource "cljs/spec/gen/alpha.cljs"] [:shadow.build.classpath/resource "cljs/spec/alpha.cljs"] [:shadow.build.classpath/resource "cljs/repl.cljs"] [:shadow.cljs.repl/resource "cljs/user.cljs"]], :call-id 1, :from 24}}
ExceptionInfo no output for id: [:shadow.cljs.repl/resource "cljs/user.cljs"] {:resource-id [:shadow.cljs.repl/resource "cljs/user.cljs"]}
shadow.build.data/get-output! (data.clj:197)
shadow.build.data/get-output! (data.clj:193)
shadow.cljs.devtools.server.worker.impl/fn--15169/fn--15172 (impl.clj:813)
clojure.core/map/fn--5866 (core.clj:2753)
clojure.lang.LazySeq.sval (LazySeq.java:42)
clojure.lang.LazySeq.seq (LazySeq.java:51)
clojure.lang.RT.seq (RT.java:535)
clojure.core/seq--5402 (core.clj:137)
clojure.core.protocols/seq-reduce (protocols.clj:24)
clojure.core.protocols/fn--8146 (protocols.clj:75)
clojure.core.protocols/fn--8146 (protocols.clj:75)
clojure.core.protocols/fn--8088/G--8083--8101 (protocols.clj:13)
My config currently looks like this, basically the minimal one I could get my hands on.
;; shadow-cljs configuration
{:source-paths
["src/dev"
"src/main"
"src/test"]
:dependencies
[[reagent "1.0.0-alpha2"]]
:dev-http {8081 "public"}
:nrepl {:port 8082}
:builds
{:frontend
{:target :browser
:modules {:main {:init-fn app/init}}}}}
I come from using figwheel and figwheel-main for a long time, first time using shadow-cljs for a project, so probably I'm doing something wrong here. Using neovim, vim-fireplace. Running shadow-cljs by running npx shadow-cljs watch frontend
, connecting my repl by doing :Connect 8082
and then :Piggieback :frontend
. Everything works except until I reload the page, then starting to get that error above and the only thing I can do to make it work is restarting shadow-cljs watch
again, then it starts working.@victorbjelkholm429 which version is this? this should have been fixed a while ago.
@thheller 2.11.4, think the project was bootstrapped from create-cljs-project
so got the version from there
hm, could be the vim-fireplace version maybe? I'll check those out too
weird. anything in particular you are doing with the REPL?
no, just calling println
's and alike, nothing extreme
not sure why you reloading the page affects anything on the compiler side
so this line doesn't look into :dev and set es6 as default?ย https://github.com/thheller/shadow-cljs/commit/ad8ea9d4aefc5d1c0ab371613a9c96c17da3d447#diff-022dc5a1b7d0a256b0203406d97d8eb8R147
@andre why would it? its not supposed to? it is supposed to be identical in dev/release?
I say again ... this very much sounds like a bug in hermes to me if it works in other engines
given that chrome, firefox, etc have no issues with this whatsoever
and again .. I suspect eval
to be the cause here. release
builds will not eval
and instead load the code directly.
I do not have any necessary setup to test hermes
so can't say much more
the code shadow-cljs produces looks exactly like it should, :es5
should not be a required setting but if it makes hermes happy then fine just set it
you can set :dev {:compiler-options {:output-feature-set :es5}}
if you only want it in dev
it doesn't work if you set it in dev @thheller, I had to set it in the top level of the build map
Is there a way to write jsx file alongside cljs and import the components in cljs files? It works with js but I don't understand the stack enough to figure out how to make sure the jsx stuff gets transpiled
Not having any luck attempting to use oz via shadow-cljs. At first I just tried going by the instructions in the Oz github readme, but kept running into an error with a missing file. Shadow-cljs was looking for a .js file, but in the folder only .min.js, .node.js and .module.js were available. Then I found this template project and the exact same error occurs: https://github.com/ivanminutillo/reagent-shadow-oz-example
[:app] Build failure:
override to file that doesn't exist
{:tag :shadow.build.npm/invalid-override, :require-from #object[java.io.File 0x4d68156d "/Users/rqf595/Code/temp/reagent-shadow-oz-example/node_modules/vega-dataflow/build/vega-dataflow.js"], :require "vega-loader", :file #object[java.io.File 0x41ebcb92 "/Users/rqf595/Code/temp/reagent-shadow-oz-example/node_modules/vega-loader/build/vega-loader.node.js"], :override "./build/vega-loader.js", :override-file #object[java.io.File 0x5d156b61 "/Users/rqf595/Code/temp/reagent-shadow-oz-example/node_modules/vega-loader/build/vega-loader.js"]}
ExceptionInfo: override to file that doesn't exist
shadow.build.npm/find-resource (npm.clj:735)
shadow.build.npm/find-resource (npm.clj:661)
shadow.build.resolve/find-npm-resource (resolve.clj:123)
shadow.build.resolve/find-npm-resource (resolve.clj:94)
So now Iโm wondering what to do? The packages are installed, but shadow-cljs is looking for e.g. vega-loader.js when only files like vega-loader.min.js is available in that folder.
@simongray not a clue. the package is linking to a file that it does not itself contain. likely just a bad config entry on their part. you can fix it by editing https://github.com/vega/vega/blob/master/packages/vega-loader/package.json#L41 to link to the correct file
Thanks Thomas. I'll attempt that. It just seems odd that a setup that presumably worked at one time using those same versions now doesn't to seem any longer.
I'm guessing that the bundling was just changed in recent versions
current seems to be 4.3.3
but 4.3.2
still had the non-min file https://unpkg.com/browse/vega-loader@4.3.2/build/vega-loader.js
so blame them ...
Thanks a lot. That got me on the right track. I managed to get it to compile by adding these two explicit dependencies to the package.json
"vega-loader": "4.3.2",
"vega-canvas": "1.2.4"
apparently, version 1.2.5 of the vega-canvas package suffered from the same issue.@sofievonge Jeg fandt ud af hvad problemet var med lidt hjรฆlp fra Thomas.
wow, this is the first time I've seen that message in my builds and you already asked about it ๐. Quite a coincidence
I would almost say that there is some new version of vega, and since package.json usually imports "^version", we both got upgraded at the same time