aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Colin McDonnell <colinmcd94@gmail.com> 2023-04-26 14:54:05 -0700
committerGravatar GitHub <noreply@github.com> 2023-04-26 14:54:05 -0700
commit68ab71eb13687ebb0889d085bb9c76132e452f60 (patch)
treeddc1b89f31d75e2a0e8f9c71410c9e097f243fbd
parentab447e4ff7cb9204f2ce8ddb9e4da74d3f3ae746 (diff)
downloadbun-68ab71eb13687ebb0889d085bb9c76132e452f60.tar.gz
bun-68ab71eb13687ebb0889d085bb9c76132e452f60.tar.zst
bun-68ab71eb13687ebb0889d085bb9c76132e452f60.zip
Basic types for Bun.build (#2713)
* Basic types for Bun.build * Tweaks * Updates
Diffstat (limited to '')
-rw-r--r--packages/bun-types/bun.d.ts51
1 files changed, 46 insertions, 5 deletions
diff --git a/packages/bun-types/bun.d.ts b/packages/bun-types/bun.d.ts
index 4454f5452..360efa813 100644
--- a/packages/bun-types/bun.d.ts
+++ b/packages/bun-types/bun.d.ts
@@ -750,7 +750,7 @@ declare module "bun" {
paths?: Record<string, string[]>;
baseUrl?: string;
/** "preserve" is not supported yet */
- jsx?: "preserve" | "react" | "react-jsx" | "react-jsxdev" | "react-native";
+ jsx?: "preserve" | "react" | "react-jsx" | "react-jsxdev";
jsxFactory?: string;
jsxFragmentFactory?: string;
jsxImportSource?: string;
@@ -962,6 +962,46 @@ declare module "bun" {
| "entry-point";
}
+ type ModuleFormat = "esm"; // later: "cjs", "iife"
+
+ interface BuildConfig {
+ entrypoints: string[]; // list of file path
+ target?: Target; // default: "browser"
+ // module?: ModuleFormat; // later: "cjs", "iife"
+ outdir?: string; // output directory
+
+ naming?: {
+ chunk?: string;
+ entrypoint?: string;
+ asset?: string;
+ }; // | string;
+ // root?: string; // project root
+ // transform?: boolean; // default: false, transform instead of bundling
+ splitting?: boolean; // default true, enable code splitting
+ bundling?: boolean; // default true, enable bundling
+ plugins?: BunPlugin[];
+ // manifest?: boolean; // whether to return manifest
+ external?: Array<string>;
+ publicPath: string;
+ // origin?: string; // e.g. http://mydomain.com
+ // loaders?: { [k in string]: Loader };
+ // sourcemap?: "none" | "inline" | "external"; // default: "none"
+ minify?:
+ | boolean
+ | {
+ whitespace?: boolean;
+ syntax?: boolean;
+ identifiers?: boolean;
+ };
+ // treeshaking?: boolean;
+ }
+
+ type BuildResult<T = Blob> = {
+ outputs: Array<{ path: string; result: T }>;
+ };
+
+ function build(config: BuildConfig): BuildResult<Blob>;
+
/**
* **0** means the message was **dropped**
*
@@ -2470,7 +2510,7 @@ declare module "bun" {
*/
export function gunzipSync(data: Uint8Array): Uint8Array;
- export type PluginTarget =
+ export type Target =
/**
* The default environment when using `bun run` or `bun` to load a script
*/
@@ -2483,6 +2523,7 @@ declare module "bun" {
* The plugin will be applied to browser builds
*/
| "browser";
+ type Loader = "js" | "jsx" | "ts" | "tsx" | "json" | "toml";
interface PluginConstraints {
/**
@@ -2525,7 +2566,7 @@ declare module "bun" {
*
* "css" will be added in a future version of Bun.
*/
- loader: "js" | "jsx" | "ts" | "tsx" | "json" | "toml";
+ loader: Loader;
}
interface OnLoadResultObject {
@@ -2637,7 +2678,7 @@ declare module "bun" {
/**
* The current target environment
*/
- target: PluginTarget;
+ target: Target;
}
interface BunPlugin {
@@ -2658,7 +2699,7 @@ declare module "bun" {
*
* If unspecified, it is assumed that the plugin is compatible with the default target.
*/
- target?: PluginTarget;
+ target?: Target;
/**
* A function that will be called when the plugin is loaded.
*