adoublef
adoublef15mo ago

Does calling `bundle` inside a handler make sense?

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);
});
3 Replies
lcasdev
lcasdev15mo ago
Which bundle function is this?
adoublef
adoublefOP15mo ago
@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
adoublef
adoublefOP15mo ago
so i guess I semi-resolved my issue