bun-types 1.3.3-canary.20251112T140644 → 1.3.3-canary.20251114T140703
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 +25 -1
- package/docs/bundler/css.mdx +2 -2
- package/docs/bundler/esbuild.mdx +52 -8
- package/docs/bundler/executables.mdx +1 -1
- package/docs/bundler/html-static.mdx +17 -3
- package/docs/bundler/index.mdx +19 -1
- package/docs/bundler/loaders.mdx +108 -13
- package/docs/bundler/minifier.mdx +343 -363
- package/docs/bundler/plugins.mdx +15 -1
- package/docs/guides/deployment/google-cloud-run.mdx +2 -5
- package/docs/guides/ecosystem/{edgedb.mdx → gel.mdx} +42 -38
- package/docs/guides/test/snapshot.mdx +2 -2
- package/docs/pm/cli/pm.mdx +1 -1
- package/docs/pm/workspaces.mdx +1 -2
- package/docs/quickstart.mdx +199 -193
- package/docs/runtime/bunfig.mdx +1 -0
- package/docs/runtime/file-types.mdx +84 -3
- package/docs/runtime/module-resolution.mdx +11 -2
- package/docs/runtime/plugins.mdx +15 -1
- package/docs/runtime/s3.mdx +1 -1
- package/package.json +1 -1
package/bun.d.ts
CHANGED
|
@@ -4041,7 +4041,21 @@ declare module "bun" {
|
|
|
4041
4041
|
| "browser";
|
|
4042
4042
|
|
|
4043
4043
|
/** https://bun.com/docs/bundler/loaders */
|
|
4044
|
-
type Loader =
|
|
4044
|
+
type Loader =
|
|
4045
|
+
| "js"
|
|
4046
|
+
| "jsx"
|
|
4047
|
+
| "ts"
|
|
4048
|
+
| "tsx"
|
|
4049
|
+
| "json"
|
|
4050
|
+
| "jsonc"
|
|
4051
|
+
| "toml"
|
|
4052
|
+
| "yaml"
|
|
4053
|
+
| "file"
|
|
4054
|
+
| "napi"
|
|
4055
|
+
| "wasm"
|
|
4056
|
+
| "text"
|
|
4057
|
+
| "css"
|
|
4058
|
+
| "html";
|
|
4045
4059
|
|
|
4046
4060
|
interface PluginConstraints {
|
|
4047
4061
|
/**
|
|
@@ -6430,6 +6444,16 @@ declare module "bun" {
|
|
|
6430
6444
|
/** @see https://bun.com/docs/install/catalogs */
|
|
6431
6445
|
catalogs?: Record<string, Record<string, string>>;
|
|
6432
6446
|
|
|
6447
|
+
/**
|
|
6448
|
+
* `0` / `undefined` for projects created before v1.3.2, `1` for projects created after.
|
|
6449
|
+
*
|
|
6450
|
+
* ---
|
|
6451
|
+
* Right now this only changes the default [install linker strategy](https://bun.com/docs/pm/cli/install#isolated-installs):
|
|
6452
|
+
* - With `0`, the linker is hoisted.
|
|
6453
|
+
* - With `1`, the linker is isolated for workspaces and hoisted for single-package projects.
|
|
6454
|
+
*/
|
|
6455
|
+
configVersion?: 0 | 1;
|
|
6456
|
+
|
|
6433
6457
|
/**
|
|
6434
6458
|
* ```
|
|
6435
6459
|
* INFO = { prod/dev/optional/peer dependencies, os, cpu, libc (TODO), bin, binDir }
|
package/docs/bundler/css.mdx
CHANGED
|
@@ -34,7 +34,7 @@ By default, Bun's CSS bundler targets the following browsers:
|
|
|
34
34
|
|
|
35
35
|
The CSS Nesting specification allows you to write more concise and intuitive stylesheets by nesting selectors inside one another. Instead of repeating parent selectors across your CSS file, you can write child styles directly within their parent blocks.
|
|
36
36
|
|
|
37
|
-
```
|
|
37
|
+
```scss title="styles.css" icon="file-code"
|
|
38
38
|
/* With nesting */
|
|
39
39
|
.card {
|
|
40
40
|
background: white;
|
|
@@ -100,7 +100,7 @@ This compiles to:
|
|
|
100
100
|
|
|
101
101
|
The `color-mix()` function gives you an easy way to blend two colors together according to a specified ratio in a chosen color space. This powerful feature lets you create color variations without manually calculating the resulting values.
|
|
102
102
|
|
|
103
|
-
```
|
|
103
|
+
```scss title="styles.css" icon="file-code"
|
|
104
104
|
.button {
|
|
105
105
|
/* Mix blue and red in the RGB color space with a 30/70 proportion */
|
|
106
106
|
background-color: color-mix(in srgb, blue 30%, red);
|
package/docs/bundler/esbuild.mdx
CHANGED
|
@@ -231,23 +231,67 @@ const myPlugin: BunPlugin = {
|
|
|
231
231
|
### onResolve
|
|
232
232
|
|
|
233
233
|
<Tabs>
|
|
234
|
-
<Tab title="options"
|
|
234
|
+
<Tab title="options">
|
|
235
|
+
|
|
236
|
+
- 🟢 `filter`
|
|
237
|
+
- 🟢 `namespace`
|
|
238
|
+
|
|
239
|
+
</Tab>
|
|
235
240
|
<Tab title="arguments">
|
|
236
|
-
|
|
241
|
+
|
|
242
|
+
- 🟢 `path`
|
|
243
|
+
- 🟢 `importer`
|
|
244
|
+
- 🔴 `namespace`
|
|
245
|
+
- 🔴 `resolveDir`
|
|
246
|
+
- 🔴 `kind`
|
|
247
|
+
- 🔴 `pluginData`
|
|
248
|
+
|
|
237
249
|
</Tab>
|
|
238
250
|
<Tab title="results">
|
|
239
|
-
|
|
240
|
-
|
|
251
|
+
|
|
252
|
+
- 🟢 `namespace`
|
|
253
|
+
- 🟢 `path`
|
|
254
|
+
- 🔴 `errors`
|
|
255
|
+
- 🔴 `external`
|
|
256
|
+
- 🔴 `pluginData`
|
|
257
|
+
- 🔴 `pluginName`
|
|
258
|
+
- 🔴 `sideEffects`
|
|
259
|
+
- 🔴 `suffix`
|
|
260
|
+
- 🔴 `warnings`
|
|
261
|
+
- 🔴 `watchDirs`
|
|
262
|
+
- 🔴 `watchFiles`
|
|
263
|
+
|
|
241
264
|
</Tab>
|
|
242
265
|
</Tabs>
|
|
243
266
|
|
|
244
267
|
### onLoad
|
|
245
268
|
|
|
246
269
|
<Tabs>
|
|
247
|
-
<Tab title="options"
|
|
248
|
-
|
|
270
|
+
<Tab title="options">
|
|
271
|
+
|
|
272
|
+
- 🟢 `filter`
|
|
273
|
+
- 🟢 `namespace`
|
|
274
|
+
|
|
275
|
+
</Tab>
|
|
276
|
+
<Tab title="arguments">
|
|
277
|
+
|
|
278
|
+
- 🟢 `path`
|
|
279
|
+
- 🔴 `namespace`
|
|
280
|
+
- 🔴 `suffix`
|
|
281
|
+
- 🔴 `pluginData`
|
|
282
|
+
|
|
283
|
+
</Tab>
|
|
249
284
|
<Tab title="results">
|
|
250
|
-
|
|
251
|
-
|
|
285
|
+
|
|
286
|
+
- 🟢 `contents`
|
|
287
|
+
- 🟢 `loader`
|
|
288
|
+
- 🔴 `errors`
|
|
289
|
+
- 🔴 `pluginData`
|
|
290
|
+
- 🔴 `pluginName`
|
|
291
|
+
- 🔴 `resolveDir`
|
|
292
|
+
- 🔴 `warnings`
|
|
293
|
+
- 🔴 `watchDirs`
|
|
294
|
+
- 🔴 `watchFiles`
|
|
295
|
+
|
|
252
296
|
</Tab>
|
|
253
297
|
</Tabs>
|
|
@@ -216,7 +216,7 @@ However, with the `BUN_BE_BUN=1` environment variable, it acts just like the `bu
|
|
|
216
216
|
|
|
217
217
|
```bash icon="terminal" terminal
|
|
218
218
|
# With the env var, the executable acts like the `bun` CLI
|
|
219
|
-
|
|
219
|
+
BUN_BE_BUN=1 ./such-bun install
|
|
220
220
|
```
|
|
221
221
|
|
|
222
222
|
```txt
|
|
@@ -237,13 +237,27 @@ Then, reference TailwindCSS in your HTML via `<link>` tag, `@import` in CSS, or
|
|
|
237
237
|
|
|
238
238
|
<Tabs>
|
|
239
239
|
<Tab title="index.html">
|
|
240
|
+
|
|
240
241
|
```html title="index.html" icon="file-code"
|
|
241
|
-
|
|
242
|
+
<!-- Reference TailwindCSS in your HTML -->
|
|
242
243
|
<link rel="stylesheet" href="tailwindcss" />
|
|
243
244
|
```
|
|
245
|
+
|
|
246
|
+
</Tab>
|
|
247
|
+
<Tab title="styles.css">
|
|
248
|
+
|
|
249
|
+
```css title="styles.css" icon="file-code"
|
|
250
|
+
@import "tailwindcss";
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
</Tab>
|
|
254
|
+
<Tab title="app.ts">
|
|
255
|
+
|
|
256
|
+
```ts title="app.ts" icon="/icons/typescript.svg"
|
|
257
|
+
import "tailwindcss";
|
|
258
|
+
```
|
|
259
|
+
|
|
244
260
|
</Tab>
|
|
245
|
-
<Tab title="styles.css">```css title="styles.css" icon="file-code" @import "tailwindcss"; ```</Tab>
|
|
246
|
-
<Tab title="app.ts">```ts title="app.ts" icon="/icons/typescript.svg" import "tailwindcss"; ```</Tab>
|
|
247
261
|
</Tabs>
|
|
248
262
|
|
|
249
263
|
<Info>Only one of those are necessary, not all three.</Info>
|
package/docs/bundler/index.mdx
CHANGED
|
@@ -160,8 +160,12 @@ Like the Bun runtime, the bundler supports an array of file types out of the box
|
|
|
160
160
|
| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
161
161
|
| `.js` `.jsx` `.cjs` `.mjs` `.mts` `.cts` `.ts` `.tsx` | Uses Bun's built-in transpiler to parse the file and transpile TypeScript/JSX syntax to vanilla JavaScript. The bundler executes a set of default transforms including dead code elimination and tree shaking. At the moment Bun does not attempt to down-convert syntax; if you use recently ECMAScript syntax, that will be reflected in the bundled code. |
|
|
162
162
|
| `.json` | JSON files are parsed and inlined into the bundle as a JavaScript object.<br/><br/>`js<br/>import pkg from "./package.json";<br/>pkg.name; // => "my-package"<br/>` |
|
|
163
|
+
| `.jsonc` | JSON with comments. Files are parsed and inlined into the bundle as a JavaScript object.<br/><br/>`js<br/>import config from "./config.jsonc";<br/>config.name; // => "my-config"<br/>` |
|
|
163
164
|
| `.toml` | TOML files are parsed and inlined into the bundle as a JavaScript object.<br/><br/>`js<br/>import config from "./bunfig.toml";<br/>config.logLevel; // => "debug"<br/>` |
|
|
165
|
+
| `.yaml` `.yml` | YAML files are parsed and inlined into the bundle as a JavaScript object.<br/><br/>`js<br/>import config from "./config.yaml";<br/>config.name; // => "my-app"<br/>` |
|
|
164
166
|
| `.txt` | The contents of the text file are read and inlined into the bundle as a string.<br/><br/>`js<br/>import contents from "./file.txt";<br/>console.log(contents); // => "Hello, world!"<br/>` |
|
|
167
|
+
| `.html` | HTML files are processed and any referenced assets (scripts, stylesheets, images) are bundled. |
|
|
168
|
+
| `.css` | CSS files are bundled together into a single `.css` file in the output directory. |
|
|
165
169
|
| `.node` `.wasm` | These files are supported by the Bun runtime, but during bundling they are treated as assets. |
|
|
166
170
|
|
|
167
171
|
### Assets
|
|
@@ -1462,7 +1466,21 @@ interface BuildArtifact extends Blob {
|
|
|
1462
1466
|
sourcemap: BuildArtifact | null;
|
|
1463
1467
|
}
|
|
1464
1468
|
|
|
1465
|
-
type Loader =
|
|
1469
|
+
type Loader =
|
|
1470
|
+
| "js"
|
|
1471
|
+
| "jsx"
|
|
1472
|
+
| "ts"
|
|
1473
|
+
| "tsx"
|
|
1474
|
+
| "css"
|
|
1475
|
+
| "json"
|
|
1476
|
+
| "jsonc"
|
|
1477
|
+
| "toml"
|
|
1478
|
+
| "yaml"
|
|
1479
|
+
| "text"
|
|
1480
|
+
| "file"
|
|
1481
|
+
| "napi"
|
|
1482
|
+
| "wasm"
|
|
1483
|
+
| "html";
|
|
1466
1484
|
|
|
1467
1485
|
interface BuildOutput {
|
|
1468
1486
|
outputs: BuildArtifact[];
|
package/docs/bundler/loaders.mdx
CHANGED
|
@@ -7,14 +7,16 @@ The Bun bundler implements a set of default loaders out of the box.
|
|
|
7
7
|
|
|
8
8
|
> As a rule of thumb: **the bundler and the runtime both support the same set of file types out of the box.**
|
|
9
9
|
|
|
10
|
-
`.js` `.cjs` `.mjs` `.mts` `.cts` `.ts` `.tsx` `.jsx` `.
|
|
10
|
+
`.js` `.cjs` `.mjs` `.mts` `.cts` `.ts` `.tsx` `.jsx` `.css` `.json` `.jsonc` `.toml` `.yaml` `.yml` `.txt` `.wasm` `.node` `.html` `.sh`
|
|
11
11
|
|
|
12
12
|
Bun uses the file extension to determine which built-in loader should be used to parse the file. Every loader has a name, such as `js`, `tsx`, or `json`. These names are used when building plugins that extend Bun with custom loaders.
|
|
13
13
|
|
|
14
|
-
You can explicitly specify which loader to use using the `'
|
|
14
|
+
You can explicitly specify which loader to use using the `'type'` import attribute.
|
|
15
15
|
|
|
16
16
|
```ts title="index.ts" icon="/icons/typescript.svg"
|
|
17
|
-
import my_toml from "./my_file" with {
|
|
17
|
+
import my_toml from "./my_file" with { type: "toml" };
|
|
18
|
+
// or with dynamic imports
|
|
19
|
+
const { default: my_toml } = await import("./my_file", { with: { type: "toml" } });
|
|
18
20
|
```
|
|
19
21
|
|
|
20
22
|
## Built-in loaders
|
|
@@ -85,7 +87,7 @@ If a `.json` file is passed as an entrypoint to the bundler, it will be converte
|
|
|
85
87
|
}
|
|
86
88
|
```
|
|
87
89
|
|
|
88
|
-
```
|
|
90
|
+
```js Output
|
|
89
91
|
export default {
|
|
90
92
|
name: "John Doe",
|
|
91
93
|
age: 35,
|
|
@@ -97,7 +99,32 @@ export default {
|
|
|
97
99
|
|
|
98
100
|
---
|
|
99
101
|
|
|
100
|
-
###
|
|
102
|
+
### `jsonc`
|
|
103
|
+
|
|
104
|
+
**JSON with Comments loader.** Default for `.jsonc`.
|
|
105
|
+
|
|
106
|
+
JSONC (JSON with Comments) files can be directly imported. Bun will parse them, stripping out comments and trailing commas.
|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
import config from "./config.jsonc";
|
|
110
|
+
console.log(config);
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
During bundling, the parsed JSONC is inlined into the bundle as a JavaScript object, identical to the `json` loader.
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
var config = {
|
|
117
|
+
option: "value",
|
|
118
|
+
};
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
<Note>
|
|
122
|
+
Bun automatically uses the `jsonc` loader for `tsconfig.json`, `jsconfig.json`, `package.json`, and `bun.lock` files.
|
|
123
|
+
</Note>
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
### `toml`
|
|
101
128
|
|
|
102
129
|
**TOML loader.** Default for `.toml`.
|
|
103
130
|
|
|
@@ -131,7 +158,7 @@ age = 35
|
|
|
131
158
|
email = "johndoe@example.com"
|
|
132
159
|
```
|
|
133
160
|
|
|
134
|
-
```
|
|
161
|
+
```js Output
|
|
135
162
|
export default {
|
|
136
163
|
name: "John Doe",
|
|
137
164
|
age: 35,
|
|
@@ -143,7 +170,53 @@ export default {
|
|
|
143
170
|
|
|
144
171
|
---
|
|
145
172
|
|
|
146
|
-
###
|
|
173
|
+
### `yaml`
|
|
174
|
+
|
|
175
|
+
**YAML loader.** Default for `.yaml` and `.yml`.
|
|
176
|
+
|
|
177
|
+
YAML files can be directly imported. Bun will parse them with its fast native YAML parser.
|
|
178
|
+
|
|
179
|
+
```js
|
|
180
|
+
import config from "./config.yaml";
|
|
181
|
+
console.log(config);
|
|
182
|
+
|
|
183
|
+
// via import attribute:
|
|
184
|
+
import data from "./data.txt" with { type: "yaml" };
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
During bundling, the parsed YAML is inlined into the bundle as a JavaScript object.
|
|
188
|
+
|
|
189
|
+
```js
|
|
190
|
+
var config = {
|
|
191
|
+
name: "my-app",
|
|
192
|
+
version: "1.0.0",
|
|
193
|
+
// ...other fields
|
|
194
|
+
};
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
If a `.yaml` or `.yml` file is passed as an entrypoint, it will be converted to a `.js` module that `export default`s the parsed object.
|
|
198
|
+
|
|
199
|
+
<CodeGroup>
|
|
200
|
+
|
|
201
|
+
```yaml Input
|
|
202
|
+
name: John Doe
|
|
203
|
+
age: 35
|
|
204
|
+
email: johndoe@example.com
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
```js Output
|
|
208
|
+
export default {
|
|
209
|
+
name: "John Doe",
|
|
210
|
+
age: 35,
|
|
211
|
+
email: "johndoe@example.com",
|
|
212
|
+
};
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
</CodeGroup>
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
### `text`
|
|
147
220
|
|
|
148
221
|
**Text loader.** Default for `.txt`.
|
|
149
222
|
|
|
@@ -173,7 +246,7 @@ If a `.txt` file is passed as an entrypoint, it will be converted to a `.js` mod
|
|
|
173
246
|
Hello, world!
|
|
174
247
|
```
|
|
175
248
|
|
|
176
|
-
```
|
|
249
|
+
```js Output
|
|
177
250
|
export default "Hello, world!";
|
|
178
251
|
```
|
|
179
252
|
|
|
@@ -181,7 +254,7 @@ export default "Hello, world!";
|
|
|
181
254
|
|
|
182
255
|
---
|
|
183
256
|
|
|
184
|
-
### napi
|
|
257
|
+
### `napi`
|
|
185
258
|
|
|
186
259
|
**Native addon loader.** Default for `.node`.
|
|
187
260
|
|
|
@@ -196,7 +269,7 @@ console.log(addon);
|
|
|
196
269
|
|
|
197
270
|
---
|
|
198
271
|
|
|
199
|
-
### sqlite
|
|
272
|
+
### `sqlite`
|
|
200
273
|
|
|
201
274
|
**SQLite loader.** Requires `with { "type": "sqlite" }` import attribute.
|
|
202
275
|
|
|
@@ -226,7 +299,9 @@ Otherwise, the database to embed is copied into the `outdir` with a hashed filen
|
|
|
226
299
|
|
|
227
300
|
---
|
|
228
301
|
|
|
229
|
-
### html
|
|
302
|
+
### `html`
|
|
303
|
+
|
|
304
|
+
**HTML loader.** Default for `.html`.
|
|
230
305
|
|
|
231
306
|
The `html` loader processes HTML files and bundles any referenced assets. It will:
|
|
232
307
|
|
|
@@ -301,7 +376,27 @@ The `html` loader behaves differently depending on how it's used:
|
|
|
301
376
|
|
|
302
377
|
---
|
|
303
378
|
|
|
304
|
-
###
|
|
379
|
+
### `css`
|
|
380
|
+
|
|
381
|
+
**CSS loader.** Default for `.css`.
|
|
382
|
+
|
|
383
|
+
CSS files can be directly imported. The bundler will parse and bundle CSS files, handling `@import` statements and `url()` references.
|
|
384
|
+
|
|
385
|
+
```js
|
|
386
|
+
import "./styles.css";
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
During bundling, all imported CSS files are bundled together into a single `.css` file in the output directory.
|
|
390
|
+
|
|
391
|
+
```css
|
|
392
|
+
.my-class {
|
|
393
|
+
background: url("./image.png");
|
|
394
|
+
}
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
---
|
|
398
|
+
|
|
399
|
+
### `sh`
|
|
305
400
|
|
|
306
401
|
**Bun Shell loader.** Default for `.sh` files.
|
|
307
402
|
|
|
@@ -313,7 +408,7 @@ bun run ./script.sh
|
|
|
313
408
|
|
|
314
409
|
---
|
|
315
410
|
|
|
316
|
-
### file
|
|
411
|
+
### `file`
|
|
317
412
|
|
|
318
413
|
**File loader.** Default for all unrecognized file types.
|
|
319
414
|
|