bun-types 1.3.3-canary.20251111T140653 → 1.3.3-canary.20251113T140630
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 +4 -4
- package/docs/bundler/html-static.mdx +17 -3
- package/docs/bundler/index.mdx +19 -1
- package/docs/bundler/loaders.mdx +105 -11
- 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/install/azure-artifacts.mdx +1 -1
- package/docs/guides/install/jfrog-artifactory.mdx +1 -1
- package/docs/guides/runtime/define-constant.mdx +1 -1
- package/docs/guides/runtime/import-html.mdx +0 -2
- package/docs/guides/runtime/typescript.mdx +1 -1
- package/docs/guides/test/snapshot.mdx +2 -2
- package/docs/pm/cli/pm.mdx +1 -1
- package/docs/pm/lifecycle.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/module-resolution.mdx +11 -2
- package/docs/runtime/networking/dns.mdx +1 -1
- package/docs/runtime/plugins.mdx +15 -1
- package/docs/runtime/s3.mdx +1 -1
- package/docs/runtime/sqlite.mdx +0 -2
- package/docs/runtime/workers.mdx +1 -3
- 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>
|
|
@@ -154,8 +154,8 @@ Using bytecode compilation, `tsc` starts 2x faster:
|
|
|
154
154
|
Bytecode compilation moves parsing overhead for large input files from runtime to bundle time. Your app starts faster, in exchange for making the `bun build` command a little slower. It doesn't obscure source code.
|
|
155
155
|
|
|
156
156
|
<Warning>
|
|
157
|
-
**Experimental:** Bytecode compilation is an experimental feature
|
|
158
|
-
|
|
157
|
+
**Experimental:** Bytecode compilation is an experimental feature. Only `cjs` format is supported (which means no
|
|
158
|
+
top-level-await). Let us know if you run into any issues!
|
|
159
159
|
</Warning>
|
|
160
160
|
|
|
161
161
|
### What do these flags do?
|
|
@@ -320,7 +320,7 @@ new Worker(new URL("./my-worker.ts", import.meta.url));
|
|
|
320
320
|
new Worker(new URL("./my-worker.ts", import.meta.url).href);
|
|
321
321
|
```
|
|
322
322
|
|
|
323
|
-
|
|
323
|
+
When you add multiple entrypoints to a standalone executable, they will be bundled separately into the executable.
|
|
324
324
|
|
|
325
325
|
In the future, we may automatically detect usages of statically-known paths in `new Worker(path)` and then bundle those into the executable, but for now, you'll need to add it to the shell command manually like the above example.
|
|
326
326
|
|
|
@@ -395,7 +395,7 @@ This database is read-write, but all changes are lost when the executable exits
|
|
|
395
395
|
|
|
396
396
|
### Embed N-API Addons
|
|
397
397
|
|
|
398
|
-
|
|
398
|
+
You can embed `.node` files into executables.
|
|
399
399
|
|
|
400
400
|
```ts index.ts icon="/icons/typescript.svg"
|
|
401
401
|
const addon = require("./addon.node");
|
|
@@ -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,7 +7,7 @@ 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
|
|
|
@@ -85,7 +85,7 @@ If a `.json` file is passed as an entrypoint to the bundler, it will be converte
|
|
|
85
85
|
}
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
-
```
|
|
88
|
+
```js Output
|
|
89
89
|
export default {
|
|
90
90
|
name: "John Doe",
|
|
91
91
|
age: 35,
|
|
@@ -97,7 +97,33 @@ export default {
|
|
|
97
97
|
|
|
98
98
|
---
|
|
99
99
|
|
|
100
|
-
###
|
|
100
|
+
### `jsonc`
|
|
101
|
+
|
|
102
|
+
**JSON with Comments loader.** Default for `.jsonc`.
|
|
103
|
+
|
|
104
|
+
JSONC (JSON with Comments) files can be directly imported. Bun will parse them, stripping out comments and trailing commas.
|
|
105
|
+
|
|
106
|
+
```js
|
|
107
|
+
import config from "./config.jsonc";
|
|
108
|
+
console.log(config);
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
During bundling, the parsed JSONC is inlined into the bundle as a JavaScript object, identical to the `json` loader.
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
var config = {
|
|
115
|
+
option: "value",
|
|
116
|
+
};
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
<Note>
|
|
120
|
+
Bun automatically uses the `jsonc` loader for `tsconfig.json`, `jsconfig.json`, `package.json`, and `bun.lock` files,
|
|
121
|
+
allowing comments and trailing commas in these files.
|
|
122
|
+
</Note>
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
### `toml`
|
|
101
127
|
|
|
102
128
|
**TOML loader.** Default for `.toml`.
|
|
103
129
|
|
|
@@ -131,7 +157,7 @@ age = 35
|
|
|
131
157
|
email = "johndoe@example.com"
|
|
132
158
|
```
|
|
133
159
|
|
|
134
|
-
```
|
|
160
|
+
```js Output
|
|
135
161
|
export default {
|
|
136
162
|
name: "John Doe",
|
|
137
163
|
age: 35,
|
|
@@ -143,7 +169,53 @@ export default {
|
|
|
143
169
|
|
|
144
170
|
---
|
|
145
171
|
|
|
146
|
-
###
|
|
172
|
+
### `yaml`
|
|
173
|
+
|
|
174
|
+
**YAML loader.** Default for `.yaml` and `.yml`.
|
|
175
|
+
|
|
176
|
+
YAML files can be directly imported. Bun will parse them with its fast native YAML parser.
|
|
177
|
+
|
|
178
|
+
```js
|
|
179
|
+
import config from "./config.yaml";
|
|
180
|
+
console.log(config);
|
|
181
|
+
|
|
182
|
+
// via import attribute:
|
|
183
|
+
import data from "./data.txt" with { type: "yaml" };
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
During bundling, the parsed YAML is inlined into the bundle as a JavaScript object.
|
|
187
|
+
|
|
188
|
+
```js
|
|
189
|
+
var config = {
|
|
190
|
+
name: "my-app",
|
|
191
|
+
version: "1.0.0",
|
|
192
|
+
// ...other fields
|
|
193
|
+
};
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
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.
|
|
197
|
+
|
|
198
|
+
<CodeGroup>
|
|
199
|
+
|
|
200
|
+
```yaml Input
|
|
201
|
+
name: John Doe
|
|
202
|
+
age: 35
|
|
203
|
+
email: johndoe@example.com
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
```js Output
|
|
207
|
+
export default {
|
|
208
|
+
name: "John Doe",
|
|
209
|
+
age: 35,
|
|
210
|
+
email: "johndoe@example.com",
|
|
211
|
+
};
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
</CodeGroup>
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
### `text`
|
|
147
219
|
|
|
148
220
|
**Text loader.** Default for `.txt`.
|
|
149
221
|
|
|
@@ -173,7 +245,7 @@ If a `.txt` file is passed as an entrypoint, it will be converted to a `.js` mod
|
|
|
173
245
|
Hello, world!
|
|
174
246
|
```
|
|
175
247
|
|
|
176
|
-
```
|
|
248
|
+
```js Output
|
|
177
249
|
export default "Hello, world!";
|
|
178
250
|
```
|
|
179
251
|
|
|
@@ -181,7 +253,7 @@ export default "Hello, world!";
|
|
|
181
253
|
|
|
182
254
|
---
|
|
183
255
|
|
|
184
|
-
### napi
|
|
256
|
+
### `napi`
|
|
185
257
|
|
|
186
258
|
**Native addon loader.** Default for `.node`.
|
|
187
259
|
|
|
@@ -196,7 +268,7 @@ console.log(addon);
|
|
|
196
268
|
|
|
197
269
|
---
|
|
198
270
|
|
|
199
|
-
### sqlite
|
|
271
|
+
### `sqlite`
|
|
200
272
|
|
|
201
273
|
**SQLite loader.** Requires `with { "type": "sqlite" }` import attribute.
|
|
202
274
|
|
|
@@ -226,7 +298,9 @@ Otherwise, the database to embed is copied into the `outdir` with a hashed filen
|
|
|
226
298
|
|
|
227
299
|
---
|
|
228
300
|
|
|
229
|
-
### html
|
|
301
|
+
### `html`
|
|
302
|
+
|
|
303
|
+
**HTML loader.** Default for `.html`.
|
|
230
304
|
|
|
231
305
|
The `html` loader processes HTML files and bundles any referenced assets. It will:
|
|
232
306
|
|
|
@@ -301,7 +375,27 @@ The `html` loader behaves differently depending on how it's used:
|
|
|
301
375
|
|
|
302
376
|
---
|
|
303
377
|
|
|
304
|
-
###
|
|
378
|
+
### `css`
|
|
379
|
+
|
|
380
|
+
**CSS loader.** Default for `.css`.
|
|
381
|
+
|
|
382
|
+
CSS files can be directly imported. The bundler will parse and bundle CSS files, handling `@import` statements and `url()` references.
|
|
383
|
+
|
|
384
|
+
```js
|
|
385
|
+
import "./styles.css";
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
During bundling, all imported CSS files are bundled together into a single `.css` file in the output directory.
|
|
389
|
+
|
|
390
|
+
```css
|
|
391
|
+
.my-class {
|
|
392
|
+
background: url("./image.png");
|
|
393
|
+
}
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
---
|
|
397
|
+
|
|
398
|
+
### `sh`
|
|
305
399
|
|
|
306
400
|
**Bun Shell loader.** Default for `.sh` files.
|
|
307
401
|
|
|
@@ -313,7 +407,7 @@ bun run ./script.sh
|
|
|
313
407
|
|
|
314
408
|
---
|
|
315
409
|
|
|
316
|
-
### file
|
|
410
|
+
### `file`
|
|
317
411
|
|
|
318
412
|
**File loader.** Default for all unrecognized file types.
|
|
319
413
|
|