Found a solution. If the code is too long, it seems it needs to be imbeded as a .jsl file that is being called, rather than having the code itself within the addin