192.168.1.76
192.168.1.76โ€ข4mo ago

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
polymorphik ๐Ÿฆ…๐Ÿ‡บ๐Ÿ‡ธ
Wouldnโ€™t Express be able to serve the HTML via โ€œstaticโ€ directory?
polymorphik ๐Ÿฆ…๐Ÿ‡บ๐Ÿ‡ธ
Maybe Iโ€™m not understanding something
192.168.1.76
192.168.1.76OPโ€ข4mo ago
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
bartlomieju
bartlomiejuโ€ข4mo ago
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.
192.168.1.76
192.168.1.76OPโ€ข4mo ago
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

Did you find this page helpful?