---
title: Bun v1.1.18
description: "Fixes 55 bugs (addressing 493 👍). Support for npmrc. Improved constant folding & enum inlining. Improved console.log output for functions. Fixes patching dependencies in workspaces. Fixes several bugs in `bun install` when linking binaries. Fixes a crash in `dns.lookup`, and normalizes DNS errors to better match Node. Fixes an assertion failure in `Bun.escapeHTML`. Upgrades JavaScriptCore."
date: "2024-07-03T23:28:26.404Z"
author: dylan
---

Bun v1.1.18 is here! This release fixes 55 bugs (addressing 493 👍). Support for npmrc. Improved constant folding & enum inlining. Improved console.log output for functions. Fixes patching dependencies in workspaces. Fixes several bugs in `bun install` when linking binaries. Fixes a crash in `dns.lookup`, and normalizes DNS errors to better match Node. Fixes an assertion failure in `Bun.escapeHTML`. Upgrades JavaScriptCore.

{% callout %}
We're hiring [systems engineers](/careers) in San Francisco to build the future of JavaScript!
{% /callout %}

#### Previous releases

- [`v1.1.17`](/blog/bun-v1.1.17) Fixes 4 bugs. Fixes a crash in bun repl. Makes fs.readdirSync 5% faster on macOS in small directories. Fixes "ws" module not calling the callback in "send" method. Fixes a crash when reading a corrupted lockfile in bun install. Makes macOS event loop a smidge faster.
- [`v1.1.16`](/blog/bun-v1.1.16) fixes 41 bugs (addressing 221 👍). lcov code coverage reports in bun test, Install dependencies from private git repositories including Gitlab and Bitbucket. `Buffer.from(string, "base64")` gets 6x - 30x faster on large input. Bug fixes to `bun patch`, `bun install`, N-AIi addons, transpiler bugfixes and Node.js compatibility improvements.
- [`v1.1.0`](/blog/bun-v1.1) Bundows. Windows support is here!

#### To install Bun

{% codetabs %}

```sh#curl
$ curl -fsSL https://bun.sh/install | bash
```

```sh#npm
$ npm install -g bun
```

```sh#powershell
$ powershell -c "irm bun.sh/install.ps1|iex"
```

```sh#scoop
$ scoop install bun
```

```sh#brew
$ brew tap oven-sh/bun
$ brew install bun
```

```sh#docker
$ docker pull oven/bun
$ docker run --rm --init --ulimit memlock=-1:-1 oven/bun
```

{% /codetabs %}

#### To upgrade Bun

```sh
$ bun upgrade
```

### .npmrc support

Bun v1.1.18 adds support for reading `.npmrc` files, enabling `bun install` to use your existing npm registry configuration with private registries and scoped packages.

```sh#.npmrc
; .npmrc
@my-company-scope:registry=https://packages.my-company.com
```

`bun install` also supports migrating existing package versions from `package-lock.json`.

Together with `.npmrc`, you can now easily test out `bun install` at your company without changing configuration files. Or you can secretly try out Bun without your coworkers noticing (other than, perhaps less time for coffee between installs).

### `enum` inlining

Bun's optimizing transpiler now supports inlining TypeScript `enum` values, which can improve performance in some cases. For example:

```ts
const enum Version {
  major = 1,
  minor = 1,
  patch = 18,
  pretty = `${major}.${minor}.${patch}`,
}

console.log("Bun v" + Version.pretty);
```

This now transpiles to:

```js
console.log("Bun v1.1.18");
```

Previously, this transpiled to:

```js
var Version;
(function (Version2) {
  Version2[(Version2["major"] = 1)] = "major";
  Version2[(Version2["minor"] = 1)] = "minor";
  Version2[(Version2["patch"] = 18)] = "patch";
  Version2[
    (Version2[
      "pretty"
    ] = `${Version2.major}.${Version2.minor}.${Version2.patch}`)
  ] = "pretty";
})(Version || (Version = {}));
console.log("Bun v" + Version.pretty);
```

This behavior is enabled by default in Bun's runtime, and in `bun build` when `--minify-syntax` is enabled.

Be careful when using `const enum` with long strings, as that may increase the size of your transpiled code.

