oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.13k stars 2.76k forks source link

bun run bun.config.ts #12170

Open jaques-tino opened 4 months ago

jaques-tino commented 4 months ago

How can we reproduce the crash?

【ignore.ts】 import type { BunPlugin } from 'bun'

export default (filter: RegExp, files: string[]): BunPlugin => { return { name: 'BunIgnore', setup(build) { build.onResolve({ filter }, (args) => { // 检查路径是否需要忽略 if (files.includes(args.path)) { return { path: args.path, external: true }; } return null; }) } } } 【bun.config.ts】 import { join } from 'path' import { existsSync, rmdirSync } from 'fs' import ignore from './plugins/ignore'

const distDect = join(__dirname, './dist') const hasDist = existsSync(distDect) hasDist && rmdirSync(distDect, { recursive: true })

async function main() { const output = await Bun.build({ entrypoints: ['./src/main.ts'], // target: 'bun', outdir: join(__dirname, './dist'), plugins: [ ignore( /@nestjs/, [ '@nestjs/microservices', '@nestjs/microservices/microservices-module', '@nestjs/websockets/socket-module', 'cache-manager', 'class-validator', 'class-transformer' ]) ] }) if (output.success) { console.log('打包成功') return } console.log('打包失败'); console.error(output.logs) }

await main()

Relevant log output

Bun v1.1.8 (89d25807) Windows x64
Args: "C:\Users\Administrator\.bun\bin\bun.exe", "run", "bun.config.ts"
Features: jsc dotenv tsconfig_paths(4) tsconfig(10)
Builtins: "bun:main" "node:fs" "node:path" "node:string_decoder" "node:util/types"
Elapsed: 89ms | User: 156ms | Sys: 140ms
RSS: 0.28GB | Peak: 0.28GB | Commit: 0.41GB | Faults: 70159
panic(thread 17616): index out of bounds
oh no: Bun has crashed. This indicates a bug in Bun, not your code.

Stack Trace (bun.report)

Bun v1.1.8 (89d2580) on windows x86_64 [RunCommand]

panic: index out of bounds

github-actions[bot] commented 4 months ago

@jaques-tino, the latest version of Bun is v1.1.16, but this crash was reported on Bun v1.1.8.

Are you able to reproduce this crash on the latest version of Bun?

bun upgrade