How to configure DENO_DIR for dynamic imports?
See original GitHub issueThanks for the Deno runtime! I came running back to Vercel because Deno Deploy doesn’t do dynamic imports and vercel-deno is a lifesaver 😸
Unfortunately, I still can’t get dynamic imports working because I get this runtime error:
TypeError: Could not create TypeScript compiler cache location: "/var/task/.deno/gen/file/var/task/commands/1"
I saw that the solution was to simply set the DENO_DIR
variable to something under /tmp
. Unfortunately, simply setting that variable either on Vercel’s settings or with the hashbang wasn’t enough to change the directory.
This is what I have right now as my hashbang, the env var as well as the two includes for files I want to import which work fine:
#!/usr/bin/env DENO_DIR=/tmp/.deno deno run --include-files ../util/**/* --include-files ../commands/**/*
Is there any other way I can configure DENO_DIR
?
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top Results From Across the Web
Dynamic imports - The Modern JavaScript Tutorial
First, we can't dynamically generate any parameters of import . The module path must be a primitive string, can't be a function call....
Read more >add --allow-import=<allow_list> for checking dynamic ... - GitHub
Context: Currently loading dynamic imports or worker code requires --allow-read and/or ... Enable Deno namespace by default in Workers #8174.
Read more >How to Dynamically Import ECMAScript Modules
You can import modules dynamically if you use import as a function — import(pathToModule) — a feature available starting ES2020.
Read more >Webpack and Dynamic Imports: Doing it Right - Medium
Dynamic imports : the basics ... The above code will load the foo module at runtime, and resolving it, will log the default...
Read more >How to use Dynamic Imports for Modules - JavaScript Tutorial
In today's video I'll be showing you how to use Dynamic Imports for your modules in JavaScript - this allows you to dynamically...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
My functions are already working dynamically with v1.0
Thank you again for the fix and ofc for the runtime! 🏆
Ok, well it’s a simple change in the
bootstrap
file to make it work (right nowDENO_DIR
is always set in that file before invoking deno. I think we can make it only set it by default, and allow to overwrite via env var).Example: https://vercel-deno-o1u7gi9m0-tootallnate.vercel.app/api/main
You can see in the Function invocation logs that the source files are downloaded / compiled at runtime (which leads to a rather slow cold boot):
That said, I’d still like overwriting
DENO_DIR
be supported, so I’ll turn this into a proper PR next.