Fork me on GitHub
#shadow-cljs
<
2023-07-26
>
thheller08:07:47

I just released version 2.25.0 which includes a fairly significant change in how ESM from npm is processed. hopefully nobody will notice a thing and everything will continue to work, but history has taught me that there is so much weird code on npm that I probably didn't account for all of it.

thheller09:07:28

please give it a try if you are using a lot of npm packages, especially if they contain ESM code.

thheller09:07:48

if something breaks you can set :js-options {:use-babel true} to revert back to the old behavior, but report first if you do so as I plan to remove that option sometime in the future.

Pragyan Tripathi10:07:52

Upgrading to this version today in our dev environment. 👍

rolt12:07:28

hello, I'm getting the following error when going from 2.24.0 to 2.25.0:

Closure compilation failed with 2 errors
--- node_modules/primereact/primereact.all.esm.js:9270
Dynamic import expressions cannot be transpiled.
--- node_modules/primereact/primereact.all.esm.js:17407
Dynamic import expressions cannot be transpiled.
use-babel works
├── [email protected]
https://registry.npmjs.org/primereact/-/primereact-9.5.0.tgz

thheller12:07:16

ok that one is sort of expected. it never really worked, it just failed silently and blows up at runtime

thheller13:07:29

gotta love libs that do build tool specific things in their code 😛

thheller13:07:32

import('quill').then(function (module) {
          if (module && DomHandler.isExist(contentRef.current)) {
            if (module["default"]) {
              // webpack
              quill.current = new module["default"](contentRef.current, configuration);
            } else {
              // parceljs
              quill.current = new module(contentRef.current, configuration);
            }
            initQuill();
          }

😅 2
thheller13:07:25

I'll see about making it fail silently again I guess? let me think about it. thanks for the report.

rolt13:07:35

oh so it's stuff I'm not using ? Is there a way to exclude those items ?

thheller13:07:31

potentially. if you use (:require ["primereact" :as p]) and then p/Accordion or :refer (Accordion) consider using (:require ["primereact/accordion" :as Accordion]) instead

thheller13:07:52

(:require ["primereact" :as p]) will include every single component and make the build rather large

thheller13:07:04

you can selectively require only the components you need instead

thheller13:07:59

each dir there appears to be one component and at least the editor is the one trying the dynamic require from above

thheller13:07:09

so if you don't use that you won't get the error

rolt13:07:24

thanks, yes we were requiring the .all.esm module to convert the components, we'll change that

rolt13:07:19

better than crashing at runtime at some point in the future when we start using stuff !

Stefan06:07:39

FYI: I just updated and found no issues. 👍

👍 4
mauricio.szabo20:07:03

@thheller hi, a question about the Shadow Remote API - I'm not sure how much it's supposed to be used "externally" or if it's only supposed to be used by internal stuff, but basically I found a situation where it breaks something: Basically, when a result is :op :eval-compile-error, and I have something that's not transit-serializable, I don't get a response on the websocket - as an example, if I send an :op :cljs-eval with the code (do; #"regex" #'some-invalid-var) I never get a response on the websocket (that is, I never get the :op :eval-compile-error on the API) and I get an error on the console that Shadow is running with: RuntimeException java.lang.Exception: Not supported: class java.util.regex.Pattern. I believe this is because when the remote API sends back a result with the error (basically, that it's unable to resolve var: some-invalid-var) it also sends back the offending form that was evaluated, and that contains the regexp which is not serializable by transit

thheller14:07:19

I get

{:op :eval-compile-error, :ex-client-id 1, :ex-oid "8ec63e28-c811-4b33-a335-d0b49b631128", :report "[line 1, col 34] Unexpected EOF while reading item 1 of list, starting at line 1 and column 1.\n", :from 36}
?

thheller14:07:46

After

{:op :cljs-eval :to 36 :input {:code "(do; #\"regex\" #'some-invalid-var)" :ns 'cljs.user}}

thheller14:07:12

note sure how you'd get to the regexp error since this is an EOF error? the form is incomplete?

thheller14:07:19

in general shadow.remote will never send any object over the wire as transit? not sure how you are getting it to that point?

thheller14:07:43

you get the :ex-oid which you can then request as edn, str, etc but not transit?

thheller14:07:08

using shadow.remote is fine, just lacking documentation 😛

thheller15:07:31

ah I suspect you just sent {:op :cljs-eval :to 36 :input {:code (do; #"regex" #'some-invalid-var) :ns 'cljs.user}} or some form of it over the websocket? ie. :code as not a string but the actual "form"?

thheller15:07:58

I'd suspect that would blow up in various forms since it already fails at the websocket read, so well before even getting to shadow.remote?

thheller15:07:47

I don't have a test setup to send invalid edn, so thats a guess? 😛

mauricio.szabo18:07:40

I sent the invalid form, that ; is a test I was doing

mauricio.szabo18:07:55

The right OP should be: {:op :cljs-eval :to 36 :input {:code "(do #\"regex\" #'some-invalid-var)" :ns 'cljs.user}}

thheller19:07:13

ah yes, that reproduces.

thheller19:07:41

fixed in 2.25.1

mauricio.szabo21:07:31

(yeah, I know, it's kinda an obscure thing I found 😄)