How to compile blender add-on?
About the title of the question: you cannot compile add-ons because they are written in Python*.

Your script causes this error because it wasn't registered with Blender. Use the normal way (i.e. the regular Blender UI) to enable your add-on, and be sure to save your preferences so that it stays enabled. Once that's done it should simply work, also with Blender compiled as a module.

(*) Little footnote: Python is compiled into bytecode, but by the Python runtime itself, and doesn't require any action from the user contrary to "compiled languages" like Go or C.