thesmartwonT
Denoβ€’12mo agoβ€’
2 replies
thesmartwon

Read dependency directory

Is it possible for a library to read its own non-importable files?

I'm publishing some static files in a library. I'd like for that library to copy the files wherever the user wants. Is there a way without transforming those files into importable JSON or JS files?

Library:
Deno.statSync(import.meta.resolve("./static").replace("file://", ""));


This works great inside the library. However, outside it will error:
error: Uncaught (in promise) NotFound: No such file or directory (os error 2): stat 'https:/jsr.io/@scope/package/version/static'
  Deno.statSync(Deno.statSync(import.meta.resolve("./static").replace("file://", "")););
                ^
    at Object.statSync (ext:deno_fs/30_fs.js:415:3)
...
Was this page helpful?