Fork me on GitHub
#shadow-cljs
<
2023-06-12
>
Ivan Fedorov09:06:21

getting a StringIndexOutOfBoundsException when trying to load a file to a repl. • Tried relaunching the server, updated to 2.23.3, didn’t help. • Project compilation on itself – works, so this happens only when loading into a repl • deleting different file parts helps, but this seems quite random.

thheller09:06:35

odd. do you maybe have an accidental special unicode char in there?

Ivan Fedorov09:06:24

seems like it’s failing when encounters lines with a ; right after closing parens

Ivan Fedorov09:06:52

The ns is special too, has some regexes and loads macros. But the ; seems to be the main contributor

thheller10:06:10

that is very odd indeed

thheller11:06:01

but could still be some kind of invisible char there? did you check?

thheller11:06:44

like that I guess?

thheller11:06:54

sometimes unicode can be tricky

Ivan Fedorov21:06:07

I checked with vim via :set list it showed ;$ where this dollar sign is semi-transparent and indicates end of string

Ivan Fedorov21:06:16

I experimented a bit and found a minimal reproduction case. Just put this into your cljs file and eval the whole ns into a repl

(def ua-regexp (js/RegExp. "(MSIE|(?!Gecko.+)Firefox|(?!AppleWebKit.+Chrome.+)Safari|(?!AppleWebKit.+)Chrome|AppleWebKit(?!.+Chrome|.+Safari)|Gecko(?!.+Firefox))(?: |\\/)([\\d\\.apre]+)"))
(def -ua-info (.exec ua-regexp js/navigator.userAgent));
(def ddd (or ua-regexp -ua-info));

Ivan Fedorov21:06:21

if you switch off the last line – it will work. with the line it breaks. until you erase the ; cc @U05224H0W

Ivan Fedorov21:06:27

I can file a ticket for you. since I can live without these semicolons – this has no impact on me.

thheller05:06:56

this isn't a shadow-cljs issue. it is a tools.reader issue

thheller05:06:02

I reduced it further to

(def foo "foo");
(def bar [])

thheller05:06:16

repro with just tools.reader

(let [rdr (clojure.tools.reader.reader-types/source-logging-push-back-reader
            "(ns demo.test)\n\n(def foo \"foo\");\n(def bar [])\n")]
  (clojure.tools.reader/read+string rdr)
  (clojure.tools.reader/read+string rdr)
  (clojure.tools.reader/read+string rdr))

thheller05:06:52

shadow-cljs uses read+string in a loop there, but the gist is reading the 3 forms in sequence

thheller05:06:22

somehow it gets into a confused state after the second I guess, no clue what is going on though

thheller05:06:44

regular compilation does not use read+string, so thats why that works.

Ivan Fedorov11:06:36

Ah, so I should pass it to tools reader project. Filed https://github.com/clojure/tools.reader/issues/19

thheller12:06:16

they don't do github issues. gotta go through http://ask.clojure.org or jira

nivekuil06:11:49

also ran into this. couldn't find anything on http://ask.clojure.org, was there a followup?

Rachel Westmacott16:06:29

Has anyone here used Material Design Icons in a clojurescript project?

Rachel Westmacott16:06:42

(I'm having a little trouble making it work)

thheller16:06:16

whats the problem?

Rachel Westmacott16:06:39

We tried to pull in with an npm install and got it in our /node_modules but we didn't get the CSS we wanted in our target directory

thheller16:06:27

shadow-cljs doesn't build any css, so that in itself won't do anything

thheller16:06:53

what are you using to build your css?

Rachel Westmacott16:06:49

So if we pull in an NPM module with CSS resources then we need to manually (programatically) ensure we copy those into our target directory?

thheller16:06:41

well you need to build your css in some way

thheller16:06:01

just copying might be fine. or tools such as postcss can be useful

Rachel Westmacott16:06:38

thank you - you've increased my understanding

Rachel Westmacott16:06:36

I guess I'm surprised to discover that js is being pulled in, but css isn't

Rachel Westmacott16:06:00

but I'm no expert on this

Rachel Westmacott16:06:06

(it may be our project setup doing something funky!)

thheller16:06:32

too many ways to handle css and non-trivial to support. I don't have the time to add that support to shadow-cljs, and frankly I don't think it should. better served by tools specifically designed for css.

gratitude 2
thheller16:06:43

you can always use webpack of course, that handles css as well