Open jacob-ebey opened 1 month ago
I totally agree, Rsbuild needs to provide similar capabilities.
First we need to clarify what is the main difference between the proposed builder.build
API and Rsbuild's JavaScript API (rsbuild.build()
). And I wonder if it should be implemented via the JavaScript API rather than the Rsbuild configuration.
I'm beyond tired of having to maintain "build CLIs". Vite's approach is correct here. It allows a plugin / framework to define the order / interplay between builds completely within their plugin. No more xyz build
, xyz dev
. It's just bundler dev
builder build --app
to specify we want the output of the environments that make up the cohesive application. For cohesion today everywhere except for Vite6 MUST be done via a custom maintained CLI / tool that uses the specific bundler JS APIs.
I'd recommend implementing it via the JS API and exposing that to plugins / config via the above convenience layer so it can be used "internally" instead of "externally".
Ok, so our goal is to allow Rsbuild plugin to orchestrate the build process, instead of calling JS API via a custom CLI. This should be useful for frameworks like Remix.
We will look at the design of Vite 6 next week and consider how Rsbuild can achieve this.
What problem does this feature solve?
In some situations (such as RSC) we need to be able to orchestrate the order and number of times an environments build is ran. A simple example of this goes something like this:
What does the proposed API look like?
Vite's new environments API comes with a
builder.buildApp
API and I propose something very similar for use here:This would allow us to write logic such as: