Next.js 13: Turbopack

At the Next.js Conference 2022, Next.js 13 was announced and it’s most important updates explained. They fall into three major categories:

  1. New compiler infrastructure
  2. New rendering infrastructure
  3. Additions/improvements to their component toolkitI’ll psend the most

I’ll dive into the first point here in this post.

New Compiler Infrastructure

Perhaps the most exciting/interesting aspect of the release was the introduction of Turbopack, a Rust-based successor to Webpack. By switching to a Rust based compiler, Vercel claims to have surpassed the performance limitations enforced by Javascript-based tooling. It is cool/interesting to note also that the author of Webpack, Tobbias Koppers, was deeply involved in the development of Turbopack.

These improvements come with some pretty drastic peformance improvement claims, including being 700x faster than Webpack, and 10x faster than Vite1. Personally, I am always a little skeptical of performance parameters when presented in a marketing context, so I am a little curious as to understand how/why this is so fast, especially when compared to it’s competitors at Vite.

Turns out there is a bit of controversy on that last point, according to some developers at Vue and elsewhere online4.

However, Rust is catching on a lot of places as an alternative to Java and Javascript, due to its security and performance2. Major tech companies like Google, Amazon, and Microsoft have been utilizing it2. Vercel CEO Guillermo Rauch¬†explains the other reason why the compiler is so much faster is due its model of incremental computation: when a change is made, only aspects of the model which are affected by the change are recomputed3. This is modeled after Google’s build system Bazel3. Vercel claims that the improvements in build time are especially important for scalability, as the performance improvements are even more apparent in larger applications1.

When Webpack was initially developed, it was done so with the idea of addressing the compilation needs of SPAs3. Although the SPA is still an integral part of the web, many sites have evolved beyond this paradigm and have expanding compilation needs. It does seem like it is about time for a next-generation bundler. Lets see how the development community responds!