Import callback should separate relative path conversion from returning file content
- Dominant language
- Jsonnet
- Stars
- 7.6k
- Forks
- 475
- PR merge metrics
- No merged PRs in 30d
Description
When you import a same file twice, the evaluation results are not cached.
Worse: the callback API for import does not distinguish (1) a file lookup step, (2) a file read step and (3) a code evaluation step. Therefore, a second import of the same file will have the callback return new file contents, which makes either cache or reevaluation cumbersome.
For compatibility with existing API, a SHA checksum for the contents could serve as the key to cache evaluation results.
In a newer API, the import function would be broken in three steps, and each could be cached separately, so that (1) file lookup returns an absolute file path or URL from the (probably relative) string of the requested import depending on the current file, (2) file read returns the file contents given the path or URL, and (3) code evaluation evaluates the code.
Contributor guide
Assessment
This issue has not been assessed yet.