I had a similar issue when I tried to break down a JSL framework into multiple modules that would include each other. I solved it by adding the following code to the main module:
// Find the current location in the source tree for the given file
__getThisPath = Function( {this_f},
{Default Local},
this_p = "";
ifl = Include File List();
For( ifli = 1, ifli <= N Items( ifl ), ifli++,
a_path = ifl[ifli];
idx = Contains( a_path, this_f );
If( idx > 0,
this_p = Left( a_path, idx - 1 );
Break();
);
);
If( this_p == "",
Throw( "Unable to find path for " || this_f )
);
Return( this_p );
);
Once I determined my script location in the file system, I was able to use it to find and include its dependencies:
// Use the current location in the source tree for this file
// in order to load its dependencies.
__INCLUDE = __getThisPath( "timeit.jsl" );
Set Path Variable( "TI_HOME", __INCLUDE );
Include( "$TI_HOME/../JSLhelpers/mfr.jsl" );