Fork me on GitHub
#shadow-cljs
<
2021-08-26
>
mkvlr07:08:38

is there a convention or existing solution to make :dev/after-load hooks not take effect when set in a library?

mkvlr08:08:08

other than moving the function to it’s own ns that is

thheller08:08:54

hmm no not currently

mkvlr08:08:51

move it to another ns and on second thought think it’s fine

thheller08:08:00

is it used during dev of the lib or why does it even exist when it shouldn't run?

mkvlr08:08:31

@thheller asked myself the same questions and came to the conclusion that it should not exists as part of the lib but in another dir like examples , outside of the lib classpath

tbrooke13:08:37

I am trying to use a javascript package (Accord Project Cicero and templatemark) that does not compile because of a pdfmake dependency - I checked and found pdfmake listed in clsjs so apparently that isn’t the problem — My error message in hopefully relevant part is: Caused by: RuntimeException: INTERNAL COMPILER ERROR. Please report this problem. Invalid node in lhs: STRINGLIT / 15252:4 [length: 15] [source_file: node_modules/pdfmake/build/pdfmake.js] Node(GETPROP default): node_modules/pdfmake/build/pdfmake.js:15259:8 exports.default = void 0; Parent(ASSIGN): node_modules/pdfmake/build/pdfmake.js:15259:0 exports.default = void 0; I know this isn’t much information but I’m not a javascript guy any thoughts on this - I’ve googled without any luck

thheller17:08:34

that is an error from the closure compiler trying to process the pdfmake sources

thheller17:08:05

I guess there is some code in there it doesn't like. can't do much about this from shadow, this is a closure-compiler problem

Simon13:08:23

I keep getting a blank screen with Uncaught Error: Assert failed: Invalid Hiccup form: [nil] but the component is just this simple one

(defn heyson []
  [:div "heyson"])
i import it like this: [app.components.cashflows :refer [graph-fn heyson]] and it is used like this
[:<>
 [input-bar app-state]
 [heyson]
 [json-city-list @app-state
   (activate-modal app-state)]]

3
Simon13:08:59

when i comment out the component and refresh it works again

[:<>
 [input-bar app-state]
 ;[heyson]
 [json-city-list @app-state
   (activate-modal app-state)]]

Simon13:08:25

but i need this simple component 🙂

Simon13:08:27

If i take the same component and input into another file it works fine. [app.components.cities.city-list :refer [json-city-list heyson]]

Simon13:08:03

The error is due to this import ["@ant-design/charts" :refer (Line)] inside the same file as the heyson component.

Simon13:08:43

but i can't just remove the import since its needed

Simon14:08:58

The issue had been solved! Just changed to a default import in the file where i couldn't import from. ["@ant-design/charts/es/plots/line" :default Line]

Simon14:08:19

So if you experience this error and you have found my post here do this: 1. Isolate the component that is causing the Uncaught Error: Assert failed: Invalid Hiccup form: [nil] error. 2. Go into the file where you imported this component from. Meaning the file in which you have defined the component that is causing the error. 3. Isolate which import/require is causing the trouble. 4. Try to replace it with a default import ["npmpackage/lib/component" :default Component] 5. Give this a thumbs up or down if it helped you. So that other people can now if it was useful, before they start reading 🙂

tbrooke13:08:06

Another naive question I watched the recent David Nolan video where he talked about keeping javascript as javascript — I have some react components that contain the code I recently asked about that crashes - Can I compile the Component as javascript and not recompile it

thheller17:08:11

your code doesn't cause the issue. the dependency does. you can use webpack or so to process the JS code after shadow-cljs is done with it.

thheller17:08:27

that is what David is doing basically (just in a react-native context)

borkdude13:08:51

@thheller I tried the suggestion from Twitter in a browser REPL:

(ns foo (:require ["goog$global.console" :refer [log]]))
That doesn't seem to work

thheller17:08:38

whoops I guess that could be considered a bug

thheller17:08:49

thats the special handling with strings in shadow-cljs

thheller17:08:58

goog$global.console does work

borkdude17:08:49

@thheller perhaps a difference in REPL vs file?

$ clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version "1.10.866"}}}' -M -m cljs.main
ClojureScript 1.10.866
cljs.user=> (ns foo (:require [goog$global.console :refer [log]]))
WARNING: foo is a single segment namespace at line 1 <cljs repl>
Unexpected error (ExceptionInfo) compiling at (REPL:1).
Invalid :refer, var goog$global.console/log does not exist in file <cljs repl>
foo=> (ns foo (:require [goog$global.console ]))
WARNING: foo is a single segment namespace at line 1 <cljs repl>
Execution error (ExceptionInfo) at cljs.repl/ns->input (repl.cljc:203).
goog$global.console does not exist

thheller17:08:43

none of what regular CLJS does in this regard affects how shadow-cljs handles it. in shadow I have the extra restriction that strings are only allowed for JS dependencies

thheller17:08:00

(:require ["clojure.string" :as str]) is valid in CLJS but not shadow-cljs

thheller17:08:36

I feel strongly about strings being only for not-regular-namespace JS code

borkdude17:08:43

I hadn't tried it with shadow.

thheller17:08:00

I'm surprised it doesn't work in CLJS though

borkdude17:08:29

