Bun 1.4: Glob Patterns, TypeScript 5.8, and Windows ARM64 – What You Need to Know
Bun 1.4 brings native glob pattern support, TypeScript 5.8 integration, and full Windows ARM64 compatibility. Learn what's new and how to upgrade your projects.
Bun 1.4 Release: Native Glob Patterns and Full Windows Support
Bun 1.4 arrived with a significant set of improvements for developer experience and platform support. The release introduces native glob pattern matching via Bun.glob(), brings TypeScript 5.8 for better type safety, and—perhaps most importantly—delivers full Windows ARM64 support, making Bun a truly cross-platform JavaScript runtime.
If you’ve been using Bun for development or production workloads, this release deserves your attention. We’ll walk through the key features, show you how to adopt them, and explain why they matter for your team.
What’s New in Bun 1.4
Native Glob Pattern Matching
One of the most practical additions is Bun.glob(), a native API for matching files using glob patterns. Previously, developers had to rely on third-party packages like glob or fast-glob. Now it’s built in.
import { glob } from "bun";
// Find all TypeScript files in src/
const files = await glob("src/**/*.ts");
console.log(files); // ["src/index.ts", "src/utils.ts", ...]
// Find all test files
const tests = await glob("**/*.test.ts");
// Exclude patterns
const nonTest = await glob("src/**/*.ts", {
ignore: ["**/*.test.ts", "**/node_modules/**"]
});
This is significantly faster than shell globbing or JavaScript alternatives because it’s implemented in Zig (Bun’s underlying language) and executes natively. For projects with thousands of files, the performance difference is noticeable.
Real-world use case: Build scripts that need to discover files dynamically.
// Build script example
import { glob } from "bun";
const sourceFiles = await glob("src/**/*.ts");
const buildDir = "dist";
for (const file of sourceFiles) {
const output = file.replace("src/", buildDir + "/").replace(".ts", ".js");
console.log(`Building ${file} → ${output}`);
// Compile with esbuild or TypeScript
}
TypeScript 5.8 Support
Bun 1.4 ships with TypeScript 5.8 built in. Key improvements include:
- Improved type narrowing for discriminated unions
- Better performance in the type checker
- New module resolution options for better Node.js compatibility
- Stricter null/undefined checks with enhanced inference
You can verify your TypeScript version:
bun --version
# v1.4.0 (or later)
bun run --version
# Bun 1.4.0 includes TypeScript 5.8
If you’re using a tsconfig.json, Bun respects your compiler options automatically. No additional configuration needed.
Windows ARM64: Full Platform Parity
This is the biggest news for Windows developers. Previously, Bun on Windows ARM64 (common on newer Surface devices and Windows 11 ARM versions) had limitations. Bun 1.4 brings full feature parity with x64 and macOS versions.
What works now on Windows ARM64:
- All bundler features
- Full test runner support
- SQLite (bundled)
- Native module support
- Hot reload in dev mode
If you’re on Windows ARM64, upgrading is straightforward:
# On Windows ARM64, use the installer from bun.sh
# Or if you use a package manager:
choco install bun # Windows
Step-by-Step: Upgrading to Bun 1.4
1. Update Bun
bun upgrade
# or if you use a version manager like Volta:
volta pin [email protected]
Verify:
bun --version # Should show 1.4.0+
2. Test Your Current Project
Bun 1.4 maintains backward compatibility with earlier versions, so most projects should work without changes. Run your test suite:
bun test
3. Adopt Bun.glob() in Your Build Scripts
If you’re using a glob package in package.json, you can now remove it and use native Bun.glob().
Before:
import glob from "glob";
const files = await new Promise((resolve, reject) => {
glob("src/**/*.ts", (err, files) => {
if (err) reject(err);
else resolve(files);
});
});
After:
import { glob } from "bun";
const files = await glob("src/**/*.ts");
The Bun API is promise-based and much simpler.
4. Leverage TypeScript 5.8 Types
If you’re using TypeScript strict mode, you may find improved type inference catches issues earlier. Update your tsconfig.json to be explicit:
{
"compilerOptions": {
"target": "ES2020",
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"skipLibCheck": true,
"lib": ["ES2020"]
}
}
Common Pitfalls
Glob Pattern Performance with Large Directories
While Bun.glob() is fast, matching millions of files can still be slow. Always use ignore patterns to exclude unnecessary directories:
// ❌ Slow: Matches everything then filters
const files = await glob("**/*.ts");
// ✅ Fast: Excludes large directories upfront
const files = await glob("src/**/*.ts", {
ignore: ["**/node_modules/**", "**/.git/**", "**/dist/**"]
});
Windows Path Separators
Glob patterns return forward slashes even on Windows. If you need backslashes for system commands, normalize them:
import { glob } from "bun";
import path from "path";
const files = await glob("src/**/*.ts");
for (const file of files) {
const normalized = path.normalize(file);
console.log(normalized); // Works on Windows
}
TypeScript Caching with Bun
Bun caches TypeScript compilation. If you modify tsconfig.json, clear the cache:
rm -rf ~/.bun/cache # macOS/Linux
rmdir %UserProfile%\.bun\cache /s # Windows
bun run your-script.ts # Rebuilds from fresh
Why It Matters
Performance Gains
Built-in glob matching eliminates the overhead of parsing and executing JavaScript glob libraries. For CI/CD pipelines processing thousands of files, this can save minutes on each build.
Reduced Dependencies
One fewer npm package means fewer security updates to track, smaller node_modules, and faster installs. This aligns with Bun’s philosophy of providing batteries-included tooling.
Windows Developer Experience
Full ARM64 support on Windows removes friction for developers on modern Windows ARM devices. No more workarounds or unsupported features.
Type Safety
TypeScript 5.8’s improved type inference catches more bugs at compile time, reducing runtime errors—especially valuable in large codebases.
Testing the New Features
Let’s build a practical example: a script that discovers and bundles all TypeScript modules.
// scripts/bundle.ts
import { glob } from "bun";
import { build } from "esbuild";
import path from "path";
async function bundleAll() {
const files = await glob("src/**/*.ts", {
ignore: ["**/*.test.ts", "**/*.d.ts"]
});
console.log(`Found ${files.length} files to bundle`);
const entryPoints = files.map(file => ({
in: file,
out: path.basename(file, ".ts")
}));
const result = await build({
entryPoints: files,
outdir: "dist",
format: "esm",
target: "es2020"
});
console.log(`Bundled to dist/`);
return result;
}
await bundleAll();
Run it:
bun run scripts/bundle.ts
Debugging Glob Patterns
If your glob pattern isn’t matching what you expect, debug it:
import { glob } from "bun";
const pattern = "src/**/*.ts";
const ignore = ["**/*.test.ts", "**/node_modules/**"];
const files = await glob(pattern, { ignore });
console.log(`Pattern: ${pattern}`);
console.log(`Ignore: ${ignore.join(", ")}`);
console.log(`Matches: ${files.length} files`);
console.log(files.slice(0, 5)); // Show first 5
Working with Bun’s Built-in Tools
Bun 1.4 works seamlessly with other built-in tools. For instance, if you’re validating configuration formats in your build, you can use Kloubot’s JSON Formatter to validate JSON before building.
For API integrations in your Bun scripts, API Request Builder can help you prototype requests. And if you’re working with environment variables or configuration, Base64 Encoder is useful for encoding secrets safely.
Common Integration Examples
With SQL.js and SQLite
Bun includes SQLite. Combine it with glob for data migrations:
import { glob } from "bun";
import Database from "bun:sqlite";
const db = new Database(":memory:");
const migrations = await glob("db/migrations/*.sql");
for (const file of migrations.sort()) {
const sql = await Bun.file(file).text();
db.exec(sql);
console.log(`Ran migration: ${file}`);
}
With Testing
Use glob to discover tests dynamically:
// test/runner.ts
import { glob } from "bun";
import { describe, it, expect } from "bun:test";
const testFiles = await glob("test/**/*.test.ts");
console.log(`Running ${testFiles.length} test files`);
for (const file of testFiles) {
await import(file);
}
Updating Your CI/CD Pipeline
If you’re using Bun in CI/CD, ensure your workflows pin to 1.4.0 or later:
# .github/workflows/test.yml
name: Test
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
with:
bun-version: 1.4.0 # Pin the version
- run: bun install
- run: bun test
- run: bun run build
Moving Forward
Bun 1.4 represents a maturation of the platform. The addition of native glob matching, TypeScript 5.8, and full Windows ARM64 support makes it a more complete JavaScript runtime. For greenfield projects or teams already invested in Bun, this is a straightforward upgrade with tangible benefits.
If you’re evaluating Bun or considering migration, the 1.4 release removes several pain points that earlier versions had. The tooling is more cohesive, the performance is better, and cross-platform support is now truly universal.
Start with bun upgrade, test your current projects, and gradually adopt features like Bun.glob() as they fit your workflows.