Compiling typescript frontend and serving it with Deno
I'm using Typescript with Express+Socket.io for my multiplayer game's backend. I have a
client
directory that should contain the frontend source code where I want access to the DOM api in the browser.
Is this possible? Or do i have to make a separate non-deno project that compiles its client post-compiled .js files to be served from my Deno backend?6 Replies
Wouldnโt Express be able to serve the HTML via โstaticโ directory?
Maybe Iโm not understanding something
Yeah, I'm already doing that -- the problem is compiling a simple frontend (index.html, main.ts, style.css) into this public directory using deno, but from a bit of searching, it looks like the DOM api isn't available, so you'd have to use something like React instead
I ended up creating a separate project for the frontend only in a different vscode workspace that uses node.js+vite+typescript
but I'm sad because this kind of defeats the point of using Deno
To do that you need a bundler (like Vite you're already using, and you can use Vite with Deno just fine). We're aiming to add support for text/bytes imports and a new built-in bundler after Deno 2 releases.
that's awesome. i think once we have the ability to configure how the frontend files should be bundled with the deno configuration, it'll truly be competing with the backend options that already exist
as a js runtime it's already sick