> not-regular-namespace JS Do you mean: always use strings for JS nss, or do you mean: there's also regular-namespace JS code?

thheller17:08:50

closure-library is regular-namespace JS code technically (well at least some of it)

borkdude17:08:18

btw, this is the convention that clj-kondo has adopted as well: use strings for JS nss, then static analysis knows what's going on, so that's in line with shadow I guess. goog.* stuff is handled separately

thheller17:08:23

you know goog.provide and goog.require etc

thheller17:08:02

yeah the issue I have with js-deps-via-symbol is that it relies on some wonky detection of whats present in the node_modules folder

borkdude17:08:03

I was about to support (:require [whateverjslib]) in nbb but perhaps I should not?

thheller17:08:17

ie (:require [react]) is valid only if node_modules/react exists but not otherwise

thheller17:08:54

with (:require ["react" :as react]) you at least tell the compiler that you intent to use JS code (and the :js-provider will know how to provide it)

borkdude17:08:13

that's also what nbb is currently suggesting

thheller17:08:15

but js-provider is only a concept in shadow-cljs so I guess that is why I'm biased here

borkdude17:08:29

this makes it easier for nbb to know what to do

thheller17:08:17

that being said .. I'm surprised goog$global.Thing doesn't work in regular CLJS. it should but there is an open ticket specifically about "globals" so maybe thats why it doesn't work

borkdude17:08:49

I'll stick to the string-subset of requires for JS libs for nbb, in line with shadow, which also works well for clj-kondo.

Tiago Dall'Oca14:08:13

Should I add .shadow-cljs to my .gitignore?

Ryan Jerue15:08:11

I keep mine in there

thheller17:08:23

yes, absolutely. none of the files in there are meant to be version controlled

jyriand18:08:29

Hello, I'm trying out Expo with shadow-cljs I'm connecting to my iPhone device through the QR code. It was working ok until recently. Now I'm getting errors:

Error
21:09
shadow-cljs - remote-error, Event {
  "isTrusted": false,
  "message": "The operation couldn't be completed. Connection refused",
}

Stack trace:
   in registerError
   in errorImpl
   in console.error
   in error
   in shadow.cljs.devtools.client.shared.Runtime.prototype.shadow$cljs$devtools$client$shared$IRemote$remote_error$arity$2
   in shadow$cljs$devtools$client$shared$remote_error
   in shadow$cljs$devtools$client$websocket$start/socket.onerror
   in dispatchEvent
   in _registerEvents/this._subscriptions<
   in emit
   in __callFunction
   in callFunctionReturnFlushedQueue/<
   in __guard
   in callFunctionReturnFlushedQueue
   in parcelRequire<.sYUN</onmessage</<
  ...
Any ideas what be going on here? It was working and then, for no apparent reason, it stopped working.

thheller18:08:06

guessing the app can't connect back to the shadow-cljs instance? maybe your network setup changed? wlan or something?

jyriand20:08:21

Do I understand correctly that get-ws-relay-url should return url with the ip address not a "localhost" in case it's running in iOS?

thheller20:08:48

so its not using localhost since that won't work

thheller20:08:03

I'm assuming you are using :target :react-native in your build config

thheller20:08:45

you can check the IP being used by running shadow-cljs clj-repl and then (shadow/get-server-addr)

thheller20:08:07

you can override it should that not be correct

jyriand20:08:08

Ok. Thanks. It's 'localhost' for some reason

thheller20:08:48

did you already configure it to be that?

thheller20:08:23

:local-ip in shadow-cljs.edn or ~/.shadow-cljs/config.edn controls that

thheller20:08:34

needless to say that localhost is an invalid value here 😛

jyriand21:08:55

was able to fix it with :local-ip "192.168.8.104"

jyriand18:08:53

Might be, because it works if I open the app in the web

John Preston20:08:28

Is anyone using shadow-cljs with Boot? I want to make an app with a frontend and backend but I'm struggling to get these two pieces to play together properly

thheller20:08:14

play together in what way? I strongly recommend keeping them separate and letting each do their thing

thheller20:08:52

others have done boot related things in the past but I can't remember any details

andrzejsliwa20:08:38

Hey I have problem with integrating firebase with shadow-cljs app:

shadow-cljs: #11 ready!
index.esm2017.js:985 Uncaught ReferenceError: regeneratorRuntime is not defined
    at PersistentConnection.value (index.esm2017.js:985)
    at eval (index.esm2017.js:979)
any ideas what could be missing

thheller20:08:06

add an extra (:require ["regenerator-runtime/runtime"]) somewhere in your project. ideally before JS deps are loaded

thheller20:08:26

seems like you have some polyfilled code

thheller20:08:45

or ideally bump :compiler-options {:output-feature-set :es8}

thheller20:08:49

don't know what firebase supports

andrzejsliwa20:08:18

The required JS dependency "regenerator-runtime/runtime" is not available, it was required 

thheller21:08:18

yeah you might need to install it first. just npm install regenerator-runtime. for reasons I don't understand babel rewrites some code to use that package without ever adding a proper require for it

andrzejsliwa21:08:09

bumping feature-set also did not help, i have tried everything above es8 (es2018, es-next, etc…)

andrzejsliwa21:08:10

ok, now its working after install regenerator-runtime