In a client setup I implemented in a hacky way external scripts.
You can refer to this thread [Solved] How to implement a Designer global external function?
The gist is I have a repository folder, the path is set as a datamapper and template runtime parameters with a sane default. Then I load and execute the scripts. Mind that the loading and execution in the datamapper and template is achieved differently.
At runtime I can specify a different path for testing. The path prefix is dynamic, inside the repository folder instead folders and script names become hard coded.
With this setup I achieved a dozen of scripts reused in 30 datamappers and 30 templates which all share business logic backbone.