-
Notifications
You must be signed in to change notification settings - Fork 710
Closed
Description
Rolldown: 1.0.0-beta.52
In rollup, static flags (imported from another file) can be tree-shaken correctly.
Example: (stackblitz)
// src/flags.js
export const flag = false;// src/index.js
import { flag } from './flags.js';
if (flag) {
console.log('should not see me in bundle!');
} else {
console.log('flag is false correctly');
}Rollup bundle:
{
console.log('flag is false correctly');
}Rolldown bundle:
//#region src/flags.js
const flag = false;
//#endregion
//#region src/index.js
if (flag) console.log("should not see me in bundle!");
else console.log("flag is false correctly");
//#endregionMore context:
- This works as intended when the const flag is in the same file
- Nitro v3 relies on this for tree-shaking server internals, and currently, tree-shaking is not effective with rolldown/rolldown-vite, causing lots of unnecessary code to be bundled. If it is a non goal of rolldown for any reason we might consider alternative methods like static code replacement.
Reactions are currently unavailable