Implement import.meta.resolve
Getting a file relative to the current script is difficult, specially when you have to take care of both file
and resource
protocols.
The import.meta.resolve
standard is a nice way to solve it as it returns a uri string and is available on all major JS runtimes. Gio has a File_new_for_uri
API that is perfect for this.
- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta/resolve
- https://docs.deno.com/runtime/manual/runtime/import_meta_api
- https://bun.sh/docs/api/import-meta
- https://nodejs.org/api/esm.html#importmetaresolvespecifier
- https://github.com/wintercg/import-meta-registry
One of the use case is Workbench, we need a way for users to load files relative to the script. We currently offer the non-standard workbench.resolve
API which does the same but we would like a standard solution.
An other one is using import.meta.resolve
together with a helper function to build GTK interfaces !853
Edited by Sonny Piers