-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Enable serve_dioxus_application for WASM targets #4170
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
Conversation
ealmloff
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see how exposing the logic to handle server functions and the default route renderer is useful in wasm, but the serve_static_assets function is documented as serving static assets which we can't do in wasm servers. How about a new method with the same signature on DioxusRouterFnExt that just serves the fullstack server function and rendering endpoints instead?
|
After re-reading the comment, I would have to agree that this approach makes more sense.
Let me know if theres anything else I can do! |
|
Those two tests seem to be failing on main also, is there anything I need to change in this PR? Also, I was wondering if I could incorporate a |
ealmloff
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks! Workflow failures are unrelated.
I think that would make sense. What is your setup for serving a fullstack app with a wasm backend? We look for the |
|
Atm, I have to do: In my code on my own app, which is a bit cumbersome, and makes it harder to mix regular fullstack with cloudflare. Ideally theres some way to directly target features for a wasm server, and it would be even better if it could be hooked into the Thanks for merging the PR. Let me know if there is any interest in a more direct integration, I would be happy to explore the idea further and potentially put forward a follow-up PR. |
* optional asset serving * optional asset serving * Add serve_api_application for WASM environments * fix cfg * remove old placeholder
* optional asset serving * optional asset serving * Add serve_api_application for WASM environments * fix cfg * remove old placeholder
Motivation
Currently, WASM servers cannot use
serve_dioxus_applicationbecause it's trait extension only has an implementation for non-WASM targets. If users try to manually implement this functionality, they encounter difficulty accessing the privatecontext_providersfield in theServeConfig, and have to rewrite a lot of the core logic for SSR which has a maintenance burden.Solution
This PR adds conditional compilation for the
serve_static_assetsmethod:self(no-op)This allows WASM servers to use the same
serve_dioxus_applicationAPI as non-WASM servers, simplifying code that needs to work across both environments. Since this trait is never used on wasm currently, it should not introduce a breaking change.