bun
bun copied to clipboard
`bun build`: uh-oh: index out of bounds
What version of Bun is running?
1.1.2+c8d072c2a
What platform is your computer?
Microsoft Windows NT 10.0.22631.0 x64
What steps can reproduce the bug?
When i try to build cli.ts with --minify, bun just crashes
bun build ./src/cli.ts --minify --target bun
uh-oh: index out of bounds
bun will crash now 😭😭😭
----- bun meta -----
Bun v1.1.2 (c8d072c2) Windows x64
BuildCommand: tsconfig_paths(2) tsconfig(4)
Elapsed: 327ms | User: 875ms | Sys: 343ms
RSS: 0.73GB | Peak: 0.73GB | Commit: 0.85GB | Faults: 178120
----- bun meta -----
0 00007FF61A62E048
1 ???
2 ???
3 ???
4 ???
5 ???
6 ???
7 ???
8 ???
Search GitHub issues https://bun.sh/issues or join in #windows channel in https://bun.sh/discord
thread 47576 panic: index out of bounds
???:?:?: 0x7ff61991a9e6 in ??? (bun.exe)
???:?:?: 0x7ff6196ecf0d in ??? (bun.exe)
???:?:?: 0x7ff6197db2e8 in ??? (bun.exe)
???:?:?: 0x7ff619065b30 in ??? (bun.exe)
???:?:?: 0x7ff6194eec39 in ??? (bun.exe)
???:?:?: 0x7ff9ede1257c in ??? (KERNEL32.DLL)
???:?:?: 0x7ff9ee7eaa47 in ??? (ntdll.dll)
Without --minify i get this error:
2 | * @typedef {import('estree-jsx').Expression} Expression
^
warn: Unsupported JSX runtime: "theRuntime`.
"
at C:\Development\pressrs\node_modules\estree-util-build-jsx\lib\index.js:2:11
126 | return require("pnpapi"); // eslint-disable-line node/no-missing-require
^
error: Could not resolve: "pnpapi". Maybe you need to "bun install"?
at C:\Development\pressrs\node_modules\enhanced-resolve\lib\ResolverFactory.js:126:18
What is the expected behavior?
No response
What do you see instead?
No response
Additional information
No response
Can you provide a minimal example of the cli.ts
file?
Sure https://github.com/maripose-js/maripose/blob/main/src/cli.ts
@malezjaa might not be the answer you are looking but
taking a look at that project I think the command you are looking for is bun run build
would it be not?
No I was trying to build project using bun build
because it's faster than tsup.
No I was trying to build project using
bun build
because it's faster than tsup.
oh my bad, I had just skimmed over it.
I was able to mostly isolate the error.
It seems its happens with the @rsbuild/core
pkg which uses enhanced-resolve
import { createRsbuild } from "@rsbuild/core";
const rsbuild = await createRsbuild();
Running bun build ./index.ts --target bun
gives me
126 | return require("pnpapi"); // eslint-disable-line node/no-missing-require
^
error: Could not resolve: "pnpapi". Maybe you need to "bun install"?
at /workspaces/workspace/node_modules/enhanced-resolve/lib/ResolverFactory.js:126:18
Minimal reproduction example with v1.1.2
Only the minify issue might be windows specific, ~~it seems it has to do with how bun tries to bundle pnpapi
which doesn't actually exists but its definitelly a bun bug.~~
I'm not a core developer so I wouldn't know how much I could help :sweat_smile:
My solution
@malezjaa I was able to build your project by marking pnpapi
and /dist/loader.js
as external (resolved at runtime)
$: bun build ./src/cli.ts --minify --target bun --external pnpapi --external "./dist/loader.js" --outdir dist
cli.js 7497.36 KB
rspack.linux-x64-musl-7622293b5797420a.node 59568.95 KB
rspack.linux-x64-gnu-aa132764ba0db361.node 60364.54 KB
[231ms] bundle 773 modules
does it builds for you (with and without minify)? I'm on linux so there is a chance we might have different results
This looks like its fixed now 🎉 (at least from my tests, and my issue linked above also is fixed at least on canary)
I'm not canary user and use scoop for pm. Looking forward to author's next update, which can include this feat/fix.