bun-types 1.1.45-canary.20250121T140608 → 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 +7 -62
- 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 +2 -2
- package/docs/bundler/fullstack.md +1 -3
- package/docs/bundler/html.md +1 -7
- package/docs/bundler/index.md +0 -31
- package/docs/bundler/loaders.md +0 -7
- package/docs/cli/bun-install.md +5 -19
- package/docs/cli/install.md +3 -3
- package/docs/cli/publish.md +1 -1
- 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 +5 -5
- package/docs/runtime/plugins.md +0 -2
- package/docs/test/dom.md +1 -1
- package/package.json +1 -1
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);
|
|
@@ -2827,31 +2801,6 @@ declare module "bun" {
|
|
|
2827
2801
|
*/
|
|
2828
2802
|
footer?: string;
|
|
2829
2803
|
|
|
2830
|
-
/**
|
|
2831
|
-
* **Experimental**
|
|
2832
|
-
*
|
|
2833
|
-
* Bundle CSS files.
|
|
2834
|
-
*
|
|
2835
|
-
* This will be enabled by default in Bun v1.2.
|
|
2836
|
-
*
|
|
2837
|
-
* @default false (until Bunv 1.2)
|
|
2838
|
-
*/
|
|
2839
|
-
experimentalCss?: boolean;
|
|
2840
|
-
|
|
2841
|
-
/**
|
|
2842
|
-
* **Experimental**
|
|
2843
|
-
*
|
|
2844
|
-
* Bundle JavaScript & CSS files from HTML files. JavaScript & CSS files
|
|
2845
|
-
* from non-external <script> or <link> tags will be bundled.
|
|
2846
|
-
*
|
|
2847
|
-
* Underneath, this works similarly to HTMLRewriter.
|
|
2848
|
-
*
|
|
2849
|
-
* This will be enabled by default in Bun v1.2.
|
|
2850
|
-
*
|
|
2851
|
-
* @default false (until Bun v1.2)
|
|
2852
|
-
*/
|
|
2853
|
-
html?: boolean;
|
|
2854
|
-
|
|
2855
2804
|
/**
|
|
2856
2805
|
* Drop function calls to matching property accesses.
|
|
2857
2806
|
*/
|
|
@@ -2860,9 +2809,7 @@ declare module "bun" {
|
|
|
2860
2809
|
/**
|
|
2861
2810
|
* When set to `true`, the returned promise rejects with an AggregateError when a build failure happens.
|
|
2862
2811
|
* When set to `false`, the `success` property of the returned object will be `false` when a build failure happens.
|
|
2863
|
-
*
|
|
2864
|
-
* This defaults to `false` in Bun 1.1 and will change to `true` in Bun 1.2
|
|
2865
|
-
* as most usage of `Bun.build` forgets to check for errors.
|
|
2812
|
+
* This defaults to `true`.
|
|
2866
2813
|
*/
|
|
2867
2814
|
throw?: boolean;
|
|
2868
2815
|
}
|
|
@@ -3107,7 +3054,7 @@ declare module "bun" {
|
|
|
3107
3054
|
* @param {Object} config - Build configuration options
|
|
3108
3055
|
* @returns {Promise<BuildOutput>} Promise that resolves to build output containing generated artifacts and build status
|
|
3109
3056
|
* @throws {AggregateError} When build fails and config.throw is true (default in Bun 1.2+)
|
|
3110
|
-
*
|
|
3057
|
+
*
|
|
3111
3058
|
* @example Basic usage - Bundle a single entrypoint and check results
|
|
3112
3059
|
```ts
|
|
3113
3060
|
const result = await Bun.build({
|
|
@@ -3120,7 +3067,7 @@ declare module "bun" {
|
|
|
3120
3067
|
process.exit(1);
|
|
3121
3068
|
}
|
|
3122
3069
|
```
|
|
3123
|
-
*
|
|
3070
|
+
*
|
|
3124
3071
|
* @example Set up multiple entrypoints with code splitting enabled
|
|
3125
3072
|
```ts
|
|
3126
3073
|
await Bun.build({
|
|
@@ -3130,7 +3077,7 @@ declare module "bun" {
|
|
|
3130
3077
|
sourcemap: "external"
|
|
3131
3078
|
});
|
|
3132
3079
|
```
|
|
3133
|
-
*
|
|
3080
|
+
*
|
|
3134
3081
|
* @example Configure minification and optimization settings
|
|
3135
3082
|
```ts
|
|
3136
3083
|
await Bun.build({
|
|
@@ -3209,7 +3156,6 @@ declare module "bun" {
|
|
|
3209
3156
|
try {
|
|
3210
3157
|
const result = await Bun.build({
|
|
3211
3158
|
entrypoints: ['./src/index.tsx'],
|
|
3212
|
-
throw: true
|
|
3213
3159
|
});
|
|
3214
3160
|
} catch (e) {
|
|
3215
3161
|
const error = e as AggregateError;
|
|
@@ -3247,7 +3193,6 @@ declare module "bun" {
|
|
|
3247
3193
|
'./src/themes/light.css'
|
|
3248
3194
|
],
|
|
3249
3195
|
outdir: './dist/css',
|
|
3250
|
-
experimentalCss: true
|
|
3251
3196
|
});
|
|
3252
3197
|
```
|
|
3253
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/1.
|
|
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); // => "1.
|
|
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`:
|
package/docs/api/sql.md
CHANGED
|
@@ -20,7 +20,7 @@ const activeUsers = await sql`
|
|
|
20
20
|
|
|
21
21
|
{% features title="Features" %}
|
|
22
22
|
|
|
23
|
-
{% icon size=20 name="Shield" /%} Tagged template literals to protect
|
|
23
|
+
{% icon size=20 name="Shield" /%} Tagged template literals to protect against SQL injection
|
|
24
24
|
|
|
25
25
|
{% icon size=20 name="GitMerge" /%} Transactions
|
|
26
26
|
|
|
@@ -561,7 +561,7 @@ The plan is to add more database drivers in the future.
|
|
|
561
561
|
|
|
562
562
|
npm packages like postgres.js, pg, and node-postgres can be used in Bun too. They're great options.
|
|
563
563
|
|
|
564
|
-
Two
|
|
564
|
+
Two reasons why:
|
|
565
565
|
|
|
566
566
|
1. We think it's simpler for developers to have a database driver built into Bun. The time you spend library shopping is time you could be building your app.
|
|
567
567
|
2. We leverage some JavaScriptCore engine internals to make it faster to create objects that would be difficult to implement in a library
|
package/docs/bundler/html.md
CHANGED
|
@@ -18,17 +18,13 @@ One command is all you need (won't be experimental after Bun v1.2):
|
|
|
18
18
|
{% codetabs %}
|
|
19
19
|
|
|
20
20
|
```bash#CLI
|
|
21
|
-
$ bun build
|
|
21
|
+
$ bun build ./index.html --outdir=dist
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
```ts#API
|
|
25
25
|
Bun.build({
|
|
26
26
|
entrypoints: ["./index.html"],
|
|
27
27
|
outdir: "./dist",
|
|
28
|
-
|
|
29
|
-
// On by default in Bun v1.2+
|
|
30
|
-
html: true,
|
|
31
|
-
experimentalCss: true,
|
|
32
28
|
});
|
|
33
29
|
```
|
|
34
30
|
|
|
@@ -63,8 +59,6 @@ Need more control? Configure the bundler through the JavaScript API and use Bun'
|
|
|
63
59
|
await Bun.build({
|
|
64
60
|
entrypoints: ["./index.html"],
|
|
65
61
|
outdir: "./dist",
|
|
66
|
-
html: true,
|
|
67
|
-
experimentalCss: true,
|
|
68
62
|
minify: true,
|
|
69
63
|
|
|
70
64
|
plugins: [
|
package/docs/bundler/index.md
CHANGED
|
@@ -1258,30 +1258,6 @@ $ bun build ./index.tsx --outdir ./out --drop=console --drop=debugger --drop=any
|
|
|
1258
1258
|
|
|
1259
1259
|
{% /codetabs %}
|
|
1260
1260
|
|
|
1261
|
-
### `experimentalCss`
|
|
1262
|
-
|
|
1263
|
-
Whether to enable _experimental_ support for bundling CSS files. Defaults to `false`. In 1.2, this property will be deleted, and CSS bundling will always be enabled.
|
|
1264
|
-
|
|
1265
|
-
This supports bundling CSS files imported from JS, as well as CSS entrypoints.
|
|
1266
|
-
|
|
1267
|
-
{% codetabs group="a" %}
|
|
1268
|
-
|
|
1269
|
-
```ts#JavaScript
|
|
1270
|
-
const result = await Bun.build({
|
|
1271
|
-
entrypoints: ["./index.ts"],
|
|
1272
|
-
experimentalCss: true,
|
|
1273
|
-
});
|
|
1274
|
-
// => { success: boolean, outputs: BuildArtifact[], logs: BuildMessage[] }
|
|
1275
|
-
```
|
|
1276
|
-
|
|
1277
|
-
{% /codetabs %}
|
|
1278
|
-
|
|
1279
|
-
### `throw`
|
|
1280
|
-
|
|
1281
|
-
If set to `true`, `Bun.build` will throw on build failure. See the section ["Logs and Errors"](#logs-and-errors) for more details on the error message structure.
|
|
1282
|
-
|
|
1283
|
-
In 1.2, this will default to `true`, with the previous behavior as `throw: false`
|
|
1284
|
-
|
|
1285
1261
|
## Outputs
|
|
1286
1262
|
|
|
1287
1263
|
The `Bun.build` function returns a `Promise<BuildOutput>`, defined as:
|
|
@@ -1583,13 +1559,6 @@ interface BuildConfig {
|
|
|
1583
1559
|
*/
|
|
1584
1560
|
footer?: string;
|
|
1585
1561
|
|
|
1586
|
-
/**
|
|
1587
|
-
* **Experimental**
|
|
1588
|
-
*
|
|
1589
|
-
* Enable CSS support.
|
|
1590
|
-
*/
|
|
1591
|
-
experimentalCss?: boolean;
|
|
1592
|
-
|
|
1593
1562
|
/**
|
|
1594
1563
|
* Drop function calls to matching property accesses.
|
|
1595
1564
|
*/
|
package/docs/bundler/loaders.md
CHANGED
|
@@ -194,13 +194,6 @@ Otherwise, the database to embed is copied into the `outdir` with a hashed filen
|
|
|
194
194
|
|
|
195
195
|
**HTML loader**. Default for `.html` after Bun v1.2.0.
|
|
196
196
|
|
|
197
|
-
To enable the html loader:
|
|
198
|
-
|
|
199
|
-
- For `Bun.build`: set `html: true`
|
|
200
|
-
- For `bun build`: `--experimental-html` CLI flag
|
|
201
|
-
|
|
202
|
-
You most likely want to use the `html` loader in conjunction with `experimentalCss: true` or `--experimental-css`.
|
|
203
|
-
|
|
204
197
|
The html loader processes HTML files and bundles any referenced assets. It will:
|
|
205
198
|
|
|
206
199
|
- Bundle and hash referenced JavaScript files (`<script src="...">`)
|
package/docs/cli/bun-install.md
CHANGED
|
@@ -95,7 +95,7 @@ disableManifest = false
|
|
|
95
95
|
[install.lockfile]
|
|
96
96
|
|
|
97
97
|
# Print a yarn v1 lockfile
|
|
98
|
-
# Note: it does not load the lockfile, it just converts bun.
|
|
98
|
+
# Note: it does not load the lockfile, it just converts bun.lock into a yarn.lock
|
|
99
99
|
print = "yarn"
|
|
100
100
|
|
|
101
101
|
# Save the lockfile to disk
|
|
@@ -170,9 +170,9 @@ Bun stores installed packages from npm in `~/.bun/install/cache/${name}@${versio
|
|
|
170
170
|
|
|
171
171
|
When the `node_modules` folder exists, before installing, Bun checks if the `"name"` and `"version"` in `package/package.json` in the expected node_modules folder matches the expected `name` and `version`. This is how it determines whether it should install. It uses a custom JSON parser which stops parsing as soon as it finds `"name"` and `"version"`.
|
|
172
172
|
|
|
173
|
-
When a `bun.
|
|
173
|
+
When a `bun.lock` doesn’t exist or `package.json` has changed dependencies, tarballs are downloaded & extracted eagerly while resolving.
|
|
174
174
|
|
|
175
|
-
When a `bun.
|
|
175
|
+
When a `bun.lock` exists and `package.json` hasn’t changed, Bun downloads missing dependencies lazily. If the package with a matching `name` & `version` already exists in the expected location within `node_modules`, Bun won’t attempt to download the tarball.
|
|
176
176
|
|
|
177
177
|
## Platform-specific dependencies?
|
|
178
178
|
|
|
@@ -184,23 +184,9 @@ Peer dependencies are handled similarly to yarn. `bun install` will automaticall
|
|
|
184
184
|
|
|
185
185
|
## Lockfile
|
|
186
186
|
|
|
187
|
-
`bun.
|
|
187
|
+
`bun.lock` is Bun’s lockfile format. See [our blogpost about the text lockfile](https://bun.sh/blog/bun-lock-text-lockfile).
|
|
188
188
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
In a word: Performance. Bun’s lockfile saves & loads incredibly quickly, and saves a lot more data than what is typically inside lockfiles.
|
|
192
|
-
|
|
193
|
-
## How do I inspect it?
|
|
194
|
-
|
|
195
|
-
For now, the easiest thing is to run `bun install -y`. That prints a Yarn v1-style yarn.lock file.
|
|
196
|
-
|
|
197
|
-
## What does the lockfile store?
|
|
198
|
-
|
|
199
|
-
Packages, metadata for those packages, the hoisted install order, dependencies for each package, what packages those dependencies resolved to, an integrity hash (if available), what each package was resolved to and which version (or equivalent).
|
|
200
|
-
|
|
201
|
-
## Why is it fast?
|
|
202
|
-
|
|
203
|
-
It uses linear arrays for all data. [Packages](https://github.com/oven-sh/bun/blob/be03fc273a487ac402f19ad897778d74b6d72963/src/install/install.zig#L1825) are referenced by an auto-incrementing integer ID or a hash of the package name. Strings longer than 8 characters are de-duplicated. Prior to saving on disk, the lockfile is garbage-collected & made deterministic by walking the package tree and cloning the packages in dependency order.
|
|
189
|
+
Prior to Bun 1.2, the lockfile was binary and called `bun.lockb`. Old lockfiles can be upgraded to the new format by running `bun install --save-text-lockfile --frozen-lockfile --lockfile-only`, and then deleting `bun.lockb`.
|
|
204
190
|
|
|
205
191
|
## Cache
|
|
206
192
|
|
package/docs/cli/install.md
CHANGED
|
@@ -33,7 +33,7 @@ Running `bun install` will:
|
|
|
33
33
|
|
|
34
34
|
- **Install** all `dependencies`, `devDependencies`, and `optionalDependencies`. Bun will install `peerDependencies` by default.
|
|
35
35
|
- **Run** your project's `{pre|post}install` and `{pre|post}prepare` scripts at the appropriate time. For security reasons Bun _does not execute_ lifecycle scripts of installed dependencies.
|
|
36
|
-
- **Write** a `bun.
|
|
36
|
+
- **Write** a `bun.lock` lockfile to the project root.
|
|
37
37
|
|
|
38
38
|
## Logging
|
|
39
39
|
|
|
@@ -136,13 +136,13 @@ To install in production mode (i.e. without `devDependencies` or `optionalDepend
|
|
|
136
136
|
$ bun install --production
|
|
137
137
|
```
|
|
138
138
|
|
|
139
|
-
For reproducible installs, use `--frozen-lockfile`. This will install the exact versions of each package specified in the lockfile. If your `package.json` disagrees with `bun.
|
|
139
|
+
For reproducible installs, use `--frozen-lockfile`. This will install the exact versions of each package specified in the lockfile. If your `package.json` disagrees with `bun.lock`, Bun will exit with an error. The lockfile will not be updated.
|
|
140
140
|
|
|
141
141
|
```bash
|
|
142
142
|
$ bun install --frozen-lockfile
|
|
143
143
|
```
|
|
144
144
|
|
|
145
|
-
For more information on Bun's
|
|
145
|
+
For more information on Bun's lockfile `bun.lock`, refer to [Package manager > Lockfile](https://bun.sh/docs/install/lockfile).
|
|
146
146
|
|
|
147
147
|
## Omitting dependencies
|
|
148
148
|
|
package/docs/cli/publish.md
CHANGED
|
@@ -22,12 +22,12 @@ WORKDIR /usr/src/app
|
|
|
22
22
|
# this will cache them and speed up future builds
|
|
23
23
|
FROM base AS install
|
|
24
24
|
RUN mkdir -p /temp/dev
|
|
25
|
-
COPY package.json bun.
|
|
25
|
+
COPY package.json bun.lock /temp/dev/
|
|
26
26
|
RUN cd /temp/dev && bun install --frozen-lockfile
|
|
27
27
|
|
|
28
28
|
# install with --production (exclude devDependencies)
|
|
29
29
|
RUN mkdir -p /temp/prod
|
|
30
|
-
COPY package.json bun.
|
|
30
|
+
COPY package.json bun.lock /temp/prod/
|
|
31
31
|
RUN cd /temp/prod && bun install --frozen-lockfile --production
|
|
32
32
|
|
|
33
33
|
# copy node_modules from temp directory
|
|
@@ -7,7 +7,7 @@ name: Migrate from npm install to bun install
|
|
|
7
7
|
We've put a lot of work into making sure that the migration path from `npm install` to `bun install` is as easy as running `bun install` instead of `npm install`.
|
|
8
8
|
|
|
9
9
|
- **Designed for Node.js & Bun**: `bun install` installs a Node.js compatible `node_modules` folder. You can use it in place of `npm install` for Node.js projects without any code changes and without using Bun's runtime.
|
|
10
|
-
- **Automatically converts `package-lock.json`** to bun's `bun.
|
|
10
|
+
- **Automatically converts `package-lock.json`** to bun's `bun.lock` lockfile format, preserving your existing resolved dependency versions without any manual work on your part. You can secretly use `bun install` in place of `npm install` at work without anyone noticing.
|
|
11
11
|
- **`.npmrc` compatible**: bun install reads npm registry configuration from npm's `.npmrc`, so you can use the same configuration for both npm and Bun.
|
|
12
12
|
- **Hardlinks**: On Windows and Linux, `bun install` uses hardlinks to conserve disk space and install times.
|
|
13
13
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
name: Generate a
|
|
2
|
+
name: Generate a yarn-compatible lockfile
|
|
3
3
|
---
|
|
4
4
|
|
|
5
5
|
{% callout %}
|
|
@@ -8,11 +8,7 @@ Bun v1.1.39 introduced `bun.lock`, a JSONC formatted lockfile. `bun.lock` is hum
|
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
Use the `--yarn` flag to generate a Yarn-compatible `yarn.lock` file (in addition to `bun.lockb`).
|
|
11
|
+
Use the `--yarn` flag to generate a Yarn-compatible `yarn.lock` file (in addition to `bun.lock`).
|
|
16
12
|
|
|
17
13
|
```sh
|
|
18
14
|
$ bun install --yarn
|
|
@@ -29,7 +25,7 @@ print = "yarn"
|
|
|
29
25
|
|
|
30
26
|
---
|
|
31
27
|
|
|
32
|
-
To print a Yarn lockfile to your console without writing it to disk,
|
|
28
|
+
To print a Yarn lockfile to your console without writing it to disk, "run" your `bun.lockb` with `bun`.
|
|
33
29
|
|
|
34
30
|
```sh
|
|
35
31
|
$ bun bun.lockb
|
package/docs/install/index.md
CHANGED
|
@@ -41,7 +41,7 @@ Running `bun install` will:
|
|
|
41
41
|
|
|
42
42
|
- **Install** all `dependencies`, `devDependencies`, and `optionalDependencies`. Bun will install `peerDependencies` by default.
|
|
43
43
|
- **Run** your project's `{pre|post}install` scripts at the appropriate time. For security reasons Bun _does not execute_ lifecycle scripts of installed dependencies.
|
|
44
|
-
- **Write** a `bun.
|
|
44
|
+
- **Write** a `bun.lock` lockfile to the project root.
|
|
45
45
|
|
|
46
46
|
To install in production mode (i.e. without `devDependencies`):
|
|
47
47
|
|
package/docs/install/lockfile.md
CHANGED
|
@@ -1,53 +1,10 @@
|
|
|
1
|
-
Running `bun install` will create a
|
|
1
|
+
Running `bun install` will create a lockfile called `bun.lock`.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
https://bun.sh/blog/bun-lock-text-lockfile
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
#### Should it be committed to git?
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Run `bun install -y` to generate a Yarn-compatible `yarn.lock` (v1) that can be inspected more easily.
|
|
10
|
-
|
|
11
|
-
#### How do I `git diff` Bun's lockfile?
|
|
12
|
-
|
|
13
|
-
Add the following to your local or global `.gitattributes` file:
|
|
14
|
-
|
|
15
|
-
```
|
|
16
|
-
*.lockb binary diff=lockb
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
Then add the following to your local git config with:
|
|
20
|
-
|
|
21
|
-
```sh
|
|
22
|
-
$ git config diff.lockb.textconv bun
|
|
23
|
-
$ git config diff.lockb.binary true
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Or to your global git config (system-wide) with the `--global` option:
|
|
27
|
-
|
|
28
|
-
```sh
|
|
29
|
-
$ git config --global diff.lockb.textconv bun
|
|
30
|
-
$ git config --global diff.lockb.binary true
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
**Why this works:**
|
|
34
|
-
|
|
35
|
-
- `textconv` tells git to run `bun` on the file before diffing
|
|
36
|
-
- `binary` tells git to treat the file as binary (so it doesn't try to diff it line-by-line)
|
|
37
|
-
|
|
38
|
-
Running `bun` on a lockfile will print a human-readable diff. So we just need to tell `git` to run `bun` on the lockfile before diffing it.
|
|
39
|
-
|
|
40
|
-
#### Platform-specific dependencies?
|
|
41
|
-
|
|
42
|
-
Bun stores normalized `cpu` and `os` values from npm in the lockfile, along with the resolved packages. It skips downloading, extracting, and installing packages disabled for the current target at runtime. This means the lockfile won’t change between platforms/architectures even if the packages ultimately installed do change.
|
|
43
|
-
|
|
44
|
-
#### What does Bun's lockfile store?
|
|
45
|
-
|
|
46
|
-
Packages, metadata for those packages, the hoisted install order, dependencies for each package, what packages those dependencies resolved to, an integrity hash (if available), what each package was resolved to, and which version (or equivalent).
|
|
47
|
-
|
|
48
|
-
#### Why is Bun's lockfile fast?
|
|
49
|
-
|
|
50
|
-
It uses linear arrays for all data. [Packages](https://github.com/oven-sh/bun/blob/be03fc273a487ac402f19ad897778d74b6d72963/src/install/install.zig#L1825) are referenced by an auto-incrementing integer ID or a hash of the package name. Strings longer than 8 characters are de-duplicated. Prior to saving on disk, the lockfile is garbage-collected & made deterministic by walking the package tree and cloning the packages in dependency order.
|
|
7
|
+
Yes
|
|
51
8
|
|
|
52
9
|
#### Generate a lockfile without installing?
|
|
53
10
|
|
|
@@ -69,7 +26,7 @@ To install without creating a lockfile:
|
|
|
69
26
|
$ bun install --no-save
|
|
70
27
|
```
|
|
71
28
|
|
|
72
|
-
To install a Yarn lockfile _in addition_ to `bun.
|
|
29
|
+
To install a Yarn lockfile _in addition_ to `bun.lock`.
|
|
73
30
|
|
|
74
31
|
{% codetabs %}
|
|
75
32
|
|
|
@@ -79,42 +36,15 @@ $ bun install --yarn
|
|
|
79
36
|
|
|
80
37
|
```toml#bunfig.toml
|
|
81
38
|
[install.lockfile]
|
|
82
|
-
# whether to save a non-Bun lockfile alongside bun.
|
|
39
|
+
# whether to save a non-Bun lockfile alongside bun.lock
|
|
83
40
|
# only "yarn" is supported
|
|
84
41
|
print = "yarn"
|
|
85
42
|
```
|
|
86
43
|
|
|
87
44
|
{% /codetabs %}
|
|
88
45
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
Bun v1.1.39 introduced `bun.lock`, a JSONC formatted lockfile. `bun.lock` is human-readable and git-diffable without configuration, at [no cost to performance](https://bun.sh/blog/bun-lock-text-lockfile#cached-bun-install-gets-30-faster).
|
|
92
|
-
|
|
93
|
-
To generate the lockfile, use `--save-text-lockfile` with `bun install`. You can do this for new projects and existing projects already using `bun.lockb` (resolutions will be preserved).
|
|
94
|
-
|
|
95
|
-
```bash
|
|
96
|
-
$ bun install --save-text-lockfile
|
|
97
|
-
$ head -n3 bun.lock
|
|
98
|
-
{
|
|
99
|
-
"lockfileVersion": 0,
|
|
100
|
-
"workspaces": {
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
Once `bun.lock` is generated, Bun will use it for all subsequent installs and updates through commands that read and modify the lockfile. If both lockfiles exist, `bun.lock` will be chosen over `bun.lockb`.
|
|
46
|
+
#### Text-based lockfile
|
|
104
47
|
|
|
105
|
-
Bun v1.2
|
|
106
|
-
|
|
107
|
-
{% details summary="Configuring lockfile" %}
|
|
108
|
-
|
|
109
|
-
```toml
|
|
110
|
-
[install.lockfile]
|
|
111
|
-
|
|
112
|
-
# whether to save the lockfile to disk
|
|
113
|
-
save = true
|
|
114
|
-
|
|
115
|
-
# whether to save a non-Bun lockfile alongside bun.lockb
|
|
116
|
-
# only "yarn" is supported
|
|
117
|
-
print = "yarn"
|
|
118
|
-
```
|
|
48
|
+
Bun v1.2 changed the default lockfile format to the text-based `bun.lock`. Existing binary `bun.lockb` lockfiles can be migrated to the new format by running `bun install --save-text-lockfile --frozen-lockfile --lockfile-only` and deleting `bun.lockb`.
|
|
119
49
|
|
|
120
|
-
|
|
50
|
+
More information about the new lockfile format can be found on [our blogpost](https://bun.sh/blog/bun-lock-text-lockfile).
|
|
@@ -14,7 +14,7 @@ The first time you run this script, Bun will auto-install `"foo"` and cache it.
|
|
|
14
14
|
|
|
15
15
|
To determine which version to install, Bun follows the following algorithm:
|
|
16
16
|
|
|
17
|
-
1. Check for a `bun.
|
|
17
|
+
1. Check for a `bun.lock` file in the project root. If it exists, use the version specified in the lockfile.
|
|
18
18
|
2. Otherwise, scan up the tree for a `package.json` that includes `"foo"` as a dependency. If found, use the specified semver version or version range.
|
|
19
19
|
3. Otherwise, use `latest`.
|
|
20
20
|
|
package/docs/runtime/bunfig.md
CHANGED
|
@@ -240,13 +240,13 @@ exact = false
|
|
|
240
240
|
|
|
241
241
|
### `install.saveTextLockfile`
|
|
242
242
|
|
|
243
|
-
|
|
243
|
+
If false, generate a binary `bun.lockb` instead of a text-based `bun.lock` file when running `bun install` and no lockfile is present.
|
|
244
244
|
|
|
245
|
-
Default `
|
|
245
|
+
Default `true` (since Bun v1.2).
|
|
246
246
|
|
|
247
247
|
```toml
|
|
248
248
|
[install]
|
|
249
|
-
saveTextLockfile =
|
|
249
|
+
saveTextLockfile = false
|
|
250
250
|
```
|
|
251
251
|
|
|
252
252
|
<!--
|
|
@@ -315,7 +315,7 @@ Valid values are:
|
|
|
315
315
|
|
|
316
316
|
### `install.frozenLockfile`
|
|
317
317
|
|
|
318
|
-
When true, `bun install` will not update `bun.
|
|
318
|
+
When true, `bun install` will not update `bun.lock`. Default `false`. If `package.json` and the existing `bun.lock` are not in agreement, this will error.
|
|
319
319
|
|
|
320
320
|
```toml
|
|
321
321
|
[install]
|
|
@@ -423,7 +423,7 @@ Whether to generate a lockfile on `bun install`. Default `true`.
|
|
|
423
423
|
save = true
|
|
424
424
|
```
|
|
425
425
|
|
|
426
|
-
Whether to generate a non-Bun lockfile alongside `bun.
|
|
426
|
+
Whether to generate a non-Bun lockfile alongside `bun.lock`. (A `bun.lock` will always be created.) Currently `"yarn"` is the only supported value.
|
|
427
427
|
|
|
428
428
|
```toml
|
|
429
429
|
[install.lockfile]
|
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.
|
|
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.0-canary.20250122T140708" -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.
|
|
131
|
+
[fetch] > User-Agent: Bun/1.2.0-canary.20250122T140708
|
|
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.
|
|
173
|
+
[fetch] > User-Agent: Bun/1.2.0-canary.20250122T140708
|
|
174
174
|
[fetch] > Accept: */*
|
|
175
175
|
[fetch] > Host: example.com
|
|
176
176
|
[fetch] > Accept-Encoding: gzip, deflate, br
|
package/docs/runtime/modules.md
CHANGED
|
@@ -34,6 +34,10 @@ This page is updated regularly to reflect compatibility status of the latest ver
|
|
|
34
34
|
|
|
35
35
|
🟢 Fully implemented. `EventEmitterAsyncResource` uses `AsyncResource` underneath. 100% of Node.js's test suite for EventEmitter passes.
|
|
36
36
|
|
|
37
|
+
### [`node:fs`](https://nodejs.org/api/fs.html)
|
|
38
|
+
|
|
39
|
+
🟢 Fully implemented. 92% of Node.js's test suite passes.
|
|
40
|
+
|
|
37
41
|
### [`node:http`](https://nodejs.org/api/http.html)
|
|
38
42
|
|
|
39
43
|
🟢 Fully implemented. Outgoing client request body is currently buffered instead of streamed.
|
|
@@ -88,7 +92,7 @@ This page is updated regularly to reflect compatibility status of the latest ver
|
|
|
88
92
|
|
|
89
93
|
### [`node:async_hooks`](https://nodejs.org/api/async_hooks.html)
|
|
90
94
|
|
|
91
|
-
🟡 `AsyncLocalStorage`, and `AsyncResource` are implemented.
|
|
95
|
+
🟡 `AsyncLocalStorage`, and `AsyncResource` are implemented. v8 promise hooks are not called, and its usage is [strongly discouraged](https://nodejs.org/docs/latest/api/async_hooks.html#async-hooks).
|
|
92
96
|
|
|
93
97
|
### [`node:child_process`](https://nodejs.org/api/child_process.html)
|
|
94
98
|
|
|
@@ -108,10 +112,6 @@ Some methods are not optimized yet.
|
|
|
108
112
|
|
|
109
113
|
🟡 Missing `Domain` `active`
|
|
110
114
|
|
|
111
|
-
### [`node:fs`](https://nodejs.org/api/fs.html)
|
|
112
|
-
|
|
113
|
-
🟡 Missing `statfs` `statfsSync`, `opendirSync`. `Dir` is partially implemented.
|
|
114
|
-
|
|
115
115
|
### [`node:http2`](https://nodejs.org/api/http2.html)
|
|
116
116
|
|
|
117
117
|
🟡 Client & server are implemented (95.25% of gRPC's test suite passes). Missing `options.allowHTTP1`, `options.enableConnectProtocol`, ALTSVC extension, and `http2stream.pushStream`.
|
package/docs/runtime/plugins.md
CHANGED
package/docs/test/dom.md
CHANGED
package/package.json
CHANGED