shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
2020-10-11T00:11:16.369800Z

@andrei.stan I'm not sure if you fixed your problem or not, but you can always use re-frame-template to obtain a working re-com app

Andrei Stan 2020-10-11T05:58:35.369900Z

i have upgraded, build is ok, it still doesn't work. the build is ok, but i receive errors in browser console:

Andrei Stan 2020-10-11T05:59:30.370100Z

component.cljs:127 Error rendering component (in netdava.homebank.app.hello.converter >  >  >  > re_com.buttons.button)
reagent$impl$component$do_render	@	component.cljs:127
eval	@	component.cljs:143
reagent$ratom$in_context	@	ratom.cljs:37
reagent$ratom$deref_capture	@	ratom.cljs:43
reagent$ratom$run_in_reaction	@	ratom.cljs:504
netdava.homebank.app.hello.convert_btn_render	@	component.cljs:143
finishClassComponent	@	react-dom.development.js:14742
updateClassComponent	@	react-dom.development.js:14697
beginWork	@	react-dom.development.js:15645
performUnitOfWork	@	react-dom.development.js:19313
workLoop	@	react-dom.development.js:19353
callCallback	@	react-dom.development.js:150
invokeGuardedCallbackImpl	@	react-dom.development.js:200
invokeGuardedCallback	@	react-dom.development.js:257
replayUnitOfWork	@	react-dom.development.js:18579
renderRoot	@	react-dom.development.js:19469
performWorkOnRoot	@	react-dom.development.js:20343
performWork	@	react-dom.development.js:20255
requestWork	@	react-dom.development.js:20229
scheduleWork	@	react-dom.development.js:19912
updateContainerAtExpirationTime	@	react-dom.development.js:20573
updateContainer	@	react-dom.development.js:20658
ReactRoot.render	@	react-dom.development.js:20954
eval	@	react-dom.development.js:21091
unbatchedUpdates	@	react-dom.development.js:20460
legacyRenderSubtreeIntoContainer	@	react-dom.development.js:21087
render	@	react-dom.development.js:21156
reagent$dom$render_comp	@	dom.cljs:21
eval	@	dom.cljs:44
eval	@	dom.cljs:39
eval	@	core.cljs:74
netdava$homebank$app$core$render	@	core.cljs:20
netdava$homebank$app$core$main	@	core.cljs:25
eval	@	shadow.module.main.append.js:4
goog.globalEval	@	main.js:577
env.evalLoad	@	main.js:1670
(anonymous)	@	main.js:1941

Andrei Stan 2020-10-11T06:01:09.370300Z

thanks for your input, i will repeat the whole process if i can't fix it

Andrei Stan 2020-10-11T06:01:46.370500Z

main.js:1673 TypeError: Cannot read property 'cljs$core$IFn$_invoke$arity$1' of undefined
    at eval (validate.cljs:87)
    at validate_arg (validate.cljs:87)
    at eval (core.cljs:4736)
    at eval (core.cljs:4736)
    at Object.eval [as sval] (core.cljs:3439)
    at Object.eval [as cljs$core$ISeqable$_seq$arity$1] (core.cljs:3496)
    at Object.cljs$core$seq [as seq] (core.cljs:1234)
    at Object.cljs$core$every_QMARK_ [as every_QMARK_] (core.cljs:4239)
    at Object.re_com$validate$validate_fns_pass_QMARK_ [as validate_fns_pass_QMARK_] (validate.cljs:102)
    at Function.eval [as cljs$core$IFn$_invoke$arity$variadic] (validate.cljs:117)

jarredlhumphrey 2020-10-11T07:15:42.376400Z

Hello fellow clojurians... I've been working on an electron + re-frame + shadow-cljs app for the past few weeks and I've been running into an issue trying include an npm package called electron-store. If I understand the error logs correctly, it seems shadow-cljs doesn't like the javascript spread syntax that the electron-store library uses in a few places. Any idea why this is the case? All of my packages are fully up to date (at least as I'm aware) and I'm running on Node.js v14.13.0. Any thoughts around root cause would be much appreciated and let me know if there's more information I can provide to help clarify. Thanks! JS Error:

