There was an answer here earlier today that seems to have disappeared, but it's what we're using now and it's working well. It's using the $ helper available in Illustrator, and the $.evalFile() method. Pass it a path and it will evaluate the file and return the result.
I created a little helper that I can include (minified, of course) at the top of my .jsx scripts so I can do Libraries.include("my-other-script") that will include, in my case, a file that's in my adobe_scripts root folder, in a directory called lib.
// indexOf polyfill from https://gist.github.com/atk/1034425 [].indexOf||(Array.prototype.indexOf=function(a,b,c){for(c=this.length,b=(c+~~b)%c;b<c&&(!(b in this)||this[b]!==a);b++);return b^c?b:-1;}); var Libraries = (function (libPath) { return { include: function (path) { if (!path.match(/\.jsx$/i)) { path = path + ".jsx"; } return $.evalFile(libPath + path); } }; })($.fileName.split("/").splice(0, $.fileName.split("/").indexOf("adobe_scripts") + 1).join("/") + "/lib/");
Minified version that I include:
/** * Libraries.include(path) -- path must be relative to adobe_scripts/lib/ * See: https://gist.github.com/jasonrhodes/5286526 */ [].indexOf||(Array.prototype.indexOf=function(a,b,c){for(c=this.length,b=(c+~~b)%c;b<c&&(!(b in this)||this[b]!==a);b++);return b^c?b:-1;});var Libraries=function(a){return{include:function(b){return b.match(/\.jsx$/i)||(b+=".jsx"),$.evalFile(a+b)}}}($.fileName.split("/").splice(0,$.fileName.split("/").indexOf("adobe_scripts")+1).join("/")+"/lib/");
See gist here: https://gist.github.com/jasonrhodes/5286526