Given a package which has some default templates or some default assets; how can a Deno application access and use such files?
A couple of example use cases:
-
An application which makes use of Nunjucks to render views and wants access to a library of templates provided by a package. For example, to take advantage of a component library, or to reuse templates which ensure consistent branding across multiple services.
-
An express application where some default assets from a package are statically served.
Here are a couple of workarounds that I have currently found:
-
Create a script which copies these files into the application repository. This works but this adds some complexity and it’s more difficult to maintain.
-
Execute deno with the
--node-modules-dir
switch which forces it to create anode_modules
directory. It is possible to load such asset files from there. This deviates from the deno way of doing things though. -
Somehow resolve paths to cached modules in the file system. This is similar to above but seems more fragile since the locations of module files could easily change in the future. There doesn’t seem to be a built-in function to resolve paths to cached modules.