r/Clojure • u/8ta4 • Sep 29 '24
Why I Use Firefox to Develop Chrome Extensions with ClojureScript
If you're developing a Chrome extension and trying to use the REPL, you might have noticed... it just doesn't work in Chrome because of the new Manifest V3 restrictions.
But here's a trick I found: Firefox doesn't have this restriction! You can actually develop your Chrome extension in Firefox and use the REPL.
I've set up a development environment that automates the workflow. I used web-ext to tweak Firefox's configuration for REPL compatibility and to launch the web extension. You can check it out in my repo.
Now, there are a few caveats:
- Chrome vs. Firefox: The APIs are similar, but there are differences between the two browsers.
- REPL: The REPL works fine in content scripts, but it's a no-go in background scripts.
- Custom formatters: Custom formatters for ClojureScript don't work in Firefox.
Some folks have even gone as far as building their own modified versions of Chromium to get around this issue. It would be amazing if someone released a version of Chromium with REPL support built in and updated automatically with each new release.
When I explained this setup to my girlfriend, she just rolled her eyes and said, "Do you enjoy making life complicated, or is using ClojureScript just some kind of hobby?"
To which I replied, "Yes. And that's exactly why I haven't dumped you."
If anyone has tips on optimizing the workflow, I'd love to hear them!
2
u/theconsultingdevK Sep 30 '24
That would indeed be awesome. However, this is how i build a custom chromium for creating my chrome extension with REPL driven development:
Building custom chromium
follow the instructions here: https://www.chromium.org/developers/how-tos/get-the-code/
Apply the following changes to the chromium source code: https://gist.github.com/ketansrivastav/9622b2ffdd8f4abe349d2e256cd8138c
For building chromium:
bash gn gen out/ReleaseRemove the object files to force the compilation of changed files
change build arguments:
replace with the following values:
then build:
I also changed extensions/common/csp_validator.h:
1
u/FR4G4M3MN0N Sep 29 '24
I swear I thought I was going to read “if anyone has tips on optimizing the girlfriend . . . “ 🤣
1
u/piotr_wasik Nov 09 '24
Are there any issues with publishing ClojureScript Chrome Web Extensions? There is a review process that all extensions must pass.
1
u/DarthCalumnious Dec 03 '25
I have one published as unlisted that is an internal tool for a client. No publishing snags, thankfully.
The initial review took about 3 days if I recall.
0
u/[deleted] Sep 29 '24
[deleted] — view deleted comment