## TypeScript Bun natively supports TypeScript out of the box. All files are transpiled on the fly by Bun's fast native transpiler before being executed. Similar to other build tools, Bun does not perform typechecking; it simply removes type annotations from the file. ```bash $ bun index.js $ bun index.jsx $ bun index.ts $ bun index.tsx ``` Some aspects of Bun's runtime behavior are affected by the contents of your `tsconfig.json` file. Refer to [Runtime > TypeScript](/docs/runtime/typescript) page for details. ## JSX Bun supports `.jsx` and `.tsx` files out of the box. Bun's internal transpiler converts JSX syntax into vanilla JavaScript before execution. ```tsx#react.tsx function Component(props: {message: string}) { return (

{props.message}

); } console.log(); ``` Bun implements special logging for JSX to make debugging easier. ```bash $ bun run react.tsx ``` ## Text files {% callout %} Supported in Bun v0.6.0 canary. {% /callout %} Text files can be imported as strings. {% codetabs %} ```ts#index.ts import text from "./text.txt"; console.log(text); // => "Hello world!" ``` ```txt#text.txt Hello world! ``` {% /codetabs %} ## JSON and TOML JSON and TOML files can be directly imported from a source file. The contents will be loaded and returned as a JavaScript object. ```ts import pkg from "./package.json"; import data from "./data.toml"; ``` ## WASM As of v0.5.2, experimental support exists for WASI, the [WebAssembly System Interface](https://github.com/WebAssembly/WASI). To run a `.wasm` binary with Bun: ```bash $ bun ./my-wasm-app.wasm # if the filename doesn't end with ".wasm" $ bun run ./my-wasm-app.whatever ``` {% callout %} **Note** — WASI support is based on [wasi-js](https://github.com/sagemathinc/cowasm/tree/main/packages/wasi-js). Currently, it only supports WASI binaries that use the `wasi_snapshot_preview1` or `wasi_unstable` APIs. Bun's implementation is not fully optimized for performance; this will become more of a priority as WASM grows in popularity. {% /callout %} ## Custom loaders Support for additional file types can be implemented with plugins. Refer to [Runtime > Plugins](/docs/bundler/plugins) for full documentation. rrick/fix/http-lowercase-headers Unnamed repository; edit this file 'description' to name the repository.
aboutsummaryrefslogtreecommitdiff
AgeCommit message (Expand)AuthorFilesLines
2022-06-22Cleanup testsGravatar Jarred Sumner 1-17/+6
2022-06-22Add checks in debug mode that strings being built via counting were actually ...Gravatar Jarred Sumner 1-3/+17
2022-06-22[JS Parser] Improve memory safety of error messages & logsGravatar Jarred Sumner 1-54/+131
2022-06-22[JS Parser] Fix undefined memory bug when printing an "cannot be used in stri...Gravatar Jarred Sumner 1-2/+3
2022-06-22[bun wiptest] Implement `beforeEach`, `afterEach`, `beforeAll`, `afterAll`Gravatar Jarred Sumner 1-19/+111
2022-06-22[websockets] Support receiving data of length 128 - 65354, bigger not support...Gravatar Jarred Sumner 1-154/+43
2022-06-22Better error for undefined memory hereGravatar Jarred Sumner 1-1/+3
2022-06-22Preallocate some event loop tasksGravatar Jarred Sumner 1-0/+3
2022-06-22Fix bugs with fifo tweaksGravatar Jarred Sumner 1-25/+27
2022-06-22Update test_command.zigGravatar Jarred Sumner 1-23/+120
2022-06-22`bun wiptest` improve test runner outputGravatar Jarred Sumner 1-25/+31
2022-06-22Sending worksGravatar Jarred Sumner 17-670/+1363
2022-06-22implement a custom websocket clientGravatar Jarred Sumner 9-75/+1171
2022-06-22It connects! but the frames are corruptGravatar Jarred Sumner 3-31/+34
2022-06-22WebSocket is a globalGravatar Jarred Sumner 23-266/+350
2022-06-22Fix most of the errorsGravatar Jarred Sumner 6-119/+117
2022-06-22more codeGravatar Jarred Sumner 4-58/+209
2022-06-22WIP WebSocketGravatar Jarred Sumner 19-22/+3701
2022-06-20Group zsh completion options by type (#194)Gravatar Alexander Kuznetsov 1-28/+16
2022-06-17Import most of `MessageEvent` from WebKitGravatar Jarred Sumner 18-12/+1410
2022-06-15some more testsGravatar Jarred Sumner 2-10/+62
2022-06-15Update WebKitGravatar Jarred Sumner 1-0/+0
2022-06-15[web standards] Add `CloseEvent` from WebKitGravatar Jarred Sumner 9-6/+636
2022-06-15Fix lazy loading internal streamsGravatar Jarred Sumner 13-360/+424
2022-06-15direct streams mostly workjarred/directGravatar Jarred Sumner 26-1167/+1782
2022-06-15wip direct streamsGravatar Jarred Sumner 24-398/+2276
2022-06-12ArrayBufferSink works and it's good.Gravatar Jarred Sumner 26-170/+2054
2022-06-12Fix build issueGravatar Jarred Sumner 2-0/+6
2022-06-12Delete broken submoduleGravatar Jarred Sumner 1-0/+0
2022-06-10Update Dockerfile.baseGravatar Jarred Sumner 1-1/+1
2022-06-10Update WebKitGravatar Jarred Sumner 1-0/+0
2022-06-10Update event_loop.zigGravatar Jarred Sumner 1-0/+1
2022-06-10Missing errno on linuxGravatar Jarred Sumner 1-3/+1
2022-06-10Update js_parser.zigGravatar Jarred Sumner 1-21/+200
2022-06-10Update MakefileGravatar Jarred Sumner 1-4/+4
2022-06-10wip fix linux buildGravatar Jarred Sumner 1-9/+11
2022-06-10Don't show generic crash info when given invalid bunfig.tomlGravatar Jarred Sumner 1-0/+4
2022-06-10Update logger.zigGravatar Jarred Sumner 1-0/+4
2022-06-10Show tracingGravatar Jarred Sumner 1-1/+1
2022-06-10Update bunfig.zigGravatar Jarred Sumner 1-0/+1
2022-06-10Update jest.zigGravatar Jarred Sumner 1-6/+9
2022-06-09Update bun.d.tsGravatar Jarred Sumner 1-2/+5
2022-06-09Add typesGravatar Jarred Sumner 1-2/+32
2022-06-09`new Response(stream).arrayBuffer()` + 3 moreGravatar Jarred Sumner 16-39/+478
2022-06-09fix some memory leaks with stringsGravatar Jarred Sumner 4-28/+45
2022-06-09Support console.log(myBigInt)Gravatar Jarred Sumner 1-1/+6
2022-06-09Fix defaultProps with JSX optimizationGravatar Jarred Sumner 6-34/+73
2022-06-09small perf improvements to encodingGravatar Jarred Sumner 1-43/+37
2022-06-07Update event_loop.zigGravatar Jarred Sumner 1-1/+2