Fork me on GitHub
#clojurescript
<
2022-08-16
>
Ben Lieberman01:08:55

I'm doing the lein-figwheel quick start to get acquainted with ClojureScript. But I got to the step where I change some code while the server is running and I get this pretty whacky error:

bidi.js:39 Uncaught SyntaxError: Invalid regular expression: /[Ö'-Û¯Ûº-ࣿâ€�-��-�ï¬-ï·¿ï¹°-ﻼ]/: Range out of order in character class
    at new RegExp (<anonymous>)
    at bidi.js:39:30
 Hey Seymore sup?!

p-himik03:08:28

The error comes from bidi, presumably https://github.com/juxt/bidi, but the quick start doesn't mention it and none of the dependencies use it. Where did it come from?

Ben Lieberman03:08:54

that's a good question, @U2FRKM4TW. I'd have to do some digging bc it's not in my dependencies either. As far as I can tell I have been following the tutorial to the letter.

p-himik03:08:15

Ah, it's actually goog.i18n.bidi.

Ben Lieberman03:08:53

This is some kind of localization library as far as I can tell?

Ben Lieberman03:08:23

What would this be doing if my code is just using plain English characters

p-himik04:08:22

It's required by Google Closure library's basic functionality, which is required by CLJS itself. Seems like the way figwheel compiles stuff, it ends up corrupting that RegEx somehow.

p-himik04:08:44

Ah, nah - it's the same for me with shadow-cljs. The RegEx itself, that is. But I don't see the same error.

p-himik04:08:19

Don't quite understand what's going on, but figwheel's compiled bidi.js has 'use strict'; at the very top and shadow-cljs' one doesn't. But also, when the RegExp is loaded it has one text. But when I open it in a separate browser's tab, it has a completely different one. No clue what's going on.

p-himik04:08:22

The file evaluated by the browser has this: goog.i18n.bidi.rtlChars_ = "Ö'-Û¯Ûº-ࣿâ€\ud802-\ud803\ud83a-\ud83b" + "ï¬-ï·¿ï¹°-ﻼ"; The very same file but opened in a separate tab has this: goog.i18n.bidi.rtlChars_ = "֑-ۯۺ-ࣿ‏\ud802-\ud803\ud83a-\ud83b" + "יִ-﷿ﹰ-ﻼ";

p-himik04:08:04

Both are valid though when you feed them to new RegExp(...) in JS console. so my bet is on 'use strict';.

Ben Lieberman04:08:48

well I guess I'm glad it's not something dumb I did. Worth opening a PR do you think?

p-himik04:08:29

If you mean an issue - then sure!

Ben Lieberman04:08:05

That is what I meant 😅

thheller05:08:28

set the proper charset encoding in your html. <meta charset="utf-8"> usually fixes this

p-himik06:08:53

Ah, then it can even become a PR since the quick start tells you what exactly to put into the HTML.

borkdude08:08:57

I have an interesting problem here: https://github.com/clavascript/clavascript/pull/25#issuecomment-1216290062 The existence of a function _PLUS_ in a library seems to affect how the symbol '+ is processed in advanced compilation...

borkdude08:08:37

Perhaps it's better to use a set with strings or so, but it's kind of surprising how this manifests...

borkdude08:08:28

Rewriting to:

(def infix-operators '#{+ += - -= / * % = == === < > <= >= !=
                        << >> <<< >>> !== & | && || not= instanceof})
seems to help

borkdude08:08:44

No, it didn't :(

wombawomba12:08:06

I'd like to do a modify a function in a CLJS lib a little bit, without having to fork said library. On the JVM I'd just use alter-var-root for this, but this seems not to be available in CLJS. Are there any alternatives?

p-himik12:08:43

You can vendor in a specific namespace and change the function there.

wombawomba12:08:04

Er, sorry, not sure I follow. What do you mean by vendor?

walterl12:08:56

Copy to your project

p-himik12:08:03

Find the right file in the lib's source code, copy it over to your project into the right directory structure based on its namespace, and then change it. It'll take precedence over the original file during compilation.

wombawomba12:08:56

got it, thanks

sirwobin15:08:48

Is there a better channel to ask shadow-cljs questions on?

thheller15:08:50

#shadow-cljs

👍 3