Thanks to [@paperclover](https://github.com/paperclover) for this optimization!

### Constant folding improvements

This release adds support for constant folding bitwise operations on statically-known values ahead of time in Bun's optimizing transpiler.

This works with numbers:

```diff#in.ts
- console.log(1 << 3);
+ console.log(8);
- console.log(1 | 3);
+ console.log(3);
- console.log(1 ^ 3);
+ console.log(2);
- console.log(1 >> 3);
+ console.log(0);
- console.log((1 + 1) ^ 2);
+ console.log(0);
- console.log(0xFF & 0x50);
+ console.log(80);
```

This also works with strings:

```diff#in.ts
- console.log("hello " + 25);
+ console.log("hello 25");
```

Internally, we reuse some code from JavaScriptCore to ensure it's consistent with the behavior of the JavaScript engine.

This behavior is supported in Bun's runtime, `bun build`, `bun test`, `Bun.build`, and `Bun.Transpiler`.

Thanks to [@paperclover](https://github.com/paperclover) for this optimization!

### TypeScript namespace merging

In TypeScript, duplicate sibling `namespace` declarations are merged into a single shared declaration. Bun now supports this behavior with the same semantics as TypeScript's compiler (`tsc`)

The following input:

```ts#in.ts
namespace A {
  export const a = 1;
}

namespace A {
  export const b = a + 1;
}

console.log(A.a, A.b);
```

Now evaluates to the expected output:

```sh#out.sh
$ bun run in.ts
1 2
```

Previously, this would error:

```ts
1 | namespace A {
2 |   export const a = 1;
3 | }
4 |
5 | namespace A {
6 |   export const b = a + 1;
                       ^
ReferenceError: Can't find variable: a
      at in.ts:6:20
      at in.ts:6:24
```

This behavior is supported in Bun's runtime, `bun build`, `bun test`, `Bun.build`, and `Bun.Transpiler`.

Thanks to [@paperclover](https://github.com/paperclover) for fixing this!

### Improved console.log output for functions

Bun will now console.log the function object types. For example

```js
function a() {}
async function b() {}
function* c() {}
async function* d() {}
console.log(a, b, c, d);
```

will now output:

```ts
[Function: a] [AsyncFunction: b] [GeneratorFunction: c] [AsyncGeneratorFunction: d]
```

Thanks to [@erik-dunteman](https://github.com/erik-dunteman) for this improvement!

### Fixed: assertion failure in `Bun.escapeHTML`

When escaping latin1 encoded input with SIMD enabled, Bun was failing an assertion due to writing to a buffer before updating the buffer's length value (not a buffer overflow, as the memory was already allocated at this point).

### Fixed: `bun install` binary linking order

To ensure installs are deterministic, Bun will now link binaries in alphabetical order, and skip linking a binary if the destination already exists.

### Fixed: missing or incorrect binary after `bun install`

When there are multiple copies of a package node_modules, Bun was only linking the binaries for the first installed copy of the package. Now Bun will link binaries for all copies, preventing the wrong binary from being used, or possibly not being able to find the binary at all.

### Fixed: normalizing shebang line endings during `bun install`

Bun will now normalize shebang line endings, allowing binaries to work whether they use CRLF or LF line endings.

### Fixed: assertion failure in `bun pm trust`

An assertion failure was occurring when running `bun pm trust` on a package in node_modules where it's parent package was already trusted. This was fixed thanks to [@dylan-conway](https://github.com/dylan-conway)

### Fixed: Crash in `"overrides"` in `bun install`

Given the following `package.json`:

```json
{
  "dependencies": {
    "is-even": "1.0.0"
  },
  "overrides": {
    "is-odd": "https://my-registry.com/is-odd/-/is-odd-1.2.3.tgz"
  }
}
```

`is-odd@1.2.3` from `my-registry.com` should be installed because `is-even@1.0.0` depends on `is-odd`. Previously, Bun would crash attempting to install this override because it was not expecting an override to be a tarball URL. This has been fixed thanks to [@dylan-conway](https://github.com/dylan-conway).

### Fixed: `bun test` directory open permissions on Windows

When searching for files to test on Windows, Bun was opening directories with the `DELETE` access mask which could cause spawned processes to fail to change their working directory.

### Fixed a crash in `dns.lookup`

A crash has been fixed in `dns.lookup` when given a malformed hostname, and improved DNS error messages have been added to better match node.

```js
const dns = require("dns");
dns.lookup(".", (err) => {
  console.log(err.name); // `DNSException`, previously `Error`
  console.log(err.errno); // `4`, previously `undefined`
});
```

### Bugfix for `bun patch` in workspaces

A bug was fixed where `bun patch <package>` would fail to find dependencies to patch within a workspace. This would happen when the dependency was hoisted to a different location.

Fixed thanks to [@zackradisic](https://github.com/zackradisic)!

### JavaScriptCore upgrade

We've upgraded to the latest version of JavaScriptCore, which fixes a bug with spread syntax semantics (`{... object }`), WebAssembly evaluation on x64, andfixes rare crashes in RegExp and exception handling.

### Thanks to 12 contributors!

- [@dylan-conway](https://github.com/dylan-conway)
- [@Electroid](https://github.com/Electroid)
- [@erik-dunteman](https://github.com/erik-dunteman)
- [@ibanks42](https://github.com/ibanks42)
- [@jakeboone02](https://github.com/jakeboone02)
- [@Jarred-Sumner](https://github.com/Jarred-Sumner)
- [@jmho](https://github.com/jmho)
- [@mangs](https://github.com/mangs)
- [@panva](https://github.com/panva)
- [@perkrlsn](https://github.com/perkrlsn)
- [@vitch](https://github.com/vitch)
- [@zackradisic](https://github.com/zackradisic)
