shadow-cljs

borkdude 2025-08-06T19:05:17.354769Z

does :target :esm support source maps? I'm not seeing any in the output dir during dev

borkdude 2025-08-07T10:03:40.873119Z

I have a repro for the source maps here if you're interested.

cd /tmp
git clone git@github.com:babashka/nbb.git nbb2
cd nbb2
clj -M -m shadow.cljs.devtools.cli --force-spawn watch modules --config-merge '{:compiler-options {:source-map true}}'
in another tab:
cd /tmp/nbb2
ls lib
No source maps...

borkdude 2025-08-07T10:04:09.799769Z

If I understand you correctly, the source-map true thing isn't even necessary since it should be the default behavior in watch?

thheller 2025-08-07T10:06:48.538209Z

right, ok so misunderstanding I guess. in dev mode the source maps are in the cljs-runtime folder

thheller 2025-08-07T10:06:59.903869Z

since all the "modules" are just basically a group of imports

borkdude 2025-08-07T10:07:15.652179Z

aaaah ok!

thheller 2025-08-07T10:07:24.959459Z

--> cat nbb_transit.js

import "./nbb_core.js";
import "./cljs-runtime/shadow.module.nbb_transit.prepend.js";
SHADOW_ENV.setLoaded("shadow.module.nbb_transit.prepend.js");
import "./cljs-runtime/com.cognitect.transit.util.js";
SHADOW_ENV.setLoaded("com.cognitect.transit.util.js");
import "./cljs-runtime/com.cognitect.transit.delimiters.js";
SHADOW_ENV.setLoaded("com.cognitect.transit.delimiters.js");
import "./cljs-runtime/com.cognitect.transit.caching.js";
SHADOW_ENV.setLoaded("com.cognitect.transit.caching.js");
import "./cljs-runtime/com.cognitect.transit.eq.js";
SHADOW_ENV.setLoaded("com.cognitect.transit.eq.js");
import "./cljs-runtime/com.cognitect.transit.types.js";
SHADOW_ENV.setLoaded("com.cognitect.transit.types.js");
import "./cljs-runtime/com.cognitect.transit.impl.decoder.js";
SHADOW_ENV.setLoaded("com.cognitect.transit.impl.decoder.js");
import "./cljs-runtime/com.cognitect.transit.impl.reader.js";
SHADOW_ENV.setLoaded("com.cognitect.transit.impl.reader.js");
import "./cljs-runtime/com.cognitect.transit.handlers.js";
SHADOW_ENV.setLoaded("com.cognitect.transit.handlers.js");
import "./cljs-runtime/com.cognitect.transit.impl.writer.js";
SHADOW_ENV.setLoaded("com.cognitect.transit.impl.writer.js");
import "./cljs-runtime/com.cognitect.transit.js";
SHADOW_ENV.setLoaded("com.cognitect.transit.js");
import "./cljs-runtime/cognitect.transit.js";
SHADOW_ENV.setLoaded("cognitect.transit.js");
import "./cljs-runtime/nbb.impl.transit.js";
SHADOW_ENV.setLoaded("nbb.impl.transit.js");
import "./cljs-runtime/shadow.module.nbb_transit.append.js";
SHADOW_ENV.setLoaded("shadow.module.nbb_transit.append.js");


try { nbb.impl.transit.init(); } catch (e) { console.error("An error occurred when calling (nbb.impl.transit/init)"); console.error(e); }

thheller 2025-08-07T10:07:36.126709Z

don't really have anything this would source map to 😉

thheller 2025-08-07T10:08:05.172829Z

but the other files will have source maps

thheller 2025-08-07T10:08:11.309809Z

and yes, the config-merge does nothing (since its true by default)

borkdude 2025-08-07T10:08:45.000709Z

yeah the transit thing is a completely different thing. I was trying to upgrade shadow to see if I would get source maps. but this mystery is now solved, thanks

borkdude 2025-08-07T10:09:04.922889Z

