ryansolid / dom-expressions

A Fine-Grained Runtime for Performant DOM Rendering
MIT License
850 stars 122 forks source link

make `voidFn()` return value explicit #305

Closed samualtnorman closed 6 months ago

samualtnorman commented 6 months ago

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.

ryansolid commented 6 months ago

Odd but can't hurt.