diff options
author | 2023-09-14 23:39:23 -0700 | |
---|---|---|
committer | 2023-09-14 23:44:19 -0700 | |
commit | 31fec8f70461f74b3ff99fe8643e9e31d470423b (patch) | |
tree | 88944c1c5bf5724306cb59172ff41bac72de6d3c | |
parent | c5e8271cdce2e8c2badb517740f4fde7fd8c0a44 (diff) | |
download | bun-31fec8f70461f74b3ff99fe8643e9e31d470423b.tar.gz bun-31fec8f70461f74b3ff99fe8643e9e31d470423b.tar.zst bun-31fec8f70461f74b3ff99fe8643e9e31d470423b.zip |
Clean up run.md
-rw-r--r-- | docs/cli/run.md | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/docs/cli/run.md b/docs/cli/run.md index 6d490e8da..59818980b 100644 --- a/docs/cli/run.md +++ b/docs/cli/run.md @@ -1,5 +1,28 @@ The `bun` CLI can be used to execute JavaScript/TypeScript files, `package.json` scripts, and [executable packages](https://docs.npmjs.com/cli/v9/configuring-npm/package-json#bin). +## Performance + +Bun is designed to start fast and run fast. + +Under the hood Bun uses the [JavaScriptCore engine](https://developer.apple.com/documentation/javascriptcore), which is developed by Apple for Safari. In most cases, the startup and running performance is faster than V8, the engine used by Node.js and Chromium-based browsers. Its transpiler and runtime are written in Zig, a modern, high-performance language. On Linux, this translates into startup times [4x faster](https://twitter.com/jarredsumner/status/1499225725492076544) than Node.js. + +{% table %} + +--- + +- `bun hello.js` +- `5.2ms` + +--- + +- `node hello.js` +- `25.1ms` + +{% /table %} +{% caption content="Running a simple Hello World script on Linux" /%} + +<!-- {% image src="/images/bun-run-speed.jpeg" caption="Bun vs Node.js vs Deno running Hello World" /%} --> + <!-- ## Speed --> <!-- @@ -120,23 +143,3 @@ By default, Bun respects this shebang and executes the script with `node`. Howev ```bash $ bun run --bun vite ``` - -## Environment variables - -Bun automatically loads environment variables from `.env` files before running a file, script, or executable. The following files are checked, in order: - -1. `.env.local` (first) -2. `NODE_ENV` === `"production"` ? `.env.production` : `.env.development` -3. `.env` - -To debug environment variables, run `bun run env` to view a list of resolved environment variables. - -## Performance - -Bun is designed to start fast and run fast. - -Under the hood Bun uses the [JavaScriptCore engine](https://developer.apple.com/documentation/javascriptcore), which is developed by Apple for Safari. In most cases, the startup and running performance is faster than V8, the engine used by Node.js and Chromium-based browsers. Its transpiler and runtime are written in Zig, a modern, high-performance language. On Linux, this translates into startup times [4x faster](https://twitter.com/jarredsumner/status/1499225725492076544) than Node.js. - -{% image src="/images/bun-run-speed.jpeg" caption="Bun vs Node.js vs Deno running Hello World" /%} - -<!-- If no `node_modules` directory is found in the working directory or above, Bun will abandon Node.js-style module resolution in favor of the `Bun module resolution algorithm`. Under Bun-style module resolution, all packages are _auto-installed_ on the fly into a [global module cache](/docs/install/cache). For full details on this algorithm, refer to [Runtime > Modules](/docs/runtime/modules). --> |