still the chrome inspector/profiler doesn't seem to use them somehow

thheller 2025-08-07T10:10:05.021019Z

always works fine to me? maybe whatever webserver you use doesn't serve .map files?

borkdude 2025-08-07T10:10:25.587719Z

I mean, I'm profiling node code

thheller 2025-08-07T10:10:28.952169Z

ah right node may require loading the source-map-support module

thheller 2025-08-07T10:10:44.885559Z

the node targets do that automatically but :esm does not

borkdude 2025-08-07T10:10:54.006629Z

ok, so I manually load this in my code?

thheller 2025-08-07T10:11:20.131349Z

node -r source-map-support/register your-file.js

thheller 2025-08-07T10:11:32.419719Z

after npm install source-map-support of course

thheller 2025-08-07T10:11:45.973249Z

no clue if that works with the chrome inspector though. never looked into that

borkdude 2025-08-07T10:12:01.216969Z

I was running this:

node --enable-source-maps --inspect-brk cli.js  -e "(require '[honey.sql])"

thheller 2025-08-07T10:12:05.999369Z

node always had a funny relationship with source maps

borkdude 2025-08-07T10:12:07.756139Z

first time I'm trying this stuff

thheller 2025-08-07T10:16:16.588129Z

didn't even know node had a --enable-source-maps option? maybe my info is outdated?

borkdude 2025-08-07T10:21:13.157629Z

I've tried both now:

node --enable-source-maps --inspect-brk -r source-map-support/register cli.js  -e "(require '[honey.sql])"
Don't see any .cljs references in the profiler, just .js

thheller 2025-08-07T10:35:08.617729Z

yeah sorry, can't help here. I don't use node much, so no clue what it takes to make this work

thheller 2025-08-07T10:36:04.951189Z

all the files do have the correct //# sourceMappingURL=cognitect.transit.js.map type comments and the files do exist, so 🤷

borkdude 2025-08-07T10:36:13.212289Z

no problem, it's fine

borkdude 2025-08-07T10:36:26.046209Z

I mean I don't detect any obvious places where I can optimize anyway

borkdude 2025-08-07T10:36:56.577709Z

thanks for the help!

thheller 2025-08-06T19:08:01.453229Z

of course? should be created by default just as all the other targets?

borkdude 2025-08-06T19:16:02.474049Z

ok not seeing any but don't have time to debug right now, will try again tomorrow. thanks for the reply

borkdude 2025-08-06T19:16:23.166759Z

when I want to upgrade to the newest shadow I should go through some other hoops

borkdude 2025-08-06T19:16:36.073149Z

[:modules] Build failure:
Module Entry "cognitect.transit" was moved out of module ":nbb_transit".
It was moved to ":nbb_core" and used by #{:nbb_transit :nbb_core}.

thheller 2025-08-06T19:17:13.913809Z

haven't touched that code for like 10 years, so that is not "new"

borkdude 2025-08-06T19:17:41.884119Z

I suspect shadow's dev code now depends on transit, could that be new?

thheller 2025-08-06T19:17:42.232169Z

as the error says. some code in :nbb_core (all the namespaces that includes) wants to use transit, but can't because it wants to be its own module

thheller 2025-08-06T19:18:06.500789Z

hmm good question

borkdude 2025-08-06T19:18:31.065939Z

coming from 2.28.18 -> 3.1.8

thheller 2025-08-06T19:19:23.166999Z

hmm well it has. but for like 5 years or something. definitely longer than 2.28.18

borkdude 2025-08-06T19:19:53.871689Z

this error is new for me though :)

borkdude 2025-08-06T19:20:00.007759Z

only happens when upgrading shadow

thheller 2025-08-06T19:20:14.681639Z

so, long time

thheller 2025-08-06T19:21:40.942179Z

so only happens in dev? release is fine?

thheller 2025-08-06T19:22:55.528299Z

so since 2.10.0 - 2020-06-04