elysiajs / elysia

Ergonomic Framework for Humans
https://elysiajs.com
MIT License
9.94k stars 212 forks source link

Does not work when compiled with pkg #532

Open dodas opened 6 months ago

dodas commented 6 months ago

What version of Elysia.JS is running?

0.8.17

What platform is your computer?

Darwin 23.1.0 arm64 arm

What steps can reproduce the bug?

When compiling an application to binary code using pkg, stringifying functions will result in a string [native code]. This breaks elysia's attempts to optimize the code by analyzing the stringified function and results in query or headers being undefined, unless explicit type schema is specified for them. Could we skip these optimizations when dealing with compiled code?

What is the expected behavior?

Elysia works with comiled code, even if with slightly worse performance.

What do you see instead?

query and headers is undefined unless I explicitly specify their type schema.

Inplex-sys commented 6 months ago

What runtime are you using ?

dodas commented 6 months ago

@Inplex-sys I am compiling with pkg, meaning it's Node (v18.12.1) and using @whatwg-node/server as the Request/Response API compatibility layer. Everything works fine when not compiling to binary. Seems like bun also supports compiling to binary, I imagine a similar issue would occur there.