philmasterplus
Active member
The require call of findScript needs to generate an error if there is more than one result.
Uh, sure. I don't have an opinion on this, and it probably won't affect me very much.
If we ask JS writers to explicitly specify a file is in the current directory or a subdirectory of the current directory and ask them to create a subdirectory of /scripts for their scripts does that eliminate name collisions with any other ash or JS script? I think yes but am open to being educated.
JS authors never had name collision troubles at run time because we always use relative paths to import other JS scripts, or because we bundle our code into one big script which imports nothing. Is there a problem that needs solving here...?
I'd like to focus on name collisions that happen during install time, which isn't tied to ASH or JS. It can be solved by enforcing strict directory structure replication.
If css and html files are expected to be in /relay and by analogy to /var/www/html are expected to be shared do we make certain named files part of the KoLmafia distribution (with all the baggage that implies) or to we voluntarily impose a naming convention on script writers in hopes of reducing collisions?
I lost your train of thought here. What "named files" are you talking about?
When writing relay scripts, we conventionally created one subdirectory per relay script and put our assets (CSS, browser-only JS) in there. Now that we know it's unsafe, we would have to give unique names to all assets.
Can we tell rhino to use the script's directory instead of /relay for name resolution?
Rhino doesn't use
relay/
for module resolution at all. It uses KoLmafia's working directory and the scripts/
directory as the base directory.Also, it doesn't search recursively for JavaScript files. If I import another JS script using
require('test.js')
(notice that it has no leading dot), Rhino will check /test.js
and /scripts/test.js
but look no further.