Fork me on GitHub
#shadow-cljs
<
2024-05-18
>
phill18:05:57

react-uswds "ReferenceError: jsxRuntime is not defined"? I followed the shadow-cljs quick-start, with only a println in the init fn, and all was well. shadow.cljs lists no dependencies. Then I added "@trussworks/react-uswds": "^9.0.0" to package.json, and 1 :require clause, ["@trussworks/react-uswds" :refer [Alert]]. Now the program dies with the cited ReferenceError in the browser console and does not execute the println in init. Perhaps the require clause is wrong? The model given by https://github.com/trussworks/react-uswds is import { Alert } from '@trussworks/react-uswds'. That page also has a whole lot of incomprehensible mumbo jumbo about peer dependencies. I see react, react-dom among many other things in node_modules. There is even node_modules/react/jsx-runtime.js! But throughout the node_modules directory tree, the only occurrences of the word jsxRuntime are in in react-uswds. I tried downgrading React to 17.0.2 but the error is the same. ?

thheller06:05:28

I got nothing. If you setup a full repro I can take a look

thheller06:05:33

the require is correct, otherwise it would have failed at compile time. this is a runtime error, so for some reason the package is unhappy at runtime

thheller06:05:51

contains no reference to jsxRuntime, so dunno where you are getting it from?

phill11:05:45

Oh well! Thank you for the sanity check. The jsxRuntime reference is found in node_modules/@trussworks/react-uswds/lib/index.iife.js node_modules/@trussworks/react-uswds/lib/index.umd.cjs Which are referenced by package.json under "exports".

thheller13:05:09

ah what fresh nonsense is that

thheller13:05:52

ok, shadow-cljs by default will pick the "browser" export since that in every other package I have seen is usually the commonjs export

thheller13:05:13

for some reason this package uses this for its CDN package I guess

thheller13:05:58

so it expects these to be available as globals, rather than referenced packages. jsxRuntime,React,FocusTrap,ReactDOM

thheller13:05:45

I suppose you can set :js-options {:export-conditions ["require" "browser" "default" "module" "import"]} in the build config to change that. no guarantee that won't break other packages though

thheller13:05:53

normally "browser" is first