shadow-cljs

borkdude 2025-08-11T15:53:17.017619Z

I'm trying to debug a module problem. I have a library "katex" that I load in exactly one namespace

(ns nextjournal.clerk.katex
  (:require ["katex" :as katex]))

(defn renderToString [s]
  (katex/renderToString s))
My modules look like this:
: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}}}
Yet I get the error:
Module Entry "katex" was moved out of module ":katex".
It was moved to ":viewer" and used by #{:katex :viewer}.
I only have the namespace nextjournal.clerk.katex because directly exposing katex resulted in the same error. How can I debug this?

✅ 1
borkdude 2025-08-12T14:13:56.857229Z

so now it works, I got rid of the dependency on nextjournal.markdown. I'm re-trying this:

:katex {:entries ["katex"]
                                     :depends-on #{:viewer}
                                     :exports {renderToString katex/renderToString}}
It works, but I do get a warning:
------ WARNING #1 -  -----------------------------------------------------------
 Resource: shadow/module/katex/append.js:2:31
 variable katex is undeclared

borkdude 2025-08-12T14:14:16.984939Z

I can wrap it in a CLJS namespace, no problem, but thought I'd mention it

borkdude 2025-08-12T14:15:26.767589Z

This works fine:

:katex {:entries [katex nextjournal.clerk.katex]
                                     :depends-on #{:viewer}
                                     :exports {renderToString nextjournal.clerk.katex/renderToString}}

borkdude 2025-08-12T14:15:49.575699Z

Just katex didn't work, but "katex" gave the result I first mentioned 1 minute ago

thheller 2025-08-11T15:54:34.450429Z

search your code base for nextjournal.clerk.katex. most likely something has a direct ns require for it

borkdude 2025-08-11T15:54:53.698949Z

I just created this namespace just for the reason to expose katex via a shadow module.

thheller 2025-08-11T15:56:10.438169Z

right. then its katex itself.

borkdude 2025-08-11T15:56:18.748949Z

$ rg '"katex"'
src/nextjournal/clerk/katex.cljs
2:  (:require ["katex" :as katex]))

src/nextjournal/clerk/sci_env.cljs
162:             #_#_"katex" katex

render/deps.cljs
18:            "katex" "^0.12.0"

thheller 2025-08-11T15:56:59.328879Z

maybe it gets confused by katex and "katex". just remove katex from the :entries

thheller 2025-08-11T15:57:33.706969Z

I mean having katex as a symbol and as a string might confuse the thing

thheller 2025-08-11T15:58:10.369469Z

has no effect to have it listed there anyway if nextjournal.clerk.katex is the only place requiring it

borkdude 2025-08-11T15:58:56.023909Z

That works but when I inspect the katex module, I see this:

$ cat build/katex.js
import { $APP, shadow$provide, $jscomp } from "./viewer.js";
const shadow_esm_import = function(x) { return import(x) };
export const renderToString=function(a){return $APP.Vub.renderToString(a)};
//# sourceMappingURL=katex.js.map
Which looks like katex is just pushed to the viewer module anyway. This is why I added the katex entry.

thheller 2025-08-11T15:59:44.787399Z

make a build report and check. that will list what is where and why

borkdude 2025-08-11T16:00:58.540939Z

got it. found why it was pushed there, the nextjournal.markdown lib depends on it. thanks!

borkdude 2025-08-11T16:03:37.662989Z

I forgot that you can hover the entry in the build report to get more info