Closed trevor-scheer closed 7 months ago
After digging around a bit more, it became apparent to me the issue was in the usage of the instant
crate somewhere within our deps, not std::time::Instant
.
The instant
crate provides a feature for wasm-bindgen
which needs to be enabled in Cargo.toml
like so:
instant = { version = "0.1.12", features = [ "wasm-bindgen" ] }
I'm not super familiar with the rust/wasm ecosystem, deps, and features of deps yet so this took me awhile to arrive at the solution. Is this something worth documenting in our README, perhaps?
This issue is probably fine to close, but I will leave it up to you folks in case there's a better solution than the one I've arrived at that y'all have in mind.
Instant is not in use anymore in the latest 1.0 betas. New code should use the 1.0 betas rather than 0.11.x!
apollo-compiler = "=1.0.0-beta.14"
Description
I tried using
apollo_compiler
in a wasm context. My Rust app compiles successfully but encounters a "Module not found" error (seemingly at thewasm-pack
step being handled by webpack, though that's not entirely apparent to me).I mention this in the repro README, but it seems
Instant::now
is unavailable in wasm and somewhere in the dependency tree ofapollo_compiler
it's being used. Unfortunately this isn't caught as part of building for wasm, else this error would turn up in our wasm build step in CI.Also in the README but worth referencing here, this thread is highly relevant.
Steps to reproduce
Clone this repo: https://github.com/trevor-scheer/compiler-wasm-reproduction Reproduction steps are at the bottom of the README.
The initial commit comes from this handy template. Things run as expected from that commit. The second commit shows my diff which introduces
apollo_compiler
usage and the error mentioned in the README occurs.Expected result
I expect to be able to use
apollo_compiler
in a wasm context without module resolution errors.Actual result
Module resolution error:
Environment
Happy to provide more specifics if needed, but I don't think this is env specific
zsh
apollo-rs
crate:apollo_compiler
0.11.3