server function: esbuild Parse Error when running from tsx
When running a ts files using the tsx library, the ts files are built using esbuild.
import server from 'solid-start/server'
const my_fn = server(()=>{})
If the server function is in the build, a Parse Error occurs.
Error: Parse error @:1:2622
...
Why are we running files with server function with the tsx library.. it needs a server runtime to work? But also I would not expect a parse error.. must be because of the typescript.. its because we ship with typescript source which vite compiles.. tsx might not be transforming dependencies (most bundlers dont)
I have a monorepo & these functions were in a library. I was able to solve the issue by moving those functions into the app.
Is it be possible to have a fallback where the server function returns it's argument if it's called outside of vite?
On Thu, Aug 25, 2022, 1:03 AM Nikhil Saraf @.***> wrote:
Why are we running files with server function with the tsx library.. it needs a server runtime to work? But also I would not expect a parse error.. must be because of the typescript.. its because we ship with typescript source which vite compiles.. tsx might not be transforming dependencies (most bundlers dont)
— Reply to this email directly, view it on GitHub https://github.com/solidjs/solid-start/issues/258#issuecomment-1226814016, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAA4UAKPEQ3O7ARMGL3GO3V24EDPANCNFSM57QKK7TQ . You are receiving this because you authored the thread.Message ID: @.***>
If not, perhaps an explicit error? I had to track down the error through process of elimination.
On Thu, Aug 25, 2022, 2:32 PM Brian Takita @.***> wrote:
I have a monorepo & these functions were in a library. I was able to solve the issue by moving those functions into the app.
Is it be possible to have a fallback where the server function returns it's argument if it's called outside of vite?
On Thu, Aug 25, 2022, 1:03 AM Nikhil Saraf @.***> wrote:
Why are we running files with server function with the tsx library.. it needs a server runtime to work? But also I would not expect a parse error.. must be because of the typescript.. its because we ship with typescript source which vite compiles.. tsx might not be transforming dependencies (most bundlers dont)
— Reply to this email directly, view it on GitHub https://github.com/solidjs/solid-start/issues/258#issuecomment-1226814016, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAA4UAKPEQ3O7ARMGL3GO3V24EDPANCNFSM57QKK7TQ . You are receiving this because you authored the thread.Message ID: @.***>
Hmm.. if the error is coming from tsx there isn't much way to get a better error. It's because tsx doesn't understand what it is looking at I gather. The server function does exist there and it just throws with a "Should be compiled away" error so this isn't a matter of stubbing it. We are hitting this at build time before anything runs.
This sort of outside of our purview because it is just a function being returned so this is more likely just a limit of how tsx executes or is configured. I don't see any more action from our side at this time.