aboutsummaryrefslogtreecommitdiff
path: root/docs/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'docs/runtime')
-rw-r--r--docs/runtime/autoimport.md4
-rw-r--r--docs/runtime/hot.md4
-rw-r--r--docs/runtime/index.md6
-rw-r--r--docs/runtime/loaders.md10
-rw-r--r--docs/runtime/modules.md34
-rw-r--r--docs/runtime/nodejs-apis.md4
-rw-r--r--docs/runtime/plugins.md4
-rw-r--r--docs/runtime/web-apis.md2
8 files changed, 29 insertions, 39 deletions
diff --git a/docs/runtime/autoimport.md b/docs/runtime/autoimport.md
index d14723024..38a2badd2 100644
--- a/docs/runtime/autoimport.md
+++ b/docs/runtime/autoimport.md
@@ -1,7 +1,3 @@
-{% callout %}
-**Note** — Added in Bun v0.3.0
-{% /callout %}
-
If no `node_modules` directory is found in the working directory or higher, Bun will abandon Node.js-style module resolution in favor of the **Bun module resolution algorithm**.
Under Bun-style module resolution, all imported packages are auto-installed on the fly into a [global module cache](/docs/install/cache) during execution (the same cache used by [`bun install`](/docs/cli/install)).
diff --git a/docs/runtime/hot.md b/docs/runtime/hot.md
index 7f0b04c28..07f3f0f66 100644
--- a/docs/runtime/hot.md
+++ b/docs/runtime/hot.md
@@ -1,7 +1,7 @@
Bun supports two kinds of automatic reloading via CLI flags:
-- `--watch` mode, which hard restarts Bun's process when imported files change (introduced in Bun v0.5.9)
-- `--hot` mode, which soft reloads the code (without restarting the process) when imported files change (introduced in Bun v0.2.0)
+- `--watch` mode, which hard restarts Bun's process when imported files change/
+- `--hot` mode, which soft reloads the code (without restarting the process) when imported files change.
## `--watch` mode
diff --git a/docs/runtime/index.md b/docs/runtime/index.md
index a10ac0cff..a4174fa25 100644
--- a/docs/runtime/index.md
+++ b/docs/runtime/index.md
@@ -103,7 +103,11 @@ import bunfig from "./bunfig.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:
+{% callout %}
+🚧 **Experimental**
+{% /callout %}
+
+Bun has experimental support for WASI, the [WebAssembly System Interface](https://github.com/WebAssembly/WASI). To run a `.wasm` binary with Bun:
```bash
$ bun ./my-wasm-app.wasm
diff --git a/docs/runtime/loaders.md b/docs/runtime/loaders.md
index a483efbec..0135d9363 100644
--- a/docs/runtime/loaders.md
+++ b/docs/runtime/loaders.md
@@ -36,10 +36,6 @@ $ bun run react.tsx
## Text files
-{% callout %}
-Supported in Bun v0.6.0 canary.
-{% /callout %}
-
Text files can be imported as strings.
{% codetabs %}
@@ -67,7 +63,11 @@ 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:
+{% callout %}
+🚧 **Experimental**
+{% /callout %}
+
+Bun has experimental support for WASI, the [WebAssembly System Interface](https://github.com/WebAssembly/WASI). To run a `.wasm` binary with Bun:
```bash
$ bun ./my-wasm-app.wasm
diff --git a/docs/runtime/modules.md b/docs/runtime/modules.md
index 207315804..dd48dfa46 100644
--- a/docs/runtime/modules.md
+++ b/docs/runtime/modules.md
@@ -161,20 +161,15 @@ If you aren't a TypeScript user, you can create a [`jsconfig.json`](https://code
## CommonJS
-Bun has native support for CommonJS modules (added in Bun v0.6.5). ES Modules are the recommended module format, but CommonJS modules are still widely used in the Node.js ecosystem. Bun supports both module formats, so that existing CommonJS packages can be used.
+Bun has native support for CommonJS modules. ES Modules are the recommended module format, but CommonJS modules are still widely used in the Node.js ecosystem. Bun supports both module formats.
-In Bun's JavaScript runtime, `require` can be used by both ES Modules and CommonJS modules.
-
-In Bun, you can `require()` ESM modules from CommonJS modules.
+In Bun's JavaScript runtime, `require` can be used by both ES Modules and CommonJS modules. If the target module is an ES Module, `require` returns the module namespace object (equivalent to `import * as`). If the target module is a CommonJS module, `require` returns the `module.exports` object (as in Node.js).
| Module Type | `require()` | `import * as` |
| ----------- | ---------------- | ----------------------------------------------------------------------- |
| ES Module | Module Namespace | Module Namespace |
| CommonJS | module.exports | `default` is `module.exports`, keys of module.exports are named exports |
-If the target module is an ES Module, `require` returns the module namespace object (equivalent to `import * as`).
-If the target module is a CommonJS module, `require` returns the `module.exports` object.
-
### What is a CommonJS module?
In 2016, ECMAScript added support for [ES Modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules). ES Modules are the standard for JavaScript modules. However, millions of npm packages still use CommonJS modules.
@@ -202,19 +197,10 @@ const myStuff = require("./my-commonjs.cjs");
### Importing ESM from CommonJS
```ts
-// this works in Bun v0.6.5+
-// It does not work in Node.js
+// this works in Bun but not Node.js
const { stuff } = require("./my-esm.mjs");
```
-### Importing CommonJS from CommonJS
-
-You can `require()` CommonJS modules from CommonJS modules.
-
-```ts
-const { stuff } = require("./my-commonjs.cjs");
-```
-
#### Top-level await
If you are using top-level await, you must use `import()` to import ESM modules from CommonJS modules.
@@ -228,11 +214,17 @@ import("./my-esm.js").then(({ stuff }) => {
const { stuff } = require("./my-esm.js");
```
-#### Low-level details of CommonJS interop in Bun
+{% details summary="Low-level details of CommonJS interop in Bun" %}
-Bun's JavaScript runtime has native support for CommonJS as of Bun v0.6.5.
+Bun's JavaScript runtime has native support for CommonJS. When Bun's JavaScript transpiler detects usages of `module.exports`, it treats the file as CommonJS. The module loader will then wrap the transpiled module in a function shaped like this:
-When Bun's JavaScript transpiler detects usages of `module.exports`, it treats the file as CommonJS. The module loader will then wrap the transpiled module in a function shaped like this:
+### Importing CommonJS from CommonJS
+
+You can `require()` CommonJS modules from CommonJS modules.
+
+```ts
+const { stuff } = require("./my-commonjs.cjs");
+```
```js
(function (module, exports, require) {
@@ -245,3 +237,5 @@ When Bun's JavaScript transpiler detects usages of `module.exports`, it treats t
Once the CommonJS module is successfully evaluated, a Synthetic Module Record is created with the `default` ES Module [export set to `module.exports`](https://github.com/oven-sh/bun/blob/9b6913e1a674ceb7f670f917fc355bb8758c6c72/src/bun.js/bindings/CommonJSModuleRecord.cpp#L212-L213) and keys of the `module.exports` object are re-exported as named exports (if the `module.exports` object is an object).
When using Bun's bundler, this works differently. The bundler will wrap the CommonJS module in a `require_${moduleName}` function which returns the `module.exports` object.
+
+{% /details %}
diff --git a/docs/runtime/nodejs-apis.md b/docs/runtime/nodejs-apis.md
index 2bdc1fe50..72504e664 100644
--- a/docs/runtime/nodejs-apis.md
+++ b/docs/runtime/nodejs-apis.md
@@ -529,7 +529,7 @@ The table below lists all globals implemented by Node.js and Bun's current compa
### [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData)
-🟢 Fully implemented. Added in Bun 0.5.7.
+🟢 Fully implemented.
### [`global`](https://nodejs.org/api/globals.html#global)
@@ -859,7 +859,7 @@ The table below lists all globals implemented by Node.js and Bun's current compa
- {% anchor id="node_formdata" %} [`FormData`](https://developer.mozilla.org/en-US/docs/Web/API/FormData) {% /anchor %}
- 🟢
-- Fully implemented. Added in Bun 0.5.7.
+- Fully implemented.
---
diff --git a/docs/runtime/plugins.md b/docs/runtime/plugins.md
index 39eea3278..5bf80ffb4 100644
--- a/docs/runtime/plugins.md
+++ b/docs/runtime/plugins.md
@@ -1,7 +1,3 @@
-{% callout %}
-**Note** — Introduced in Bun v0.1.11.
-{% /callout %}
-
Bun provides a universal plugin API that can be used to extend both the _runtime_ and [_bundler_](/docs/bundler).
Plugins intercept imports and perform custom loading logic: reading files, transpiling code, etc. They can be used to add support for additional file types, like `.scss` or `.yaml`. In the context of Bun's bundler, plugins can be used to implement framework-level features like CSS extraction, macros, and client-server code co-location.
diff --git a/docs/runtime/web-apis.md b/docs/runtime/web-apis.md
index 98c822274..1deb7cc40 100644
--- a/docs/runtime/web-apis.md
+++ b/docs/runtime/web-apis.md
@@ -32,7 +32,7 @@ The following Web APIs are partially or completely supported.
---
- WebSockets
-- [`WebSocket`](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket)
+- [`WebSocket`](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket) (_not production ready_)
---