Debugging new typescript modules


First of all: Hi! It’s been a while. Hope you’re well :slight_smile:

I’ve had to take a bit of a hiatus from contributing to Anki due to life stuff, but I’ve slowly been getting back into the groove and had a quick question:

I’ve been looking into getting some of my editor-adjacent add-ons back up and running on 2.1.41 and up, and wanted to debug the view with Chrome as I would normally do. However, I seem to be having trouble getting the TS <-> JS source maps to work for all the new(-ish) TS modules under ts/ in the project root (e.g. for the editor package).

Everything under ./qt/aqt/data/web/js is still mapped fine out of the box, OTOH (e.g. webview.ts):


Not sure if this is just on my end, but I assume this happens because editor is now packaged by rollup, right?

I’ve tried playing around with the rollup config a bit (the sourcemap value specifically), but no luck so far.

Is this something you’ve already set up locally by any chance?

1 Like

ah, realized this was your PR @hengiesel. Any pointers?

I never utilized the mapping, which is why I didn’t notice once they were missing. If anything, that configuration should probably go into the build file, where rollup_bundle takes a sourcemap argument, which currently is "false". I tried passing "true", but it still did not work. It seems to me that Bazel is not copying the sourcemaps to the correct location.

1 Like

When using ./run from the source tree, the bundled js won’t be minified, so it should be fairly easy to follow. I imagine it would be possible to make the source maps accessible, but it’s not something I’ve looked into.

1 Like

Edit: Sorry, I made a mistake in the first edit. I’ve updated this post.

Deleting the line sourcemap = ..., or sourcemap = "inline" (“inline” is
the default value of sourcemap) would work. The sourcemap was appended to editor.js as a data URI. To make use of sourcemaps in chrome/chromium dev tools, it is required that "enable javascript source maps" is checked in the dev tools settings.