-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
Description
Rollup Version
4.27.2
Operating System (or Browser)
MacOS 14.3
Node Version (if applicable)
21.6.0
Link To Reproduction
export const getBuilder = () => {
const variantShapeId = {
errors: 1n,
events: 2n,
calls: 3n,
};
const buildVariant = (variantType) => () => {
try {
return variantShapeId[variantType];
} catch (_) {
return null;
}
};
return {
buildCall: buildVariant("calls"),
buildEvent: buildVariant("events"),
buildError: buildVariant("errors"),
};
};
Expected Behaviour
The object variantShapeId
should be left as-is, since it's being indexed by an external parameter.
Actual Behaviour
The object tree-shaking removes properties from variantShapeId
that should be accessible.
In this specific example, this only happens when wrapping the statement that accesses the object with a try-catch.
Additional context
This is a regression introduced in 4.27, related to #5420
The example is the minimum reproduction case based on existing code of our library.
Razunter