mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 04:18:58 +00:00
Remove comment and add test for process.isBun DCE
- Removed the explanatory comment as requested - Added bundler test to ensure process.isBun DCE works when target=bun - Test verifies that the Node.js branch is eliminated and only Bun code runs 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1511,7 +1511,6 @@ pub fn definesFromTransformOptions(
|
||||
}));
|
||||
}
|
||||
|
||||
// Set process.isBun to true for DCE when target is bun
|
||||
if (!user_defines.contains("process.isBun")) {
|
||||
_ = try environment_defines.getOrPutValue("process.isBun", .init(.{
|
||||
.valueless = false,
|
||||
|
||||
@@ -3401,4 +3401,29 @@ describe("bundler", () => {
|
||||
// "/project/node_modules/pkg/styles.css": `button { color: red }`,
|
||||
// },
|
||||
// });
|
||||
|
||||
itBundled("dce/ProcessIsBunTargetBun", {
|
||||
files: {
|
||||
"/entry.js": /* js */ `
|
||||
if (process.isBun) {
|
||||
console.log("BUN_CODE");
|
||||
function bunOnlyFunction() {
|
||||
return "bun-specific";
|
||||
}
|
||||
console.log(bunOnlyFunction());
|
||||
} else {
|
||||
console.log("NODE_CODE");
|
||||
function nodeOnlyFunction() {
|
||||
return "node-specific";
|
||||
}
|
||||
console.log(nodeOnlyFunction());
|
||||
}
|
||||
`,
|
||||
},
|
||||
target: "bun",
|
||||
dce: true,
|
||||
run: {
|
||||
stdout: "BUN_CODE\nbun-specific",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user