bun-types 1.3.3-canary.20251113T140630 → 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.
@@ -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
- bun_BE_BUN=1 ./such-bun install
219
+ BUN_BE_BUN=1 ./such-bun install
220
220
  ```
221
221
 
222
222
  ```txt
@@ -11,10 +11,12 @@ The Bun bundler implements a set of default loaders out of the box.
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 `'loader'` import attribute.
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 { loader: "toml" };
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
@@ -117,8 +119,7 @@ var config = {
117
119
  ```
118
120
 
119
121
  <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
+ Bun automatically uses the `jsonc` loader for `tsconfig.json`, `jsconfig.json`, `package.json`, and `bun.lock` files.
122
123
  </Note>
123
124
 
124
125
  ---
@@ -5,14 +5,16 @@ description: "File types and loaders supported by Bun's bundler and runtime"
5
5
 
6
6
  The Bun bundler implements a set of default loaders out of the box. As a rule of thumb, the bundler and the runtime both support the same set of file types out of the box.
7
7
 
8
- `.js` `.cjs` `.mjs` `.mts` `.cts` `.ts` `.tsx` `.jsx` `.toml` `.json` `.txt` `.wasm` `.node` `.html`
8
+ `.js` `.cjs` `.mjs` `.mts` `.cts` `.ts` `.tsx` `.jsx` `.css` `.json` `.jsonc` `.toml` `.yaml` `.yml` `.txt` `.wasm` `.node` `.html` `.sh`
9
9
 
10
10
  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](/bundler/plugins) that extend Bun with custom loaders.
11
11
 
12
- You can explicitly specify which loader to use using the 'loader' import attribute.
12
+ You can explicitly specify which loader to use using the `'type'` import attribute.
13
13
 
14
14
  ```ts
15
- import my_toml from "./my_file" with { loader: "toml" };
15
+ import my_toml from "./my_file" with { type: "toml" };
16
+ // or with dynamic imports
17
+ const { default: my_toml } = await import("./my_file", { with: { type: "toml" } });
16
18
  ```
17
19
 
18
20
  ---
@@ -84,6 +86,29 @@ export default {
84
86
 
85
87
  </CodeGroup>
86
88
 
89
+ ### `jsonc`
90
+
91
+ **JSON with Comments loader**. Default for `.jsonc`.
92
+
93
+ JSONC (JSON with Comments) files can be directly imported. Bun will parse them, stripping out comments and trailing commas.
94
+
95
+ ```ts
96
+ import config from "./config.jsonc";
97
+ console.log(config);
98
+ ```
99
+
100
+ During bundling, the parsed JSONC is inlined into the bundle as a JavaScript object, identical to the `json` loader.
101
+
102
+ ```ts
103
+ var config = {
104
+ option: "value",
105
+ };
106
+ ```
107
+
108
+ <Note>
109
+ Bun automatically uses the `jsonc` loader for `tsconfig.json`, `jsconfig.json`, `package.json`, and `bun.lock` files.
110
+ </Note>
111
+
87
112
  ### `toml`
88
113
 
89
114
  **TOML loader**. Default for `.toml`.
@@ -128,6 +153,50 @@ export default {
128
153
 
129
154
  </CodeGroup>
130
155
 
156
+ ### `yaml`
157
+
158
+ **YAML loader**. Default for `.yaml` and `.yml`.
159
+
160
+ YAML files can be directly imported. Bun will parse them with its fast native YAML parser.
161
+
162
+ ```ts
163
+ import config from "./config.yaml";
164
+ console.log(config);
165
+
166
+ // via import attribute:
167
+ import data from "./data.txt" with { type: "yaml" };
168
+ ```
169
+
170
+ During bundling, the parsed YAML is inlined into the bundle as a JavaScript object.
171
+
172
+ ```ts
173
+ var config = {
174
+ name: "my-app",
175
+ version: "1.0.0",
176
+ // ...other fields
177
+ };
178
+ ```
179
+
180
+ 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.
181
+
182
+ <CodeGroup>
183
+
184
+ ```yaml Input
185
+ name: John Doe
186
+ age: 35
187
+ email: johndoe@example.com
188
+ ```
189
+
190
+ ```ts Output
191
+ export default {
192
+ name: "John Doe",
193
+ age: 35,
194
+ email: "johndoe@example.com",
195
+ };
196
+ ```
197
+
198
+ </CodeGroup>
199
+
131
200
  ### `text`
132
201
 
133
202
  **Text loader**. Default for `.txt`.
@@ -283,6 +352,18 @@ The `html` loader behaves differently depending on how it's used:
283
352
 
284
353
  </Note>
285
354
 
355
+ ### `css`
356
+
357
+ **CSS loader**. Default for `.css`.
358
+
359
+ CSS files can be directly imported. This is primarily useful for [full-stack applications](/bundler/html-static) where CSS is bundled alongside HTML.
360
+
361
+ ```ts
362
+ import "./styles.css";
363
+ ```
364
+
365
+ There isn't any value returned from the import, it's only used for side effects.
366
+
286
367
  ### `sh` loader
287
368
 
288
369
  **Bun Shell loader**. Default for `.sh` files
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.3.3-canary.20251113T140630",
2
+ "version": "1.3.3-canary.20251114T140703",
3
3
  "name": "bun-types",
4
4
  "license": "MIT",
5
5
  "types": "./index.d.ts",