Simpler way to read a file relative to current module?
So I wrote a little helper function for reading the text content of a file relative to the current module. I came up with the following, but is there any simpler way that I'm missing? It seems a bit wordy 😄
9 Replies
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Ah, thanks a lot 🙂
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
even simpler:
import.meta.resolve(filename)
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
That's a good one, but I think it will only resolve modules, not any file
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
It resolves any URL and take into account the import_map.
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View