Skip to content

[Feature]: Build orchestration API #2916

Open
@jacob-ebey

Description

@jacob-ebey

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:

  1. Build server, discover "use client"
  2. Build client with discovered client modules, discover "use server"
  3. Re-build server with discovered server modules, discover new "use client"
  4. 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());
    },
  },
});

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions