shadow-cljs

borkdude 2025-08-18T14:37:11.679279Z

I have this config:

:modules {:viewer {:entries [nextjournal.clerk.sci-env
                                                nextjournal.clerk.trim-image]}
                             :katex {:entries [katex nextjournal.clerk.katex]
                                     :depends-on #{:viewer}
                                     :exports {renderToString nextjournal.clerk.katex/renderToString}}}
(forgive the messed up layout due to copy pasting from the middle of an edn file) This executes fine:
$ node build/viewer.js
but this won't:
$ node build/katex.js
file:///Users/borkdude/dev/clerk/build/katex.js:1
import { $APP, shadow$provide, $jscomp } from "./viewer.js";
                               ^^^^^^^
What could be the issue here?

✅ 1
borkdude 2025-08-18T14:43:39.495199Z

When I manually add:

export { $jscomp };
to the output, no errors.

borkdude 2025-08-18T14:44:48.700939Z

ah in the changelog:

[ 07ef0 ] make :esm smarter about detecting if $jscomp is needed

borkdude 2025-08-18T14:44:52.410669Z

I'll try that update

borkdude 2025-08-18T14:51:17.380599Z

yep, fixed.

👍 1
roboli 2025-08-18T15:02:15.370219Z

Hi all. Anyone having issues working with shadow-cljs@3 and msw@2? After compilation, it asks me for the "utils" and other node modules. I solved this (or I believe so) by using :js-options {:keep-as-require #{"utils"} ... but then, when I require msw/node and it is empty {}. I have no idea what's going here tbh :(

roboli 2025-08-19T10:35:13.138659Z

Thanks @thheller... :target :browser-test I'm trying to run some unit tests. My library does some fetch calls to an API and I need msw (https://mswjs.io/docs/) to intercept those calls. I used shadow-cljs@2 and msw@1 long ago, I remember having uses but it worked. Here is the current build, I removed the js-options:

:test {:target   :browser-test
         :test-dir "public/test"
         :devtools  {:http-port 8021
                     :http-root "public/test"}}

thheller 2025-08-19T10:40:20.615359Z

ok, so you are building for the browser but said you do a require for msw/node? The docs say there is a msw/browser require you are supposed to do? https://mswjs.io/docs/integrations/browser

thheller 2025-08-19T10:40:53.869879Z

import { setupWorker } from 'msw/browser' I mean. translated to cljs of course.

roboli 2025-08-19T11:13:15.786919Z

Yes, that would another option. As I mentioned, I used shadow and msw/node before, and it worked, so I was trying to follow same path but switching to shadow v3 and msw v2, something changed. I'm not sure which is it. What I can see is that packages like node-libs-browser won't be included anymore...

thheller 2025-08-19T11:15:24.262379Z

that is possible, but seems like the msw package is pretty clearly structured so that msw/node isn't supposed to work in the browser?

thheller 2025-08-19T11:16:55.562389Z

I mean its package.json explicitely disables the msw/node entry for the browser https://unpkg.com/msw@2.10.5/package.json

thheller 2025-08-19T11:17:04.575539Z

"./node": {
      "browser": null,

thheller 2025-08-19T11:19:25.770679Z

what keeps you from just switching msw/node to msw/browser like the docs suggest? or does that still have the same issue?

roboli 2025-08-19T17:17:55.032579Z

Ah, I see. Yeah it could be that msw/node is now forbidden on purpose. Well, I was reluctant because I did it once so I was hoping to do a copy/paste from that previous work. I'll give msw/browser a try, things must be done a bit different I believe, but if I find issues I'll ask for help if that's okay. Thanks again @thheller

thheller 2025-08-18T15:34:53.408009Z

seems like you are building for the browser but trying to use a node only package?

thheller 2025-08-18T15:35:23.153789Z

no clue what msw is, so can't say for sure

thheller 2025-08-18T15:40:50.226669Z

:js-options {:keep-as-require #{"utils"} isn't really the solution either, that just tells shadow-cljs to not bundle it. but if any code actually wants to use it it would just fail at runtime (which I suspect is whats happening)

thheller 2025-08-18T15:41:19.387639Z

to give you a proper answer I need more info on what it is you are trying to do. what is your :target or better yet the entire build config