bun-types 1.1.44 → 1.1.45-canary.20250119T140626
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 +299 -1
- package/docs/api/fetch.md +1 -1
- package/docs/api/spawn.md +1 -1
- package/docs/api/transpiler.md +4 -2
- package/docs/bundler/index.md +2 -1
- package/docs/bundler/loaders.md +0 -13
- package/docs/cli/publish.md +1 -1
- package/docs/cli/run.md +13 -2
- package/docs/guides/ecosystem/ssr-react.md +3 -3
- package/docs/runtime/debugger.md +3 -3
- package/docs/runtime/nodejs-apis.md +5 -5
- package/docs/test/dom.md +1 -1
- package/package.json +1 -1
package/bun.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ declare module "bun" {
|
|
|
22
22
|
PeerCertificate,
|
|
23
23
|
} from "tls";
|
|
24
24
|
import type { Stats } from "node:fs";
|
|
25
|
+
import type { X509Certificate } from "node:crypto";
|
|
25
26
|
interface Env {
|
|
26
27
|
NODE_ENV?: string;
|
|
27
28
|
/**
|
|
@@ -2036,6 +2037,300 @@ declare module "bun" {
|
|
|
2036
2037
|
*/
|
|
2037
2038
|
stat(path: string, options?: S3Options): Promise<S3Stats>;
|
|
2038
2039
|
};
|
|
2040
|
+
/**
|
|
2041
|
+
* Configuration options for SQL client connection and behavior
|
|
2042
|
+
* @example
|
|
2043
|
+
* const config: SQLOptions = {
|
|
2044
|
+
* host: 'localhost',
|
|
2045
|
+
* port: 5432,
|
|
2046
|
+
* user: 'dbuser',
|
|
2047
|
+
* password: 'secretpass',
|
|
2048
|
+
* database: 'myapp',
|
|
2049
|
+
* idleTimeout: 30000,
|
|
2050
|
+
* max: 20,
|
|
2051
|
+
* onconnect: (client) => {
|
|
2052
|
+
* console.log('Connected to database');
|
|
2053
|
+
* }
|
|
2054
|
+
* };
|
|
2055
|
+
*/
|
|
2056
|
+
type SQLOptions = {
|
|
2057
|
+
/** Connection URL (can be string or URL object) */
|
|
2058
|
+
url: URL | string;
|
|
2059
|
+
/** Database server hostname */
|
|
2060
|
+
host: string;
|
|
2061
|
+
/** Database server port number */
|
|
2062
|
+
port: number | string;
|
|
2063
|
+
/** Database user for authentication */
|
|
2064
|
+
user: string;
|
|
2065
|
+
/** Database password for authentication */
|
|
2066
|
+
password: string;
|
|
2067
|
+
/** Name of the database to connect to */
|
|
2068
|
+
database: string;
|
|
2069
|
+
/** Database adapter/driver to use */
|
|
2070
|
+
adapter: string;
|
|
2071
|
+
/** Maximum time in milliseconds to wait for connection to become available */
|
|
2072
|
+
idleTimeout: number;
|
|
2073
|
+
/** Maximum time in milliseconds to wait when establishing a connection */
|
|
2074
|
+
connectionTimeout: number;
|
|
2075
|
+
/** Maximum lifetime in milliseconds of a connection */
|
|
2076
|
+
maxLifetime: number;
|
|
2077
|
+
/** Whether to use TLS/SSL for the connection */
|
|
2078
|
+
tls: boolean;
|
|
2079
|
+
/** Callback function executed when a connection is established */
|
|
2080
|
+
onconnect: (client: SQL) => void;
|
|
2081
|
+
/** Callback function executed when a connection is closed */
|
|
2082
|
+
onclose: (client: SQL) => void;
|
|
2083
|
+
/** Maximum number of connections in the pool */
|
|
2084
|
+
max: number;
|
|
2085
|
+
};
|
|
2086
|
+
|
|
2087
|
+
/**
|
|
2088
|
+
* Represents a SQL query that can be executed, with additional control methods
|
|
2089
|
+
* Extends Promise to allow for async/await usage
|
|
2090
|
+
*/
|
|
2091
|
+
interface SQLQuery extends Promise<any> {
|
|
2092
|
+
/** Indicates if the query is currently executing */
|
|
2093
|
+
active: boolean;
|
|
2094
|
+
/** Indicates if the query has been cancelled */
|
|
2095
|
+
cancelled: boolean;
|
|
2096
|
+
/** Cancels the executing query */
|
|
2097
|
+
cancel(): SQLQuery;
|
|
2098
|
+
/** Executes the query */
|
|
2099
|
+
execute(): SQLQuery;
|
|
2100
|
+
/** Returns the raw query result */
|
|
2101
|
+
raw(): SQLQuery;
|
|
2102
|
+
/** Returns only the values from the query result */
|
|
2103
|
+
values(): SQLQuery;
|
|
2104
|
+
}
|
|
2105
|
+
|
|
2106
|
+
/**
|
|
2107
|
+
* Callback function type for transaction contexts
|
|
2108
|
+
* @param sql Function to execute SQL queries within the transaction
|
|
2109
|
+
*/
|
|
2110
|
+
type SQLContextCallback = (
|
|
2111
|
+
sql: (strings: string, ...values: any[]) => SQLQuery | Array<SQLQuery>,
|
|
2112
|
+
) => Promise<any>;
|
|
2113
|
+
|
|
2114
|
+
/**
|
|
2115
|
+
* Main SQL client interface providing connection and transaction management
|
|
2116
|
+
*/
|
|
2117
|
+
interface SQL {
|
|
2118
|
+
/** Creates a new SQL client instance
|
|
2119
|
+
* @example
|
|
2120
|
+
* const sql = new SQL("postgres://localhost:5432/mydb");
|
|
2121
|
+
* const sql = new SQL(new URL("postgres://localhost:5432/mydb"));
|
|
2122
|
+
*/
|
|
2123
|
+
new (connectionString: string | URL): SQL;
|
|
2124
|
+
/** Creates a new SQL client instance with options
|
|
2125
|
+
* @example
|
|
2126
|
+
* const sql = new SQL("postgres://localhost:5432/mydb", { idleTimeout: 1000 });
|
|
2127
|
+
*/
|
|
2128
|
+
new (connectionString: string | URL, options: SQLOptions): SQL;
|
|
2129
|
+
/** Creates a new SQL client instance with options
|
|
2130
|
+
* @example
|
|
2131
|
+
* const sql = new SQL({ url: "postgres://localhost:5432/mydb", idleTimeout: 1000 });
|
|
2132
|
+
*/
|
|
2133
|
+
new (options?: SQLOptions): SQL;
|
|
2134
|
+
/** Executes a SQL query using template literals
|
|
2135
|
+
* @example
|
|
2136
|
+
* const [user] = await sql`select * from users where id = ${1}`;
|
|
2137
|
+
*/
|
|
2138
|
+
(strings: string, ...values: any[]): SQLQuery;
|
|
2139
|
+
/** Commits a distributed transaction also know as prepared transaction in postgres or XA transaction in MySQL
|
|
2140
|
+
* @example
|
|
2141
|
+
* await sql.commitDistributed("my_distributed_transaction");
|
|
2142
|
+
*/
|
|
2143
|
+
commitDistributed(name: string): Promise<undefined>;
|
|
2144
|
+
/** Rolls back a distributed transaction also know as prepared transaction in postgres or XA transaction in MySQL
|
|
2145
|
+
* @example
|
|
2146
|
+
* await sql.rollbackDistributed("my_distributed_transaction");
|
|
2147
|
+
*/
|
|
2148
|
+
rollbackDistributed(name: string): Promise<undefined>;
|
|
2149
|
+
/** Waits for the database connection to be established
|
|
2150
|
+
* @example
|
|
2151
|
+
* await sql.connect();
|
|
2152
|
+
*/
|
|
2153
|
+
connect(): Promise<SQL>;
|
|
2154
|
+
/** Closes the database connection with optional timeout in seconds
|
|
2155
|
+
* @example
|
|
2156
|
+
* await sql.close({ timeout: 1 });
|
|
2157
|
+
*/
|
|
2158
|
+
close(options?: { timeout?: number }): Promise<undefined>;
|
|
2159
|
+
/** Closes the database connection with optional timeout in seconds
|
|
2160
|
+
* @alias close
|
|
2161
|
+
* @example
|
|
2162
|
+
* await sql.end({ timeout: 1 });
|
|
2163
|
+
*/
|
|
2164
|
+
end(options?: { timeout?: number }): Promise<undefined>;
|
|
2165
|
+
/** Flushes any pending operations */
|
|
2166
|
+
flush(): void;
|
|
2167
|
+
/** The reserve method pulls out a connection from the pool, and returns a client that wraps the single connection.
|
|
2168
|
+
* This can be used for running queries on an isolated connection.
|
|
2169
|
+
* Calling reserve in a reserved Sql will return a new reserved connection, not the same connection (behavior matches postgres package).
|
|
2170
|
+
* @example
|
|
2171
|
+
* const reserved = await sql.reserve();
|
|
2172
|
+
* await reserved`select * from users`;
|
|
2173
|
+
* await reserved.release();
|
|
2174
|
+
* // with in a production scenario would be something more like
|
|
2175
|
+
* const reserved = await sql.reserve();
|
|
2176
|
+
* try {
|
|
2177
|
+
* // ... queries
|
|
2178
|
+
* } finally {
|
|
2179
|
+
* await reserved.release();
|
|
2180
|
+
* }
|
|
2181
|
+
* //To make it simpler bun supportsSymbol.dispose and Symbol.asyncDispose
|
|
2182
|
+
* {
|
|
2183
|
+
* // always release after context (safer)
|
|
2184
|
+
* using reserved = await sql.reserve()
|
|
2185
|
+
* await reserved`select * from users`
|
|
2186
|
+
* }
|
|
2187
|
+
*/
|
|
2188
|
+
reserve(): Promise<ReservedSQL>;
|
|
2189
|
+
/** Begins a new transaction
|
|
2190
|
+
* 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.
|
|
2191
|
+
* 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.
|
|
2192
|
+
* @example
|
|
2193
|
+
* const [user, account] = await sql.begin(async sql => {
|
|
2194
|
+
* const [user] = await sql`
|
|
2195
|
+
* insert into users (
|
|
2196
|
+
* name
|
|
2197
|
+
* ) values (
|
|
2198
|
+
* 'Murray'
|
|
2199
|
+
* )
|
|
2200
|
+
* returning *
|
|
2201
|
+
* `
|
|
2202
|
+
* const [account] = await sql`
|
|
2203
|
+
* insert into accounts (
|
|
2204
|
+
* user_id
|
|
2205
|
+
* ) values (
|
|
2206
|
+
* ${ user.user_id }
|
|
2207
|
+
* )
|
|
2208
|
+
* returning *
|
|
2209
|
+
* `
|
|
2210
|
+
* return [user, account]
|
|
2211
|
+
* })
|
|
2212
|
+
*/
|
|
2213
|
+
begin(fn: SQLContextCallback): Promise<any>;
|
|
2214
|
+
/** Begins a new transaction with options
|
|
2215
|
+
* 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.
|
|
2216
|
+
* 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.
|
|
2217
|
+
* @example
|
|
2218
|
+
* const [user, account] = await sql.begin("read write", async sql => {
|
|
2219
|
+
* const [user] = await sql`
|
|
2220
|
+
* insert into users (
|
|
2221
|
+
* name
|
|
2222
|
+
* ) values (
|
|
2223
|
+
* 'Murray'
|
|
2224
|
+
* )
|
|
2225
|
+
* returning *
|
|
2226
|
+
* `
|
|
2227
|
+
* const [account] = await sql`
|
|
2228
|
+
* insert into accounts (
|
|
2229
|
+
* user_id
|
|
2230
|
+
* ) values (
|
|
2231
|
+
* ${ user.user_id }
|
|
2232
|
+
* )
|
|
2233
|
+
* returning *
|
|
2234
|
+
* `
|
|
2235
|
+
* return [user, account]
|
|
2236
|
+
* })
|
|
2237
|
+
*/
|
|
2238
|
+
begin(options: string, fn: SQLContextCallback): Promise<any>;
|
|
2239
|
+
/** Alternative method to begin a transaction
|
|
2240
|
+
* 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.
|
|
2241
|
+
* 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.
|
|
2242
|
+
* @alias begin
|
|
2243
|
+
* @example
|
|
2244
|
+
* const [user, account] = await sql.transaction(async sql => {
|
|
2245
|
+
* const [user] = await sql`
|
|
2246
|
+
* insert into users (
|
|
2247
|
+
* name
|
|
2248
|
+
* ) values (
|
|
2249
|
+
* 'Murray'
|
|
2250
|
+
* )
|
|
2251
|
+
* returning *
|
|
2252
|
+
* `
|
|
2253
|
+
* const [account] = await sql`
|
|
2254
|
+
* insert into accounts (
|
|
2255
|
+
* user_id
|
|
2256
|
+
* ) values (
|
|
2257
|
+
* ${ user.user_id }
|
|
2258
|
+
* )
|
|
2259
|
+
* returning *
|
|
2260
|
+
* `
|
|
2261
|
+
* return [user, account]
|
|
2262
|
+
* })
|
|
2263
|
+
*/
|
|
2264
|
+
transaction(fn: SQLContextCallback): Promise<any>;
|
|
2265
|
+
/** Alternative method to begin a transaction with options
|
|
2266
|
+
* 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.
|
|
2267
|
+
* 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.
|
|
2268
|
+
* @alias begin
|
|
2269
|
+
* @example
|
|
2270
|
+
* const [user, account] = await sql.transaction("read write", async sql => {
|
|
2271
|
+
* const [user] = await sql`
|
|
2272
|
+
* insert into users (
|
|
2273
|
+
* name
|
|
2274
|
+
* ) values (
|
|
2275
|
+
* 'Murray'
|
|
2276
|
+
* )
|
|
2277
|
+
* returning *
|
|
2278
|
+
* `
|
|
2279
|
+
* const [account] = await sql`
|
|
2280
|
+
* insert into accounts (
|
|
2281
|
+
* user_id
|
|
2282
|
+
* ) values (
|
|
2283
|
+
* ${ user.user_id }
|
|
2284
|
+
* )
|
|
2285
|
+
* returning *
|
|
2286
|
+
* `
|
|
2287
|
+
* return [user, account]
|
|
2288
|
+
* })
|
|
2289
|
+
*/
|
|
2290
|
+
transaction(options: string, fn: SQLContextCallback): Promise<any>;
|
|
2291
|
+
/** Begins a distributed transaction
|
|
2292
|
+
* 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.
|
|
2293
|
+
* 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.
|
|
2294
|
+
* beginDistributed will automatic rollback if any exception are not caught, and you can commit and rollback later if everything goes well.
|
|
2295
|
+
* 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.
|
|
2296
|
+
* 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.
|
|
2297
|
+
* @example
|
|
2298
|
+
* await sql.beginDistributed("numbers", async sql => {
|
|
2299
|
+
* await sql`create table if not exists numbers (a int)`;
|
|
2300
|
+
* await sql`insert into numbers values(1)`;
|
|
2301
|
+
* });
|
|
2302
|
+
* // later you can call
|
|
2303
|
+
* await sql.commitDistributed("numbers");
|
|
2304
|
+
* // or await sql.rollbackDistributed("numbers");
|
|
2305
|
+
*/
|
|
2306
|
+
beginDistributed(name: string, fn: SQLContextCallback): Promise<any>;
|
|
2307
|
+
/** Alternative method to begin a distributed transaction
|
|
2308
|
+
* @alias beginDistributed
|
|
2309
|
+
*/
|
|
2310
|
+
distributed(name: string, fn: SQLContextCallback): Promise<any>;
|
|
2311
|
+
/** Current client options */
|
|
2312
|
+
options: SQLOptions;
|
|
2313
|
+
}
|
|
2314
|
+
|
|
2315
|
+
/**
|
|
2316
|
+
* Represents a reserved connection from the connection pool
|
|
2317
|
+
* Extends SQL with additional release functionality
|
|
2318
|
+
*/
|
|
2319
|
+
interface ReservedSQL extends SQL {
|
|
2320
|
+
/** Releases the client back to the connection pool */
|
|
2321
|
+
release(): void;
|
|
2322
|
+
}
|
|
2323
|
+
|
|
2324
|
+
/**
|
|
2325
|
+
* Represents a client within a transaction context
|
|
2326
|
+
* Extends SQL with savepoint functionality
|
|
2327
|
+
*/
|
|
2328
|
+
interface TransactionSQL extends SQL {
|
|
2329
|
+
/** Creates a savepoint within the current transaction */
|
|
2330
|
+
savepoint(name: string, fn: SQLContextCallback): Promise<undefined>;
|
|
2331
|
+
}
|
|
2332
|
+
|
|
2333
|
+
var sql: SQL;
|
|
2039
2334
|
|
|
2040
2335
|
/**
|
|
2041
2336
|
* This lets you use macros as regular imports
|
|
@@ -2356,7 +2651,8 @@ declare module "bun" {
|
|
|
2356
2651
|
| "import-rule"
|
|
2357
2652
|
| "url-token"
|
|
2358
2653
|
| "internal"
|
|
2359
|
-
| "entry-point"
|
|
2654
|
+
| "entry-point-run"
|
|
2655
|
+
| "entry-point-build";
|
|
2360
2656
|
|
|
2361
2657
|
interface Import {
|
|
2362
2658
|
path: string;
|
|
@@ -5594,6 +5890,7 @@ declare module "bun" {
|
|
|
5594
5890
|
* socket has been destroyed, `null` will be returned.
|
|
5595
5891
|
*/
|
|
5596
5892
|
getCertificate(): PeerCertificate | object | null;
|
|
5893
|
+
getX509Certificate(): X509Certificate | undefined;
|
|
5597
5894
|
|
|
5598
5895
|
/**
|
|
5599
5896
|
* Returns an object containing information on the negotiated cipher suite.
|
|
@@ -5632,6 +5929,7 @@ declare module "bun" {
|
|
|
5632
5929
|
* @return A certificate object.
|
|
5633
5930
|
*/
|
|
5634
5931
|
getPeerCertificate(): PeerCertificate;
|
|
5932
|
+
getPeerX509Certificate(): X509Certificate;
|
|
5635
5933
|
|
|
5636
5934
|
/**
|
|
5637
5935
|
* See [SSL\_get\_shared\_sigalgs](https://www.openssl.org/docs/man1.1.1/man3/SSL_get_shared_sigalgs.html) for more 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.1.45-canary.20250119T140626
|
|
199
199
|
[fetch] > Accept: */*
|
|
200
200
|
[fetch] > Host: example.com
|
|
201
201
|
[fetch] > Accept-Encoding: gzip, deflate, br
|
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.1.45-canary.20250119T140626"
|
|
114
114
|
```
|
|
115
115
|
|
|
116
116
|
Configure the output stream by passing one of the following values to `stdout/stderr`:
|
package/docs/api/transpiler.md
CHANGED
|
@@ -137,7 +137,8 @@ Each import in the `imports` array has a `path` and `kind`. Bun categories impor
|
|
|
137
137
|
- `import-rule`: `@import 'foo.css'`
|
|
138
138
|
- `url-token`: `url('./foo.png')`
|
|
139
139
|
<!-- - `internal`: `import {foo} from 'bun:internal'`
|
|
140
|
-
- `entry-point`: `import {foo} from 'bun:entry'`
|
|
140
|
+
- `entry-point-build`: `import {foo} from 'bun:entry'`
|
|
141
|
+
- `entry-point-run`: `bun ./mymodule` -->
|
|
141
142
|
|
|
142
143
|
## `.scanImports()`
|
|
143
144
|
|
|
@@ -267,7 +268,8 @@ type Import = {
|
|
|
267
268
|
// The import was injected by Bun
|
|
268
269
|
| "internal"
|
|
269
270
|
// Entry point (not common)
|
|
270
|
-
| "entry-point"
|
|
271
|
+
| "entry-point-build"
|
|
272
|
+
| "entry-point-run"
|
|
271
273
|
}
|
|
272
274
|
|
|
273
275
|
const transpiler = new Bun.Transpiler({ loader: "jsx" });
|
package/docs/bundler/index.md
CHANGED
package/docs/bundler/loaders.md
CHANGED
|
@@ -152,19 +152,6 @@ export default "Hello, world!";
|
|
|
152
152
|
|
|
153
153
|
{% /codetabs %}
|
|
154
154
|
|
|
155
|
-
### `wasm`
|
|
156
|
-
|
|
157
|
-
**WebAssembly loader**. Default for `.wasm`.
|
|
158
|
-
|
|
159
|
-
In the runtime, WebAssembly files can be directly imported. The file is read and returned as a `WebAssembly.Module`.
|
|
160
|
-
|
|
161
|
-
```ts
|
|
162
|
-
import wasm from "./module.wasm";
|
|
163
|
-
console.log(wasm); // => WebAssembly.Module
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
In the bundler, `.wasm` files are handled using the [`file`](#file) loader.
|
|
167
|
-
|
|
168
155
|
### `napi`
|
|
169
156
|
|
|
170
157
|
**Native addon loader**. Default for `.node`.
|
package/docs/cli/publish.md
CHANGED
package/docs/cli/run.md
CHANGED
|
@@ -106,13 +106,13 @@ $ bun run clean
|
|
|
106
106
|
Done.
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
-
Bun executes the script command in a subshell.
|
|
109
|
+
Bun executes the script command in a subshell. On Linux & macOS, it checks for the following shells in order, using the first one it finds: `bash`, `sh`, `zsh`. On windows, it uses [bun shell](https://bun.sh/docs/runtime/shell) to support bash-like syntax and many common commands.
|
|
110
110
|
|
|
111
111
|
{% callout %}
|
|
112
112
|
⚡️ The startup time for `npm run` on Linux is roughly 170ms; with Bun it is `6ms`.
|
|
113
113
|
{% /callout %}
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
Scripts can also be run with the shorter command `bun <script>`, however if there is a built-in bun command with the same name, the built-in command takes precedence. In this case, use the more explicit `bun run <script>` command to execute your package script.
|
|
116
116
|
|
|
117
117
|
```bash
|
|
118
118
|
$ bun run dev
|
|
@@ -194,3 +194,14 @@ $ bun --smol run index.tsx
|
|
|
194
194
|
```
|
|
195
195
|
|
|
196
196
|
This causes the garbage collector to run more frequently, which can slow down execution. However, it can be useful in environments with limited memory. Bun automatically adjusts the garbage collector's heap size based on the available memory (accounting for cgroups and other memory limits) with and without the `--smol` flag, so this is mostly useful for cases where you want to make the heap size grow more slowly.
|
|
197
|
+
|
|
198
|
+
## Resolution order
|
|
199
|
+
|
|
200
|
+
Absolute paths and paths starting with `./` or `.\\` are always executed as source files. Unless using `bun run`, running a file with an allowed extension will prefer the file over a package.json script.
|
|
201
|
+
|
|
202
|
+
When there is a package.json script and a file with the same name, `bun run` prioritizes the package.json script. The full resolution order is:
|
|
203
|
+
|
|
204
|
+
1. package.json scripts, eg `bun run build`
|
|
205
|
+
2. Source files, eg `bun run src/main.js`
|
|
206
|
+
3. Binaries from project packages, eg `bun add eslint && bun run eslint`
|
|
207
|
+
4. (`bun run` only) System commands, eg `bun run ls`
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
name: Server-side render (SSR) a React component
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
To get started, install
|
|
5
|
+
To get started, install `react` & `react-dom`:
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
8
|
# Any package manager can be used
|
|
9
|
-
$ bun add react
|
|
9
|
+
$ bun add react react-dom
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
---
|
|
@@ -48,4 +48,4 @@ Bun.serve({
|
|
|
48
48
|
|
|
49
49
|
---
|
|
50
50
|
|
|
51
|
-
React `19` and later includes an [SSR optimization](https://github.com/facebook/react/pull/25597) that takes advantage of Bun's "direct" `ReadableStream` implementation. If you run into an error like `export named 'renderToReadableStream' not found`, please make sure to install
|
|
51
|
+
React `19` and later includes an [SSR optimization](https://github.com/facebook/react/pull/25597) that takes advantage of Bun's "direct" `ReadableStream` implementation. If you run into an error like `export named 'renderToReadableStream' not found`, please make sure to install version `19` of `react` & `react-dom`, or import from `react-dom/server.browser` instead of `react-dom/server`. See [facebook/react#28941](https://github.com/facebook/react/issues/28941) for more information.
|
package/docs/runtime/debugger.md
CHANGED
|
@@ -124,11 +124,11 @@ await fetch("https://example.com", {
|
|
|
124
124
|
This prints the `fetch` request as a single-line `curl` command to let you copy-paste into your terminal to replicate the request.
|
|
125
125
|
|
|
126
126
|
```sh
|
|
127
|
-
[fetch] $ curl --http1.1 "https://example.com/" -X POST -H "content-type: application/json" -H "Connection: keep-alive" -H "User-Agent: Bun/
|
|
127
|
+
[fetch] $ curl --http1.1 "https://example.com/" -X POST -H "content-type: application/json" -H "Connection: keep-alive" -H "User-Agent: Bun/1.1.45-canary.20250119T140626" -H "Accept: */*" -H "Host: example.com" -H "Accept-Encoding: gzip, deflate, br" --compressed -H "Content-Length: 13" --data-raw "{\"foo\":\"bar\"}"
|
|
128
128
|
[fetch] > HTTP/1.1 POST https://example.com/
|
|
129
129
|
[fetch] > content-type: application/json
|
|
130
130
|
[fetch] > Connection: keep-alive
|
|
131
|
-
[fetch] > User-Agent: Bun/
|
|
131
|
+
[fetch] > User-Agent: Bun/1.1.45-canary.20250119T140626
|
|
132
132
|
[fetch] > Accept: */*
|
|
133
133
|
[fetch] > Host: example.com
|
|
134
134
|
[fetch] > Accept-Encoding: gzip, deflate, br
|
|
@@ -170,7 +170,7 @@ This prints the following to the console:
|
|
|
170
170
|
[fetch] > HTTP/1.1 POST https://example.com/
|
|
171
171
|
[fetch] > content-type: application/json
|
|
172
172
|
[fetch] > Connection: keep-alive
|
|
173
|
-
[fetch] > User-Agent: Bun/
|
|
173
|
+
[fetch] > User-Agent: Bun/1.1.45-canary.20250119T140626
|
|
174
174
|
[fetch] > Accept: */*
|
|
175
175
|
[fetch] > Host: example.com
|
|
176
176
|
[fetch] > Accept-Encoding: gzip, deflate, br
|
|
@@ -58,6 +58,10 @@ This page is updated regularly to reflect compatibility status of the latest ver
|
|
|
58
58
|
|
|
59
59
|
🟢 Fully implemented.
|
|
60
60
|
|
|
61
|
+
### [`node:stream`](https://nodejs.org/api/stream.html)
|
|
62
|
+
|
|
63
|
+
🟢 Fully implemented.
|
|
64
|
+
|
|
61
65
|
### [`node:string_decoder`](https://nodejs.org/api/string_decoder.html)
|
|
62
66
|
|
|
63
67
|
🟢 Fully implemented. 100% of Node.js's test suite passes.
|
|
@@ -92,7 +96,7 @@ This page is updated regularly to reflect compatibility status of the latest ver
|
|
|
92
96
|
|
|
93
97
|
### [`node:crypto`](https://nodejs.org/api/crypto.html)
|
|
94
98
|
|
|
95
|
-
🟡 Missing `
|
|
99
|
+
🟡 Missing `ECDH` `checkPrime` `checkPrimeSync` `generatePrime` `generatePrimeSync` `hkdf` `hkdfSync` `secureHeapUsed` `setEngine` `setFips`
|
|
96
100
|
|
|
97
101
|
Some methods are not optimized yet.
|
|
98
102
|
|
|
@@ -129,10 +133,6 @@ Some methods are not optimized yet.
|
|
|
129
133
|
|
|
130
134
|
🟡 See [`process`](#process) Global.
|
|
131
135
|
|
|
132
|
-
### [`node:stream`](https://nodejs.org/api/stream.html)
|
|
133
|
-
|
|
134
|
-
🟡 Missing `toWeb`
|
|
135
|
-
|
|
136
136
|
### [`node:sys`](https://nodejs.org/api/util.html)
|
|
137
137
|
|
|
138
138
|
🟡 See [`node:util`](#node-util).
|
package/docs/test/dom.md
CHANGED
package/package.json
CHANGED