nx-bun
nx-bun copied to clipboard
bun build does not respect target in project.json options object
Describe the bug
Even though bun
target is specified in project.json, the following error message still persists:
31 | const tls = __importStar(require("tls"));
^
error: Browser build cannot require() Node.js builtin: "tls". To use Node.js builtins, set target to 'node' or 'bun'
at /home/amir/projects/dealzone/node_modules/https-proxy-agent/dist/index.js:31:34
To Reproduce
- Add https-proxy-agent to an nx project
- Add in project.json build step "target": "bun":
"build": {
"executor": "@nx-bun/nx:build",
"outputs": [
"{options.outputPath}"
],
"defaultConfiguration": "production",
"options": {
"outputPath": "dist/apps/proj",
"tsConfig": "apps/proj/tsconfig.app.json",
"entrypoints": [
"apps/proj/src/main.ts"
],
"target": "bun"
}
},
- Build the project using
nx build proj
Expected behavior Build succeeds.
Additional context The fix is adding
if (options.target) {
args.push(`--target=${options.target}`);
}
in here: https://github.com/Jordan-Hall/nx-bun/blob/b8dd4bf3f5fe22bba121859cee29498d0214d330/packages/nx-bun/src/executors/build/executor.ts#L179
I tried creating a PR but I lack permissions.