shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
vinurs 2021-05-09T09:59:04.032900Z

hello, how can i use this remote in render file with electron

import {remote} from "electron";
when i import it ,it outputs
An error occurred when loading app.renderer.core.js
env.evalLoad @ renderer.js:1562
(anonymous) @ renderer.js:2005
renderer.js:1563 TypeError: exports.existsSync is not a function
    at Object.shadow$provide.module$node_modules$electron$index (index.js:9)
    at Object.shadow.js.jsRequire (js.js:66)
    at Object.shadow.js.require (js.js:113)
    at eval (js/cljs-runtime/app.renderer.core.js:3)
    at eval (<anonymous>)
    at Object.goog.globalEval (renderer.js:497)
    at Object.env.evalLoad (renderer.js:1560)
    at renderer.js:2005
env.evalLoad @ renderer.js:1563
(anonymous) @ renderer.js:2005
js/cljs-runtime/shadow.module.renderer.append.js:4 An error occurred when calling (app.renderer.core/start!)
eval @ js/cljs-runtime/shadow.module.renderer.append.js:4
goog.globalEval @ renderer.js:497
env.evalLoad @ renderer.js:1560
(anonymous) @ renderer.js:2006
renderer.js:1562 An error occurred when loading shadow.module.renderer.append.js
env.evalLoad @ renderer.js:1562
(anonymous) @ renderer.js:2006
renderer.js:1563 TypeError: app.renderer.core.start_BANG_ is not a function
    at eval (js/cljs-runtime/shadow.module.renderer.append.js:4)
    at eval (<anonymous>)
    at Object.goog.globalEval (renderer.js:497)
    at Object.env.evalLoad (renderer.js:1560)
    at renderer.js:2006

anonimitoraf 2021-05-09T10:18:33.034600Z

Hi guys, I'm getting this error

The required JS dependency "entities/maps/entities.json" is not available, it was required by "node_modules/htmlparser2/lib/Tokenizer.js".

Dependency Trace:
	tung_frontend/devcards/core.cljs
	tung_frontend/devcards/text_chat.cljs
	node_modules/stream-chat-react/dist/index.js
	node_modules/react-markdown/with-html.js
	node_modules/react-markdown/lib/with-html.js
	node_modules/react-markdown/lib/plugins/html-parser.js
	node_modules/html-to-react/index.js
	node_modules/html-to-react/lib/parser.js
	node_modules/htmlparser2/lib/index.js
	node_modules/htmlparser2/lib/Parser.js
	node_modules/htmlparser2/lib/Tokenizer.js

Searched for npm packages in:
	/home/anonimito/work/pegleg/clojure/eviota-frontend/node_modules

See: <https://shadow-cljs.github.io/docs/UsersGuide.html#npm-install>
I found this old shadow-cljs thread that contains this exact error message https://clojurians-log.clojureverse.org/shadow-cljs/2020-08-20/1598004360.046400 but it doesn't seem to work for me. Relevant config:
:devcards {:asset-path "js/devcards"
                                    :modules {:main {:init-fn tung-frontend.devcards.core/main}}
                                    :compiler-options {:devcards true}
                                    :output-dir "resources/public/js/devcards"
                                    ;; :devtools {:httop-root "resources/public" :http-port 8281}
                                    :target :browser
                                    :build-options {:ns-aliases {devcards-marked
                                                                 tung-frontend.devcards.cljsjs.marked
                                                                 devcards-syntax-highlighter
                                                                 tung-frontend.devcards.cljsjs.highlight}}
                                    ;; See <https://clojurians-log.clojureverse.org/shadow-cljs/2020-08-20>
                                    :js-options {:resolve {"entities/maps/entities.json"
                                                           {:target :npm
                                                            :require "entities/lib/maps/entities.json"}}}}
I'm using thheller/shadow-cljs "2.11.4"

anonimitoraf 2021-05-09T10:25:29.034900Z

Weird, installing htmlparser2 manually seems to solve it. πŸ˜•

thheller 2021-05-09T10:33:16.035100Z

very likely a dependency conflict

thheller 2021-05-09T10:34:42.035300Z

not enough code to comment. you are calling existsSync on something but I can't guess the code doing that.

anonimitoraf 2021-05-09T10:47:15.035500Z

Right, I see 2 versions of it (via yarn why)

=&gt; Found "htmlparser2@3.10.1"
info Has been hoisted to "htmlparser2"
info Reasons this module exists
   - Hoisted from "stylelint#postcss-html#htmlparser2"
   - Hoisted from "stream-chat-react#react-images#html-react-parser#html-dom-parser#htmlparser2"
info Disk size without dependencies: "420KB"
info Disk size with unique dependencies: "1.09MB"
info Disk size with transitive dependencies: "1.29MB"
info Number of shared dependencies: 12
=&gt; Found "html-to-react#htmlparser2@5.0.1"
info This module exists because "stream-chat-react#react-markdown#html-to-react" depends on it.
info Disk size without dependencies: "164KB"
info Disk size with unique dependencies: "584KB"
info Disk size with transitive dependencies: "608KB"
info Number of shared dependencies: 5

vinurs 2021-05-09T10:50:12.035700Z

const fs = require('fs');
const path = require('path');

const pathFile = path.join(__dirname, 'path.txt');

function getElectronPath () {
  if (fs.existsSync(pathFile)) {
    const executablePath = fs.readFileSync(pathFile, 'utf-8');
    if (process.env.ELECTRON_OVERRIDE_DIST_PATH) {
      return path.join(process.env.ELECTRON_OVERRIDE_DIST_PATH, executablePath);
    }
    return path.join(__dirname, 'dist', executablePath);
  } else {
    throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again');
  }
}

module.exports = getElectronPath();
i found it in node_modules/electron/index.js

vinurs 2021-05-09T10:51:00.035900Z

using "electron": "^12.0.6",

thheller 2021-05-09T10:54:45.036100Z

I'm guessing you are not supposed to use that in the renderer?

thheller 2021-05-09T10:55:08.036300Z

I don't use electron so I really cannot help much

vinurs 2021-05-09T10:55:11.036500Z

yes, i just want to use dialog in electron.remote

Ivan Fedorov 2021-05-09T11:07:19.039900Z

anyone had any issues with watching changes in Linux on Windows environment? I have a client, who has launched shadow-cljs watch app , then he changes a view file, but shadow doesn’t recompile. Perhaps may be some WSL issue. If shadow-cljs build is re-launched – then it updates the view. ---- UPD: My client found this https://stackoverflow.com/questions/66055215/emacs-cider-with-shadow-cljs-browser-settings-on-windows-wsl2-hot-code-reload/66061927#66061927, so suspicion moves strongly towards WSL conf. ---- UPD2: Fixed with SO instructions

thheller 2021-05-09T11:10:38.040900Z

yes, common wsl2 problem

πŸ‘ 1
naomarik 2021-05-09T13:09:28.041700Z

I've done all my wsl2 development from within the linux FS and had no problems with any watchers.

πŸ‘ 1
Aron 2021-05-09T13:24:07.042300Z

same here, vim and vscode, latter has own support for editing wsl projects, works very well

πŸ‘ 1
thheller 2021-05-09T13:35:12.043Z

the problem happens when you edit the files from windows via the mounted fs. if you edit files from within the wsl distro that is fine

πŸ‘ 1