Path/Module resolve callback #21
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While working with wrenbind17, I have found the library quite lacking in handling wren imports for files. The original wren library includes a module resolution callback so that things like relative imports and path aliasing problems can be handled correctly. Wrenbind17 does not expose this feature of wren to the user and using the vector of import paths is quite limited.
This pull request fixes that by adding a
pathResolveFn
to thevm
class with an appropriate setter, quite like theprintFn
andloadModuleFn
. This also changes the signature ofLoadModuleFn
, since it no longer requires the vector of import paths as inputs (since it only needs the resolved output ofpathResolveFn
).The default implementation for the path resolution function simply contains the resolution part of the old
LoadModuleFn
that checks for a valid path based on the import paths. This maintains the behaviour of the library and should not break users that don't want to use this feature.If I missed anything or you have any tweaks I should consider, please let me know 👍