saikyun / freja

Self-modifiable editor for coding graphical things
68 stars 3 forks source link

Loading plugins using relative paths gets a bit strange #9

Closed saikyun closed 3 years ago

saikyun commented 3 years ago

One would like to be able to import freja internals for use with plugins, without having to use relative paths. This is because the relative paths makes it impossible to run plugins in directories other than the freja root folder. The alternatives I can come up with are:

  1. use absolute imports, like (import src/state) 1.1 this is nice since one would be able to use e.g. linting and tests outside of freja 1.2 the drawback is that it's not 100% apparent how to make freja and the plugin use the same modules 1.2.1 probably best solution here would be to jpm install freja, then all internals would be available for any code 1.2.2 however if one were to run a standalone freja binary, the plugin would stop working
  2. do something tricky, like (freja-import src/state) 2.1 same amount of code as above, but would only work withing freja
  3. magically make symbols available when loading files inside of freja 3.1 easy to get started, but annoying to not have control of symbols in environment 3.2 might mess with non-plugin programs being run inside freja

I think I'll need to wait for https://github.com/janet-lang/janet/issues/710 to get fixed before trying out how it would work with a binary freja, and how to use the same dependencies as binary freja.

saikyun commented 3 years ago

Now one can do (import freja/state). If you find a module that you can't import this way, create an issue.