D
Deno

help

Does calling `bundle` inside a handler make sense?

Aadoublef9/4/2023
hey all I wanted to understand if this is smart to do. I am using the cacheRoot option and wanted to know if that affects the way the code is executed here. As its being called inside a handler I am unsure if this is going to compile everytime or does the cacheRoot option speed that up?
app.get("/index.js", async (c) => {
const { code } = await bundle(
new URL("./components/mod.ts", import.meta.url),
{ cacheRoot: Deno.cwd() },
);
return c.text(code);
});
app.get("/index.js", async (c) => {
const { code } = await bundle(
new URL("./components/mod.ts", import.meta.url),
{ cacheRoot: Deno.cwd() },
);
return c.text(code);
});
Llcasdev9/4/2023
Which bundle function is this?
Aadoublef9/4/2023
@lucacasonato the one from deno_emit https://github.com/denoland/deno_emit/blob/main/js/README.md#bundle I did move it out the handler which allowed it to be ran once, but wasn't sure what the internal cache options are supposed to enable
GitHub
deno_emit/js/README.md at main · denoland/deno_emit
Transpile and bundle JavaScript and TypeScript under Deno and Deno Deploy - denoland/deno_emit
Aadoublef9/4/2023
so i guess I semi-resolved my issue

Looking for more? Join the community!