Trying to actually write one before, it's incredibly frustrating experience, as you still need to have some weird native glue code in in Swift/Obj-C. And everything is under-documented, as it the true Apple Experience. (I forgot the details. I can find the code on github, maybe.)
If you ask yourself why there are so little Safari extensions, this is why.
edit: I look at the code now... I needed to wrestle with BOTH cocoapods and npm, at which point I gave up
in my repo. Then I opened xcode, configured the signing/capabilities, and built it. IIRC I had to create the directory for the output because xcode didn't do it itself, but once that was done I could install it to both macOS and iOS. Honestly I was surprised it was so little effort. I don’t doubt that an extension with more functionality than mine might require a jumping through a lot more hoops, but it definitely can be easy to successfully target Safari IME.
If you ask yourself why there are so little Safari extensions, this is why.
edit: I look at the code now... I needed to wrestle with BOTH cocoapods and npm, at which point I gave up