Fork me on GitHub
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?!


The error comes from bidi, presumably, 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.


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


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.


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


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.


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" + "יִ-﷿ﹰ-ﻼ";


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?


If you mean an issue - then sure!

Ben Lieberman04:08:05

That is what I meant 😅


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


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


I have an interesting problem here: The existence of a function _PLUS_ in a library seems to affect how the symbol '+ is processed in advanced compilation...


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


Rewriting to:

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


No, it didn't :(


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?


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


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


Copy to your project


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.


got it, thanks


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



👍 3