Fork me on GitHub
#shadow-cljs
<
2021-09-04
>
Chase00:09:00

So I compiled a release build using shadow-cljs release app and it builds fine but how do I actually run the release build? Everything I am trying is failing. shadow-cljs watch app still works for the dev build. But anything like shadow-cljs run app or shadow-cljs run core give me classpath errors

javi02:09:43

just start a server in the public folder. the release files are just javascript. python -m http.server 8000 for example. Then point the browser to localhost:8000 and your app will load.

Chase02:09:22

yeah I tried that and it's trying to reconnect to shadow-cljs so I think that is still running the dev setup?

Chase02:09:41

A lot of console errors too

javi02:09:41

yeah, it sounds like that could be the issue. try deleting your ‘js’ folder inside ‘public’ before running ‘release’.

Chase03:09:03

that seems to have been it. thanks!

thheller06:09:37

release should override all the relevant files unless you have configured it not to

thheller06:09:41

don't know your config

thheller07:09:57

ah, if you just want the http server back you can run shadow-cljs server. as a bonus while that is running shadow-cljs release app is also much faster

Chase12:09:55

Ok cool, I will switch to that workflow. Thanks!

Chase12:09:12

As a side note, on a small Hello World Reagent app, running the release build with optimizations set to :advanced I get a performance score of 86% on Lighthouse (it says I should reduce my unused JS but I thought that is what the optimizations/Google Closure Compiler took care of?). It says my JS transfer size is 271kb but it thinks there is potential savings of 168kb more. Does that sound about right? How would I get that extra savings (it says it would save my transfer time 1.2 sec from 3.2s which sounds big or am I prematurely optimizing here)?

thheller18:09:39

you can create a build report to figure out what exactly is in your build and how large https://shadow-cljs.github.io/docs/UsersGuide.html#build-report

Chase22:09:50

Ahh, cool! Yeah its 60% cljs/core.cljs which I guess is to be expected. I assume as I continue building out the app, the size will grow at a slower rate (if that makes any sense)

thheller07:09:38

yeah cljs.core is typically the largest one. some other exceptions but they are usually easily avoided (eg. cljs.pprint)

Chase00:09:16

I'm using the minimal reagent front end template if that matters

zendevil.eth09:09:21

I installed the js sdk for browser client using npm i --save moralis, but I’m getting the following error:

The required JS dependency "json-rpc-engine/src/createAsyncMiddleware" is not available, it was required by "node_modules/eth-json-rpc-middleware/block-cache.js".


	node_modules/moralis/index.js
	node_modules/moralis/lib/browser/Parse.js
	node_modules/moralis/lib/browser/decode.js
	node_modules/moralis/lib/browser/ParseACL.js
	node_modules/moralis/lib/browser/ParseUser.js
	node_modules/moralis/lib/browser/MoralisWeb3.js
	node_modules/moralis/lib/browser/MoralisWalletConnectProvider.js
	node_modules/@walletconnect/web3-provider/dist/esm/index.js
	node_modules/web3-provider-engine/subproviders/cache.js
	node_modules/eth-json-rpc-middleware/block-cache.js
I tried removing node_modules and reinstalling using npm i. I also tried npm i --save json-rpc-engine but that still gives the error. I tried npm i --save json-rpc-engine/src/createAsyncMiddleware, but that npm package doesn’t exist. How to fix this?

thheller18:09:48

looks like the eth-json-rpc-middleware package maybe expects a different version of json-rpc-engine than you have installed

thheller18:09:01

typical dependency version conflict error

thheller18:09:17

using a file that is only in a given version of the package

huygn09:09:26

So I just had a (naive) working template to run/deploy with Deno & shadow-cljs, used uix for render/hydrate a simple React app. Thanks @thheller for adding esm support! now I just wished watch mode would work for esm target too. deploy url: https://deno-cljs.deno.dev https://github.com/huygn/deno-cljs-template

borkdude10:09:55

@gnhuy91 I am using watch for nbb which is esm as well

huygn10:09:43

hmm my error being document was referenced in :server build, but compile/release mode works fine :thinking_face:

> deno run -A --unstable --watch src/index.ts

