Skip to content

Constant propagation for top-level var #5719

@TheAlexLichter

Description

@TheAlexLichter

At the moment, Rolldown will try to replace const values if a symbol is exported to other modules. On a module-level, Rolldown does nothing as Oxc is taking care of the inlining already.

This gives room for optimization: Constant values can be propagated if the variable is used top-level.

Example Rolldown REPL.

Expected result:

const prod = 'PROD';
console.log(prod);

Or even inlined as console.log('PROD');

Related: #4258

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions