Open
Description
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:
- Build server, discover "use client"
- Build client with discovered client modules, discover "use server"
- Re-build server with discovered server modules, discover new "use client"
- etc...
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:
export default defineConfig({
builder: {
buildApp: async (builder) => {
await builder.build(builder.environments.browser);
await builder.build(builder.environments.server);
},
},
});
This would allow us to write logic such as:
export default defineConfig({
builder: {
buildApp: async (builder) => {
do {
checkpointDiscoveredModules();
await builder.build(builder.environments.server);
await Promise.all([
builder.build(builder.environments.browser),
builder.build(builder.environments.ssr),
]);
} while (discoveredNewModules());
},
},
});