Fork me on GitHub

hello, I'm trying to add electron-updater to an app, but when the app starts I see this error shadow.js.shim.module$electron_updater.AppUpdater.checkForUpdatesAndNotify is not a function


is shadow addimg some shim around electron_updater?


shadow.js.shim.module$electron_updater = require("electron-updater"); is basically what it does


so the function just doesn't exist on AppUpdater. maybe you need to instantiate it?


Not sure, but have you tried to hint that this is ^js like in this part of the doc: If you do that it shouldn't rename that function during compilation.


Is there a way to require data from a .edn file?


kind of when in webpack one can import a .json file?


Hi! I need some help, I'm new to shadow-cljs and unfamiliar with the larger JS/node ecosystem. I'm trying to import a npm package using shadow-cljs (the package is called ipfs) and use it in a browser app (:target is :browser). However, the compilation fails on the "crypto" package. ("The required JS dependency "crypto" is not available, it was required by "node_modules/nanoid/index.cjs".). From what I understand, crypto is something provided by node.js and not normally available in browsers. Does it mean that I need to use some kind of packer (like browserify or webpack) or can I somehow configure shadow-cljs to help me with that?


install shadow-cljs in the project itself. that will bring in a few polyfills for packages like those


but it also just might be that the package you are trying to use isn't compatible with the browser at all


Thanks! I do have shadow-cljs installed locally both. I tried both with --save and --save-dev (dunno if there's a difference). I didn't manage to get it working though. I'll stick to the CDN version and if I ever get deeper into this project, I might check what does webpack do differently. Regardless of that, thanks for shadow-cljs!


Oh, I can override it via :resolve in in :js-options. Is this how it's commonly done? Do I need to manually craft them for every node module?


Or should I just stop the fight and use a packed version of the library from CDN?


is there a react-native framework or template for shadow like re-natal is for Figwheel?

Ahmed Hassan06:04:59

;; shadow-cljs.edn in project
{:deps {:aliases [:cljs]}}

;; ~/.shadow-cljs/config.edn
{:deps-aliases [:cider]}
What's difference between using :deps and :deps-aliases ?


@ahmed1hsn the difference is that :deps-aliases allies to all projects and thus uses a different name


@pshar10 I only made a couple examples for RN, otherwise you just use shadow-cljs. nothing more specific for RN really.


Sometimes when loading a function, I get the following error in the repl:

no source by provide: myapp.workspaces.dom
{:provide myapp.workspaces.dom}
ExceptionInfo: no source by provide: myapp.workspaces.dom (data.clj:184) (data.clj:181) (data.clj:187) (data.clj:186)
	shadow.cljs.repl/repl-compile/fn--37359/fn--37360 (repl.clj:453)
	shadow.cljs.repl/repl-compile/fn--37359 (repl.clj:429)
	shadow.cljs.repl/repl-compile (repl.clj:427)
	shadow.cljs.repl/repl-compile (repl.clj:424)
	shadow.cljs.repl/process-read-result (repl.clj:515)
	shadow.cljs.repl/process-read-result (repl.clj:491)
	shadow.cljs.devtools.server.worker.impl/do-repl-rpc (impl.clj:859)
	shadow.cljs.devtools.server.worker.impl/do-repl-rpc (impl.clj:813)
	shadow.cljs.devtools.server.worker.impl/eval38290/fn--38291 (impl.clj:894)
	clojure.lang.MultiFn.invoke (
	shadow.cljs.devtools.server.util/server-thread/fn--37822/fn--37823/fn--37831 (util.clj:285)
	shadow.cljs.devtools.server.util/server-thread/fn--37822/fn--37823 (util.clj:284)
	shadow.cljs.devtools.server.util/server-thread/fn--37822 (util.clj:257) (
And the only way out is to quit the repl and start it again. Why would this be?


@pshar10 "Sometimes when loading a function" no clue what you mean by that


I mean evaluating a function in cider or the repl directly gives this error.


I don't know what causes it though.


The error gives no context


yeah I'll improve that error


@pshar10 which shadow-cljs do you use? your stacktrace doesn't line up with my code at all? seems like its a rather old version?


it's 2.8.102


please open shadow-cljs clj-repl and try ( "shadow/cljs/repl.clj") and post the result


it is very strange that your line numbers do not line up with the actual code


This way it actually shows a different version:

( "shadow/cljs/repl.clj")
#object[.URL 0xfee791d "jar:file:/private/var/root/.m2/repository/thheller/shadow-cljs/2.8.93/shadow-cljs-2.8.93.jar!/shadow/cljs/repl.clj"]


Why would this be?


I guess you are using leiningen or deps.edn?


then you have the old version in there


the npm version is only for the command line stuff


gotcha thanks

Chris McCormick13:04:38

is there a way to cause shadow-cljs's debug mode console to show a value? i am trying to debug on a platform without console access.


@chris358 "debug mode console"? you mean inspect?

Chris McCormick23:04:42

i mean the text which shows up at the bottom of the window when you have e.g. an undefined symbol in your code at compile time. i wanted to mis-use this to quickly display some value at runtime instead of doing js/alert but i should probably just install proper tooling instead. or just a pre tag facepalm sorry it was late.

Chris McCormick23:04:28

yes, inspect is what i need. WOW.


I can't evaluate things in Calva's :node-library , atm. The nrepl load-file op works, but not eval. It never returns. This happened w/o me upgrading shadow-cljs, which was still on 2.8.77. Using .102 makes no difference. The only thing I think has changed is my node version, which is now v12.13.0. Could that be the issue?


I don't know? works fine for me. any logs of the shadow-cljs server side maybe?


I also released .103 earlier which should log REPL errors more visibly


It seems that if I restart the extension host (within where my library runs) and then connect the repl again, things start to work. I can live with that, but a bit strange that it started happening. Will use .103, and see if it says something more about the condition.


No matching version found for [email protected]^2.8.103.


oh sry. forgot to push the npm package. should be available now.


@pshar10 you might also want to upgrade to 2.8.103. at least the errors should log more info now. hopefully that makes figuring out what is happening easier for me. Its just a raw data dump so I don't expect anyone to make sense of it, just report it.


@thheller FYI as of 2.8.102 something broke my (admittedly very unconventional) environment: I was loading a WebAssembly module, and I now see that the (automatically generated) js loader file does a require("fs"), making shadow-cljs complain with The required JS dependency "fs" is not available I reverted to 2.8.101 and everything started working again 🙂


care to share which package that is?


I didn't really change any of the polyfill behavior? so as long as you have shadow-cljs in the project it should find fs just fine?


that’s what I thought. I looked at the commits in .102 and couldn’t find the reason for it starting to complain at that point. Btw I can’t share that package as it’s proprietary, but I can try to create a minimal project that replicates the error. What’s the easiest way to setup a shadow-cljs project these days? (My codebase is 2 years old 🙂 )


npx create-cljs-project foo


cool, that’ll be a useful exercise


I only really need the package.json. if its just a blank require("fs") in the source file then only package.json can modify what that would do


ah that’s pretty basic, I don’t think there’s anything specific in there, let me check


alongside your own build config of course


@thheller I’m preparing a gist with package.json & shadow-cljs.edn, bear with me


@bru I didn't mean your package.json, I meant the package.json of the package that contains the require("fs")


oh wait it isn't a package at all?


@thheller ups, gotcha. It doesn’t have one at the moment, it’s a legacy C++ app that’s being converted to a wasm module


hmm weird, dunno how this is affected then?


eh, no idea. let me try to create that minimal shadow-cljs project, it will definitely be easier to debug a simpler setup


just to check. you do have shadow-cljs IN THE PROJECT and not globally?


hmm actually nevermind


it’s in the project, yes


let me test something


sure, I’m carrying on with my refresher on how to setup a project in shadow 🙂

Lucy Wang15:04:42

My project depends on a js lib, say "foo", and I have cloned that repo locally. Is it possible to tell shadow-cljs to auto reload it when I modify the source of foo?

Lucy Wang15:04:06

I have tried "yarn link" but shadow-cljs seems not compatible with it

Lucy Wang15:04:48

{:tag, :entries ["dist/index.js"], :package-dir #object[.File 0x69de6ee "/src/project-mine/node_modules/foo"]}
ExceptionInfo: package in /src/project-my/node_modules/foo specified entries but they were all missing


@wxitb2017 shadow-cljs no longer auto-reloads changes in node_modules if individual files are modified but it should recompiled if the package.json of that package is modified


so you can touch node_modules/foo/package.json


well does the /src/project-my/node_modules/foo/dist/index.js exist?

Lucy Wang15:04:55

it exists if I install it normally, but not when I use yarn link


if you just clone a package and not build it the files may just be missing


most packages will have a build step they do before publishing

Lucy Wang15:04:52

totally makes sense

Lucy Wang15:04:58

just tried, it works. Thx a ton @thheller!

👍 4
Lucy Wang17:04:16

Anyone experienced shadow-cljs interferencing with input methods? I have a form input field in my react application, and as long as I add some println functions in my on-change function, after typing a char the input method would be automatically switched back from Chinese to system default (English)

Lucy Wang17:04:01

And 1. if I disconnect the browser from the repl - the problem magically disappears 2. reproducible on both chrome/ff/safari 3. only println would cause this problem, OTOH js/console.log is fine

Lucy Wang17:04:31

reworded ☝️

Lucy Wang17:04:25

nvm - turned out to be a bug os my system config


@thheller here’s the minimal project I promised ->

🙌 4
Chris McCormick23:04:18

thanks for sharing this!


wow ! interesting !


the glue code this generates is still horrible 😛


but doesn't have anything to do with this particular problem. I just messed up a boolean statement 😛


I know, it wasn’t meant to be pretty, just straight to the point 😄


or, actually, demonstrate all the steps I need to take in the mothership project 😊


I'm surprised this actually runs to be honest 🙂


should be fine again in 2.8.104


I was too. It is very brittle though, I really don’t like having to keep babel in the picture for example


can you just add all the generated files to the repo?


I don't have any of the wasm related tools


@thheller those are already in place. You don’t really need to care about the last part of the setup (that’s just if you want to modify the C source).


uhm hang on, maybe I gitignored them


yeah the .wasm file is missing at least

👍 4

@thheller added now, in /resources/wasm. I’m also writing a build script to simplify the setup


don't bother 😛


hmm why the babel stuff though?


too late, pushed 😉 babel was the easiest way I found to massage the js files to please the google closure compiler. Honestly for this minimal project it’s overkill, but as said I wanted to replicate the setup of the original one


:thinking_face: actually I’ll try to use this to come up with a plan to eradicate babel


I just did 😛


awesome, your package-lock.json will be far slimmer now!


if you add me to the repo I can push the branch I made


the only problem I found is the ESM CommonJS interop. the generated libadd.js is commonjs but you glue.js was ESM


so the import WasmAdder ... was the problem


I switched it to

const WasmAdder = require('./libadd.js');

let add, malloc, free;

const wait = new Promise(done => {
  WasmAdder().then(Module => {
    malloc = Module._malloc;
    free = Module._free;
    add = Module.cwrap('add2', 'number', ['number', 'number']);

exports.add2wasm = function add2wasm(x, y) {
  return wait.then(() => { return add(x, y); });
and then you can just compile it with only shadow-cljs


yup, that makes perfectly sense. the original project is a bit more complex as it includes JS from different styles / sources.


yeah thats an issue. should be either all ESM or all CommonJS. the mix isn't supported well right now


eheh I noticed


btw, I invited you to the repo. If you want to push that branch, it’d be greatly appreciated


anyway, I hope this can help somehow push the wasm story for cljs. I know t’s brittle and sketchy at the moment, but it works and I’m mixing cljs, js and wasm in a single project (not saying it’s a good idea, but can be done 🙂 ).

👏 4

well now I did 😛

👍 4
👏 4

thank you so much for your help! I can confirm 2.8.104 works on both the small and the big projects