Scarlett
Scarlett
DDeno
Created by Scarlett on 2/12/2024 in #help
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
}
4 replies