Rust Port of Webpack? Rspack, the New Kid on the Block
Tags: javascript, frontend, webdev, webpack
Published: 2023-08-25 22:00:50


Created by the ByteDance Web Infra team, Rspack is a Rust-based bundler. It’s known for fast performance, interoperability with the Webpack ecosystem, strong customization abilities, and defaults — letting users hit the ground running without needing to configure much. It’s been made to solve tough challenges in business settings, improving the experience of many developers.

We’ve officially open-sourced Rspack to encourage innovation and teamwork. Developers, tech fans, and anyone interested in web development are welcome to join us. Whether you want to explore, create, or just be part of something big, Rspack is ready for you.

{% embed https://twitter.com/_hyf0/status/1655538017669648385?ref_src=twsrc%5Etfw%7Ctwcamp%5Etweetembed%7Ctwterm%5E1655538017669648385%7Ctwgr%5E6b25a8f0467fb6e8a50e19e3ce1b10617d9ef661%7Ctwcon%5Es1_c10&ref_url=https%3A%2F%2Fcdn.embedly.com%2Fwidgets%2Fmedia.html%3Ftype%3Dtext2Fhtmlkey%3Dd04bfffea46d4aeda930ec88cc64b87cschema%3Dtwitterurl%3Dhttps3A%2F%2Ftwitter.com%2F_hyf0%2Fstatus%2F16555380176696483853Fs3D20image%3Dhttps3A%2F%2Fi.embed.ly%2F1%2Fimage3Furl3Dhttps253A252F252Fabs.twimg.com252Ferrors252Flogo46x38.png26key3D4fce0568f2ce49e8b54624ef71a8a5bd %}

> This [article](https://zhuanlan.zhihu.com/p/612776782) was translated, written by @hardfist 

## Rspack: An In-Depth Look

### Why Develop Rspack?
ByteDance works with lots of big front-end applications, about 6,500, that take a long time to build, sometimes up to half an hour. They tried many ways to make the process faster, but nothing from the existing community tools worked well enough. After looking deeper into the problem, they found that no tools were quite right for what they needed, so they decided to create [Rspack](https://rspack.dev):

{% embed https://twitter.com/sebastienlorber/status/1646081461622128641?ref_src=twsrc%5Etfw%7Ctwcamp%5Etweetembed%7Ctwterm%5E1646081461622128641%7Ctwgr%5E858ba1861183808d843055b37f114ac1add971fc%7Ctwcon%5Es1_c10&ref_url=https%3A%2F%2Fcdn.embedly.com%2Fwidgets%2Fmedia.html%3Ftype%3Dtext2Fhtmlkey%3Da19fcc184b9711e1b4764040d3dc5c07schema%3Dtwitterurl%3Dhttps3A%2F%2Ftwitter.com%2Fsebastienlorber%2Fstatus%2F16460814616221286413Fs3D20image%3Dhttps3A%2F%2Fi.embed.ly%2F1%2Fimage3Furl3Dhttps253A252F252Fabs.twimg.com252Ferrors252Flogo46x38.png26key3Da19fcc184b9711e1b4764040d3dc5c07 %}

1. Good Dev Start Performance: Engineers often run the npm run dev command multiple times a day. With large-scale projects, each run might require a 10 minute wait, causing significant inconvenience. Therefore, optimizing the dev start time became a crucial necessity.
2. Good Build Performance: The npm run build command is frequently executed in the CI/CD environment, determining the efficiency of application production delivery. In some instances, build times could reach 20 to 30 minutes, emphasizing the need for a more time-efficient solution.
3. Enough Flexible Configuration: ByteDance’s varied user project configurations haven’t been fully unified, leading to issues when migrating the Webpack configuration to other build tools. The need for a solution with the flexibility of Webpack was apparent.
4. Production Environment Optimization Capability: Prior to Rspack, community solutions encountered negative impacts on the production environment optimization. Ensuring product optimization in the production environment was a non-negotiable feature.

After examining four main areas in need of improvement and looking into existing solutions, it became clear that nothing quite met the specific needs of large-scale front-end applications. The decision was made to create Rspack, though not without challenges.

Rspack isn’t just an answer to existing problems; it’s a custom-built tool, carefully designed to fit unique build requirements of large projects and modern needs. It represents a thoughtful effort to enhance performance, flexibility, and optimization, with the hope of making a meaningful difference in the web development landscape.

### The Ambitious Path to Rspack:
A thorough investigation into existing community solutions showed that there were no tools that fulfilled all the specific needs identified. This led to the decision to develop Rspack in-house. By shaping the tool to meet these challenges, the team embarked on an innovative path, crafting a customized solution that holds the potential to become a force to be reckoned with.

{% embed https://twitter.com/rspack_dev/status/1694617380452962615?ref_src=twsrc%5Etfw%7Ctwcamp%5Etweetembed%7Ctwterm%5E1694617380452962615%7Ctwgr%5Ebd44ba7afc2723576d7ab14a4d4836fdf72905cb%7Ctwcon%5Es1_c10&ref_url=https%3A%2F%2Fcdn.embedly.com%2Fwidgets%2Fmedia.html%3Ftype%3Dtext2Fhtmlkey%3Da19fcc184b9711e1b4764040d3dc5c07schema%3Dtwitterurl%3Dhttps3A%2F%2Ftwitter.com%2Frspack_dev%2Fstatus%2F16946173804529626153Fs3D20image%3Dhttps3A%2F%2Fi.embed.ly%2F1%2Fimage3Furl3Dhttps253A252F252Fabs.twimg.com252Ferrors252Flogo46x38.png26key3Da19fcc184b9711e1b4764040d3dc5c07 %}

### Community Collaboration and Inspirations
Rspack’s development is a result of collective inspiration, guidance, and support from various projects and individuals in the community:


- Webpack Team and Community: For creating an excellent packaging tool and a rich ecosystem.
- @sokra: For significant work on the webpack project.
- @ScriptedAlchemy: For creating the module federation and helping connect Rspack with the community.
- SWC project (created by @kdy1): For support in Rspack’s dependency analysis, code transpilation, and compression.
- esbuild project (created by @evanw): Inspiring Rspack’s concurrency architecture.
- NAPI-RS project (created by @Brooooooklyn): For support in Rspack’s node-binding implementation.
- Parcel project (created by @devongovett): An early explorer of Rust Bundler, inspiring Rspack’s incremental build architecture.
- Vite project (created by @尤雨溪): Its compatibility design with the Rollup community inspired the compatibility design of Rspack and Webpack communities.
- Rolldown project (created by the Rolldown team): Explores using Rust to build a high-performance Bundler + compatible Rollup API, inspired the design direction of Rspack.
- html-webpack-plugin project (created by @jantimon): Rspack forks this to avoid using webpack API not yet supported in Rspack.
- Turbopack project: Inspired the AST-based path rewriting logic in Rspack.

Rspack’s unique appeal extends to its interoperability with the existing Webpack ecosystem, including loaders, API, and config. While boasting a seamless integration, Rspack offers an added advantage: it comes with “wheels on.” This means that developers can get started without the verbosity or complexity typically associated with powerful tools. The design philosophy of Rspack is to provide power as and when you need it, making it accessible for beginners yet robust for experts.

What sets Rspack apart is its commitment to compatibility without compromising on functionality. The team behind Rspack is constantly expanding the API surface by adding more of Webpack’s plugin hooks, ensuring a broad alignment with the existing ecosystem. This thoughtful inclusion provides a dual benefit: it allows for easy transition for those familiar with Webpack and opens up avenues for exploiting more advanced features.

The development environment at ByteDance, characterized by a vast portfolio of software and a high-speed iterative process, demands an agile and powerful tool like Rspack. With the capability to compile large codebases rapidly, integration with Webpack’s ecosystem, and a design that enables both ease of entry and advanced utilization, Rspack proves itself as a valuable asset.

To try out Rspack, view the repository: [GitHub](https://github.com/web-infra-dev/rspack) — Rspack and check the official website: [Rspack Official Website](https://rspack.dev/).


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6214x2hqvkf8vytmyb70.png)



[Continue reading on JavaScript in Plain English »](https://javascript.plainenglish.io/rust-port-of-webpack-rspack-the-new-kid-on-the-block-c3a3de569bfb?source=rss-9ef1379caffc------2)