-
Notifications
You must be signed in to change notification settings - Fork 426
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
wasm32-unknown-unknown support in non-browser environment #1118
Comments
Hmmm, not too familiar with the wasm stuff, but we do check in CI: https://github.com/graphql-rust/juniper/blob/master/.github/workflows/ci.yml#L302 |
@dustin-rcg do you have an example of CI testing |
@LegNeato The issue will not show up in cargo check because it does not validate the dependencies against a particular wasm runtime environment. @ilslv I can give an example in terms of wasmcloud. The steps would roughly be: In dev environment:
In CI build:
The
On the other hand, if these commands succeed, then this should validate the non-browser environment. You can of course, also validate that the graphql server works by sending a graphql query. This requires a few additional steps to start the HTTP capability provider, link the actor to the provider, and send the HTTP request to the wasmcloud host on the port specified in the link values. Roughly, those commands (for
|
Does the above work with no default features? Curious to know if the issue is only contained to dependencies or it is also in Juniper proper. |
@LegNeato Yes, I am able to successfully run |
I just realized that I am on an old version of juniper. It seems I was referring to an old version of the juniper book somehow. I will upgrade my project and update this issue accordingly. |
OK, using juniper 0.15.10, this is the minimum feature set I can get that passes
As soon as I add |
OK, It looks like the problem is that juniper depends on an old version of juniper 0.15.10 -> bson ^1.0 = 1.2.4: https://github.com/graphql-rust/juniper/blob/juniper-v0.15.10/juniper/Cargo.toml#L39 This is pulling in the unwanted dependencies
|
Looks like this is already fixed in |
@dustin-rcg could you check this directly from |
Actually, there is still the problem in master:
|
Here is how https://github.com/rust-random/getrandom/blob/master/Cargo.toml#L23 |
Likely blocked on rust-random/getrandom#319 |
Yet more info / another example of a library requiring |
@dustin-rcg juniper = { git = "https://github.com/graphql-rust/juniper", branch = "master", default-features = false } |
When compiling projects targeting wasm32-unknown-unknown, dependencies on wbindgen are emitted in the wasm file.
In a non-browser environment, these dependencies will not be supported. A non-browser environment is a substantial use case for a graphql server (perhaps more than a browser environment), and should be supported.
I came across this issue in the context of wasmcloud:
There is a detailed discussion in the wasmcloud Slack on this issue about the
time
crate.More info
The feature request for wasm32-uknown-unknown support from four years ago was limited to browsers with
offline
support. With the more recent developments in non-browser use cases, this should be revisited.Some versions of dependencies such as
time
andchrono
assume thatwasm-bindgen
is used, and requirejs-sys
, which is only available in browser environments. Providing proper support for non-browser environments will involve scrutinizing/pinning the dependency versions to ensure they do not suffer from this problem.Here are some example issues:
Ultimately, it seems like the wasm and rust communities need to define more appropriate build targets to differentiate browser and non-browser targets, but until then, support needs to be gated through dependencies.
The text was updated successfully, but these errors were encountered: