---
title: Bun v1.0.14
description: Introduces `Bun.Glob` - a fast glob matcher, fixes a race condition when extracting dependencies during `bun install`, improves TypeScript module resolution in `node_modules`, makes error messages easier to read, and more fixes.
date: "2023-11-22T22:54:46+00:00"
author: ashcon
draft: false
---

Bun v1.0.14 introduces `Bun.Glob`, a fast API for matching files and strings using glob patterns. It also fixes a race condition when extracting dependencies during `bun install`, improves TypeScript module resolution in `node_modules`, and makes error messages easier to read.

Bun is an incredibly fast JavaScript runtime, bundler, transpiler, and package manager &mdash; all in one. In case you missed it, here are some of the recent changes to Bun:

- [`v1.0.9`](/blog/bun-v1.0.9) - Fixes a glibc symbol version error, illegal instruction error, a Bun.spawn bug, an edgecase with peer dependency installs, and a JSX transpiler bugfix
- [`v1.0.10`](/blog/bun-v1.0.10) - Fixes 14 bugs (addressing 102 👍 reactions), node:http gets 14% faster, stability improvements to Bun for Linux ARM64, bun install bugfix, and node:http bugfixes
- [`v1.0.11`](/blog/bun-v1.0.11) - Fixes 5 bugs, adds `Bun.semver`, fixes a bug in bun install and fixes bugs impacting `astro` and `@google-cloud/storage`
- [`v1.0.12`](/blog/bun-v1.0.12) - Adds `bun -e` for evaluating scripts, `bun --env-file` for loading environment variables, `server.url`, `import.meta.env`, `expect.unreachable()`, improved CLI help output, and more
- [`v1.0.13`](/blog/bun-v1.0.13) - Fixes 6 bugs (addressing 317 👍 reactions). 'http2' module & gRPC.js work now. Vite 5 & Rollup 4 work. Implements process.report.getReport(), improves support for ES5 'with' statements, fixes a regression in bun install, fixes a crash when printing exceptions, fixes a Bun.spawn bug, and fixes a peer dependencies bug

To install Bun:

{% codetabs %}

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

```sh#npm
$ npm install -g 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
```

## `Bun.Glob`

`Bun.Glob` is a fast API for matching files and strings using glob patterns.

It's similar to popular Node.js libraries like `fast-glob` or `micromatch`, except it matches strings 3x faster.

{% image src="https://github.com/oven-sh/bun/assets/709451/0214879d-6fae-4857-8665-e77e6d838b74" /%}

Use `glob.scan()` to scan for files that match the glob, which returns an `AsyncIterator` that yields matching paths.

```js
import { Glob } from "bun";

const glob = new Glob("**/*.ts");
for await (const path of glob.scan("src")) {
  console.log(path); // "src/index.ts"
}
```

Use `glob.match()` to match a string against a glob pattern.

```js
import { Glob } from "bun";

const glob = new Glob("**/*.ts");

const match = glob.match("src/index.ts");
console.log(match); // true
```

Thanks to [@zackradisic](https://github.com/zackradisic) for implementing this! Also, thanks to [@mrmlnc](https://github.com/mrmlnc) for `fast-glob` along with the contributors to `micromatch` & `picomatch`, which our tests were inspired by. Much of our Zig implementation was inspired by Devon Govett (@devongovett) and Stephen Gregoratto (@The-King-of-Toasters)'s glob implementations, which we are grateful for.

## Fixed bug with missing dependencies using `bun install`

Bun had a race condition that could cause `bun install` to occasionally fail to install a dependency when many different versions of the same package were being extracted concurrently. This was caused by a bug in how Bun created the temporary filename for installing dependencies. The path used was not unique enough, which could cause one build to overwrite another build's temporary folder, sometimes.

## TypeScript module resolution changes in `node_modules`

To mimick `tsc` behavior, Bun loads TypeScript files before JavaScript files. This works well in local development, but sometimes npm packages ship TypeScript source files that transpilers cannot transpile, such as:

- TypeScript transformer plugins.
- Using `import {Foo}` instead of `import {type Foo}`.
- Using `export {Foo}` instead of `export {type Foo}`.

Going forward, when inside `node_modules`, Bun will prefer JavaScript files over TypeScript files when both are present.

This fixes errors that looked like:

```js
SyntaxError: Indirectly exported binding name 'Foo' is not found.
```

Bun continues to support TypeScript files in `node_modules`. When both `.ts` and `.js` files are present, Bun will prefer the `.js` file when inside `node_modules`. Otherwise, Bun continues to prefer `.ts` files.

## More readable error messages when a build fails

Bun now shows better error messages when a build fails:

- Fixed a bug where it only highlighed the first character
- Trimmed extraneous newlines in the error message
- Made the styling for build errors match the styling for runtime errors

{% image src="https://github.com/oven-sh/bun/assets/709451/8e344a23-3924-40fa-b110-0e2dca003cfc" /%}

## Better export & import error messages

{% raw %}

<blockquote class="twitter-tweet"><p lang="en" dir="ltr">In the next version of Bun<br><br>When you confuse a named import for a default import, it suggests using the named import instead <a href="https://t.co/UGIxbEeO7C">pic.twitter.com/UGIxbEeO7C</a></p>&mdash; Jarred Sumner (@jarredsumner) <a href="https://twitter.com/jarredsumner/status/1726115774673396194?ref_src=twsrc%5Etfw">November 19, 2023</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

<br />

<blockquote class="twitter-tweet"><p lang="en" dir="ltr">In the next version of Bun <br><br>When you confuse a default import for a named import, it suggests using the default import instead <a href="https://t.co/Tjx3px19pa">pic.twitter.com/Tjx3px19pa</a></p>&mdash; Jarred Sumner (@jarredsumner) <a href="https://twitter.com/jarredsumner/status/1726116117285122321?ref_src=twsrc%5Etfw">November 19, 2023</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

{% /raw %}

## Errors for unsupported ESM <> CommonJS features

Bun supports both `require()` and `import` in the same file, but you cannot use import and `module.exports` in the same file. You also cannot use `exports`, `module`, `with`, or top-level return.

Previously, Bun relied on a runtime error message from JavaScriptCore for this, but the error message was a little confusing.

Now, these errors are detected at build-time and show a better error message. In this example, you cannot use `import` and `with` in the same file:

```js
import "abc";

with (Bun) {
  write("/tmp/file.txt", escapeHTML(file("/tmp/file.html").text()));
  console.log({
    contents: file("/tmp/file.txt").text(),
  });
}
```

Before:

```js
1 | import "abc";
2 |
3 | with (Bun) {
   ^
SyntaxError: Unexpected string literal "abc". import call expects one or two arguments.
      at unsupported.js:3:0
```

After:

```js
1 | import "abc";
           ^
error: Cannot use import statement with CommonJS-only features
    at unsupported.js:1:8 7

note: Try require("abc") instead
note: This file is CommonJS because a "with" statement is used
```

## Class name shown in `console.log`

`console.log()` now shows the class name of the object in more cases, which matches the behavior of Node.js.

```js
class Foo {}
class Bar {
  value = 1;
}

console.log(new Foo()); // Foo {}
console.log(new Bar()); // Bar { value: 1 }
```

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

## Fixed signal using `process.kill()`

A bug was fixed where `SIGKILL` and `SIGSTOP` were not supported by `process.kill()`.

```js
process.kill("SIGKILL"); // or "SIGSTOP"
```

If you encountered the following error, it is now fixed:

```js
RangeError: Unknown signal name
```

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

If you want to see the full changelog, you can find it [here](https://github.com/oven-sh/bun/compare/bun-v1.0.13...bun-v1.0.14).

## Thanks to 7 contributors!

- [@antongolub](https://github.com/@antongolub)
- [@dylan-conway](https://github.com/@dylan-conway)
- [@Jarred-Sumner](https://github.com/@Jarred-Sumner)
- [@jerome-benoit](https://github.com/@jerome-benoit)
- [@JibranKalia](https://github.com/@JibranKalia)
- [@liz3](https://github.com/@liz3)
- [@zackradisic](https://github.com/@zackradisic)