SHADOW import error <DIR>/.shadow-cljs/builds/main/dev/out/cljs-runtime/shadow.js.shim.module$electron_store.js
App threw an error during load
<DIR>/node_modules/electron-store/index.js:13
			...options
			^^^
SyntaxError: Unexpected token ...
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:528:28)
    at Object.Module._extensions..js (module.js:565:10)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
    at Function.Module._load (module.js:424:3)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at <DIR>/.shadow-cljs/builds/main/dev/out/cljs-runtime/shadow.js.shim.module$electron_store.js:3:40
    at global.SHADOW_IMPORT (<DIR>/resources/main.js:64:44) 
shadow-cljs.edn:
;; shadow-cljs configuration
{:source-paths ["src"]

 :dependencies [[reagent "0.10.0"]
                [re-frame "1.1.1"]
                [cider/cider-nrepl "0.21.0"]]

 :dev-http {8080 "resources/public/"}

 :builds {:main {:target :node-script
                 :output-to "resources/main.js"
                 :main app.main.core/main}

          :renderer {:target :browser
                     :output-dir "resources/public/js"
                     :asset-path "js"
                     :modules {:renderer {:init-fn app.renderer.core/start!}}}}}
package.json
{
  "name": "placeholder",
  "version": "1.0.0",
  "description": "placeholder",
  "main": "resources/main.js",
  "scripts": {
    "dev": "./node_modules/.bin/shadow-cljs watch main renderer",
    "build": "./node_modules/.bin/shadow-cljs compile main renderer",
    "clean": "rm -rf resources/public/js/* && rm -rf target"
  },
  "keywords": [
    "shadow-cljs",
    "reagent",
    "electron"
  ],
  "author": "placeholder",
  "devDependencies": {
    "electron": "^10.1.3",
    "shadow-cljs": "^2.11.5"
  },
  "dependencies": {
    "@material-ui/core": "^4.11.0",
    "create-react-class": "^15.6.3",
    "electron-store": "^6.0.1",
    "normalize.css": "^8.0.1",
    "react": "^16.13.0",
    "react-dom": "^16.13.0"
  }
}

thheller 2020-10-11T08:44:47.377Z

@jarredlhumphrey this is an internal electron/node error. it has trouble loading that file. not shadow-cljs.

thheller 2020-10-11T08:45:34.377400Z

just run node and then require("electron-store"). that should give you the same error.

thheller 2020-10-11T08:47:49.378100Z

maybe some electron/node setting configures which language version it accepts or so?

teodorlu 2020-10-11T10:03:39.379700Z

Hey! I'm having trouble using Datascript under Shadow-CLJS and advanced compilation. Before I write up a minimal example, has anyone else had this problem? I'm using Shadow-CLJS 2.11.5 and Datascript 1.0.1.

thheller 2020-10-11T10:11:59.380Z

you need to include the externs for some reason. no clue why.

teodorlu 2020-10-11T10:15:53.380700Z

Ah, that's a bit random. Thanks!

teodorlu 2020-10-11T10:23:45.381200Z

That fixed it. Thanks a lot, @thheller 🙏

jarredlhumphrey 2020-10-11T19:19:47.381300Z

@thheller hmm when I do this from Node I don't receive any errors. Similarly, when I try to run an example vm.runInThisContext call from Node with a spread operator (as thats the command in shadow-cljs thats choking) I dont have any issues. So it seems to be just from the context of shadow-cljs that its barfing. I'm going to dig into electron a bit and see if it does anything special to node or the vm that might effect this, but otherwise still a little stumped. Anyhow, thanks for your help here I really appreciate it.

thheller 2020-10-11T19:22:38.381500Z

no clue. shadow.js.shim.module$electron_store.js is literally only doing require("electron-store") and the failure is in that file. shadow-cljs has not processed that file in any way and it is just up to electron fulfilling that require.

👍 1
jarredlhumphrey 2020-10-11T19:34:04.381800Z

Ok thanks for the clarification. Appreciate it!