Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server$ should work in not only .jsx and .tsx files #408

Closed
jchatard opened this issue Nov 8, 2022 · 2 comments · Fixed by #668
Closed

server$ should work in not only .jsx and .tsx files #408

jchatard opened this issue Nov 8, 2022 · 2 comments · Fixed by #668
Labels
bug Something isn't working

Comments

@jchatard
Copy link
Contributor

jchatard commented Nov 8, 2022

Using server$ as default export breaks build.

export default server$(async (path: string) => {
  // Do stuff
});

Produces:

An error occured while server rendering /program/33740:
  
Error: Should be compiled away
    at Module.server$ [as default] (/Users/jchatard/Documents/XXXX/XXXX.fr/front-solidjs/node_modules/.pnpm/solid-start@0.2.5_hbwrjiud3j45e6mxm6q434ty3e/node_modules/solid-start/server/server-functions/server.ts:21:8)
    at /Users/jchatard/Documents/XXXX/XXXX.fr/front-solidjs/src/lib/fetcher.ts:14:23
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async instantiateModule (file:///Users/jchatard/Documents/XXXX/XXXX.fr/front-solidjs/node_modules/.pnpm/vite@3.2.3/node_modules/vite/dist/node/chunks/dep-51c4f80a.js:53053:9

But this works:

export const fetchAPI = () => server$(async (path: string) => {
  // Do stuff
}); 

Works!

@jchatard
Copy link
Contributor Author

jchatard commented Nov 9, 2022

And here's a repro: https://github.com/jchatard/should_be_compiled_away

@jchatard
Copy link
Contributor Author

To give an update, I have been struggling to make it work in my full app, until I stumbled accross this comment from @nksaraf on Discord:

Yeah this is very fair... since its only me who has worked on it and used it extensively.. subconciously I know what to do.. one thing to look out for it to make sure the files are .tsx when you use server functions since that can cause the compiled error thing

So renaming files which contained server$calls from *.ts to *.tsx, solved my issue.

@ryansolid ryansolid changed the title server$ can't be exported as default server$ should work in not only .jsx and .tsx files Dec 21, 2022
@ryansolid ryansolid added the bug Something isn't working label Dec 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants