chromex
chromex copied to clipboard
NB: Sourcemaps from chrome-extension:// URLs don't load
This is more of a heads up for anyone attempting to write extensions in ClojureScript. Your sourcemaps, although correctly generated and present won't load. Will manifest as Warnings in Console that print URL path to respective source map with 404 and ERR_UNRECOGNIZED_URL
. Ironically, you can click said link and happily navigate to the sourcemap.
Actual issue has been open with Chrome devs for quite some time now, but sadly gets completely drowned by noise when you try to Google it. Link to Chrome Bug tracker.
Every existing Chrome build (including Canary) is effected. Discussion in chromium-review mentioned a solution which someone may attempt to build from source, but the latest comment (late June 2021) marks solution as abandoned in favor of yet to be revealed one. Issue remains outstanding since at least Feb 2020, so don't hold your breath.
FWIW sourcemaps for extensions work just fine in Firefox, and in fact you should be able to load chromex examples as is. That said any code in Chromex or CLJS WebTools that touches custom Chrome APIs won't run. E.g. custom formatters and some (maybe all) stuff under chrome.runtime
e.g. chrome.runtime.onSuspendCanceled
Honestly, I think Chrome devs dropped the ball big time on this one, since this probably effects any "compiles to JS" language out there including TypeScript.
I don't use chromex (yet) but I am an extension developer. Anyway, I just wanted to say that inline source-maps (where the mapping is a large comment at end of JavaScript files) do work. You might want to pursue using those, at least in development, until the linked bug's fixed in Chromium.
Good point. I'll need to figure out who in the pipeline is responsible for sourcemap generation and switch it over to inline maps. Wish CLJS compiler could do the trick. Related issues found:
- https://github.com/thheller/shadow-cljs/issues/656
- https://github.com/thheller/shadow-cljs/commit/94c99bd609bf674e24b47964d37c89e57e838414 Although may turn out too Shadow specific. I'd much rather go with neither Lein, nor Shadow - way too much magic
I also made some effort to implement inline source maps in CLJS compiler: https://clojure.atlassian.net/browse/CLJS-1902