alexheretic / glyph-brush

Fast GPU cached text rendering
Apache License 2.0
688 stars 52 forks source link

Compile error with wasm-pack build #145

Open mmulli opened 2 years ago

mmulli commented 2 years ago

Hi,

It seems that there is an issue with wasm / wasm-pack when using the latest crates.io glyph_brush 0.7.3 The following rust wasm compile errors are generated after calling wasm-pack build:

error: the wasm32-unknown-unknown target is not supported by default, you may need to enable the "js" feature. For more information see: https://docs.rs/getrandom/#webassembly-support
   --> <blanked out path>/getrandom-0.2.3/src/lib.rs:219:9
    |
219 | /         compile_error!("the wasm32-unknown-unknown target is not supported by \
220 | |                         default, you may need to enable the \"js\" feature. \
221 | |                         For more information see: \
222 | |                         https://docs.rs/getrandom/#webassembly-support");
    | |________________________________________________________________________^

error[E0433]: failed to resolve: use of undeclared crate or module `imp`
   --> /<blanked out path>/getrandom-0.2.3/src/lib.rs:246:5
    |
246 |     imp::getrandom_inner(dest)
    |     ^^^ use of undeclared crate or module `imp`

To get the error I just added a dependency to that version of glyph brush to an existing wasm-pack based project of mine.

My guess is that the following section in toml is getting built on WASM that for some reason my configuration is always returning false and then building it. I wonder if this is something to do with wasm pack or perhaps the new target family options need to be used?

# enable twox-hash rand/std everywhere except wasm
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.twox-hash]
version = "1.6.1"
features = ["std"]

Built with

wasm-pack 0.10.1 rust: rustc 1.59.0-nightly glyph_brush = 0.7.3

alexheretic commented 2 years ago

The manifest allows cargo check --target wasm32-unknown-unknown to work. I'm not sure why a wasm-pack project wouldn't work.

mmulli commented 2 years ago

Okay thats good to know. If i still can't work out why wasm-pack is having issues i'll raise it over in that project.