DenoDDeno
Powered by
ScarlettS
Denoโ€ข3y agoโ€ข
3 replies
Scarlett

Typing for Dynamic imports

So I have a function like this that uses a dynamic import like
export async function func1(image: uInt8Array[]) {
    const {decode, }= await import(
      "https://deno.land/x/imagescript@1.2.17/mod.ts"
    );
}
export async function func1(image: uInt8Array[]) {
    const {decode, }= await import(
      "https://deno.land/x/imagescript@1.2.17/mod.ts"
    );
}

But this function gets called like once a day, but it gets repeated called like 4 or 5 times at once. So I am just wondering if deno will import that module again and again for each time the function is called?

I also tried something like this which breaks typing all together
let import = false
let decode;
export async function func1(image: uInt8Array[]) {
  if(!imported){
    const {decode:d }= await import("https://deno.land/x/imagescript@1.2.17/mod.ts");
decode = d
    imported = true
  }
// rest of the function
}
let import = false
let decode;
export async function func1(image: uInt8Array[]) {
  if(!imported){
    const {decode:d }= await import("https://deno.land/x/imagescript@1.2.17/mod.ts");
decode = d
    imported = true
  }
// rest of the function
}
Deno banner
DenoJoin
Chat about Deno, a modern runtime for JavaScript and TypeScript.
20,944Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Emit with dynamic imports?
KayKKay / help
2y ago
Dynamic npm imports don't work
ร“scarร“ร“scar / help
4y ago
About imports
drom765Ddrom765 / help
2y ago
Deno Imports
stephenSstephen / help
3y ago