Skip to content

Application constants get replaced with magic number when an operator is used #5967

@MathieuBranchaud

Description

@MathieuBranchaud

Rollup Version

4.30.0

Operating System (or Browser)

Windows

Node Version (if applicable)

22.10.0

Link To Reproduction

https://rollupjs.org/repl/?version=4.41.1&shareable=JTdCJTIyZXhhbXBsZSUyMiUzQW51bGwlMkMlMjJtb2R1bGVzJTIyJTNBJTVCJTdCJTIyY29kZSUyMiUzQSUyMmV4cG9ydCUyMColMjBmcm9tJTIwJTVDJTIyLiUyRkNvbnN0YW50cy5qcyU1QyUyMiUzQiU1Q25leHBvcnQlMjAqJTIwZnJvbSUyMCU1QyUyMi4lMkZMaWJyYXJ5LmpzJTVDJTIyJTNCJTIyJTJDJTIyaXNFbnRyeSUyMiUzQXRydWUlMkMlMjJuYW1lJTIyJTNBJTIybWFpbi5qcyUyMiU3RCUyQyU3QiUyMmNvZGUlMjIlM0ElMjJleHBvcnQlMjBjb25zdCUyMEJPQiUyMCUzRCUyMDMlM0IlMjIlMkMlMjJpc0VudHJ5JTIyJTNBZmFsc2UlMkMlMjJuYW1lJTIyJTNBJTIyQ29uc3RhbnRzLmpzJTIyJTdEJTJDJTdCJTIyY29kZSUyMiUzQSUyMmltcG9ydCUyMCU3QiUyMEJPQiUyMCU3RCUyMGZyb20lMjAlNUMlMjIuJTJGQ29uc3RhbnRzLmpzJTVDJTIyJTNCJTVDbiU1Q25leHBvcnQlMjBmdW5jdGlvbiUyMGdldEJvYigpJTIwJTdCJTVDbiUyMCUyMHJldHVybiUyMCU3QnglM0ElMjBCT0IlMkMlMjB5JTNBJTIwLUJPQiUyQyUyMHolM0ElMjAlMkJCT0IlN0QlNUNuJTdEJTIyJTJDJTIyaXNFbnRyeSUyMiUzQWZhbHNlJTJDJTIybmFtZSUyMiUzQSUyMkxpYnJhcnkuanMlMjIlN0QlNUQlMkMlMjJvcHRpb25zJTIyJTNBJTdCJTdEJTdE

Expected Behaviour

Description:

Last working version was rollup 4.29.2.
Starting with rollup 4.30.0 and up to the latest version (4.41.1), some application constants get replaced with magic number if an operator is added. This is a minor issue as the value is accurate and the code is valid. But is still a minor annoyance when building a reusable library used by multiple applications as now when debugging and stepping into the library built code you will get magic numbers and will have to check the library source code to find the origin of the numbers.

Expected:

const BOB = 3;

function getBob() {
return {x: BOB, y: -BOB, z: +BOB}
}

export { BOB, getBob };

Actual Behaviour

const BOB = 3;

function getBob() {
return {x: BOB, y: -3, z: 3}
}

export { BOB, getBob };

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions