Bun build users find dirname and filename replaced with build directory strings
17 posts since May 2023, all from GitHub.
“What version of Bun is running? 1.2.2+c1708ea6a What platform is your computer? Microsoft Windows NT 10.0.19045.0 x64 What steps can reproduce the bug? 1. Run this code via bun 2. Crash with this error What is the expected behavior? The example code runs fine without any…”
“What is the problem this feature would solve? i need to link to an entrypoint using an absolute path like: but Bun.build only accepts string[] What is the feature you are proposing to solve the problem? like Bun.file , i think Bun.build 's entrypoints can and should accept URL…”
“What is the problem this feature would solve? When bundling applications with bun build I've run into this error message: This code is not used directly in my application, so it must be used in some imported library, however it's pretty much impossible to figure out which one…”
Developers using Bun's build tool are encountering issues where `dirname` and `filename` variables within included CommonJS modules are incorrectly replaced with the build machine's directory, causing code to fail when run outside that environment.
SOURCES (17)
“What version of Bun is running? 1.4.4+38afee6c8 What platform is your computer? Linux 6.17.0 x86 64 What steps can reproduce the bug? Save as repro.ts and run bun repro.ts : What is the expected behavior? The second build resolves dir/created.js , which exists before the…”
“On upstream main d0f4fdd65fbd9548042aa5cd811a08f837ce4b4c , scripts/build/tools.ts:findBun() returns the executable in /.bun/bin before considering process.execPath , even when configure is already running under a newer explicitly selected Bun. During a normal debug source build on macOS arm64, I ran configure with Pantry's unchanged Bun 1.4.4 ( 38afee6c8 ) but the resulting tool selection chose the existing /.bun/bin/bun 1.4.2 for code generators. Neither installed executable was modified. This”
“What happens When a CommonJS file is included in a bun build compile binary as an extra entrypoint, dirname and filename in that module are replaced at build time with string literals of the build machine's directory ( var dirname = "/private/tmp/.../chunks"; is visible in the embedded source). Code that loads siblings via require(path.join( dirname, "x.cjs")) therefore fails once the binary runs anywhere the build directory doesn't exist. require("./x.cjs") and require.resolve("./x.cjs") (→ /$b”
“What version of Bun is running? 1.4.2 What platform is your computer? Darwin 27.0.0 arm64 What steps can reproduce the bug? A native addon that links a shared library sitting next to it works with bun app.js but fails inside a compile binary, even when the library is embedded too. Bun extracts only the .node file to a temp path, so the addon's @loader path rpath points at the temp directory and the library is not there. What is the expected behavior? answer = 42 , since lib/libfoo.dylib is embed”
“What version of Bun is running? 1.3.12+700fc117a What platform is your computer? Linux 6.12. aarch64 unknown What steps can reproduce the bug? bun:sql creates server side named prepared statements and caches them per connection. When DDL changes the rowtype of a table referenced by a cached plan, PostgreSQL rejects subsequent executions of that plan with SQLSTATE 0A000 ("cached plan must not change result type"). bun:sql surfaces the error to the caller but does not evict the stale plan or retry”
“What version of Bun is running? 1.2.21+7c45ed97d What platform is your computer? No response What steps can reproduce the bug? building with esbuild and bun: What is the expected behavior? Bun is able to dead code eliminate the import since it knows that TEST is false, and so the async import will never be reached. What do you see instead? Bun complains about the top level await, even though it's unreachable. Additional information This might actually be a bug in ESBuild, with it not complaining”
“What version of Bun is running? 1.3.5+1e86cebd7 What platform is your computer? Darwin 25.1.0 arm64 arm What steps can reproduce the bug? 1. Create a Conditional Configuration for the CI as outlined in the docs 2. Run bun test config=ci What is the expected behavior? Expected it to run the config under [test.ci] , e.g. defining another root folder or a prolonged timeout. What do you see instead? Additional information Current Workaround : I setup another file, bunfig.ci.toml and pass it as bun t”
“What version of Bun is running? 1.3.0+b0a6feca5 What platform is your computer? Darwin 25.0.0 arm64 arm What steps can reproduce the bug? When building single executables with embedded directories, it seems that Bun does not include all files as expected. Example index.ts: bun build compile ./src/index.ts ./static/ / outfile ./build/server <img width="162" height="328" alt="Image" src="https://github.com/user attachments/assets/86ffca22 b42d 4a47 b1a6 edee0d90b0ad" / Result: Not all files from t”
“What version of Bun is running? 1.2.20 What platform is your computer? x64 What steps can reproduce the bug? When using bun build , specifying both outdir and outfile leads to unexpected outcome. For example: Expected: Output file is dist/myfile.js Actual: Output file is dist/index.js (the outfile flag is ignored) For a single entry file, the correct usage is: Currently, using both outdir and outfile together does not fail, but outfile is ignored. This is confusing for users. What is the expecte”
“What version of Bun is running? 1.2.19 What platform is your computer? x64 What steps can reproduce the bug? index.js run build output ( Invalid Javascript ) What is the expected behavior? 1. a variable being "defined" with define should not be substituted in an assignment expression when it is on the left side ( leftSide = rightSide ), and the value is not assignable like a number, string ,etc a warning should be raised. "read" of the VAR1 will be substituted. will output We should also still b”
“What version of Bun is running? 1.2.3 What platform is your computer? Linux 6.12.12 400.asahi.fc41.aarch64+16k aarch64 unknown What steps can reproduce the bug? When you import with a path that uses suffix like ?raw there is inconsistency between bun run and bun build , when using run it works correctly but when using build it errors out with Could not resolve: "./text.txt?raw" What is the expected behavior? It should import text content into variable just like it does when using bun run What do”
“What version of Bun is running? 1.2.2+c1708ea6a What platform is your computer? Microsoft Windows NT 10.0.19045.0 x64 What steps can reproduce the bug? 1. Run this code via bun 2. Crash with this error What is the expected behavior? The example code runs fine without any problems What do you see instead? Bun crashes with the EEXIST error and logs a warn: internal error: OBJECT NAME INVALID message to the console which cannot be suppressed Additional information This only happens when the path st”
“What version of Bun is running? 1.2.2+c1708ea6a What platform is your computer? Microsoft Windows NT 10.0.22631.0 x64 What steps can reproduce the bug? When compiling a project that uses DuckDB , the process fails. Perhaps due to DuckDBs use of native modules. See the repo below to reproduce the error. https://github.com/rodryquintero/deno compile gist/tree/duckdb bun compile error What is the expected behavior? A compiled .exe that works with DuckDB What do you see instead? An error when loadin”
“What version of Bun is running? 1.1.42+50eec0025 What platform is your computer? Linux 6.8.0 51 generic x86 64 x86 64 What steps can reproduce the bug? Create a file named lib/a.js . And another file main.js that import that file: And bundle it using Bun.build or the CLI to bundled.js . Run the main.js and bundled.js file. What is the expected behavior? Both file should output: What do you see instead? bundled.js output: Additional information I see import.meta.path kept as it is in the output s”
“What version of Bun is running? 1.1.7+b0b7db5c0 What platform is your computer? Darwin 23.1.0 arm64 arm What steps can reproduce the bug? What is the expected behavior? Build output that doesn't fail upon execution when require() is unavailable What do you see instead? An error message that misidentifies the require() call as dynamic in the build output, when it is clearly static: The artifact throws this in environments where require() is unavailable (such as the browser). Additional informatio”
“What is the problem this feature would solve? i need to link to an entrypoint using an absolute path like: but Bun.build only accepts string[] What is the feature you are proposing to solve the problem? like Bun.file , i think Bun.build 's entrypoints can and should accept URL as a file path without needing to use Bun.fileURLToPath . What alternatives have you considered?”
“What is the problem this feature would solve? When bundling applications with bun build I've run into this error message: This code is not used directly in my application, so it must be used in some imported library, however it's pretty much impossible to figure out which one What is the feature you are proposing to solve the problem? it'd be nice to have a more verbose build log, perhaps behind a verbose flag if you think it'd pollute the output, to print extra information that could help hunt”
