bun-types 1.2.21 → 1.2.22-canary.20250829T140616

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 CHANGED
@@ -619,6 +619,33 @@ declare module "bun" {
619
619
  export function parse(input: string): object;
620
620
  }
621
621
 
622
+ /**
623
+ * YAML related APIs
624
+ */
625
+ namespace YAML {
626
+ /**
627
+ * Parse a YAML string into a JavaScript value
628
+ *
629
+ * @category Utilities
630
+ *
631
+ * @param input The YAML string to parse
632
+ * @returns A JavaScript value
633
+ *
634
+ * @example
635
+ * ```ts
636
+ * import { YAML } from "bun";
637
+ *
638
+ * console.log(YAML.parse("123")) // 123
639
+ * console.log(YAML.parse("123")) // null
640
+ * console.log(YAML.parse("false")) // false
641
+ * console.log(YAML.parse("abc")) // "abc"
642
+ * console.log(YAML.parse("- abc")) // [ "abc" ]
643
+ * console.log(YAML.parse("abc: def")) // { "abc": "def" }
644
+ * ```
645
+ */
646
+ export function parse(input: string): unknown;
647
+ }
648
+
622
649
  /**
623
650
  * Synchronously resolve a `moduleId` as though it were imported from `parent`
624
651
  *
@@ -1814,9 +1841,10 @@ declare module "bun" {
1814
1841
  drop?: string[];
1815
1842
 
1816
1843
  /**
1817
- * When set to `true`, the returned promise rejects with an AggregateError when a build failure happens.
1818
- * When set to `false`, the `success` property of the returned object will be `false` when a build failure happens.
1819
- * This defaults to `true`.
1844
+ * - When set to `true`, the returned promise rejects with an AggregateError when a build failure happens.
1845
+ * - When set to `false`, returns a {@link BuildOutput} with `{success: false}`
1846
+ *
1847
+ * @default true
1820
1848
  */
1821
1849
  throw?: boolean;
1822
1850
 
