Fork me on GitHub
#clojurescript
<
2022-05-17
>
henrik11:05:30

Why am I getting Use of undeclared Var cljs.analyzer/Throwable with 1.11.54?

------ WARNING #2 - :undeclared-var --------------------------------------------
 Resource: cljs/analyzer.cljc:4403:12
--------------------------------------------------------------------------------
4400 |   []
4401 |   (try
4402 |     @(ns-resolve 'clojure.tools.reader '*alias-map*)
4403 |     (catch Throwable t
------------------^-------------------------------------------------------------
 Use of undeclared Var cljs.analyzer/Throwable
--------------------------------------------------------------------------------
4404 |       nil)))
4405 |
4406 | #?(:clj
4407 |    (defn forms-seq*
--------------------------------------------------------------------------------
It's also complaining about cljs.analyzer/ns-resolve.

henrik14:05:46

@dnolen Let me know if I can provide you with any further information 👍

dnolen14:05:21

@U06B8J0AJ it's already fixed, please use ClojureScript master and let me know if it works for you

👍 1
henrik15:05:53

@dnolen c0d305274d7813e22cd2753d247a02e9dd95ddee fixes the warnings.

dnolen15:05:18

I'm curious what you are doing since this didn't arise in the unit tests, I guess you're calling analyze-form-seq yourself?

henrik16:05:16

Honestly, I have no idea. I've been hunting for the origin of this (since no source is given except for CLJS itself). My best guess is that it's some transitive dependency. I haven't dug into those yet.

dnolen16:05:41

hrm ok, thanks

henrik16:05:45

Although, hang on. Could it be this lazy-ass thing I wrote for a test seed?

(defmacro entities-in-ns
     "Returns a vector of all entities defined in the supplied namespace."
     [ns-symbol]
     `(filterv entity? (map deref (vals (ns-publics ~ns-symbol)))))

dnolen16:05:27

hrm from what's visible there, I doubt it

thheller11:05:49

looks like a bug introduced in 1.11.51 I guess. Throwable is a java thing, so needs to be behind a reader conditional for self-host I guess

👍 1
arohner12:05:50

I have some JS that I’d like to compile via :foreign-lib so it can be live reloaded. If foo/a.js calls require ./b.js, is that supported? I’m trying to specify it as :provides ["foo.a"] and :provides ["foo.b"], but closure isn’t finding ./b.js. It looks like it’s searching for ./b.js relative to my package.json, rather than relative to a.js

dnolen14:05:15

@thheller hrm, odd that didn't get caught by the self host tests

dnolen14:05:17

@arohner you're saying something a bit contradictory. If it's foreign lib - you cannot compile through Closure (technically you can, but it just doesn't work well in the general case, so you need to really know what you are doing). So not sure what you mean or what you are trying to do.

dnolen14:05:31

If it's custom JS you wrote, then you don't need foreign libs.

arohner14:05:50

My existing build is using :target :bundle. I have JS I wrote that is currently nodeJS and using node deps. I would like the custom JS to live reload using figwheel. AIUI, the easiest way to do that is to run the JS through Closure

dnolen14:05:34

that's just not how :target :bundle works

dnolen14:05:02

ClojureScript does not understand Node.js stuff, it assumes the JS bundler will bundle all that stuff into one big thing

dnolen14:05:27

to clarify a bit more (:require [some-node-thing :as ...]) in your ns form is completely synthetic

dnolen14:05:21

there is nothing really to load, because some JS bundler already bundled the JS bits into one big file (when using :target :bundle)

dnolen14:05:10

:foreign-lib use directly can support live reload, but that's separate from :target :bundle stuff

arohner14:05:31

If I define :foreign-lib for the npm deps of my custom JS, and then foreign lib my JS, would that work?

dnolen14:05:16

let's step back for a second

dnolen14:05:49

:foreign-lib is an old thing that existed before Webpack and it's ilk, before people stored web libs in Node.js - remember Bower

dnolen14:05:11

the assumption is the JS library is read to go - has no dependencies, already compiled, etc.

dnolen14:05:45

in this case we load these files for you at development time, and we concatenate them in advanced builds

dnolen14:05:03

that's the true purpose of :foreign-lib

dnolen14:05:31

:target :bundle solves a different problem - you want to use something from node_modules - your JS is not ready to go

dnolen14:05:06

in fact, the JS you want to use has an complex dependency graph, or feature set only JS tools can understand

dnolen14:05:38

in this case we don't really load anything, we assume that you will bundle all this stuff up into one big file

dnolen14:05:59

we inject ClojureScript into the entrypoint, but all your deps are already loaded

dnolen14:05:03

based on this I would say :target :bundle + hot reloading some JS through Figwheel is not really practical

dnolen14:05:13

and probably in many cases cannot even work

dnolen14:05:29

because JS libs are represented as closures in the tooling

dnolen14:05:43

I haven't followed JS hot loaders because far as I can tell it is a big mess and they never got it work (to our REPL expectations) because the whole thing is conceptually broken from a Lisp viewpoint

arohner14:05:49

AFAICT, the JS hotloaders also don’t work for us because they assume ESM/commonJS modules, and the CLJS hot reloaders assume closure modules

dnolen14:05:01

there are bigger problems due to ESM/CJS here, we would never use it anyway

dnolen14:05:12

with :foreign-lib you could setup a watching JS bundler, and then have Figwheel watch for changes to the produced .js file if you don't need what :target :bundle provides

vlad_poh19:05:53

Are there any https://github.com/day8/re-com alternatives? A full suite of styled clojurescript components?

p-himik19:05:59

There are CLJS bindings/wrappers for other libraries, like MUI.

p-himik19:05:29

And there's always an option to use a UI library directly - i.e. creating your own wrapper for it, in a way.

vlad_poh19:05:36

Interesting taking a look at MUI right now. Thanks

vlad_poh18:05:15

@U06B8J0AJ do you have an example in clojurescript or do you use regular react

henrik11:05:52

In Reagent, you'd do something like

(def listbox
  (reagent/adapt-react-class Headless/Listbox))

henrik11:05:07

Given an import of

["@headlessui/react" :as Headless]

henrik11:05:20

And then just use it as you would a normal Reagent component,

[listbox {...}]

henrik11:05:25

Follow the structure of the examples on the Headless website. Keep in mind that some things need to be converted to JS, and some keywords are different, like :className instead of :class, etc.

👍 1
hkrish22:05:30

Cann't display an image from S3! Getting the image ->

{:http-xhrio {:method          :get
              :uri             (:s3/url data)
              :timeout         8000
  
              :headers         {"Content-Type" "image/*"}
              :response-format (ajax/raw-response-format)
             
              :on-success      [::get-uploaded-image-success]
              :on-failure      [::s3-url-failure]}
 }
I can see the response-->
"_response" "�PNG\r\n\n\rIHDR��\bΧ&�HiCCPICC Profile(�c``I,(�aa``��+)\nrwR���R`��� Ė\fl����>@%\f0|���\b�/��\nch���{�ѷ���X1գ����d ��3��JS�l����):\nȞb�C�@�$\b�\bXMH�3�}
............

on the reagent comp->>
[:img {:src    @form-values-image}]

The image is not being displayed!  But when I click on the link in the browser console, it downloads the image.

Any idea?  Thanks in advance.

manutter5122:05:51

Hmm, I don't know anything at all about S3, but the symptoms you describe are what happens when the server sends a PNG file with a Content-Type that's not image/png.

hkrish23:05:37

Thank you. I think it is in the right direction. I uploaded a new image (png), with Content-Type, image/png. Checked on aws, and it is right. But still getting the same issue. Does the :img on the reagent comp has a content-type attr? will theck. Thanks.

hkrish23:05:32

Thanks again. I figured out, finally. First, I changed the seeting at AWS metadata of that image to "image/png", as previously stated. Second, I used the URL directly inside the map to :img tag in the reagent component, as shown below:

[:div.display-image     [:img {:src    @get-image-s3-url}]]
Thanks again.

👍 1
vanelsas06:05:08

I think :src expects a base64 encoding.

bteuber07:05:23

vorher zur stadt zähltzalbwegs kann