Achieving this is definitely possible.
One source suggests that SystemJS.import() may be utilized, although personal experimentation is needed.
The provided repository on GitHub showcases a detailed example using an alternate method. While not explicitly stated in the slim Grafana scripted dashboard documentation, it appears that certain versions of lodash.com (commit to include lodash) and jquery can be accessed within all scripted dashboards.
The individual behind this repository, anryko, has effectively employed these two libraries to reference custom utility scripts as described.
All scripted dashboards contain a primary script; getdash.sh serves as anryko's main script, indicated by the dashboard URL in the README.md:
http://grafanaIP/dashboard/script/getdash.js
Reviewing the conclusion of getdash.sh, one will encounter a line referencing code within other user-provided scripts:
var dash = getDashApp(datasources, getDashConf());
For instance:
This section from getdash.js demonstrates the usage of jquery and lodash for loading the source files:
// loadScripts :: [scriptSourceStr] -> Promise([jQuery.getScript Result])
var loadScripts = function loadScripts (scriptSrcs) {
var gettingScripts = _.map(scriptSrcs, function (src) {
return $.getScript(src);
});
return Promise.all(gettingScripts);
};
Refer to the lodash documentation for the aforementioned _.map.
The scriptedDashboard() function (also found in getdash.js) invokes the above loadScripts(), supplying it with paths to the source files like so:
loadScripts([
'public/app/getdash/getdash.app.js',
'public/app/getdash/getdash.conf.js'
]).then(function () {
To be candid, delving deeper into how all this enables the utility code to be 'reference-able' remains on my agenda.