bun-types 1.2.3-canary.20250214T140552 → 1.2.3-canary.20250216T140609
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 +214 -58
- package/docs/api/fetch.md +1 -1
- package/docs/api/spawn.md +1 -1
- package/docs/api/sql.md +46 -1
- package/docs/bundler/fullstack.md +23 -15
- package/docs/bundler/html.md +1 -1
- package/docs/cli/publish.md +1 -1
- package/docs/guides/ecosystem/nuxt.md +1 -1
- package/docs/guides/install/add-peer.md +2 -2
- package/docs/guides/install/from-npm-install-to-bun-install.md +1 -1
- package/docs/guides/test/run-tests.md +3 -3
- package/docs/guides/test/snapshot.md +3 -3
- package/docs/guides/test/update-snapshots.md +1 -1
- package/docs/guides/util/version.md +1 -1
- package/docs/installation.md +4 -4
- package/docs/runtime/debugger.md +3 -3
- package/docs/test/dom.md +1 -1
- package/package.json +1 -1
package/bun.d.ts
CHANGED
|
@@ -475,44 +475,181 @@ declare module "bun" {
|
|
|
475
475
|
| UnixWebSocketServeOptions<WebSocketDataType>
|
|
476
476
|
| UnixTLSWebSocketServeOptions<WebSocketDataType>;
|
|
477
477
|
|
|
478
|
-
/**
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
478
|
+
/**
|
|
479
|
+
Bun.serve provides a high-performance HTTP server with built-in routing support.
|
|
480
|
+
It enables both function-based and object-based route handlers with type-safe
|
|
481
|
+
parameters and method-specific handling.
|
|
482
|
+
|
|
483
|
+
@example Basic Usage
|
|
484
|
+
```ts
|
|
485
|
+
Bun.serve({
|
|
486
|
+
port: 3000,
|
|
487
|
+
fetch(req) {
|
|
488
|
+
return new Response("Hello World");
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
@example Route-based Handlers
|
|
494
|
+
```ts
|
|
495
|
+
Bun.serve({
|
|
496
|
+
routes: {
|
|
497
|
+
// Static responses
|
|
498
|
+
"/": new Response("Home page"),
|
|
499
|
+
|
|
500
|
+
// Function handlers with type-safe parameters
|
|
501
|
+
"/users/:id": (req) => {
|
|
502
|
+
// req.params.id is typed as string
|
|
503
|
+
return new Response(`User ${req.params.id}`);
|
|
504
|
+
},
|
|
505
|
+
|
|
506
|
+
// Method-specific handlers
|
|
507
|
+
"/api/posts": {
|
|
508
|
+
GET: () => new Response("Get posts"),
|
|
509
|
+
POST: async (req) => {
|
|
510
|
+
const body = await req.json();
|
|
511
|
+
return new Response("Created post");
|
|
512
|
+
},
|
|
513
|
+
DELETE: (req) => new Response("Deleted post")
|
|
514
|
+
},
|
|
515
|
+
|
|
516
|
+
// Wildcard routes
|
|
517
|
+
"/static/*": (req) => {
|
|
518
|
+
// Handle any path under /static/
|
|
519
|
+
return new Response("Static file");
|
|
520
|
+
},
|
|
521
|
+
|
|
522
|
+
// Disable route (fall through to fetch handler)
|
|
523
|
+
"/api/legacy": false
|
|
524
|
+
},
|
|
525
|
+
|
|
526
|
+
// Fallback handler for unmatched routes
|
|
527
|
+
fetch(req) {
|
|
528
|
+
return new Response("Not Found", { status: 404 });
|
|
529
|
+
}
|
|
530
|
+
});
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
@example Path Parameters
|
|
534
|
+
```ts
|
|
535
|
+
Bun.serve({
|
|
536
|
+
routes: {
|
|
537
|
+
// Single parameter
|
|
538
|
+
"/users/:id": (req: BunRequest<"/users/:id">) => {
|
|
539
|
+
return new Response(`User ID: ${req.params.id}`);
|
|
540
|
+
},
|
|
541
|
+
|
|
542
|
+
// Multiple parameters
|
|
543
|
+
"/posts/:postId/comments/:commentId": (
|
|
544
|
+
req: BunRequest<"/posts/:postId/comments/:commentId">
|
|
545
|
+
) => {
|
|
546
|
+
return new Response(JSON.stringify(req.params));
|
|
547
|
+
// Output: {"postId": "123", "commentId": "456"}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
});
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
@example Route Precedence
|
|
554
|
+
```ts
|
|
555
|
+
// Routes are matched in the following order:
|
|
556
|
+
// 1. Exact static routes ("/about")
|
|
557
|
+
// 2. Parameter routes ("/users/:id")
|
|
558
|
+
// 3. Wildcard routes ("/api/*")
|
|
559
|
+
|
|
560
|
+
Bun.serve({
|
|
561
|
+
routes: {
|
|
562
|
+
"/api/users": () => new Response("Users list"),
|
|
563
|
+
"/api/users/:id": (req) => new Response(`User ${req.params.id}`),
|
|
564
|
+
"/api/*": () => new Response("API catchall"),
|
|
565
|
+
"/*": () => new Response("Root catchall")
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
```
|
|
569
|
+
|
|
570
|
+
@example Error Handling
|
|
571
|
+
```ts
|
|
572
|
+
Bun.serve({
|
|
573
|
+
routes: {
|
|
574
|
+
"/error": () => {
|
|
575
|
+
throw new Error("Something went wrong");
|
|
576
|
+
}
|
|
577
|
+
},
|
|
578
|
+
error(error) {
|
|
579
|
+
// Custom error handler
|
|
580
|
+
console.error(error);
|
|
581
|
+
return new Response(`Error: ${error.message}`, {
|
|
582
|
+
status: 500
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
@example Server Lifecycle
|
|
589
|
+
```ts
|
|
590
|
+
const server = Bun.serve({
|
|
591
|
+
// Server config...
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
// Update routes at runtime
|
|
595
|
+
server.reload({
|
|
596
|
+
routes: {
|
|
597
|
+
"/": () => new Response("Updated route")
|
|
598
|
+
}
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
// Stop the server
|
|
602
|
+
server.stop();
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
@example Development Mode
|
|
606
|
+
```ts
|
|
607
|
+
Bun.serve({
|
|
608
|
+
development: true, // Enable hot reloading
|
|
609
|
+
routes: {
|
|
610
|
+
// Routes will auto-reload on changes
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
@example Type-Safe Request Handling
|
|
616
|
+
```ts
|
|
617
|
+
type Post = {
|
|
618
|
+
id: string;
|
|
619
|
+
title: string;
|
|
620
|
+
};
|
|
621
|
+
|
|
622
|
+
Bun.serve({
|
|
623
|
+
routes: {
|
|
624
|
+
"/api/posts/:id": async (
|
|
625
|
+
req: BunRequest<"/api/posts/:id">
|
|
626
|
+
) => {
|
|
627
|
+
if (req.method === "POST") {
|
|
628
|
+
const body: Post = await req.json();
|
|
629
|
+
return Response.json(body);
|
|
630
|
+
}
|
|
631
|
+
return new Response("Method not allowed", {
|
|
632
|
+
status: 405
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
```
|
|
638
|
+
@param options - Server configuration options
|
|
639
|
+
@param options.routes - Route definitions mapping paths to handlers
|
|
640
|
+
*/
|
|
641
|
+
function serve<
|
|
642
|
+
T,
|
|
643
|
+
R extends { [K in keyof R]: RouterTypes.RouteValue<K & string> },
|
|
644
|
+
>(
|
|
645
|
+
options: Serve<T> & {
|
|
646
|
+
routes?: R;
|
|
647
|
+
/**
|
|
648
|
+
* @deprecated Use {@link routes} instead in new code
|
|
649
|
+
*/
|
|
650
|
+
static?: R;
|
|
651
|
+
},
|
|
652
|
+
): Server;
|
|
516
653
|
|
|
517
654
|
/**
|
|
518
655
|
* Synchronously resolve a `moduleId` as though it were imported from `parent`
|
|
@@ -3805,6 +3942,45 @@ declare module "bun" {
|
|
|
3805
3942
|
};
|
|
3806
3943
|
}
|
|
3807
3944
|
|
|
3945
|
+
namespace RouterTypes {
|
|
3946
|
+
type ExtractRouteParams<T> =
|
|
3947
|
+
T extends `${string}:${infer Param}/${infer Rest}`
|
|
3948
|
+
? { [K in Param]: string } & ExtractRouteParams<Rest>
|
|
3949
|
+
: T extends `${string}:${infer Param}`
|
|
3950
|
+
? { [K in Param]: string }
|
|
3951
|
+
: T extends `${string}*`
|
|
3952
|
+
? {}
|
|
3953
|
+
: {};
|
|
3954
|
+
|
|
3955
|
+
type RouteHandler<T extends string> = (
|
|
3956
|
+
req: BunRequest<T>,
|
|
3957
|
+
server: Server,
|
|
3958
|
+
) => Response | Promise<Response>;
|
|
3959
|
+
|
|
3960
|
+
type HTTPMethod =
|
|
3961
|
+
| "GET"
|
|
3962
|
+
| "POST"
|
|
3963
|
+
| "PUT"
|
|
3964
|
+
| "DELETE"
|
|
3965
|
+
| "PATCH"
|
|
3966
|
+
| "HEAD"
|
|
3967
|
+
| "OPTIONS";
|
|
3968
|
+
|
|
3969
|
+
type RouteHandlerObject<T extends string> = {
|
|
3970
|
+
[K in HTTPMethod]?: RouteHandler<T>;
|
|
3971
|
+
};
|
|
3972
|
+
|
|
3973
|
+
type RouteValue<T extends string> =
|
|
3974
|
+
| Response
|
|
3975
|
+
| false
|
|
3976
|
+
| RouteHandler<T>
|
|
3977
|
+
| RouteHandlerObject<T>;
|
|
3978
|
+
}
|
|
3979
|
+
|
|
3980
|
+
interface BunRequest<T extends string = string> extends Request {
|
|
3981
|
+
params: RouterTypes.ExtractRouteParams<T>;
|
|
3982
|
+
}
|
|
3983
|
+
|
|
3808
3984
|
interface GenericServeOptions {
|
|
3809
3985
|
/**
|
|
3810
3986
|
* What URI should be used to make {@link Request.url} absolute?
|
|
@@ -3869,26 +4045,6 @@ declare module "bun" {
|
|
|
3869
4045
|
* This string will currently do nothing. But in the future it could be useful for logs or metrics.
|
|
3870
4046
|
*/
|
|
3871
4047
|
id?: string | null;
|
|
3872
|
-
|
|
3873
|
-
/**
|
|
3874
|
-
* Server static Response objects by route.
|
|
3875
|
-
*
|
|
3876
|
-
* @example
|
|
3877
|
-
* ```ts
|
|
3878
|
-
* Bun.serve({
|
|
3879
|
-
* static: {
|
|
3880
|
-
* "/": new Response("Hello World"),
|
|
3881
|
-
* "/about": new Response("About"),
|
|
3882
|
-
* },
|
|
3883
|
-
* fetch(req) {
|
|
3884
|
-
* return new Response("Fallback response");
|
|
3885
|
-
* },
|
|
3886
|
-
* });
|
|
3887
|
-
* ```
|
|
3888
|
-
*
|
|
3889
|
-
* @experimental
|
|
3890
|
-
*/
|
|
3891
|
-
static?: Record<`/${string}`, Response>;
|
|
3892
4048
|
}
|
|
3893
4049
|
|
|
3894
4050
|
interface ServeOptions extends GenericServeOptions {
|
package/docs/api/fetch.md
CHANGED
|
@@ -337,7 +337,7 @@ This will print the request and response headers to your terminal:
|
|
|
337
337
|
```sh
|
|
338
338
|
[fetch] > HTTP/1.1 GET http://example.com/
|
|
339
339
|
[fetch] > Connection: keep-alive
|
|
340
|
-
[fetch] > User-Agent: Bun/1.2.3-canary.
|
|
340
|
+
[fetch] > User-Agent: Bun/1.2.3-canary.20250216T140609
|
|
341
341
|
[fetch] > Accept: */*
|
|
342
342
|
[fetch] > Host: example.com
|
|
343
343
|
[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); // => "1.2.3-canary.
|
|
113
|
+
console.log(text); // => "1.2.3-canary.20250216T140609"
|
|
114
114
|
```
|
|
115
115
|
|
|
116
116
|
Configure the output stream by passing one of the following values to `stdout/stderr`:
|
package/docs/api/sql.md
CHANGED
|
@@ -165,6 +165,24 @@ await sql`
|
|
|
165
165
|
`;
|
|
166
166
|
```
|
|
167
167
|
|
|
168
|
+
## `sql``.simple()`
|
|
169
|
+
|
|
170
|
+
The PostgreSQL wire protocol supports two types of queries: "simple" and "extended". Simple queries can contain multiple statements but don't support parameters, while extended queries (the default) support parameters but only allow one statement.
|
|
171
|
+
|
|
172
|
+
To run multiple statements in a single query, use `sql``.simple()`:
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
// Multiple statements in one query
|
|
176
|
+
await sql`
|
|
177
|
+
SELECT 1;
|
|
178
|
+
SELECT 2;
|
|
179
|
+
`.simple();
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
Simple queries are often useful for database migrations and setup scripts.
|
|
183
|
+
|
|
184
|
+
Note that simple queries cannot use parameters (`${value}`). If you need parameters, you must split your query into separate statements.
|
|
185
|
+
|
|
168
186
|
### Unsafe Queries
|
|
169
187
|
|
|
170
188
|
You can use the `sql.unsafe` function to execute raw SQL strings. Use this with caution, as it will not escape user input.
|
|
@@ -431,6 +449,33 @@ try {
|
|
|
431
449
|
} // Automatically released
|
|
432
450
|
```
|
|
433
451
|
|
|
452
|
+
## Prepared Statements
|
|
453
|
+
|
|
454
|
+
By default, Bun's SQL client automatically creates prepared statements for queries where it can be inferred that the query is static. This provides better performance and security. However, you can disable prepared statements by setting `prepare: false` in the connection options:
|
|
455
|
+
|
|
456
|
+
```ts
|
|
457
|
+
const sql = new SQL({
|
|
458
|
+
// ... other options ...
|
|
459
|
+
prepare: false, // Disable prepared statements
|
|
460
|
+
});
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
When prepared statements are disabled:
|
|
464
|
+
|
|
465
|
+
- Queries are executed using simple query protocol
|
|
466
|
+
- Each query is sent to the server as a raw SQL string
|
|
467
|
+
- Multiple statements can be executed in a single query (using `sql``.simple()`)
|
|
468
|
+
- Parameter binding is still safe against SQL injection, but simple queries cannot include parameters
|
|
469
|
+
- Each query is parsed and planned from scratch by the server
|
|
470
|
+
|
|
471
|
+
You might want to disable prepared statements when:
|
|
472
|
+
|
|
473
|
+
- Using PGBouncer in transaction mode (though since PGBouncer 1.21.0, protocol-level named prepared statements are supported when configured properly)
|
|
474
|
+
- Debugging query execution plans
|
|
475
|
+
- Working with dynamic SQL where query plans need to be regenerated frequently
|
|
476
|
+
|
|
477
|
+
Note that disabling prepared statements may impact performance for queries that are executed frequently with different parameters, as the server needs to parse and plan each query from scratch.
|
|
478
|
+
|
|
434
479
|
## Error Handling
|
|
435
480
|
|
|
436
481
|
The client provides typed errors for different failure scenarios:
|
|
@@ -501,7 +546,7 @@ The client provides typed errors for different failure scenarios:
|
|
|
501
546
|
|
|
502
547
|
## Numbers and BigInt
|
|
503
548
|
|
|
504
|
-
Bun's SQL client includes special handling for large numbers that exceed the range of a 53-bit integer. Here
|
|
549
|
+
Bun's SQL client includes special handling for large numbers that exceed the range of a 53-bit integer. Here's how it works:
|
|
505
550
|
|
|
506
551
|
```ts
|
|
507
552
|
import { sql } from "bun";
|
|
@@ -1,33 +1,39 @@
|
|
|
1
|
-
Using `Bun.serve()`'s `
|
|
1
|
+
Using `Bun.serve()`'s `routes` option, you can run your frontend and backend in the same app with no extra steps.
|
|
2
2
|
|
|
3
|
-
To get started, import HTML files and pass them to the `
|
|
3
|
+
To get started, import HTML files and pass them to the `routes` option in `Bun.serve()`.
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
import dashboard from "./dashboard.html";
|
|
7
7
|
import homepage from "./index.html";
|
|
8
8
|
|
|
9
9
|
const server = Bun.serve({
|
|
10
|
-
// Add HTML imports to `static`
|
|
11
|
-
|
|
10
|
+
// Add HTML imports to `routes` (before Bun v1.2.3, this was called `static`)
|
|
11
|
+
routes: {
|
|
12
12
|
// Bundle & route index.html to "/"
|
|
13
13
|
"/": homepage,
|
|
14
14
|
// Bundle & route dashboard.html to "/dashboard"
|
|
15
15
|
"/dashboard": dashboard,
|
|
16
|
+
|
|
17
|
+
// API endpoints:
|
|
18
|
+
"/api/users": async req => {
|
|
19
|
+
const users = await Bun.sql`SELECT * FROM users`;
|
|
20
|
+
return Response.json(users);
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
"/api/users/:id": async req => {
|
|
24
|
+
const { id } = req.params;
|
|
25
|
+
const [user] = await Bun.sql`SELECT * FROM users WHERE id = ${id}`;
|
|
26
|
+
return Response.json(user);
|
|
27
|
+
},
|
|
16
28
|
},
|
|
17
29
|
|
|
18
30
|
// Enable development mode for:
|
|
19
31
|
// - Detailed error messages
|
|
20
|
-
// -
|
|
32
|
+
// - Hot reloading (Bun v1.2.3+ required)
|
|
21
33
|
development: true,
|
|
22
34
|
|
|
23
35
|
// Handle API requests
|
|
24
36
|
async fetch(req) {
|
|
25
|
-
// ...your API code
|
|
26
|
-
if (req.url.endsWith("/api/users")) {
|
|
27
|
-
const users = await Bun.sql`SELECT * FROM users`;
|
|
28
|
-
return Response.json(users);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
37
|
// Return 404 for unmatched routes
|
|
32
38
|
return new Response("Not Found", { status: 404 });
|
|
33
39
|
},
|
|
@@ -55,7 +61,7 @@ These HTML files are used as routes in Bun's dev server you can pass to `Bun.ser
|
|
|
55
61
|
|
|
56
62
|
```ts
|
|
57
63
|
Bun.serve({
|
|
58
|
-
|
|
64
|
+
routes: {
|
|
59
65
|
"/": homepage,
|
|
60
66
|
"/dashboard": dashboard,
|
|
61
67
|
}
|
|
@@ -113,7 +119,7 @@ import dashboard from "../public/dashboard.html";
|
|
|
113
119
|
import { serve } from "bun";
|
|
114
120
|
|
|
115
121
|
serve({
|
|
116
|
-
|
|
122
|
+
routes: {
|
|
117
123
|
"/": dashboard,
|
|
118
124
|
},
|
|
119
125
|
|
|
@@ -171,7 +177,7 @@ import homepage from "./index.html";
|
|
|
171
177
|
import dashboard from "./dashboard.html";
|
|
172
178
|
|
|
173
179
|
Bun.serve({
|
|
174
|
-
|
|
180
|
+
routes: {
|
|
175
181
|
"/": homepage,
|
|
176
182
|
"/dashboard": dashboard,
|
|
177
183
|
}
|
|
@@ -249,6 +255,8 @@ plugins = ["./my-plugin-implementation.ts"]
|
|
|
249
255
|
|
|
250
256
|
Bun will lazily resolve and load each plugin and use them to bundle your routes.
|
|
251
257
|
|
|
258
|
+
Note: this is currently in `bunfig.toml` to make it possible to know statically which plugins are in use when we eventually integrate this with the `bun build` CLI. These plugins work in `Bun.build()`'s JS API, but are not yet supported in the CLI.
|
|
259
|
+
|
|
252
260
|
## How this works
|
|
253
261
|
|
|
254
262
|
Bun uses [`HTMLRewriter`](/docs/api/html-rewriter) to scan for `<script>` and `<link>` tags in HTML files, uses them as entrypoints for [Bun's bundler](/docs/bundler), generates an optimized bundle for the JavaScript/TypeScript/TSX/JSX and CSS files, and serves the result.
|
|
@@ -293,5 +301,5 @@ This works similarly to how [`Bun.build` processes HTML files](/docs/bundler/htm
|
|
|
293
301
|
|
|
294
302
|
## This is a work in progress
|
|
295
303
|
|
|
296
|
-
- Client-side hot reloading isn't wired up yet. It will be in the future.
|
|
304
|
+
- ~Client-side hot reloading isn't wired up yet. It will be in the future.~ New in Bun v1.2.3
|
|
297
305
|
- This doesn't support `bun build` yet. It also will in the future.
|
package/docs/bundler/html.md
CHANGED
|
@@ -301,6 +301,6 @@ This is a small wrapper around Bun's support for HTML imports in JavaScript.
|
|
|
301
301
|
|
|
302
302
|
### Adding a backend to your frontend
|
|
303
303
|
|
|
304
|
-
To add a backend to your frontend, you can use the `"
|
|
304
|
+
To add a backend to your frontend, you can use the `"routes"` option in `Bun.serve`.
|
|
305
305
|
|
|
306
306
|
Learn more in [the full-stack docs](/docs/bundler/fullstack).
|
package/docs/cli/publish.md
CHANGED
|
@@ -9,7 +9,7 @@ $ bunx nuxi init my-nuxt-app
|
|
|
9
9
|
✔ Which package manager would you like to use?
|
|
10
10
|
bun
|
|
11
11
|
◐ Installing dependencies...
|
|
12
|
-
bun install v1.2.3-canary.
|
|
12
|
+
bun install v1.2.3-canary.20250216T140609 (16b4bf34)
|
|
13
13
|
+ @nuxt/devtools@0.8.2
|
|
14
14
|
+ nuxt@3.7.0
|
|
15
15
|
785 packages installed [2.67s]
|
|
@@ -16,7 +16,7 @@ This will add the package to `peerDependencies` in `package.json`.
|
|
|
16
16
|
```json-diff
|
|
17
17
|
{
|
|
18
18
|
"peerDependencies": {
|
|
19
|
-
+ "@types/bun": "^1.2.3-canary.
|
|
19
|
+
+ "@types/bun": "^1.2.3-canary.20250216T140609"
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
```
|
|
@@ -28,7 +28,7 @@ Running `bun install` will install peer dependencies by default, unless marked o
|
|
|
28
28
|
```json-diff
|
|
29
29
|
{
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@types/bun": "^1.2.3-canary.
|
|
31
|
+
"@types/bun": "^1.2.3-canary.20250216T140609"
|
|
32
32
|
},
|
|
33
33
|
"peerDependenciesMeta": {
|
|
34
34
|
+ "@types/bun": {
|
|
@@ -97,7 +97,7 @@ $ bun update
|
|
|
97
97
|
$ bun update @types/bun --latest
|
|
98
98
|
|
|
99
99
|
# Update a dependency to a specific version
|
|
100
|
-
$ bun update @types/bun@1.2.3-canary.
|
|
100
|
+
$ bun update @types/bun@1.2.3-canary.20250216T140609
|
|
101
101
|
|
|
102
102
|
# Update all dependencies to the latest versions
|
|
103
103
|
$ bun update --latest
|
|
@@ -21,7 +21,7 @@ Here's what the output of a typical test run looks like. In this case, there are
|
|
|
21
21
|
|
|
22
22
|
```sh
|
|
23
23
|
$ bun test
|
|
24
|
-
bun test v1.2.3-canary.
|
|
24
|
+
bun test v1.2.3-canary.20250216T140609 (9c68abdb)
|
|
25
25
|
|
|
26
26
|
test.test.js:
|
|
27
27
|
✓ add [0.87ms]
|
|
@@ -47,7 +47,7 @@ To only run certain test files, pass a positional argument to `bun test`. The ru
|
|
|
47
47
|
|
|
48
48
|
```sh
|
|
49
49
|
$ bun test test3
|
|
50
|
-
bun test v1.2.3-canary.
|
|
50
|
+
bun test v1.2.3-canary.20250216T140609 (9c68abdb)
|
|
51
51
|
|
|
52
52
|
test3.test.js:
|
|
53
53
|
✓ add [1.40ms]
|
|
@@ -85,7 +85,7 @@ Adding `-t add` will only run tests with "add" in the name. This works with test
|
|
|
85
85
|
|
|
86
86
|
```sh
|
|
87
87
|
$ bun test -t add
|
|
88
|
-
bun test v1.2.3-canary.
|
|
88
|
+
bun test v1.2.3-canary.20250216T140609 (9c68abdb)
|
|
89
89
|
|
|
90
90
|
test.test.js:
|
|
91
91
|
✓ add [1.79ms]
|
|
@@ -18,7 +18,7 @@ The first time this test is executed, Bun will evaluate the value passed into `e
|
|
|
18
18
|
|
|
19
19
|
```sh
|
|
20
20
|
$ bun test test/snap
|
|
21
|
-
bun test v1.2.3-canary.
|
|
21
|
+
bun test v1.2.3-canary.20250216T140609 (9c68abdb)
|
|
22
22
|
|
|
23
23
|
test/snap.test.ts:
|
|
24
24
|
✓ snapshot [1.48ms]
|
|
@@ -61,7 +61,7 @@ Later, when this test file is executed again, Bun will read the snapshot file an
|
|
|
61
61
|
|
|
62
62
|
```sh
|
|
63
63
|
$ bun test
|
|
64
|
-
bun test v1.2.3-canary.
|
|
64
|
+
bun test v1.2.3-canary.20250216T140609 (9c68abdb)
|
|
65
65
|
|
|
66
66
|
test/snap.test.ts:
|
|
67
67
|
✓ snapshot [1.05ms]
|
|
@@ -78,7 +78,7 @@ To update snapshots, use the `--update-snapshots` flag.
|
|
|
78
78
|
|
|
79
79
|
```sh
|
|
80
80
|
$ bun test --update-snapshots
|
|
81
|
-
bun test v1.2.3-canary.
|
|
81
|
+
bun test v1.2.3-canary.20250216T140609 (9c68abdb)
|
|
82
82
|
|
|
83
83
|
test/snap.test.ts:
|
|
84
84
|
✓ snapshot [0.86ms]
|
package/docs/installation.md
CHANGED
|
@@ -14,7 +14,7 @@ Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1. Us
|
|
|
14
14
|
```bash#macOS/Linux_(curl)
|
|
15
15
|
$ curl -fsSL https://bun.sh/install | bash # for macOS, Linux, and WSL
|
|
16
16
|
# to install a specific version
|
|
17
|
-
$ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.3-canary.
|
|
17
|
+
$ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.3-canary.20250216T140609"
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
```bash#npm
|
|
@@ -188,10 +188,10 @@ Since Bun is a single binary, you can install older versions of Bun by re-runnin
|
|
|
188
188
|
|
|
189
189
|
### Installing a specific version of Bun on Linux/Mac
|
|
190
190
|
|
|
191
|
-
To install a specific version of Bun, you can pass the git tag of the version you want to install to the install script, such as `bun-v1.2.0` or `bun-v1.2.3-canary.
|
|
191
|
+
To install a specific version of Bun, you can pass the git tag of the version you want to install to the install script, such as `bun-v1.2.0` or `bun-v1.2.3-canary.20250216T140609`.
|
|
192
192
|
|
|
193
193
|
```sh
|
|
194
|
-
$ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.3-canary.
|
|
194
|
+
$ curl -fsSL https://bun.sh/install | bash -s "bun-v1.2.3-canary.20250216T140609"
|
|
195
195
|
```
|
|
196
196
|
|
|
197
197
|
### Installing a specific version of Bun on Windows
|
|
@@ -200,7 +200,7 @@ On Windows, you can install a specific version of Bun by passing the version num
|
|
|
200
200
|
|
|
201
201
|
```sh
|
|
202
202
|
# PowerShell:
|
|
203
|
-
$ iex "& {$(irm https://bun.sh/install.ps1)} -Version 1.2.3-canary.
|
|
203
|
+
$ iex "& {$(irm https://bun.sh/install.ps1)} -Version 1.2.3-canary.20250216T140609"
|
|
204
204
|
```
|
|
205
205
|
|
|
206
206
|
## Downloading Bun binaries directly
|
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/1.2.3-canary.
|
|
127
|
+
[fetch] $ curl --http1.1 "https://example.com/" -X POST -H "content-type: application/json" -H "Connection: keep-alive" -H "User-Agent: Bun/1.2.3-canary.20250216T140609" -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/1.2.3-canary.
|
|
131
|
+
[fetch] > User-Agent: Bun/1.2.3-canary.20250216T140609
|
|
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/1.2.3-canary.
|
|
173
|
+
[fetch] > User-Agent: Bun/1.2.3-canary.20250216T140609
|
|
174
174
|
[fetch] > Accept: */*
|
|
175
175
|
[fetch] > Host: example.com
|
|
176
176
|
[fetch] > Accept-Encoding: gzip, deflate, br
|
package/docs/test/dom.md
CHANGED
package/package.json
CHANGED