Skip to content

bun build turns const into var #19046

@mkahvi

Description

@mkahvi

What version of Bun is running?

1.2.9

What platform is your computer?

Microsoft Windows NT 10.0.26100.0 x64

What steps can reproduce the bug?

bun build the following

const str = 'n/a';
console.log(str);

What is the expected behavior?

const remaining const, or at most being converted to let

What do you see instead?

var str

Additional information

Considering var has side effects and is generally undesirable in almost every context except when explicitly desired, the build process converting my const to var seems very strange. It also behaves differently from const so that makes this doubly strange, tho if no re-assignments are detected, it's probably fine from that angle.

However, it should be converted to let at most, not var.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbundlerSomething to do with the bundler

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions