Closed aifrim closed 8 months ago
1.0.25+a8ff7be64
Darwin 23.3.0 arm64 arm
Just run this code
function MaybeConstructor(value) { if (!this) { return new MaybeConstructor(value); } this.value = value; } const a = new MaybeConstructor(42); const b = MaybeConstructor(42); console.log(a); console.log(b);
Node / Chrome / Safari / Firefox
MaybeConstructor { value: 42 } undefined
Output
MaybeConstructor { value: 42, } MaybeConstructor { value: 42, }
No response
this is sloppy vs strict mode. bun uses ESM by default unless there's a clear sign it should use CJS.
Add module.exports = 123; to the bottom of the file and you'll see it behaves the same as others
module.exports = 123;
What version of Bun is running?
1.0.25+a8ff7be64
What platform is your computer?
Darwin 23.3.0 arm64 arm
What steps can reproduce the bug?
Just run this code
What is the expected behavior?
Node / Chrome / Safari / Firefox
What do you see instead?
Output
Additional information
No response