Fork me on GitHub
#shadow-cljs
<
2020-10-11
>
mikethompson00:10:16

@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 Stan06:10:09

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

jarredlhumphrey07:10:42

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"
  }
}

thheller08:10:47

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

thheller08:10:34

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

jarredlhumphrey19:10:47

@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.

thheller19:10:38

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.

👍 3
jarredlhumphrey19:10:04

Ok thanks for the clarification. Appreciate it!

thheller08:10:49

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

teodorlu10:10:39

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.

thheller10:10:59

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

teodorlu10:10:53

Ah, that's a bit random. Thanks!

teodorlu10:10:45

That fixed it. Thanks a lot, @thheller 🙏