Check file:///Users/macair/src/github.com/huygn/my-project/src/index.ts
error: Uncaught ReferenceError: document is not defined
  return goog.dom.createElement_(document, name);
                                 ^
    at Object.goog.dom.createElement (file:///Users/macair/src/github.com/huygn/my-project/dist/server/cljs-runtime/goog.dom.dom.js:288:34)
    at file:///Users/macair/src/github.com/huygn/my-project/dist/server/cljs-runtime/goog.style.transition.js:39:21
    at Object.isSupported (file:///Users/macair/src/github.com/huygn/my-project/dist/server/cljs-runtime/goog.functions.functions.js:142:15)
    at file:///Users/macair/src/github.com/huygn/my-project/dist/server/cljs-runtime/shadow.dom.js:3:99

huygn10:09:51

not like it doesn't work (should have correct that), but in my case I have no clue what caused this

borkdude10:09:18

oh I am using shadow watch

borkdude10:09:34

to re-compile files using shadow

huygn10:09:23

what I did was running shadow watch and then start deno

huygn10:09:35

so that error throw from deno yea

huygn10:09:55

but shadow compile doesnt have such error

zendevil.eth11:09:57

Now I’m getting this error on auto-reload:

no source by provide: module
{:provide module}
ExceptionInfo: no source by provide: module
	shadow.build.data/get-source-id-by-provide (data.clj:186)
	shadow.build.data/get-source-id-by-provide (data.clj:183)
	shadow.build.data/get-source-by-provide (data.clj:189)
	shadow.build.data/get-source-by-provide (data.clj:188)
	shadow.build.js-support/shim-require-sugar-resource/fn--34338 (js_support.clj:107)
	shadow.build.data/get-source-code (data.clj:319)
	shadow.build.data/get-source-code (data.clj:306)
	shadow.build.closure/convert-goog*/iter--34184--34188/fn--34189/fn--34190 (closure.clj:2187)
	shadow.build.closure/convert-goog*/iter--34184--34188/fn--34189 (closure.clj:2186)
	clojure.lang.LazySeq.sval (LazySeq.java:42)
	clojure.lang.LazySeq.seq (LazySeq.java:51)
	clojure.lang.ChunkedCons.chunkedNext (ChunkedCons.java:59)
	clojure.core/chunk-next (core.clj:710)
	clojure.core.protocols/fn--8176 (protocols.clj:137)
	clojure.core.protocols/fn--8176 (protocols.clj:124)
	clojure.core.protocols/fn--8136/G--8131--8145 (protocols.clj:19)
	clojure.core.protocols/seq-reduce (protocols.clj:31)
	clojure.core.protocols/fn--8168 (protocols.clj:75)
	clojure.core.protocols/fn--8168 (protocols.clj:75)
	clojure.core.protocols/fn--8110/G--8105--8123 (protocols.clj:13)
	clojure.core/reduce (core.clj:6830)
	clojure.core/into (core.clj:6897)
	clojure.core/into (core.clj:6889)
	shadow.build.closure/convert-goog* (closure.clj:2190)
	shadow.build.closure/convert-goog* (closure.clj:2182)
	shadow.build.closure/convert-goog (closure.clj:2361)
	shadow.build.closure/convert-goog (closure.clj:2311)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1195)
	shadow.build.compiler/maybe-closure-convert (compiler.clj:1188)
	shadow.build.compiler/compile-all (compiler.clj:1426)
	shadow.build.compiler/compile-all (compiler.clj:1307)
	shadow.build.api/compile-sources (api.clj:261)
	shadow.build.api/compile-sources (api.clj:253)
	shadow.build/compile (build.clj:442)
	shadow.build/compile (build.clj:432)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:363)
	shadow.cljs.devtools.server.worker.impl/build-compile (impl.clj:344)
	shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:531)
	shadow.cljs.devtools.server.worker.impl/do-resource-update (impl.clj:486)
	shadow.cljs.devtools.server.util/server-thread/fn--37229/fn--37230/fn--37238 (util.clj:284)
	shadow.cljs.devtools.server.util/server-thread/fn--37229/fn--37230 (util.clj:283)
	shadow.cljs.devtools.server.util/server-thread/fn--37229 (util.clj:256)
	java.lang.Thread.run (Thread.java:748)

zendevil.eth12:09:33

I restarted shadow watch and it started working

Chase12:09:12

As a side note, on a small Hello World Reagent app, running the release build with optimizations set to :advanced I get a performance score of 86% on Lighthouse (it says I should reduce my unused JS but I thought that is what the optimizations/Google Closure Compiler took care of?). It says my JS transfer size is 271kb but it thinks there is potential savings of 168kb more. Does that sound about right? How would I get that extra savings (it says it would save my transfer time 1.2 sec from 3.2s which sounds big or am I prematurely optimizing here)?