Fork me on GitHub
#shadow-cljs
<
2019-06-23
>
thheller08:06:05

@mark340 I don't know anything about gmail add-ons. if you have a basic JS example I can maybe tell you how to do it CLJS

Mark Addleman18:06:27

The basic challenge is GMail add-ons need a javascript entry function (the entry function is referenced by the GMail add-on manifest file). Of course, the entry function name cannot be mangled by the closure compiler using advanced compilation. For some reason, declaring it ^export doesn't work. I looked at the resulting javascript and cannot find a clear function definition with the exported name. I found an example of doing this using the ClojureScript compiler directly: https://github.com/plexus/gas-of-life The basic approach is to create a snippet of javascript that are the entry point functions. They call into the 'real' functions written in clojurescript. Then, tell the clojurescript compiler that these snippets are a foreign library. The resulting javascript (again, using advanced) incudes the js snippet verbatim so gmail can find the entrypoints. Essentially, it seems my code is a foreign library for itself 😕 I want to believe there's a more straightforward solution but I cannot find another magical incantation to make it work.

thheller08:06:32

uhm did you actually use ^export because that would be wrong?

thheller08:06:13

judging from that file you need an onOpen callback defined?

thheller08:06:38

you can do that in your ns by doing (defn ^{:export "onOpen"} your-on-open [e] ...)

thheller08:06:56

just ^:export isn't enough because that would create a fully qualified name

thheller08:06:35

dunno why he created that extra file. guess it isn't well known that the :export takes an actual string as well

Mark Addleman16:06:53

Ah, that could be it! I'll give it a try. Thanks!