This is to get tree shaking when using SolidStart's getRequestEvent() function e.g.
export default () => {
const requestEvent = getRequestEvent()
if (requestEvent) {
// server code here
}
// ...
}
For some reason Rollup can't statically analyse a function without an explicit return value. So before this change, the server code gets bundled into the client, but after this change, Rollup is able to see that getRequestEvent() always returns undefined meaning that requestEvent is always undefined meaning that the if statement can be tree shaken away for the client build.
This is to get tree shaking when using SolidStart's
getRequestEvent()
function e.g.For some reason Rollup can't statically analyse a function without an explicit return value. So before this change, the server code gets bundled into the client, but after this change, Rollup is able to see that
getRequestEvent()
always returnsundefined
meaning thatrequestEvent
is alwaysundefined
meaning that the if statement can be tree shaken away for the client build.