No longer possible to enable debug mode on a per-plugin basis?

Hi, I’m the author of the hot-reload plugin that is used by many Obsidian plugin devs. Unfortunately, since the addition of app.debugMode(), it’s no longer possible to enable sourcemap handling during a plugin reload, because Obsidian has switched from checking the “debug-mode” localstorage at load time, to checking a vault-specific “DebugMode” at application start. (Meaning it ignores any intermediate changes even to the new localstorage variable.)

Would it be possible to at least check the new localstorage variable at plugin load time, and/or make app.debugMode() not reload the entire app? Or is there something that has changed with the sourcemap stripping behavior that means it really isn’t possible to turn it on or off without reloading the entire Obsidian app? Thanks.

I raised a very similar problem once they trimmed this support

There is a workaround that works without setting app.debugMode(), though.

If you add at the end of main.js

(newline)/* nosourcemap */(end of file)

then, the sourcemaps won’t be trimmed, even if debug mode is not enabled

I even made an esbuild plugin that adds this magic string on npm run dev

Maybe you can consider adding this magic string within your Hot Reload plugin. I can send a corresponding PR, if you are interested.

Yes, I’d planned to use that workaround as a fallback, at least in ophidian/build’s esbuild config. But the only way hot-reload can do it would be to patch the vault adapter read() function during hot reload to add the string automatically. (Making hot-reload write to the plugin files themselves is not an option as that would break my ability to test a plugin in multiple Obsidian versions simultaneously using Sandboxie.)

I’m just not keen on patching the vault adapter if I can possibly avoid it.

1 Like

Can you elaborate what’s the problem if you edit main.js and add the magic line? How exactly will it break your testing?