diff options
author | 2023-04-13 18:26:45 -0700 | |
---|---|---|
committer | 2023-04-13 18:26:45 -0700 | |
commit | 011e157cac7698050370e24495a9002dacfceea9 (patch) | |
tree | ebb561dbda3e8f67302cc4d5b398f4a2744f7884 /docs/ecosystem | |
parent | 0cc56e8efce9c7d4905b3649827bf9b40a677b25 (diff) | |
download | bun-011e157cac7698050370e24495a9002dacfceea9.tar.gz bun-011e157cac7698050370e24495a9002dacfceea9.tar.zst bun-011e157cac7698050370e24495a9002dacfceea9.zip |
Docs restructuring (#2638)
* Restructure
* Update nav
* Reorg
* Reshuffle ecosystem pages
* Split up runtime/runtime
* Back to runtime/index
* Fix issue
* Split up runtime/index
* Add Writing Tests page
* Prettier matcher table
* More updates
Diffstat (limited to 'docs/ecosystem')
-rw-r--r-- | docs/ecosystem/express.md | 6 | ||||
-rw-r--r-- | docs/ecosystem/nodejs.md | 682 | ||||
-rw-r--r-- | docs/ecosystem/react.md | 8 | ||||
-rw-r--r-- | docs/ecosystem/typescript.md | 92 |
4 files changed, 7 insertions, 781 deletions
diff --git a/docs/ecosystem/express.md b/docs/ecosystem/express.md index 856d2aafc..bbca048ab 100644 --- a/docs/ecosystem/express.md +++ b/docs/ecosystem/express.md @@ -1,7 +1,7 @@ -Projects that use Express and other major Node.js HTTP libraries should work out of the box. +Projects that use Express and other major Node.js HTTP libraries should work out of the box. {% callout %} -If you run into bugs, [please file an issue](https://bun.sh/issues) *in Bun's repo*, not the library. It is Bun's responsibility to address Node.js compatibility issues. +If you run into bugs, [please file an issue](https://bun.sh/issues) _in Bun's repo_, not the library. It is Bun's responsibility to address Node.js compatibility issues. {% /callout %} ```ts @@ -22,7 +22,7 @@ app.listen(port, () => { Bun implements the [`node:http`](https://nodejs.org/api/http.html) and [`node:https`](https://nodejs.org/api/https.html) modules that these libraries rely on. These modules can also be used directly, though [`Bun.serve`](/docs/api/http) is recommended for most use cases. {% callout %} -**Note** — Refer to the [Runtime > Node.js APIs](/docs/ecosystem/nodejs#node_http) page for more detailed compatibility information. +**Note** — Refer to the [Runtime > Node.js APIs](/docs/runtime/nodejs-apis#node_http) page for more detailed compatibility information. {% /callout %} ```ts diff --git a/docs/ecosystem/nodejs.md b/docs/ecosystem/nodejs.md deleted file mode 100644 index c821d3d9a..000000000 --- a/docs/ecosystem/nodejs.md +++ /dev/null @@ -1,682 +0,0 @@ -Bun aims for complete Node.js API compatibility. Most `npm` packages intended for `Node.js` environments will work with Bun out of the box; the best way to know for certain is to try it. - -This page is updated regularly to reflect compatibility status of the latest version of Bun. - -## Built-in modules - -{% block className="ScrollFrame" %} -{% table %} - -- Module -- Status -- Notes - ---- - -- {% anchor id="node_assert" %} [`node:assert`](https://nodejs.org/api/assert.html) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_async_hooks" %} [`node:async_hooks`](https://nodejs.org/api/async_hooks.html) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_buffer" %} [`node:buffer`](https://nodejs.org/api/buffer.html) {% /anchor %} -- 🟡 -- Incomplete implementation of `base64` and `base64url` encodings. - ---- - -- {% anchor id="node_child_process" %} [`node:child_process`](https://nodejs.org/api/child_process.html) {% /anchor %} -- 🟡 -- Missing IPC, `Stream` stdio, `proc.gid`, `proc.uid`, advanced serialization. - ---- - -- {% anchor id="node_cluster" %} [`node:cluster`](https://nodejs.org/api/cluster.html) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_console" %} [`node:console`](https://nodejs.org/api/console.html) {% /anchor %} -- 🟢 -- Recommended to use `console` global instead - ---- - -- {% anchor id="node_crypto" %} [`node:crypto`](https://nodejs.org/api/crypto.html) {% /anchor %} -- 🟡 -- Missing `crypto.Certificate` `crypto.ECDH` `crypto.KeyObject` `crypto.X509Certificate` `crypto.checkPrime{Sync}` `crypto.createPrivateKey` `crypto.createPublicKey` `crypto.createSecretKey` `crypto.diffieHellman` `crypto.generateKey{Sync}` `crypto.generateKeyPair{Sync}` `crypto.generatePrime{Sync}` `crypto.getCipherInfo` `crypto.getCurves` `crypto.{get|set}Fips` `crypto.hkdf` `crypto.hkdfSync` `crypto.randomInt` `crypto.secureHeapUsed` `crypto.setEngine` `crypto.sign` `crypto.verify` - ---- - -- {% anchor id="node_dgram" %} [`node:dgram`](https://nodejs.org/api/dgram.html) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_diagnostics_channel" %} [`node:diagnostics_channel`](https://nodejs.org/api/diagnostics_channel.html) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_dns" %} [`node:dns`](https://nodejs.org/api/dns.html) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_domain" %} [`node:domain`](https://nodejs.org/api/domain.html) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_events" %} [`node:events`](https://nodejs.org/api/events.html) {% /anchor %} -- 🟡 -- Missing `EventEmitterAsyncResource`. `EventEmitter` is missing `{get}set}MaxListeners` `usingDomains` `init`. - ---- - -- {% anchor id="node_fs" %} [`node:fs`](https://nodejs.org/api/fs.html) {% /anchor %} -- 🟡 -- Missing `fs.fdatasync{Sync}` `fs.opendir{Sync}` `fs.readv{Sync}` `fs.{watch|watchFile|unwatchFile}` `fs.writev{Sync}`. - ---- - -- {% anchor id="node_http" %} [`node:http`](https://nodejs.org/api/http.html) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_http2" %} [`node:http2`](https://nodejs.org/api/http2.html) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_https" %} [`node:https`](https://nodejs.org/api/https.html) {% /anchor %} -- 🟡 -- See `node:http`. - ---- - -- {% anchor id="node_inspector" %} [`node:inspector`](https://nodejs.org/api/inspector.html) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_module" %} [`node:module`](https://nodejs.org/api/module.html) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_net" %} [`node:net`](https://nodejs.org/api/net.html) {% /anchor %} -- 🟡 -- Missing `net.createServer` `net.{get|set}DefaultAutoSelectFamily` `net.SocketAddress` `net.BlockList`. - ---- - -- {% anchor id="node_os" %} [`node:os`](https://nodejs.org/api/os.html) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_path" %} [`node:path`](https://nodejs.org/api/path.html) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_perf_hooks" %} [`node:perf_hooks`](https://nodejs.org/api/perf_hooks.html) {% /anchor %} -- 🟡 -- Only `perf_hooks.performance.now()` and `perf_hooks.performance.timeOrigin` are implemented. Recommended to use `performance` global instead of `perf_hooks.performance`. - ---- - -- {% anchor id="node_process" %} [`node:process`](https://nodejs.org/api/process.html) {% /anchor %} -- 🟡 -- See `Globals > process`. - ---- - -- {% anchor id="node_punycode" %} [`node:punycode`](https://nodejs.org/api/punycode.html) {% /anchor %} -- 🟢 -- Fully implemented. _Deprecated by Node.js._ - ---- - -- {% anchor id="node_querystring" %} [`node:querystring`](https://nodejs.org/api/querystring.html) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_readline" %} [`node:readline`](https://nodejs.org/api/readline.html) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_repl" %} [`node:repl`](https://nodejs.org/api/repl.html) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_stream" %} [`node:stream`](https://nodejs.org/api/stream.html) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_string_decoder" %} [`node:string_decoder`](https://nodejs.org/api/string_decoder.html) {% /anchor %} -- 🟢 - ---- - -- {% anchor id="node_sys" %} [`node:sys`](https://nodejs.org/api/util.html) {% /anchor %} -- 🟡 -- See `node:util`. - ---- - -- {% anchor id="node_timers" %} [`node:timers`](https://nodejs.org/api/timers.html) {% /anchor %} -- 🟢 -- Recommended to use global `setTimeout`, et. al. instead. - ---- - -- {% anchor id="node_tls" %} [`node:tls`](https://nodejs.org/api/tls.html) {% /anchor %} -- 🟡 -- Missing `tls.Server` `tls.createServer` `tls.createSecurePair` `tls.checkServerIdentity` `tls.rootCertificates` - ---- - -- {% anchor id="node_trace_events" %} [`node:trace_events`](https://nodejs.org/api/tracing.html) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_tty" %} [`node:tty`](https://nodejs.org/api/tty.html) {% /anchor %} -- 🟡 -- Missing `tty.ReadStream` and `tty.WriteStream`. - ---- - -- {% anchor id="node_url" %} [`node:url`](https://nodejs.org/api/url.html) {% /anchor %} -- 🟡 -- Missing `url.domainTo{ASCII|Unicode}` `url.urlToHttpOptions`. Recommended to use `URL` and `URLSearchParams` globals instead. - ---- - -- {% anchor id="node_util" %} [`node:util`](https://nodejs.org/api/util.html) {% /anchor %} -- 🟡 -- Missing `util.MIMEParams` `util.MIMEType` `util.formatWithOptions()` `util.getSystemErrorMap()` `util.getSystemErrorName()` `util.parseArgs()` `util.stripVTControlCharacters()` `util.toUSVString()` `util.transferableAbortController()` `util.transferableAbortSignal()`. - ---- - -- {% anchor id="node_v8" %} [`node:v8`](https://nodejs.org/api/v8.html) {% /anchor %} -- 🔴 -- Not implemented or planned. For profiling, use `bun:jsc` instead. - ---- - -- {% anchor id="node_vm" %} [`node:vm`](https://nodejs.org/api/vm.html) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_wasi" %} [`node:wasi`](https://nodejs.org/api/wasi.html) {% /anchor %} -- 🟡 -- Partially implemented. - ---- - -- {% anchor id="node_worker_threads" %} [`node:worker_threads`](https://nodejs.org/api/worker_threads.html) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_zlib" %} [`node:zlib`](https://nodejs.org/api/zlib.html) {% /anchor %} -- 🟡 -- Missing `zlib.brotli*` - -{% /table %} -{% /block %} - -## Globals - -The table below lists all globals implemented by Node.js and Bun's current compatibility status. - -{% table %} - ---- - -- {% anchor id="node_abortcontroller" %} [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_abortsignal" %} [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_blob" %} [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_buffer" %} [`Buffer`](https://nodejs.org/api/buffer.html#class-buffer) {% /anchor %} -- 🟡 -- Incomplete implementation of `base64` and `base64url` encodings. - ---- - -- {% anchor id="node_bytelengthqueuingstrategy" %} [`ByteLengthQueuingStrategy`](https://developer.mozilla.org/en-US/docs/Web/API/ByteLengthQueuingStrategy) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_dirname" %} [`__dirname`](https://nodejs.org/api/globals.html#__dirname) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_filename" %} [`__filename`](https://nodejs.org/api/globals.html#__filename) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_atob" %} [`atob()`](https://developer.mozilla.org/en-US/docs/Web/API/atob) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_broadcastchannel" %} [`BroadcastChannel`](https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_btoa" %} [`btoa()`](https://developer.mozilla.org/en-US/docs/Web/API/btoa) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_clearimmediate" %} [`clearImmediate()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/clearImmediate) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_clearinterval" %} [`clearInterval()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/clearInterval) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_cleartimeout" %} [`clearTimeout()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/clearTimeout) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_compressionstream" %} [`CompressionStream`](https://developer.mozilla.org/en-US/docs/Web/API/CompressionStream) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_console" %} [`console`](https://developer.mozilla.org/en-US/docs/Web/API/console) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_countqueuingstrategy" %} [`CountQueuingStrategy`](https://developer.mozilla.org/en-US/docs/Web/API/CountQueuingStrategy) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_crypto" %} [`Crypto`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_crypto" %} [`crypto`](https://developer.mozilla.org/en-US/docs/Web/API/crypto) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_cryptokey" %} [`CryptoKey`](https://developer.mozilla.org/en-US/docs/Web/API/CryptoKey) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_customevent" %} [`CustomEvent`](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_decompressionstream" %} [`DecompressionStream`](https://developer.mozilla.org/en-US/docs/Web/API/DecompressionStream) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_event" %} [`Event`](https://developer.mozilla.org/en-US/docs/Web/API/Event) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_eventtarget" %} [`EventTarget`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_exports" %} [`exports`](https://nodejs.org/api/globals.html#exports) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_fetch" %} [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/fetch) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_formdata" %} [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) {% /anchor %} -- 🟢 -- Fully implemented. Added in Bun 0.5.7. - ---- - -- {% anchor id="node_global" %} [`global`](https://nodejs.org/api/globals.html#global) {% /anchor %} -- 🟢 -- Implemented. This is an object containing all objects in the global namespace. It's rarely referenced directly, as its contents are available without an additional prefix, e.g. `__dirname` instead of `global.__dirname`. - ---- - -- {% anchor id="node_globalthis" %} [`globalThis`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis) {% /anchor %} -- 🟢 -- Aliases to `global`. - ---- - -- {% anchor id="node_headers" %} [`Headers`](https://developer.mozilla.org/en-US/docs/Web/API/Headers) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_messagechannel" %} [`MessageChannel`](https://developer.mozilla.org/en-US/docs/Web/API/MessageChannel) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_messageevent" %} [`MessageEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_messageport" %} [`MessagePort`](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_module" %} [`module`](https://nodejs.org/api/globals.html#module) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_performanceentry" %} [`PerformanceEntry`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceEntry) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_performancemark" %} [`PerformanceMark`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceMark) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_performancemeasure" %} [`PerformanceMeasure`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceMeasure) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_performanceobserver" %} [`PerformanceObserver`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserver) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_performanceobserverentrylist" %} [`PerformanceObserverEntryList`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceObserverEntryList) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_performanceresourcetiming" %} [`PerformanceResourceTiming`](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_performance" %} [`performance`](https://developer.mozilla.org/en-US/docs/Web/API/performance) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_process" %} [`process`](https://nodejs.org/api/process.html) {% /anchor %} -- 🟡 -- Missing `process.allowedNodeEnvironmentFlags` `process.channel()` `process.connected` `process.constrainedMemory()` `process.cpuUsage()` `process.debugPort` `process.disconnect()` `process.{get|set}ActiveResourcesInfo()` `process.{get|set}{uid|gid|egid|euid|groups}()` `process.hasUncaughtExceptionCaptureCallback` `process.initGroups()` `process.kill()` `process.listenerCount` `process.memoryUsage()` `process.report` `process.resourceUsage()` `process.setSourceMapsEnabled()` `process.send()`. - ---- - -- {% anchor id="node_queuemicrotask" %} [`queueMicrotask()`](https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_readablebytestreamcontroller" %} [`ReadableByteStreamController`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableByteStreamController) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_readablestream" %} [`ReadableStream`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_readablestreambyobreader" %} [`ReadableStreamBYOBReader`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamBYOBReader) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_readablestreambyobrequest" %} [`ReadableStreamBYOBRequest`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamBYOBRequest) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_readablestreamdefaultcontroller" %} [`ReadableStreamDefaultController`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultController) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_readablestreamdefaultreader" %} [`ReadableStreamDefaultReader`](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_require" %} [`require()`](https://nodejs.org/api/globals.html#require) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_response" %} [`Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_request" %} [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_setimmediate" %} [`setImmediate()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/setImmediate) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_setinterval" %} [`setInterval()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/setInterval) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_settimeout" %} [`setTimeout()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/setTimeout) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_structuredclone" %} [`structuredClone()`](https://developer.mozilla.org/en-US/docs/Web/API/structuredClone) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_subtlecrypto" %} [`SubtleCrypto`](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_domexception" %} [`DOMException`](https://developer.mozilla.org/en-US/docs/Web/API/DOMException) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_textdecoder" %} [`TextDecoder`](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_textdecoderstream" %} [`TextDecoderStream`](https://developer.mozilla.org/en-US/docs/Web/API/TextDecoderStream) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_textencoder" %} [`TextEncoder`](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_textencoderstream" %} [`TextEncoderStream`](https://developer.mozilla.org/en-US/docs/Web/API/TextEncoderStream) {% /anchor %} -- 🔴 -- Not implemented. - ---- - -- {% anchor id="node_transformstream" %} [`TransformStream`](https://developer.mozilla.org/en-US/docs/Web/API/TransformStream) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_transformstreamdefaultcontroller" %} [`TransformStreamDefaultController`](https://developer.mozilla.org/en-US/docs/Web/API/TransformStreamDefaultController) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_url" %} [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_urlsearchparams" %} [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_webassembly" %} [`WebAssembly`](https://nodejs.org/api/globals.html#webassembly) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_writablestream" %} [`WritableStream`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStream) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_writablestreamdefaultcontroller" %} [`WritableStreamDefaultController`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStreamDefaultController) {% /anchor %} -- 🟢 -- Fully implemented. - ---- - -- {% anchor id="node_writablestreamdefaultwriter" %} [`WritableStreamDefaultWriter`](https://developer.mozilla.org/en-US/docs/Web/API/WritableStreamDefaultWriter) {% /anchor %} -- 🟢 -- Fully implemented. - -{% /table %} diff --git a/docs/ecosystem/react.md b/docs/ecosystem/react.md index 197edb30f..84f1a4536 100644 --- a/docs/ecosystem/react.md +++ b/docs/ecosystem/react.md @@ -19,23 +19,23 @@ $ bun run react.tsx <Component message="Hello world!" /> ``` -### Prop punning +### Prop punning -The Bun runtime also supports "prop punning for JSX. This is a shorthand syntax useful for assigning a variable to a prop with the same name. +The Bun runtime also supports "prop punning" for JSX. This is a shorthand syntax useful for assigning a variable to a prop with the same name. ```tsx function Div(props: {className: string;}) { const {className} = props; - + // without punning return <div className={className} />; // with punning return <div {className} />; - } ``` ### Server-side rendering + To server-side render (SSR) React in an [HTTP server](/docs/api/http): ```tsx#ssr.tsx diff --git a/docs/ecosystem/typescript.md b/docs/ecosystem/typescript.md deleted file mode 100644 index dfedfb850..000000000 --- a/docs/ecosystem/typescript.md +++ /dev/null @@ -1,92 +0,0 @@ -Bun can directly execute `.ts` and `.tsx` files just like vanilla JavaScript, with no extra configuration. If you import a `.ts` or `.tsx` file (or an `npm` module that exports these files), Bun internally transpiles it into JavaScript then executes the file. - -{% callout %} -**Note** — Similar to other build tools, Bun does not typecheck the files. Use [`tsc --noEmit`](https://www.typescriptlang.org/docs/handbook/compiler-options.html) (the official TypeScript CLI) if you're looking to catch static type errors. -{% /callout %} - -## Type definitions - -To install TypeScript definitions for Bun's built-in APIs, first install `bun-types`. - -```sh -$ bun add -d bun-types # dev dependency -``` - -Then include `"bun-types"` in the `compilerOptions.types` in your `tsconfig.json`: - -```json-diff - { - "compilerOptions": { -+ "types": ["bun-types"] - } - } -``` - -## Compiler options - -Bun's runtime implements [modern ECMAScript features](https://github.com/sudheerj/ECMAScript-features), like bigint literals, nullish coalescing, dynamic imports, `import.meta`, `globalThis`, ES modules, top-level await, and more. To use these features without seeing TypeScript errors in your IDE, your `tsconfig.json` needs to be properly configured. - -These are the recommended `compilerOptions` for a Bun project. - -> The config below sets `moduleResolution` to `bundler` which requires TypeScript option is set to `"bundler"` to support [path mapping](#path-mapping). - -```jsonc -{ - "compilerOptions": { - // enable latest features - "lib": ["esnext"], - "module": "esnext", - "target": "esnext", - - // requires typescript 5.x+ - // use "nodenext" for earlier versions - "moduleResolution": "bundler", - - // support JSX, CommonJS - "jsx": "react-jsx", // support JSX (value doesn't matter) - "allowJs": true, // allow importing `.js` from `.ts` - "esModuleInterop": true, // allow default imports for CommonJS modules - - // best practices - "strict": true, - "forceConsistentCasingInFileNames": true, - "skipLibCheck": true, - - // add Bun type definitions - "types": ["bun-types"] - } -} -``` - -If you use `bun init`, an appropriate `tsconfig.json` is automatically generated for you. - -## Path mapping - -When resolving modules, Bun's runtime respects path mappings defined in [`compilerOptions.paths`](https://www.typescriptlang.org/tsconfig#paths) in your `tsconfig.json`. No other runtime does this. - -Given the following `tsconfig.json`... - -```json -{ - "compilerOptions": { - "paths": { - "data": ["./data.ts"] - } - } -} -``` - -...the import from `"data"` will work as expected. - -{% codetabs %} - -```ts#index.ts -import { foo } from "data"; -console.log(foo); // => "Hello world!" -``` - -```ts#data.ts -export const foo = "Hello world!" -``` - -{% /codetabs %} |