bun-types 1.1.45 → 1.2.0-canary.20250122T140708
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bun.d.ts +342 -63
- package/docs/api/fetch.md +1 -1
- package/docs/api/s3.md +6 -5
- package/docs/api/spawn.md +1 -1
- package/docs/api/sql.md +571 -0
- package/docs/api/transpiler.md +4 -2
- package/docs/bundler/fullstack.md +49 -4
- package/docs/bundler/html.md +1 -7
- package/docs/bundler/index.md +4 -97
- package/docs/bundler/loaders.md +0 -20
- package/docs/cli/bun-install.md +5 -19
- package/docs/cli/install.md +3 -3
- package/docs/cli/publish.md +1 -1
- package/docs/cli/run.md +13 -2
- package/docs/guides/ecosystem/docker.md +2 -2
- package/docs/guides/ecosystem/render.md +1 -1
- package/docs/guides/install/from-npm-install-to-bun-install.md +1 -1
- package/docs/guides/install/trusted.md +1 -1
- package/docs/guides/install/yarnlock.md +3 -7
- package/docs/install/index.md +1 -1
- package/docs/install/lockfile.md +9 -79
- package/docs/install/workspaces.md +1 -1
- package/docs/runtime/autoimport.md +1 -1
- package/docs/runtime/bunfig.md +5 -5
- package/docs/runtime/debugger.md +3 -3
- package/docs/runtime/modules.md +0 -1
- package/docs/runtime/nodejs-apis.md +14 -15
- package/docs/runtime/plugins.md +0 -2
- package/docs/test/dom.md +1 -1
- package/package.json +2 -2
package/bun.d.ts
CHANGED
|
@@ -1300,33 +1300,7 @@ declare module "bun" {
|
|
|
1300
1300
|
}
|
|
1301
1301
|
|
|
1302
1302
|
var S3Client: S3Client;
|
|
1303
|
-
|
|
1304
|
-
/**
|
|
1305
|
-
* Creates a new S3File instance for working with a single file.
|
|
1306
|
-
*
|
|
1307
|
-
* @param path The path or key of the file
|
|
1308
|
-
* @param options S3 configuration options
|
|
1309
|
-
* @returns `S3File` instance for the specified path
|
|
1310
|
-
*
|
|
1311
|
-
* @example
|
|
1312
|
-
* import { s3 } from "bun";
|
|
1313
|
-
* const file = s3("my-file.txt", {
|
|
1314
|
-
* bucket: "my-bucket",
|
|
1315
|
-
* accessKeyId: "your-access-key",
|
|
1316
|
-
* secretAccessKey: "your-secret-key"
|
|
1317
|
-
* });
|
|
1318
|
-
*
|
|
1319
|
-
* // Read the file
|
|
1320
|
-
* const content = await file.text();
|
|
1321
|
-
*
|
|
1322
|
-
* @example
|
|
1323
|
-
* // Using s3:// protocol
|
|
1324
|
-
* const file = s3("s3://my-bucket/my-file.txt", {
|
|
1325
|
-
* accessKeyId: "your-access-key",
|
|
1326
|
-
* secretAccessKey: "your-secret-key"
|
|
1327
|
-
* });
|
|
1328
|
-
*/
|
|
1329
|
-
function s3(path: string | URL, options?: S3Options): S3File;
|
|
1303
|
+
var s3: S3Client;
|
|
1330
1304
|
|
|
1331
1305
|
/**
|
|
1332
1306
|
* Configuration options for S3 operations
|
|
@@ -1630,7 +1604,7 @@ declare module "bun" {
|
|
|
1630
1604
|
*
|
|
1631
1605
|
* // Write large chunks of data efficiently
|
|
1632
1606
|
* for (const chunk of largeDataChunks) {
|
|
1633
|
-
*
|
|
1607
|
+
* writer.write(chunk);
|
|
1634
1608
|
* }
|
|
1635
1609
|
* await writer.end();
|
|
1636
1610
|
*
|
|
@@ -1638,7 +1612,7 @@ declare module "bun" {
|
|
|
1638
1612
|
* // Error handling
|
|
1639
1613
|
* const writer = file.writer();
|
|
1640
1614
|
* try {
|
|
1641
|
-
*
|
|
1615
|
+
* writer.write(data);
|
|
1642
1616
|
* await writer.end();
|
|
1643
1617
|
* } catch (err) {
|
|
1644
1618
|
* console.error('Upload failed:', err);
|
|
@@ -2037,6 +2011,339 @@ declare module "bun" {
|
|
|
2037
2011
|
*/
|
|
2038
2012
|
stat(path: string, options?: S3Options): Promise<S3Stats>;
|
|
2039
2013
|
};
|
|
2014
|
+
/**
|
|
2015
|
+
* Configuration options for SQL client connection and behavior
|
|
2016
|
+
* @example
|
|
2017
|
+
* const config: SQLOptions = {
|
|
2018
|
+
* host: 'localhost',
|
|
2019
|
+
* port: 5432,
|
|
2020
|
+
* user: 'dbuser',
|
|
2021
|
+
* password: 'secretpass',
|
|
2022
|
+
* database: 'myapp',
|
|
2023
|
+
* idleTimeout: 30000,
|
|
2024
|
+
* max: 20,
|
|
2025
|
+
* onconnect: (client) => {
|
|
2026
|
+
* console.log('Connected to database');
|
|
2027
|
+
* }
|
|
2028
|
+
* };
|
|
2029
|
+
*/
|
|
2030
|
+
type SQLOptions = {
|
|
2031
|
+
/** Connection URL (can be string or URL object) */
|
|
2032
|
+
url: URL | string;
|
|
2033
|
+
/** Database server hostname */
|
|
2034
|
+
host: string;
|
|
2035
|
+
/** Database server port number */
|
|
2036
|
+
port: number | string;
|
|
2037
|
+
/** Database user for authentication */
|
|
2038
|
+
username: string;
|
|
2039
|
+
/** Database password for authentication */
|
|
2040
|
+
password: string;
|
|
2041
|
+
/** Name of the database to connect to */
|
|
2042
|
+
database: string;
|
|
2043
|
+
/** Database adapter/driver to use */
|
|
2044
|
+
adapter: string;
|
|
2045
|
+
/** Maximum time in milliseconds to wait for connection to become available */
|
|
2046
|
+
idleTimeout: number;
|
|
2047
|
+
/** Maximum time in milliseconds to wait when establishing a connection */
|
|
2048
|
+
connectionTimeout: number;
|
|
2049
|
+
/** Maximum lifetime in milliseconds of a connection */
|
|
2050
|
+
maxLifetime: number;
|
|
2051
|
+
/** Whether to use TLS/SSL for the connection */
|
|
2052
|
+
tls: boolean;
|
|
2053
|
+
/** Callback function executed when a connection is established */
|
|
2054
|
+
onconnect: (client: SQL) => void;
|
|
2055
|
+
/** Callback function executed when a connection is closed */
|
|
2056
|
+
onclose: (client: SQL) => void;
|
|
2057
|
+
/** Maximum number of connections in the pool */
|
|
2058
|
+
max: number;
|
|
2059
|
+
/** By default values outside i32 range are returned as strings. If this is true, values outside i32 range are returned as BigInts. */
|
|
2060
|
+
bigint: boolean;
|
|
2061
|
+
};
|
|
2062
|
+
|
|
2063
|
+
/**
|
|
2064
|
+
* Represents a SQL query that can be executed, with additional control methods
|
|
2065
|
+
* Extends Promise to allow for async/await usage
|
|
2066
|
+
*/
|
|
2067
|
+
interface SQLQuery extends Promise<any> {
|
|
2068
|
+
/** Indicates if the query is currently executing */
|
|
2069
|
+
active: boolean;
|
|
2070
|
+
/** Indicates if the query has been cancelled */
|
|
2071
|
+
cancelled: boolean;
|
|
2072
|
+
/** Cancels the executing query */
|
|
2073
|
+
cancel(): SQLQuery;
|
|
2074
|
+
/** Executes the query */
|
|
2075
|
+
execute(): SQLQuery;
|
|
2076
|
+
/** Returns the raw query result */
|
|
2077
|
+
raw(): SQLQuery;
|
|
2078
|
+
/** Returns only the values from the query result */
|
|
2079
|
+
values(): SQLQuery;
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
/**
|
|
2083
|
+
* Callback function type for transaction contexts
|
|
2084
|
+
* @param sql Function to execute SQL queries within the transaction
|
|
2085
|
+
*/
|
|
2086
|
+
type SQLTransactionContextCallback = (
|
|
2087
|
+
sql: TransactionSQL,
|
|
2088
|
+
) => Promise<any> | Array<SQLQuery>;
|
|
2089
|
+
/**
|
|
2090
|
+
* Callback function type for savepoint contexts
|
|
2091
|
+
* @param sql Function to execute SQL queries within the savepoint
|
|
2092
|
+
*/
|
|
2093
|
+
type SQLSavepointContextCallback = (
|
|
2094
|
+
sql: SavepointSQL,
|
|
2095
|
+
) => Promise<any> | Array<SQLQuery>;
|
|
2096
|
+
|
|
2097
|
+
/**
|
|
2098
|
+
* Main SQL client interface providing connection and transaction management
|
|
2099
|
+
*/
|
|
2100
|
+
interface SQL {
|
|
2101
|
+
/** Creates a new SQL client instance
|
|
2102
|
+
* @example
|
|
2103
|
+
* const sql = new SQL("postgres://localhost:5432/mydb");
|
|
2104
|
+
* const sql = new SQL(new URL("postgres://localhost:5432/mydb"));
|
|
2105
|
+
*/
|
|
2106
|
+
new (connectionString: string | URL): SQL;
|
|
2107
|
+
/** Creates a new SQL client instance with options
|
|
2108
|
+
* @example
|
|
2109
|
+
* const sql = new SQL("postgres://localhost:5432/mydb", { idleTimeout: 1000 });
|
|
2110
|
+
*/
|
|
2111
|
+
new (connectionString: string | URL, options: SQLOptions): SQL;
|
|
2112
|
+
/** Creates a new SQL client instance with options
|
|
2113
|
+
* @example
|
|
2114
|
+
* const sql = new SQL({ url: "postgres://localhost:5432/mydb", idleTimeout: 1000 });
|
|
2115
|
+
*/
|
|
2116
|
+
new (options?: SQLOptions): SQL;
|
|
2117
|
+
/** Executes a SQL query using template literals
|
|
2118
|
+
* @example
|
|
2119
|
+
* const [user] = await sql`select * from users where id = ${1}`;
|
|
2120
|
+
*/
|
|
2121
|
+
(strings: string | TemplateStringsArray, ...values: any[]): SQLQuery;
|
|
2122
|
+
/**
|
|
2123
|
+
* Helper function to allow easy use to insert values into a query
|
|
2124
|
+
* @example
|
|
2125
|
+
* const result = await sql`insert into users ${sql(users)} RETURNING *`;
|
|
2126
|
+
*/
|
|
2127
|
+
(obj: any): SQLQuery;
|
|
2128
|
+
/** Commits a distributed transaction also know as prepared transaction in postgres or XA transaction in MySQL
|
|
2129
|
+
* @example
|
|
2130
|
+
* await sql.commitDistributed("my_distributed_transaction");
|
|
2131
|
+
*/
|
|
2132
|
+
commitDistributed(name: string): Promise<undefined>;
|
|
2133
|
+
/** Rolls back a distributed transaction also know as prepared transaction in postgres or XA transaction in MySQL
|
|
2134
|
+
* @example
|
|
2135
|
+
* await sql.rollbackDistributed("my_distributed_transaction");
|
|
2136
|
+
*/
|
|
2137
|
+
rollbackDistributed(name: string): Promise<undefined>;
|
|
2138
|
+
/** Waits for the database connection to be established
|
|
2139
|
+
* @example
|
|
2140
|
+
* await sql.connect();
|
|
2141
|
+
*/
|
|
2142
|
+
connect(): Promise<SQL>;
|
|
2143
|
+
/** Closes the database connection with optional timeout in seconds. If timeout is 0, it will close immediately, if is not provided it will wait for all queries to finish before closing.
|
|
2144
|
+
* @example
|
|
2145
|
+
* await sql.close({ timeout: 1 });
|
|
2146
|
+
*/
|
|
2147
|
+
close(options?: { timeout?: number }): Promise<undefined>;
|
|
2148
|
+
/** Closes the database connection with optional timeout in seconds. If timeout is 0, it will close immediately, if is not provided it will wait for all queries to finish before closing.
|
|
2149
|
+
* @alias close
|
|
2150
|
+
* @example
|
|
2151
|
+
* await sql.end({ timeout: 1 });
|
|
2152
|
+
*/
|
|
2153
|
+
end(options?: { timeout?: number }): Promise<undefined>;
|
|
2154
|
+
/** Flushes any pending operations */
|
|
2155
|
+
flush(): void;
|
|
2156
|
+
/** The reserve method pulls out a connection from the pool, and returns a client that wraps the single connection.
|
|
2157
|
+
* This can be used for running queries on an isolated connection.
|
|
2158
|
+
* Calling reserve in a reserved Sql will return a new reserved connection, not the same connection (behavior matches postgres package).
|
|
2159
|
+
* @example
|
|
2160
|
+
* const reserved = await sql.reserve();
|
|
2161
|
+
* await reserved`select * from users`;
|
|
2162
|
+
* await reserved.release();
|
|
2163
|
+
* // with in a production scenario would be something more like
|
|
2164
|
+
* const reserved = await sql.reserve();
|
|
2165
|
+
* try {
|
|
2166
|
+
* // ... queries
|
|
2167
|
+
* } finally {
|
|
2168
|
+
* await reserved.release();
|
|
2169
|
+
* }
|
|
2170
|
+
* //To make it simpler bun supportsSymbol.dispose and Symbol.asyncDispose
|
|
2171
|
+
* {
|
|
2172
|
+
* // always release after context (safer)
|
|
2173
|
+
* using reserved = await sql.reserve()
|
|
2174
|
+
* await reserved`select * from users`
|
|
2175
|
+
* }
|
|
2176
|
+
*/
|
|
2177
|
+
reserve(): Promise<ReservedSQL>;
|
|
2178
|
+
/** Begins a new transaction
|
|
2179
|
+
* Will reserve a connection for the transaction and supply a scoped sql instance for all transaction uses in the callback function. sql.begin will resolve with the returned value from the callback function.
|
|
2180
|
+
* BEGIN is automatically sent with the optional options, and if anything fails ROLLBACK will be called so the connection can be released and execution can continue.
|
|
2181
|
+
* @example
|
|
2182
|
+
* const [user, account] = await sql.begin(async sql => {
|
|
2183
|
+
* const [user] = await sql`
|
|
2184
|
+
* insert into users (
|
|
2185
|
+
* name
|
|
2186
|
+
* ) values (
|
|
2187
|
+
* 'Murray'
|
|
2188
|
+
* )
|
|
2189
|
+
* returning *
|
|
2190
|
+
* `
|
|
2191
|
+
* const [account] = await sql`
|
|
2192
|
+
* insert into accounts (
|
|
2193
|
+
* user_id
|
|
2194
|
+
* ) values (
|
|
2195
|
+
* ${ user.user_id }
|
|
2196
|
+
* )
|
|
2197
|
+
* returning *
|
|
2198
|
+
* `
|
|
2199
|
+
* return [user, account]
|
|
2200
|
+
* })
|
|
2201
|
+
*/
|
|
2202
|
+
begin(fn: SQLTransactionContextCallback): Promise<any>;
|
|
2203
|
+
/** Begins a new transaction with options
|
|
2204
|
+
* Will reserve a connection for the transaction and supply a scoped sql instance for all transaction uses in the callback function. sql.begin will resolve with the returned value from the callback function.
|
|
2205
|
+
* BEGIN is automatically sent with the optional options, and if anything fails ROLLBACK will be called so the connection can be released and execution can continue.
|
|
2206
|
+
* @example
|
|
2207
|
+
* const [user, account] = await sql.begin("read write", async sql => {
|
|
2208
|
+
* const [user] = await sql`
|
|
2209
|
+
* insert into users (
|
|
2210
|
+
* name
|
|
2211
|
+
* ) values (
|
|
2212
|
+
* 'Murray'
|
|
2213
|
+
* )
|
|
2214
|
+
* returning *
|
|
2215
|
+
* `
|
|
2216
|
+
* const [account] = await sql`
|
|
2217
|
+
* insert into accounts (
|
|
2218
|
+
* user_id
|
|
2219
|
+
* ) values (
|
|
2220
|
+
* ${ user.user_id }
|
|
2221
|
+
* )
|
|
2222
|
+
* returning *
|
|
2223
|
+
* `
|
|
2224
|
+
* return [user, account]
|
|
2225
|
+
* })
|
|
2226
|
+
*/
|
|
2227
|
+
begin(options: string, fn: SQLTransactionContextCallback): Promise<any>;
|
|
2228
|
+
/** Alternative method to begin a transaction
|
|
2229
|
+
* Will reserve a connection for the transaction and supply a scoped sql instance for all transaction uses in the callback function. sql.transaction will resolve with the returned value from the callback function.
|
|
2230
|
+
* BEGIN is automatically sent with the optional options, and if anything fails ROLLBACK will be called so the connection can be released and execution can continue.
|
|
2231
|
+
* @alias begin
|
|
2232
|
+
* @example
|
|
2233
|
+
* const [user, account] = await sql.transaction(async sql => {
|
|
2234
|
+
* const [user] = await sql`
|
|
2235
|
+
* insert into users (
|
|
2236
|
+
* name
|
|
2237
|
+
* ) values (
|
|
2238
|
+
* 'Murray'
|
|
2239
|
+
* )
|
|
2240
|
+
* returning *
|
|
2241
|
+
* `
|
|
2242
|
+
* const [account] = await sql`
|
|
2243
|
+
* insert into accounts (
|
|
2244
|
+
* user_id
|
|
2245
|
+
* ) values (
|
|
2246
|
+
* ${ user.user_id }
|
|
2247
|
+
* )
|
|
2248
|
+
* returning *
|
|
2249
|
+
* `
|
|
2250
|
+
* return [user, account]
|
|
2251
|
+
* })
|
|
2252
|
+
*/
|
|
2253
|
+
transaction(fn: SQLTransactionContextCallback): Promise<any>;
|
|
2254
|
+
/** Alternative method to begin a transaction with options
|
|
2255
|
+
* Will reserve a connection for the transaction and supply a scoped sql instance for all transaction uses in the callback function. sql.transaction will resolve with the returned value from the callback function.
|
|
2256
|
+
* BEGIN is automatically sent with the optional options, and if anything fails ROLLBACK will be called so the connection can be released and execution can continue.
|
|
2257
|
+
* @alias begin
|
|
2258
|
+
* @example
|
|
2259
|
+
* const [user, account] = await sql.transaction("read write", async sql => {
|
|
2260
|
+
* const [user] = await sql`
|
|
2261
|
+
* insert into users (
|
|
2262
|
+
* name
|
|
2263
|
+
* ) values (
|
|
2264
|
+
* 'Murray'
|
|
2265
|
+
* )
|
|
2266
|
+
* returning *
|
|
2267
|
+
* `
|
|
2268
|
+
* const [account] = await sql`
|
|
2269
|
+
* insert into accounts (
|
|
2270
|
+
* user_id
|
|
2271
|
+
* ) values (
|
|
2272
|
+
* ${ user.user_id }
|
|
2273
|
+
* )
|
|
2274
|
+
* returning *
|
|
2275
|
+
* `
|
|
2276
|
+
* return [user, account]
|
|
2277
|
+
* })
|
|
2278
|
+
*/
|
|
2279
|
+
transaction(
|
|
2280
|
+
options: string,
|
|
2281
|
+
fn: SQLTransactionContextCallback,
|
|
2282
|
+
): Promise<any>;
|
|
2283
|
+
/** Begins a distributed transaction
|
|
2284
|
+
* Also know as Two-Phase Commit, in a distributed transaction, Phase 1 involves the coordinator preparing nodes by ensuring data is written and ready to commit, while Phase 2 finalizes with nodes committing or rolling back based on the coordinator's decision, ensuring durability and releasing locks.
|
|
2285
|
+
* In PostgreSQL and MySQL distributed transactions persist beyond the original session, allowing privileged users or coordinators to commit/rollback them, ensuring support for distributed transactions, recovery, and administrative tasks.
|
|
2286
|
+
* beginDistributed will automatic rollback if any exception are not caught, and you can commit and rollback later if everything goes well.
|
|
2287
|
+
* PostgreSQL natively supports distributed transactions using PREPARE TRANSACTION, while MySQL uses XA Transactions, and MSSQL also supports distributed/XA transactions. However, in MSSQL, distributed transactions are tied to the original session, the DTC coordinator, and the specific connection.
|
|
2288
|
+
* These transactions are automatically committed or rolled back following the same rules as regular transactions, with no option for manual intervention from other sessions, in MSSQL distributed transactions are used to coordinate transactions using Linked Servers.
|
|
2289
|
+
* @example
|
|
2290
|
+
* await sql.beginDistributed("numbers", async sql => {
|
|
2291
|
+
* await sql`create table if not exists numbers (a int)`;
|
|
2292
|
+
* await sql`insert into numbers values(1)`;
|
|
2293
|
+
* });
|
|
2294
|
+
* // later you can call
|
|
2295
|
+
* await sql.commitDistributed("numbers");
|
|
2296
|
+
* // or await sql.rollbackDistributed("numbers");
|
|
2297
|
+
*/
|
|
2298
|
+
beginDistributed(
|
|
2299
|
+
name: string,
|
|
2300
|
+
fn: SQLTransactionContextCallback,
|
|
2301
|
+
): Promise<any>;
|
|
2302
|
+
/** Alternative method to begin a distributed transaction
|
|
2303
|
+
* @alias beginDistributed
|
|
2304
|
+
*/
|
|
2305
|
+
distributed(name: string, fn: SQLTransactionContextCallback): Promise<any>;
|
|
2306
|
+
/**If you know what you're doing, you can use unsafe to pass any string you'd like.
|
|
2307
|
+
* Please note that this can lead to SQL injection if you're not careful.
|
|
2308
|
+
* You can also nest sql.unsafe within a safe sql expression. This is useful if only part of your fraction has unsafe elements.
|
|
2309
|
+
* @example
|
|
2310
|
+
* const result = await sql.unsafe(`select ${danger} from users where id = ${dragons}`)
|
|
2311
|
+
*/
|
|
2312
|
+
unsafe(string: string, values?: any[]): SQLQuery;
|
|
2313
|
+
|
|
2314
|
+
/** Current client options */
|
|
2315
|
+
options: SQLOptions;
|
|
2316
|
+
|
|
2317
|
+
[Symbol.asyncDispose](): Promise<any>;
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2320
|
+
/**
|
|
2321
|
+
* Represents a reserved connection from the connection pool
|
|
2322
|
+
* Extends SQL with additional release functionality
|
|
2323
|
+
*/
|
|
2324
|
+
interface ReservedSQL extends SQL {
|
|
2325
|
+
/** Releases the client back to the connection pool */
|
|
2326
|
+
release(): void;
|
|
2327
|
+
[Symbol.dispose](): void;
|
|
2328
|
+
}
|
|
2329
|
+
|
|
2330
|
+
/**
|
|
2331
|
+
* Represents a client within a transaction context
|
|
2332
|
+
* Extends SQL with savepoint functionality
|
|
2333
|
+
*/
|
|
2334
|
+
interface TransactionSQL extends SQL {
|
|
2335
|
+
/** Creates a savepoint within the current transaction */
|
|
2336
|
+
savepoint(name: string, fn: SQLSavepointContextCallback): Promise<any>;
|
|
2337
|
+
savepoint(fn: SQLSavepointContextCallback): Promise<any>;
|
|
2338
|
+
}
|
|
2339
|
+
/**
|
|
2340
|
+
* Represents a savepoint within a transaction
|
|
2341
|
+
*/
|
|
2342
|
+
interface SavepointSQL extends SQL {}
|
|
2343
|
+
|
|
2344
|
+
var sql: SQL;
|
|
2345
|
+
var postgres: SQL;
|
|
2346
|
+
var SQL: SQL;
|
|
2040
2347
|
|
|
2041
2348
|
/**
|
|
2042
2349
|
* This lets you use macros as regular imports
|
|
@@ -2357,7 +2664,8 @@ declare module "bun" {
|
|
|
2357
2664
|
| "import-rule"
|
|
2358
2665
|
| "url-token"
|
|
2359
2666
|
| "internal"
|
|
2360
|
-
| "entry-point"
|
|
2667
|
+
| "entry-point-run"
|
|
2668
|
+
| "entry-point-build";
|
|
2361
2669
|
|
|
2362
2670
|
interface Import {
|
|
2363
2671
|
path: string;
|
|
@@ -2493,31 +2801,6 @@ declare module "bun" {
|
|
|
2493
2801
|
*/
|
|
2494
2802
|
footer?: string;
|
|
2495
2803
|
|
|
2496
|
-
/**
|
|
2497
|
-
* **Experimental**
|
|
2498
|
-
*
|
|
2499
|
-
* Bundle CSS files.
|
|
2500
|
-
*
|
|
2501
|
-
* This will be enabled by default in Bun v1.2.
|
|
2502
|
-
*
|
|
2503
|
-
* @default false (until Bunv 1.2)
|
|
2504
|
-
*/
|
|
2505
|
-
experimentalCss?: boolean;
|
|
2506
|
-
|
|
2507
|
-
/**
|
|
2508
|
-
* **Experimental**
|
|
2509
|
-
*
|
|
2510
|
-
* Bundle JavaScript & CSS files from HTML files. JavaScript & CSS files
|
|
2511
|
-
* from non-external <script> or <link> tags will be bundled.
|
|
2512
|
-
*
|
|
2513
|
-
* Underneath, this works similarly to HTMLRewriter.
|
|
2514
|
-
*
|
|
2515
|
-
* This will be enabled by default in Bun v1.2.
|
|
2516
|
-
*
|
|
2517
|
-
* @default false (until Bun v1.2)
|
|
2518
|
-
*/
|
|
2519
|
-
html?: boolean;
|
|
2520
|
-
|
|
2521
2804
|
/**
|
|
2522
2805
|
* Drop function calls to matching property accesses.
|
|
2523
2806
|
*/
|
|
@@ -2526,9 +2809,7 @@ declare module "bun" {
|
|
|
2526
2809
|
/**
|
|
2527
2810
|
* When set to `true`, the returned promise rejects with an AggregateError when a build failure happens.
|
|
2528
2811
|
* When set to `false`, the `success` property of the returned object will be `false` when a build failure happens.
|
|
2529
|
-
*
|
|
2530
|
-
* This defaults to `false` in Bun 1.1 and will change to `true` in Bun 1.2
|
|
2531
|
-
* as most usage of `Bun.build` forgets to check for errors.
|
|
2812
|
+
* This defaults to `true`.
|
|
2532
2813
|
*/
|
|
2533
2814
|
throw?: boolean;
|
|
2534
2815
|
}
|
|
@@ -2773,7 +3054,7 @@ declare module "bun" {
|
|
|
2773
3054
|
* @param {Object} config - Build configuration options
|
|
2774
3055
|
* @returns {Promise<BuildOutput>} Promise that resolves to build output containing generated artifacts and build status
|
|
2775
3056
|
* @throws {AggregateError} When build fails and config.throw is true (default in Bun 1.2+)
|
|
2776
|
-
*
|
|
3057
|
+
*
|
|
2777
3058
|
* @example Basic usage - Bundle a single entrypoint and check results
|
|
2778
3059
|
```ts
|
|
2779
3060
|
const result = await Bun.build({
|
|
@@ -2786,7 +3067,7 @@ declare module "bun" {
|
|
|
2786
3067
|
process.exit(1);
|
|
2787
3068
|
}
|
|
2788
3069
|
```
|
|
2789
|
-
*
|
|
3070
|
+
*
|
|
2790
3071
|
* @example Set up multiple entrypoints with code splitting enabled
|
|
2791
3072
|
```ts
|
|
2792
3073
|
await Bun.build({
|
|
@@ -2796,7 +3077,7 @@ declare module "bun" {
|
|
|
2796
3077
|
sourcemap: "external"
|
|
2797
3078
|
});
|
|
2798
3079
|
```
|
|
2799
|
-
*
|
|
3080
|
+
*
|
|
2800
3081
|
* @example Configure minification and optimization settings
|
|
2801
3082
|
```ts
|
|
2802
3083
|
await Bun.build({
|
|
@@ -2875,7 +3156,6 @@ declare module "bun" {
|
|
|
2875
3156
|
try {
|
|
2876
3157
|
const result = await Bun.build({
|
|
2877
3158
|
entrypoints: ['./src/index.tsx'],
|
|
2878
|
-
throw: true
|
|
2879
3159
|
});
|
|
2880
3160
|
} catch (e) {
|
|
2881
3161
|
const error = e as AggregateError;
|
|
@@ -2913,7 +3193,6 @@ declare module "bun" {
|
|
|
2913
3193
|
'./src/themes/light.css'
|
|
2914
3194
|
],
|
|
2915
3195
|
outdir: './dist/css',
|
|
2916
|
-
experimentalCss: true
|
|
2917
3196
|
});
|
|
2918
3197
|
```
|
|
2919
3198
|
@example Define compile-time constants and version information
|
package/docs/api/fetch.md
CHANGED
|
@@ -195,7 +195,7 @@ This will print the request and response headers to your terminal:
|
|
|
195
195
|
```sh
|
|
196
196
|
[fetch] > HTTP/1.1 GET http://example.com/
|
|
197
197
|
[fetch] > Connection: keep-alive
|
|
198
|
-
[fetch] > User-Agent: Bun/
|
|
198
|
+
[fetch] > User-Agent: Bun/1.2.0-canary.20250122T140708
|
|
199
199
|
[fetch] > Accept: */*
|
|
200
200
|
[fetch] > Host: example.com
|
|
201
201
|
[fetch] > Accept-Encoding: gzip, deflate, br
|
package/docs/api/s3.md
CHANGED
|
@@ -68,7 +68,6 @@ const client = new S3Client({
|
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
// Bun.s3 is a global singleton that is equivalent to `new Bun.S3Client()`
|
|
71
|
-
Bun.s3 = client;
|
|
72
71
|
```
|
|
73
72
|
|
|
74
73
|
### Working with S3 Files
|
|
@@ -375,7 +374,7 @@ If the `S3_*` environment variable is not set, Bun will also check for the `AWS_
|
|
|
375
374
|
|
|
376
375
|
These environment variables are read from [`.env` files](/docs/runtime/env) or from the process environment at initialization time (`process.env` is not used for this).
|
|
377
376
|
|
|
378
|
-
These defaults are overridden by the options you pass to `s3(credentials)`, `new Bun.S3Client(credentials)`, or any of the methods that accept credentials. So if, for example, you use the same credentials for different buckets, you can set the credentials once in your `.env` file and then pass `bucket: "my-bucket"` to the `s3()`
|
|
377
|
+
These defaults are overridden by the options you pass to `s3.file(credentials)`, `new Bun.S3Client(credentials)`, or any of the methods that accept credentials. So if, for example, you use the same credentials for different buckets, you can set the credentials once in your `.env` file and then pass `bucket: "my-bucket"` to the `s3.file()` function without having to specify all the credentials again.
|
|
379
378
|
|
|
380
379
|
### `S3Client` objects
|
|
381
380
|
|
|
@@ -459,7 +458,7 @@ const exists = await client.exists("my-file.txt");
|
|
|
459
458
|
|
|
460
459
|
## `S3File`
|
|
461
460
|
|
|
462
|
-
`S3File` instances are created by calling the `
|
|
461
|
+
`S3File` instances are created by calling the `S3Client` instance method or the `s3.file()` function. Like `Bun.file()`, `S3File` instances are lazy. They don't refer to something that necessarily exists at the time of creation. That's why all the methods that don't involve network requests are fully synchronous.
|
|
463
462
|
|
|
464
463
|
```ts
|
|
465
464
|
interface S3File extends Blob {
|
|
@@ -482,7 +481,7 @@ interface S3File extends Blob {
|
|
|
482
481
|
| Response
|
|
483
482
|
| Request,
|
|
484
483
|
options?: BlobPropertyBag,
|
|
485
|
-
): Promise<
|
|
484
|
+
): Promise<number>;
|
|
486
485
|
|
|
487
486
|
exists(options?: S3Options): Promise<boolean>;
|
|
488
487
|
unlink(options?: S3Options): Promise<void>;
|
|
@@ -600,7 +599,9 @@ const exists = await S3Client.exists("my-file.txt", credentials);
|
|
|
600
599
|
The same method also works on `S3File` instances.
|
|
601
600
|
|
|
602
601
|
```ts
|
|
603
|
-
|
|
602
|
+
import { s3 } from "bun";
|
|
603
|
+
|
|
604
|
+
const s3file = s3.file("my-file.txt", {
|
|
604
605
|
...credentials,
|
|
605
606
|
});
|
|
606
607
|
const exists = await s3file.exists();
|
package/docs/api/spawn.md
CHANGED
|
@@ -110,7 +110,7 @@ You can read results from the subprocess via the `stdout` and `stderr` propertie
|
|
|
110
110
|
```ts
|
|
111
111
|
const proc = Bun.spawn(["bun", "--version"]);
|
|
112
112
|
const text = await new Response(proc.stdout).text();
|
|
113
|
-
console.log(text); // => "
|
|
113
|
+
console.log(text); // => "1.2.0-canary.20250122T140708"
|
|
114
114
|
```
|
|
115
115
|
|
|
116
116
|
Configure the output stream by passing one of the following values to `stdout/stderr`:
|