Library bundling is an interesting topic because Vite currently ships with a Vite library mode, which not many people actually use it because we have sort of held back in investing into the command due to library bundling actually being quite a complicated topic in itself. The behavior is quite different from bundling applications. That's why it needs a dedicated command or a mode to handle it. So we recently started, we recently moved TS-down, a project by Kevin Den, into the scope of Voice Zero and the Rodown organization. So TS-down is now the official library bundler based on Rodown and it is also the successor to TS-up, which is a wildly popular library bundler, which is now no longer active maintained.
The interesting thing that TS-down does is it comes with built-in TypeScript DTS generation and bundling. So there are two important things here. One is you can enable isolated declarations in your TS config to let OXC generate your individual DTS files without going through TSC. This makes the DTS generation process a pure syntactical transform, which is orders of magnitude faster than generating it through TSC. Second is we also implemented and shipped a plugin called Rodown Plugin DTS that uses some custom techniques to be able to bundle your DTS into a single file, so that it not only reduces your package distribution size but also makes the consumer of your package be able to type check your library faster because TypeScript works better when it has fewer files to work with. So it also handles a lot of conventions like multiple output formats, export conditions, patch manifest correctness, linting, etc. And this will be integrated into VitePlus as its library mode.
A bit about testing, right? So ViteTest is going to essentially be the Vite test command in VitePlus. ViteTest now is probably the most feature complete JavaScript test runner. Initially, ViteTest was born as a sort of replica of Jest with the same API, but designed for Vite. But now it comes with a lot more, so it comes with browser mode, component testing, and even benchmarking features. One important thing I want to mention here is when we are evaluating test runner speed. There are some test runners, for example, BounceTestRunner by default runs the commands, runs each test without isolation, so a lot of these tests actually share global state, which means it's not technically safe. So if a test mutates global state, it can actually impact the results of other tests. ViteTest opts to be safe by default, so all the test cases are isolated, forced to be isolated by default, which makes things, you know, there is a performance overhead for this, but we opt for correctness over performance in this case. You can disable it if you want, but we recommend turning isolation off. Linting and formatting. So OX-Lint handles the syntactic linting, and it's 100 times faster than ES-Lint. The rules are not as complete, and we're currently working on a JavaScript plugin system for OX-Lint, so you can write custom plugins for OX-Lint and potentially be compatible with some popular ES-Lint plugins. But in OX-Lint itself, we have already ported a majority of the rules in some most of some of the most popular plugins. Another important topic that we're researching right now is type-aware linting. There are multiple ways to do this. There are different projects, for example, Biome, exploring different directions, but our current short-term approach is likely going to integrate TSS-Lint together with OX-Lint to serve as the lint command in B-plus. So TSS-Lint actually integrates TSC type check paths to implement linting rules during the type check, so you only pay the TSC cost once instead of running it again in your linter. We are also actively looking at the TS-Go implementation and checking out how we can implement an efficient Go-Rust interop, probably using SyncRPC, so that we can hook into TS-Go diagnostics in our linting to perform the type-aware linting with the best performance.
Comments