aboutsummaryrefslogtreecommitdiff
path: root/docs/rfcs/bun-build.ts
blob: e6c9412c49146120a142819667b343a6fdbd26d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { FileBlob } from "bun";
import { BuildConfig, BuildManifest, BundlerConfig } from "./bun-build-config";
import { Log } from "./bun-build-logs";

namespace Bun {
  export declare function build(config: BuildConfig): BuildResult<Blob>;
}

export type BuildResult<T> = {
  // T will usually be a FileBlob
  // or a Blob (for in-memory builds)
  outputs: Map<string, FileBlob | Blob>;
  // only exists if `manifest` is true
  manifest?: BuildManifest;
  log: Log;
};

// simple build, writes to disk
{
  Bun.build({
    target: "bun",
    entrypoints: ["index.js"],
    naming: "[name]-[hash].[ext]",
    outdir: "./build",
  });
}

// RSC
{
  Bun.build({
    target: "bun",
    entrypoints: ["index.js"],
    naming: "[name]-[hash].[ext]",
    outdir: "./build",
    plugins: [
      //@ts-ignore
      BunPluginRSC({
        client: {
          entrypoints: ["client-entry.ts"],
          outdir: "./build/client",
          /* ... */
        },
        ssr: {
          entrypoints: ["ssr-entry.ts"],
          outdir: "./build/ssr",
          /* ... */
        },
      }),
    ],
  });
}