Fork me on GitHub
#shadow-cljs
<
2022-07-14
>
steveb8n02:07:34

Q: I upgraded to latest shadow and I’m getting a new release build error: Invalid Regular Expression. Anyone seen/fixed this? more in thread….

steveb8n02:07:43

ES6 does support unicode regexes so I’m trying to figure out the correct shadow config to support this for advanced compile

steveb8n02:07:51

works fine in dev builds

steveb8n02:07:02

using :output-feature-set :es-next doesn’t seem to help as I hoped

steveb8n02:07:23

but I don’t understand how that lib could be generally used in that case

steveb8n02:07:16

I’m not actually using that lib (it’s a transitive npm dep) so I could trying excluding it as a fix

steveb8n02:07:51

or is there a way to exclude an npm source file (since I don’t need it)?

steveb8n02:07:22

worst case I have to fork/override the lib but I’d prefer not to do that

steveb8n03:07:50

hmm, case-anything is a dep of remirror which is the lib I need. I could also try excluding it there

steveb8n04:07:16

@U0509NKGK something to watch out for if you are using remirror

robert-stuttaford05:07:58

thanks Steve! we've ended up going full tiptap 🙂

steveb8n06:07:26

Ah yes, makes sense for a rum app

thheller07:07:49

do you have the actual full error including stacktrace/location info?

thheller07:07:03

the closure compiler is sometimes a little overeager when it comes to validating code

thheller07:07:33

and sometimes complains about stuff that is actually perfectly valid

thheller07:07:20

but that doesn't mean its not a bug

steveb8n08:07:26

I’ll generate a full error now…..

steveb8n08:07:41

Uncaught SyntaxError: Invalid regular expression: /^[a-zà -öø-ÿ]+|[A-ZÀ-ÖØ-ß][a-zà -öø-ÿ]+|[a-zà -öø-ÿ]+|[0-9]+|[A-ZÀ-ÖØ-ß]+(?![a-zà -öø-ÿ])/: Range out of order in character class (at main.js:3287:266)

steveb8n08:07:45

when I look at that line in the generated js, it seems to be from the case-anything transitive npm dep

thheller08:07:17

thats not a compiler error thats a runtime error

steveb8n08:07:24

my suspicion in Google Closure as you say

thheller08:07:32

which may just mean that its an encoding issue

thheller08:07:37

do you set you page encoding properly?

steveb8n08:07:47

true enough

thheller08:07:49

<meta charset="utf-8"> in the head?

steveb8n08:07:59

no I didn’t check that. will do now

steveb8n08:07:36

boom! that fixes it. once again you are a legend

steveb8n08:07:59

much appreciated. I’m glad I only spent 3 hours before I decided to wait to ask you 🙂

p-himik06:07:43

When working with JS files within a CLJS project, I find that changing those JS files results in shadow-cljs reloading them, along with the CLJS files that use them. However: • Still the old code is used - so I have to refresh the page to make it take the changes into account • Other JS files that use the changed JS files don't seem to be reloaded (according to what I've seen in the shadow-cljs' WebSocket packets), so I assume even if the previous item is fixed, it still won't work correctly in some cases Is it possible to fix the above?

thheller07:07:16

@p-himik define JS file. reloading should only sort of work for ESM code. commonjs code can't really be reloaded

thheller07:07:14

not a whole lot of people use many JS files directly (me included), so there might be bugs or problems

thheller07:07:29

and as always its directly exposed to and relying on the closure compiler. they frequently change how they rewrite stuff and I might miss those changes if they need adjustment on the shadow-cljs side

p-himik07:07:52

> define JS file I'm still a bit hazy on this I'm afraid. Ones that use const {x} = require('/something'); - you recommended this approach to me some time ago.

thheller07:07:12

thats commonjs. its treated like node_modules files so less reliant on closure compiler rewriting

thheller07:07:04

but also less friendly to reloading and stuff

thheller07:07:25

I mean you are aware of how much more complicated hot-reload is in the JS world

p-himik07:07:32

Only superficially, and the most recent piece of knowledge that I have is that people from the React ecosystem have apparently figured out how to reload Reacts apps properly, without even losing any state. But that's probably not relevant here at all.

thheller07:07:46

well, yes its possible. but it is much more complicated than just "eval this new code over the old one"

thheller07:07:09

but yeah, shadow-cljs doesn't support reloading commonjs code at this time

thheller07:07:34

I mean it attempts to but it is fairly limited

p-himik07:07:01

Right... Shame, page refreshing it is then. Thanks!

bbss14:07:56

@p-himik fwiw, I also started playing with react fast-refresh. I :require some JS here and there and sometimes it reloads sometimes it doesn't haven't really dug into that too deep. It's cool to re-eval a react component from the repl and have only the relevant components reload. To get used to fast-refresh I even turned off file-save and only used eval from my ide to change components, it's quite instant, whereas file save reload can start adding up when the files get bigger. Although forgetting to save a file when you inevitably refresh your browser/state sucks, so I'd say having both is nice 🙂

👍 1
mkvlr17:07:48

I’m trying to use a js lib that uses wasm: https://github.com/lekoala/barcode-detector-zbar and getting:

Failed to inspect file
  /Users/mk/dev/ductile/node_modules/zbar.wasm/dist/zbar.wasm.bin

it was required from
  /Users/mk/dev/ductile/node_modules/zbar.wasm/dist/load-browser.js

Errors encountered while trying to parse file
  /Users/mk/dev/ductile/node_modules/zbar.wasm/dist/zbar.wasm.bin
  {:line 1, :column 0, :message "Character '' (U+0000) is not a valid identifier start char"}
I’ve read https://github.com/thheller/wasm-pack-cljs but failing to understand how to adjust it for this use case. Any pointers would be appreciated. 🙏

thheller18:07:56

shadow-cljs doesn't support bundling wasm files which this appears to require

mkvlr19:07:37

alright, will load it via a script tag for now, thanks.

thheller19:07:57

yeah still need to investigate how webpack wasm bundling actually works. it just seems to do something but I couldn't find docs on this. should be easy enough to support but given the non-standard nature I was going to wait for a more proper standard

👍 1