mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 19:08:50 +00:00
29 lines
1.1 KiB
Markdown
29 lines
1.1 KiB
Markdown
A loader determines how to map imports & file extensions to transforms and output.
|
|
|
|
Currently, Bun implements the following loaders:
|
|
|
|
| Input | Loader | Output |
|
|
| ----- | ----------------------------- | ------ |
|
|
| .js | JSX + JavaScript | .js |
|
|
| .jsx | JSX + JavaScript | .js |
|
|
| .ts | TypeScript + JavaScript | .js |
|
|
| .tsx | TypeScript + JSX + JavaScript | .js |
|
|
| .mjs | JavaScript | .js |
|
|
| .cjs | JavaScript | .js |
|
|
| .mts | TypeScript | .js |
|
|
| .cts | TypeScript | .js |
|
|
| .toml | TOML | .js |
|
|
| .css | CSS | .css |
|
|
| .env | Env | N/A |
|
|
| .\* | file | string |
|
|
|
|
Everything else is treated as `file`. `file` replaces the import with a URL (or a path).
|
|
|
|
You can configure which loaders map to which extensions by passing `--loaders` to `bun`. For example:
|
|
|
|
```sh
|
|
$ bun --loader=.js:js
|
|
```
|
|
|
|
This will disable JSX transforms for `.js` files.
|