@@ -5485,6 +5513,7 @@ declare module "bun" {
5485
5513
  type OnLoadResult = OnLoadResultSourceCode | OnLoadResultObject | undefined | void;
5486
5514
  type OnLoadCallback = (args: OnLoadArgs) => OnLoadResult | Promise<OnLoadResult>;
5487
5515
  type OnStartCallback = () => void | Promise<void>;
5516
+ type OnEndCallback = (result: BuildOutput) => void | Promise<void>;
5488
5517
 
5489
5518
  interface OnResolveArgs {
5490
5519
  /**
@@ -5562,6 +5591,25 @@ declare module "bun" {
5562
5591
  * @returns `this` for method chaining
5563
5592
  */
5564
5593
  onStart(callback: OnStartCallback): this;
5594
+ /**
5595
+ * Register a callback which will be invoked when bundling ends. This is
5596
+ * called after all modules have been bundled and the build is complete.
5597
+ *
5598
+ * @example
5599
+ * ```ts
5600
+ * const plugin: Bun.BunPlugin = {
5601
+ * name: "my-plugin",
5602
+ * setup(builder) {
5603
+ * builder.onEnd((result) => {
5604
+ * console.log("bundle just finished!!", result);
5605
+ * });
5606
+ * },
5607
+ * };
5608
+ * ```
5609
+ *
5610
+ * @returns `this` for method chaining
5611
+ */
5612
+ onEnd(callback: OnEndCallback): this;
5565
5613
  onBeforeParse(
5566
5614
  constraints: PluginConstraints,
5567
5615
  callback: {
package/docs/api/fetch.md CHANGED
@@ -336,7 +336,7 @@ This will print the request and response headers to your terminal:
336
336
  ```sh
337
337
  [fetch] > HTTP/1.1 GET http://example.com/
338
338
  [fetch] > Connection: keep-alive
339
- [fetch] > User-Agent: Bun/1.2.21
339
+ [fetch] > User-Agent: Bun/1.2.22-canary.20250829T140616
340
340
  [fetch] > Accept: */*
341
341
  [fetch] > Host: example.com
342
342
  [fetch] > Accept-Encoding: gzip, deflate, br
package/docs/api/spawn.md CHANGED
@@ -140,7 +140,7 @@ You can read results from the subprocess via the `stdout` and `stderr` propertie
140
140
  ```ts
141
141
  const proc = Bun.spawn(["bun", "--version"]);
142
142
  const text = await proc.stdout.text();
143
- console.log(text); // => "1.2.21\n"
143
+ console.log(text); // => "1.2.22-canary.20250829T140616\n"
144
144
  ```
145
145
 
146
146
  Configure the output stream by passing one of the following values to `stdout/stderr`:
package/docs/api/sql.md CHANGED
@@ -90,8 +90,7 @@ const db2 = new SQL({
90
90
  const db3 = new SQL("myapp.db", { adapter: "sqlite" });
91
91
  ```
92
92
 
93
- <details>
94
- <summary>SQLite Connection String Formats</summary>
93
+ {% details summary="SQLite Connection String Formats" %}
95
94
 
96
95
  SQLite accepts various URL formats for connection strings:
97
96
 
@@ -122,10 +121,9 @@ new SQL("sqlite://data.db?mode=rwc"); // Read-write-create mode (default)
122
121
 
123
122
  **Note:** Simple filenames without a protocol (like `"myapp.db"`) require explicitly specifying `{ adapter: "sqlite" }` to avoid ambiguity with PostgreSQL.
124
123
 
125
- </details>
124
+ {% /details %}
126
125
 
127
- <details>
128
- <summary>SQLite-Specific Options</summary>
126
+ {% details summary="SQLite-Specific Options" %}
129
127
 
130
128
  SQLite databases support additional configuration options:
131
129
 
@@ -151,7 +149,7 @@ Query parameters in the URL are parsed to set these options:
151
149
  - `?mode=rw` → `readonly: false, create: false`
152
150
  - `?mode=rwc` → `readonly: false, create: true` (default)
153
151
 
154
- </details>
152
+ {% /details %}
155
153
 
156
154
  ### Inserting data
157
155
 
@@ -532,15 +530,14 @@ const db = new SQL({
532
530
  });
533
531
  ```
534
532
 
535
- <details>
536
- <summary>SQLite Connection Notes</summary>
533
+ {% details summary="SQLite Connection Notes" %}
537
534
 
538
535
  - **Connection Pooling**: SQLite doesn't use connection pooling as it's a file-based database. Each `SQL` instance represents a single connection.
539
536
  - **Transactions**: SQLite supports nested transactions through savepoints, similar to PostgreSQL.
540
537
  - **Concurrent Access**: SQLite handles concurrent access through file locking. Use WAL mode for better concurrency.
541
538
  - **Memory Databases**: Using `:memory:` creates a temporary database that exists only for the connection lifetime.
542
539
 
543
- </details>
540
+ {% /details %}
544
541
 
545
542
  ## Dynamic passwords
546
543
 
@@ -838,6 +835,8 @@ try {
838
835
  }
839
836
  ```
840
837
 
838
+ {% details summary="PostgreSQL-Specific Error Codes" %}
839
+
841
840
  ### PostgreSQL Connection Errors
842
841
 
843
842
  | Connection Errors | Description |
@@ -903,12 +902,13 @@ try {
903
902
  | `ERR_POSTGRES_UNSAFE_TRANSACTION` | Unsafe transaction operation detected |
904
903
  | `ERR_POSTGRES_INVALID_TRANSACTION_STATE` | Invalid transaction state |
905
904
 
905
+ {% /details %}
906
+
906
907
  ### SQLite-Specific Errors
907
908
 
908
909
  SQLite errors provide error codes and numbers that correspond to SQLite's standard error codes:
909
910
 
910
- <details>
911
- <summary>Common SQLite Error Codes</summary>
911
+ {% details summary="Common SQLite Error Codes" %}
912
912
 
913
913
  | Error Code | errno | Description |
914
914
  | ------------------- | ----- | ---------------------------------------------------- |
@@ -945,7 +945,7 @@ try {
945
945
  }
946
946
  ```
947
947
 
948
- </details>
948
+ {% /details %}
949
949
 
950
950
  ## Numbers and BigInt
951
951
 
@@ -998,13 +998,7 @@ We also haven't implemented some of the more uncommon features like:
998
998
  - Point & PostGIS types
999
999
  - All the multi-dimensional integer array types (only a couple of the types are supported)
1000
1000
 
1001
- ## Frequently Asked Questions
1002
-
1003
- > Why is this `Bun.sql` and not `Bun.postgres`?
1004
-
1005
- The plan is to add more database drivers in the future.
1006
-
1007
- > Why not just use an existing library?
1001
+ ## Why not just use an existing library?
1008
1002
 
1009
1003
  npm packages like postgres.js, pg, and node-postgres can be used in Bun too. They're great options.
1010
1004
 
@@ -1259,6 +1259,33 @@ $ bun build ./index.tsx --outdir ./out --drop=console --drop=debugger --drop=any
1259
1259
 
1260
1260
  {% /codetabs %}
1261
1261
 
1262
+ ### `throw`
1263
+
1264
+ Controls error handling behavior when the build fails. When set to `true` (default), the returned promise rejects with an `AggregateError`. When set to `false`, the promise resolves with a `BuildOutput` object where `success` is `false`.
1265
+
1266
+ ```ts#JavaScript
1267
+ // Default behavior: throws on error
1268
+ try {
1269
+ await Bun.build({
1270
+ entrypoints: ['./index.tsx'],
1271
+ throw: true, // default
1272
+ });
1273
+ } catch (error) {
1274
+ // Handle AggregateError
1275
+ console.error("Build failed:", error);
1276
+ }
1277
+
1278
+ // Alternative: handle errors via success property
1279
+ const result = await Bun.build({
1280
+ entrypoints: ['./index.tsx'],
1281
+ throw: false,
1282
+ });
1283
+
1284
+ if (!result.success) {
1285
+ console.error("Build failed with errors:", result.logs);
1286
+ }
1287
+ ```
1288
+
1262
1289
  ## Outputs
1263
1290
 
1264
1291
  The `Bun.build` function returns a `Promise<BuildOutput>`, defined as:
@@ -1569,8 +1596,7 @@ interface BuildConfig {
1569
1596
  * When set to `true`, the returned promise rejects with an AggregateError when a build failure happens.
1570
1597
  * When set to `false`, the `success` property of the returned object will be `false` when a build failure happens.
1571
1598
  *
1572
- * This defaults to `false` in Bun 1.1 and will change to `true` in Bun 1.2
1573
- * as most usage of `Bun.build` forgets to check for errors.
1599
+ * This defaults to `true`.
1574
1600
  */
1575
1601
  throw?: boolean;
1576
1602
  }
@@ -9,6 +9,7 @@ Plugins can register callbacks to be run at various points in the lifecycle of a
9
9
  - [`onStart()`](#onstart): Run once the bundler has started a bundle
10
10
  - [`onResolve()`](#onresolve): Run before a module is resolved
11
11
  - [`onLoad()`](#onload): Run before a module is loaded.
12
+ - [`onEnd()`](#onend): Run after the bundle has completed
12
13
  - [`onBeforeParse()`](#onbeforeparse): Run zero-copy native addons in the parser thread before a file is parsed.
13
14
 
14
15
  ### Reference
@@ -18,6 +19,7 @@ A rough overview of the types (please refer to Bun's `bun.d.ts` for the full typ
18
19
  ```ts
19
20
  type PluginBuilder = {
20
21
  onStart(callback: () => void): void;
22
+ onEnd(callback: (result: BuildOutput) => void | Promise<void>): void;
21
23
  onResolve: (
22
24
  args: { filter: RegExp; namespace?: string },
23
25
  callback: (args: { path: string; importer: string }) => {
@@ -285,6 +287,53 @@ plugin({
285
287
 
286
288
  Note that the `.defer()` function currently has the limitation that it can only be called once per `onLoad` callback.
287
289
 
290
+ ### `onEnd`
291
+
292
+ ```ts
293
+ onEnd(callback: (result: BuildOutput) => void | Promise<void>): void;
294
+ ```
295
+
296
+ Registers a callback to be run when the bundler completes a bundle (whether successful or not).
297
+
298
+ The callback receives the `BuildOutput` object containing:
299
+
300
+ - `success`: boolean indicating if the build succeeded
301
+ - `outputs`: array of generated build artifacts
302
+ - `logs`: array of build messages (warnings, errors, etc.)
303
+
304
+ This is useful for post-processing, cleanup, notifications, or custom error handling.
305
+
306
+ ```ts
307
+ await Bun.build({
308
+ entrypoints: ["./index.ts"],
309
+ outdir: "./out",
310
+ plugins: [
311
+ {
312
+ name: "onEnd example",
313
+ setup(build) {
314
+ build.onEnd(result => {
315
+ if (result.success) {
316
+ console.log(
317
+ `✅ Build succeeded with ${result.outputs.length} outputs`,
318
+ );
319
+ } else {
320
+ console.error(`❌ Build failed with ${result.logs.length} errors`);
321
+ }
322
+ });
323
+ },
324
+ },
325
+ ],
326
+ });
327
+ ```
328
+
329
+ The `onEnd` callbacks are called:
330
+
331
+ - **Before** the build promise resolves or rejects
332
+ - **After** all bundling is complete
333
+ - **In the order** they were registered
334
+
335
+ Multiple plugins can register `onEnd` callbacks, and they will all be called sequentially. If an `onEnd` callback returns a promise, the build will wait for it to resolve before continuing.
336
+
288
337
  ## Native plugins
289
338
 
290
339
  One of the reasons why Bun's bundler is so fast is that it is written in native code and leverages multi-threading to load and parse modules in parallel.
package/docs/cli/pm.md CHANGED
@@ -213,7 +213,7 @@ To display current package version and help:
213
213
 
214
214
  ```bash
215
215
  $ bun pm version
216
- bun pm version v1.2.21 (ca7428e9)
216
+ bun pm version v1.2.22-canary.20250829T140616 (ca7428e9)
217
217
  Current package version: v1.0.0
218
218
 
219
219
  Increment:
@@ -7,7 +7,7 @@ Use `bun publish` to publish a package to the npm registry.
7
7
  $ bun publish
8
8
 
9
9
  ## Output
10
- bun publish v1.2.21 (ca7428e9)
10
+ bun publish v1.2.22-canary.20250829T140616 (ca7428e9)
11
11
 
12
12
  packed 203B package.json
13
13
  packed 224B README.md
@@ -0,0 +1,157 @@
1
+ ---
2
+ name: Deploy a Bun application on Railway
3
+ description: Deploy Bun applications to Railway with this step-by-step guide covering CLI and dashboard methods, optional PostgreSQL setup, and automatic SSL configuration.
4
+ ---
5
+
6
+ Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud. It enables instant deployments from GitHub with zero configuration, automatic SSL, and built-in database provisioning.
7
+
8
+ This guide walks through deploying a Bun application with a PostgreSQL database (optional), which is exactly what the template below provides.
9
+
10
+ You can either follow this guide step-by-step or simply deploy the pre-configured template with one click:
11
+
12
+ {% raw %}
13
+
14
+ <a href="https://railway.com/deploy/bun-react-postgres?referralCode=Bun&utm_medium=integration&utm_source=template&utm_campaign=bun" target="_blank">
15
+ <img src="https://railway.com/button.svg" alt="Deploy on Railway" />
16
+ </a>
17
+
18
+ {% /raw %}
19
+
20
+ ---
21
+
22
+ **Prerequisites**:
23
+
24
+ - A Bun application ready for deployment
25
+ - A [Railway account](https://railway.app/)
26
+ - Railway CLI (for CLI deployment method)
27
+ - A GitHub account (for Dashboard deployment method)
28
+
29
+ ---
30
+
31
+ ## Method 1: Deploy via CLI
32
+
33
+ ---
34
+
35
+ #### Step 1
36
+
37
+ Ensure sure you have the Railway CLI installed.
38
+
39
+ ```bash
40
+ bun install -g @railway/cli
41
+ ```
42
+
43
+ ---
44
+
45
+ #### Step 2
46
+
47
+ Log into your Railway account.
48
+
49
+ ```bash
50
+ railway login
51
+ ```
52
+
53
+ ---
54
+
55
+ #### Step 3
56
+
57
+ After successfully authenticating, initialize a new project.
58
+
59
+ ```bash
60
+ # Initialize project
61
+ bun-react-postgres$ railway init
62
+ ```
63
+
64
+ ---
65
+
66
+ #### Step 4
67
+
68
+ After initializing the project, add a new database and service.
69
+
70
+ > **Note:** Step 4 is only necessary if your application uses a database. If you don't need PostgreSQL, skip to Step 5.
71
+
72
+ ```bash
73
+ # Add PostgreSQL database. Make sure to add this first!
74
+ bun-react-postgres$ railway add --database postgres
75
+
76
+ # Add your application service.
77
+ bun-react-postgres$ railway add --service bun-react-db --variables DATABASE_URL=\${{Postgres.DATABASE_URL}}
78
+ ```
79
+
80
+ ---
81
+
82
+ #### Step 5
83
+
84
+ After the services have been created and connected, deploy the application to Railway. By default, services are only accessible within Railway's private network. To make your app publicly accessible, you need to generate a public domain.
85
+
86
+ ```bash
87
+ # Deploy your application
88
+ bun-nextjs-starter$ railway up
89
+
90
+ # Generate public domain
91
+ bun-nextjs-starter$ railway domain
92
+ ```
93
+
94
+ ---
95
+
96
+ ## Method 2: Deploy via Dashboard
97
+
98
+ ---
99
+
100
+ #### Step 1
101
+
102
+ Create a new project
103
+
104
+ 1. Go to [Railway Dashboard](http://railway.com/dashboard?utm_medium=integration&utm_source=docs&utm_campaign=bun)
105
+ 2. Click **"+ New"** → **"GitHub repo"**
106
+ 3. Choose your repository
107
+
108
+ ---
109
+
110
+ #### Step 2
111
+
112
+ Add a PostgreSQL database, and connect this database to the service
113
+
114
+ > **Note:** Step 2 is only necessary if your application uses a database. If you don't need PostgreSQL, skip to Step 3.
115
+
116
+ 1. Click **"+ New"** → **"Database"** → **"Add PostgreSQL"**
117
+ 2. After the database has been created, select your service (not the database)
118
+ 3. Go to **"Variables"** tab
119
+ 4. Click **"+ New Variable"** → **"Add Reference"**
120
+ 5. Select `DATABASE_URL` from postgres
121
+
122
+ ---
123
+
124
+ #### Step 3
125
+
126
+ Generate a public domain
127
+
128
+ 1. Select your service
129
+ 2. Go to **"Settings"** tab
130
+ 3. Under **"Networking"**, click **"Generate Domain"**
131
+
132
+ ---
133
+
134
+ Your app is now live! Railway auto-deploys on every GitHub push.
135
+
136
+ ---
137
+
138
+ ## Configuration (Optional)
139
+
140
+ ---
141
+
142
+ By default, Railway uses [Nixpacks](https://docs.railway.com/guides/build-configuration#nixpacks-options) to automatically detect and build your Bun application with zero configuration.
143
+
144
+ However, using the [Railpack](https://docs.railway.com/guides/build-configuration#railpack) application builder provides better Bun support, and will always support the latest version of Bun. The pre-configured templates use Railpack by default.
145
+
146
+ To enable Railpack in a custom project, add the following to your `railway.json`:
147
+
148
+ ```json
149
+ {
150
+ "$schema": "https://railway.com/railway.schema.json",
151
+ "build": {
152
+ "builder": "RAILPACK"
153
+ }
154
+ }
155
+ ```
156
+
157
+ For more build configuration settings, check out the [Railway documentation](https://docs.railway.com/guides/build-configuration).
@@ -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.21 (16b4bf34)
12
+ bun install v1.2.22-canary.20250829T140616 (16b4bf34)
13
13
  + @nuxt/devtools@0.8.2
14
14
  + nuxt@3.7.0
15
15
  785 packages installed [2.67s]
@@ -15,7 +15,7 @@ This will add the package to `peerDependencies` in `package.json`.
15
15
  ```json-diff
16
16
  {
17
17
  "peerDependencies": {
18
- + "@types/bun": "^1.2.21"
18
+ + "@types/bun": "^1.2.22-canary.20250829T140616"
19
19
  }
20
20
  }
21
21
  ```
@@ -27,7 +27,7 @@ Running `bun install` will install peer dependencies by default, unless marked o
27
27
  ```json-diff
28
28
  {
29
29
  "peerDependencies": {
30
- "@types/bun": "^1.2.21"
30
+ "@types/bun": "^1.2.22-canary.20250829T140616"
31
31
  },
32
32
  "peerDependenciesMeta": {
33
33
  + "@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.21
100
+ $ bun update @types/bun@1.2.22-canary.20250829T140616
101
101
 
102
102
  # Update all dependencies to the latest versions
103
103
  $ bun update --latest
@@ -17,7 +17,7 @@ Bun reads the following files automatically (listed in order of increasing prece
17
17
 
18
18
  - `.env`
19
19
  - `.env.production`, `.env.development`, `.env.test` (depending on value of `NODE_ENV`)
20
- - `.env.local`
20
+ - `.env.local` (not loaded when `NODE_ENV=test`)
21
21
 
22
22
  ```txt#.env
23
23
  FOO=hello
@@ -35,7 +35,7 @@ Add this directive to _just one file_ in your project, such as:
35
35
  - Any single `.ts` file that TypeScript includes in your compilation
36
36
 
37
37
  ```ts
38
- /// <reference types="bun/test-globals" />
38
+ /// <reference types="bun-types/test-globals" />
39
39
  ```
40
40
 
41
41
  ---
@@ -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.21 (9c68abdb)
24
+ bun test v1.2.22-canary.20250829T140616 (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.21 (9c68abdb)
50
+ bun test v1.2.22-canary.20250829T140616 (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.21 (9c68abdb)
88
+ bun test v1.2.22-canary.20250829T140616 (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.21 (9c68abdb)
21
+ bun test v1.2.22-canary.20250829T140616 (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.21 (9c68abdb)
64
+ bun test v1.2.22-canary.20250829T140616 (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.21 (9c68abdb)
81
+ bun test v1.2.22-canary.20250829T140616 (9c68abdb)
82
82
 
83
83
  test/snap.test.ts:
84
84
  ✓ snapshot [0.86ms]
@@ -29,7 +29,7 @@ To regenerate snapshots, use the `--update-snapshots` flag.
29
29
 
30
30
  ```sh
31
31
  $ bun test --update-snapshots
32
- bun test v1.2.21 (9c68abdb)
32
+ bun test v1.2.22-canary.20250829T140616 (9c68abdb)
33
33
 
34
34
  test/snap.test.ts:
35
35
  ✓ snapshot [0.86ms]
@@ -5,7 +5,7 @@ name: Get the current Bun version
5
5
  Get the current version of Bun in a semver format.
6
6
 
7
7
  ```ts#index.ts
8
- Bun.version; // => "1.2.21"
8
+ Bun.version; // => "1.2.22-canary.20250829T140616"
9
9
  ```
10
10
 
11
11
  ---
@@ -76,6 +76,6 @@ For a complete example with tests and CI setup, see the official template:
76
76
 
77
77
  ## Related
78
78
 
79
- - [Configuration (bunfig.toml)](/docs/runtime/bunfig#installsecurityscanner)
79
+ - [Configuration (bunfig.toml)](/docs/runtime/bunfig#install-security-scanner)
80
80
  - [Package Manager](/docs/install)
81
81
  - [Security Scanner Template](https://github.com/oven-sh/security-scanner-template)
@@ -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.com/install | bash # for macOS, Linux, and WSL
16
16
  # to install a specific version
17
- $ curl -fsSL https://bun.com/install | bash -s "bun-v1.2.21"
17
+ $ curl -fsSL https://bun.com/install | bash -s "bun-v1.2.22-canary.20250829T140616"
18
18
  ```
19
19
 
20
20
  ```bash#npm
@@ -189,10 +189,10 @@ Since Bun is a single binary, you can install older versions of Bun by re-runnin
189
189
 
190
190
  ### Installing a specific version of Bun on Linux/Mac
191
191
 
192
- 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.21`.
192
+ 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.22-canary.20250829T140616`.
193
193
 
194
194
  ```sh
195
- $ curl -fsSL https://bun.com/install | bash -s "bun-v1.2.21"
195
+ $ curl -fsSL https://bun.com/install | bash -s "bun-v1.2.22-canary.20250829T140616"
196
196
  ```
197
197
 
198
198
  ### Installing a specific version of Bun on Windows
@@ -201,7 +201,7 @@ On Windows, you can install a specific version of Bun by passing the version num
201
201
 
202
202
  ```sh
203
203
  # PowerShell:
204
- $ iex "& {$(irm https://bun.com/install.ps1)} -Version 1.2.21"
204
+ $ iex "& {$(irm https://bun.com/install.ps1)} -Version 1.2.22-canary.20250829T140616"
205
205
  ```
206
206
 
207
207
  ## Downloading Bun binaries directly
@@ -223,8 +223,8 @@ $ git clone https://github.com/oven-sh/WebKit vendor/WebKit
223
223
  $ git -C vendor/WebKit checkout <commit_hash>
224
224
 
225
225
  # Make a debug build of JSC. This will output build artifacts in ./vendor/WebKit/WebKitBuild/Debug
226
- # Optionally, you can use `make jsc` for a release build
227
- $ make jsc-debug && rm vendor/WebKit/WebKitBuild/Debug/JavaScriptCore/DerivedSources/inspector/InspectorProtocolObjects.h
226
+ # Optionally, you can use `bun run jsc:build` for a release build
227
+ $ bun run jsc:build:debug && rm vendor/WebKit/WebKitBuild/Debug/JavaScriptCore/DerivedSources/inspector/InspectorProtocolObjects.h
228
228
 
229
229
  # After an initial run of `make jsc-debug`, you can rebuild JSC with:
230
230
  $ cmake --build vendor/WebKit/WebKitBuild/Debug --target jsc && rm vendor/WebKit/WebKitBuild/Debug/JavaScriptCore/DerivedSources/inspector/InspectorProtocolObjects.h
@@ -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.21" -H "Accept: */*" -H "Host: example.com" -H "Accept-Encoding: gzip, deflate, br" --compressed -H "Content-Length: 13" --data-raw "{\"foo\":\"bar\"}"
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.22-canary.20250829T140616" -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.21
131
+ [fetch] > User-Agent: Bun/1.2.22-canary.20250829T140616
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.21
173
+ [fetch] > User-Agent: Bun/1.2.22-canary.20250829T140616
174
174
  [fetch] > Accept: */*
175
175
  [fetch] > Host: example.com
176
176
  [fetch] > Accept-Encoding: gzip, deflate, br
@@ -8,6 +8,10 @@ Bun reads the following files automatically (listed in order of increasing prece
8
8
  - `.env.production`, `.env.development`, `.env.test` (depending on value of `NODE_ENV`)
9
9
  - `.env.local`
10
10
 
11
+ {% callout %}
12
+ **Note:** When `NODE_ENV=test`, `.env.local` is **not** loaded. This ensures consistent test environments across different executions by preventing local overrides during testing. This behavior matches popular frameworks like [Next.js](https://nextjs.org/docs/pages/guides/environment-variables#test-environment-variables) and [Create React App](https://create-react-app.dev/docs/adding-custom-environment-variables/#what-other-env-files-can-be-used).
13
+ {% /callout %}
14
+
11
15
  ```txt#.env
12
16
  FOO=hello
13
17
  BAR=world
package/docs/test/dom.md CHANGED
@@ -55,7 +55,7 @@ Let's run this test with `bun test`:
55
55
 
56
56
  ```bash
57
57
  $ bun test
58
- bun test v1.2.21
58
+ bun test v1.2.22-canary.20250829T140616
59
59
 
60
60
  dom.test.ts:
61
61
  ✓ dom test [0.82ms]
@@ -12,6 +12,8 @@ test("NODE_ENV is set to test", () => {
12
12
  });
13
13
  ```
14
14
 
15
+ When `NODE_ENV` is set to `"test"`, Bun will not load `.env.local` files. This ensures consistent test environments across different executions by preventing local overrides during testing. Instead, use `.env.test` for test-specific environment variables, which should be committed to your repository for consistency across all developers and CI environments.
16
+
15
17
  #### `$TZ` environment variable
16
18
 
17
19
  By default, all `bun test` runs use UTC (`Etc/UTC`) as the time zone unless overridden by the `TZ` environment variable. This ensures consistent date and time behavior across different development environments.
package/experimental.d.ts CHANGED
@@ -191,7 +191,9 @@ declare module "bun" {
191
191
  * };
192
192
  * ```
193
193
  */
194
- export type SSGPage<Params extends SSGParamsLike = SSGParamsLike> = React.ComponentType<SSGPageProps<Params>>;
194
+ export type SSGPage<Params extends SSGParamsLike = SSGParamsLike> = import("react").ComponentType<
195
+ SSGPageProps<Params>
196
+ >;
195
197
 
196
198
  /**
197
199
  * getStaticPaths is Bun's implementation of SSG (Static Site Generation) path determination.
package/overrides.d.ts CHANGED
@@ -174,6 +174,96 @@ declare global {
174
174
  UV_ENODATA: number;
175
175
  UV_EUNATCH: number;
176
176
  };
177
+ binding(m: "http_parser"): {
178
+ methods: [
179
+ "DELETE",
180
+ "GET",
181
+ "HEAD",
182
+ "POST",
183
+ "PUT",
184
+ "CONNECT",
185
+ "OPTIONS",
186
+ "TRACE",
187
+ "COPY",
188
+ "LOCK",
189
+ "MKCOL",
190
+ "MOVE",
191
+ "PROPFIND",
192
+ "PROPPATCH",
193
+ "SEARCH",
194
+ "UNLOCK",
195
+ "BIND",
196
+ "REBIND",
197
+ "UNBIND",
198
+ "ACL",
199
+ "REPORT",
200
+ "MKACTIVITY",
201
+ "CHECKOUT",
202
+ "MERGE",
203
+ "M - SEARCH",
204
+ "NOTIFY",
205
+ "SUBSCRIBE",
206
+ "UNSUBSCRIBE",
207
+ "PATCH",
208
+ "PURGE",
209
+ "MKCALENDAR",
210
+ "LINK",
211
+ "UNLINK",
212
+ "SOURCE",
213
+ "QUERY",
214
+ ];
215
+ allMethods: [
216
+ "DELETE",
217
+ "GET",
218
+ "HEAD",
219
+ "POST",
220
+ "PUT",
221
+ "CONNECT",
222
+ "OPTIONS",
223
+ "TRACE",
224
+ "COPY",
225
+ "LOCK",
226
+ "MKCOL",
227
+ "MOVE",
228
+ "PROPFIND",
229
+ "PROPPATCH",
230
+ "SEARCH",
231
+ "UNLOCK",
232
+ "BIND",
233
+ "REBIND",
234
+ "UNBIND",
235
+ "ACL",
236
+ "REPORT",
237
+ "MKACTIVITY",
238
+ "CHECKOUT",
239
+ "MERGE",
240
+ "M - SEARCH",
241
+ "NOTIFY",
242
+ "SUBSCRIBE",
243
+ "UNSUBSCRIBE",
244
+ "PATCH",
245
+ "PURGE",
246
+ "MKCALENDAR",
247
+ "LINK",
248
+ "UNLINK",
249
+ "SOURCE",
250
+ "PRI",
251
+ "DESCRIBE",
252
+ "ANNOUNCE",
253
+ "SETUP",
254
+ "PLAY",
255
+ "PAUSE",
256
+ "TEARDOWN",
257
+ "GET_PARAMETER",
258
+ "SET_PARAMETER",
259
+ "REDIRECT",
260
+ "RECORD",
261
+ "FLUSH",
262
+ "QUERY",
263
+ ];
264
+ HTTPParser: unknown;
265
+ ConnectionsList: unknown;
266
+ };
177
267
  binding(m: string): object;
178
268
  }
179
269
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.21",
2
+ "version": "1.2.22-canary.20250829T140616",
3
3
  "name": "bun-types",
4
4
  "license": "MIT",
5
5
  "types": "./index.d.ts",
package/test-globals.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  // This file gets loaded by developers including the following triple slash directive:
4
4
  //
5
5
  // ```ts
6
- // /// <reference types="bun/test-globals" />
6
+ // /// <reference types="bun-types/test-globals" />
7
7
  // ```
8
8
 
9
9
  declare var test: typeof import("bun:test").test;
@@ -19,3 +19,6 @@ declare var setDefaultTimeout: typeof import("bun:test").setDefaultTimeout;
19
19
  declare var mock: typeof import("bun:test").mock;
20
20
  declare var spyOn: typeof import("bun:test").spyOn;
21
21
  declare var jest: typeof import("bun:test").jest;
22
+ declare var xit: typeof import("bun:test").xit;
23
+ declare var xtest: typeof import("bun:test").xtest;
24
+ declare var xdescribe: typeof import("bun:test").xdescribe;
package/test.d.ts CHANGED
@@ -262,6 +262,15 @@ declare module "bun:test" {
262
262
  * @param fn the function that defines the tests
263
263
  */
264
264
  export const describe: Describe;
265
+ /**
266
+ * Skips a group of related tests.
267
+ *
268
+ * This is equivalent to calling `describe.skip()`.
269
+ *
270
+ * @param label the label for the tests
271
+ * @param fn the function that defines the tests
272
+ */
273
+ export const xdescribe: Describe;
265
274
  /**
266
275
  * Runs a function, once, before all the tests.
267
276
  *
@@ -515,7 +524,17 @@ declare module "bun:test" {
515
524
  * @param fn the test function
516
525
  */
517
526
  export const test: Test;
518
- export { test as it };
527
+ export { test as it, xtest as xit };
528
+
529
+ /**
530
+ * Skips a test.
531
+ *
532
+ * This is equivalent to calling `test.skip()`.
533
+ *
534
+ * @param label the label for the test
535
+ * @param fn the test function
536
+ */
537
+ export const xtest: Test;
519
538
 
520
539
  /**
521
540
  * Asserts that a value matches some criteria.