DEV Community

Cover image for Use deno to build a Tauri App
Daniel Thompson-Yvetot for Tauri

Posted on

Use deno to build a Tauri App

At Tauri we originally built our CLI with typescript and node.js, but we've been looking into alternatives for a while. In that vein, we just POC'd building a Tauri app with Deno (instead of node.js)

We won't explain how to install the toolchains (deno, rust and tauri), and expect you to have already built your first Tauri apps already. But if you are new to all of this, here are the details:

Rig and build!

git clone git@github.com:tauri-apps/tauri
cd tauri/cli
git clone git@github.com:lucasfernog/tauri-deno-cli deno
cd ../tauri/examples/communication
deno run --unstable --allow-read --allow-run --allow-net --allow-env --allow-write ../../../cli/deno/index.ts build
Enter fullscreen mode Exit fullscreen mode

Tauri by Deno

Benchmarking

The second time you run deno build, you'll have all the deps already installed and the rust crates as well, so let's see how long it takes on MacOS (this isn't a scientific bench):

deno

command

$ time deno run --unstable --allow-read --allow-run --allow-net --allow-env --allow-write ../../../cli/deno/index.ts build
Enter fullscreen mode Exit fullscreen mode

with antibloat

  real    1m2.738s
  user    0m42.514s
  sys     0m2.933s
Enter fullscreen mode Exit fullscreen mode

no antibloat

  real    0m25.001s
  user    0m16.473s
  sys     0m1.758s
Enter fullscreen mode Exit fullscreen mode

no antibloat, just .app

real    0m5.906s
user    0m11.780s
sys     0m1.268s
Enter fullscreen mode Exit fullscreen mode

node.js

command

$ time node ../../../cli/tauri.js/bin/tauri build
Enter fullscreen mode Exit fullscreen mode

with antibloat

  real    1m10.295s
  user    0m51.990s
  sys     0m3.009s
Enter fullscreen mode Exit fullscreen mode

no antibloat

  real    0m44.562s
  user    1m5.383s
  sys     0m3.187s
Enter fullscreen mode Exit fullscreen mode

no antibloat, just .app

real    0m26.423s
user    0m59.936s
sys     0m2.805s
Enter fullscreen mode Exit fullscreen mode

Discussion

The ~1 minute build time might seem like it takes a long time, but we are actually using these antibloat techniques only possible when single-threading.

Also, if you are trying this in your own project, you should know that you will have to run yarn tauri dev at least once in order to create index.tauri.html. We haven't started porting the inliner to deno.

Nevertheless, deno performs better in both cases - without antibloat almost twice as fast, and just building a .app its about 4.5x faster. So I absolutely have to agree with Lucas' sentiment:

deno is f!cking amazing

Top comments (1)

Collapse
 
jayanthsaikiran profile image
Jayanth Saikiran • Edited

Hey Daniel,
Great article. I have a mern stack web app. I want to convert this to a desktop application using tauri. But for some reason, I am not able to integrate backend (node js) code to the frontend using tauri.