shadow-cljs

Pepijn de Vos 2025-05-26T10:35:50.932219Z

I'm trying to update project dependencies and am getting a bit puzzling error:

The required JS dependency "events" is not available, it was required by "node_modules/pouchdb/lib/index-browser.js".
afaict "events" is a nodejs builtin so it seems something weird is going on because I'm trying to compile for browser

Pepijn de Vos 2025-05-26T10:38:04.144989Z

hmmmm https://github.com/pouchdb/pouchdb/issues/8968

thheller 2025-05-26T10:40:37.329709Z

npm install events

Pepijn de Vos 2025-05-26T10:41:39.314179Z

So did pouchdb just... not include a dependency? reading the issues it seems like they might be doing something weird expecting the npm package to run on node but I'll try

thheller 2025-05-26T10:43:06.832319Z

a long time ago webpack used to do automatic polyfilling for node built-in packages, but they stopped supporting this out of the box since webpack v5 (5+ years ago)

thheller 2025-05-26T10:43:40.880329Z

guess that still isn't enough time for npm packages to adopt and adjust accordingly

thheller 2025-05-26T10:44:03.723609Z

problem is that for node you don't actually want this dependency, but for the browser you need it

Pepijn de Vos 2025-05-26T10:44:12.546919Z

tbh pouchdb isn't that actively developed

thheller 2025-05-26T10:44:27.095249Z

since npm packages can't tell what you are going to use this in they kinda don't have a choice

thheller 2025-05-26T10:47:30.132059Z

FWIW I also removed the automatic polyfilling in shadow-cljs 3+

thheller 2025-05-26T10:47:42.792929Z

guess I underestimated how relevant this still is 😛

Pepijn de Vos 2025-05-26T12:57:25.433379Z

okay indeed installing that just fixed the problem

Pepijn de Vos 2025-05-26T12:57:30.240689Z

thanks

erwinrooijakkers 2025-05-26T15:45:26.039679Z

After upgrading to React 18.3.1 and loading the survey-react-ui library, we get the error failed to load module$node_modules$survey_react_ui$fesm$survey_react_ui_mjs at line var module$node_modules$survey_react_ui$fesm$survey_react_ui_mjs = shadow.js.require("module$node_modules$survey_react_ui$fesm$survey_react_ui_mjs", {}); The extended class that is missing is class SurveyElementBase extends React.Component { Any directions on how to fix?

thheller 2025-05-26T15:56:58.872249Z

looks like the esm variant is used. dunno why that wouldn't work but did you configure it to do that manually? the default shouldn't pick that survey_react_ui$fesm$survey_react_ui_mjs file

thheller 2025-05-26T15:57:40.428499Z

which shadow-cljs version do you use?

erwinrooijakkers 2025-05-27T08:47:14.454819Z

ah in project.clj still using 2.20.13

erwinrooijakkers 2025-05-27T08:47:17.645299Z

maybe just bump that

erwinrooijakkers 2025-05-27T08:47:34.122729Z

thanks

erwinrooijakkers 2025-05-27T10:08:28.004819Z

alright that was it @thheller 🤦. Thanks for suggestion!