profile
viewpoint

Ask questionsStatic non-code resources in modules

Let's say I want to write a module that communicates with some service using Protobuf.

In Node.js, the npm package would contain .proto files which the module would load directly from the file system (using __dirname).

What's the deno equivalent? It seems import works only for code and fetch wouldn't be cached.

denoland/deno

Answer questions brandonkal

As far as I am aware, browsers do not handle arbitrary resources through import. I would like to see the ability to statically import YAML as a JS object but that isn't portable to browser runtimes.

Now I use a proxy and parse its default export text as YAML. That works fine for now because I can use Deno's existing import cache.

It would be the same for other resource types. If browsers support their static import, Deno should as well. Otherwise it should not diverge here.

useful!

Related questions

{WSL 2} Permission denied (os error 13) hot 1
gRPC in Deno? hot 1
deno remove/uninstall subcommand hot 1
Insight required: Resource (TCP) errors hot 1
TCP accept loop doesn't use for-await hot 1
Support d.ts files hot 1
Restore runtime lib generation capability hot 1
disable flaky tests _048_media_types_jsx and _019_media_types hot 1
Typescript Custom Transformers Support hot 1
reorg directory structure hot 1
Centos 7 GLIBC_2.18 not found hot 1
"deno ast script.ts" hot 1
Text decoding performance abysmally slow. hot 1
"deno ast script.ts" hot 1
Can't build master hot 1
Github User Rank List