I am trying to import and use a library I made myself in rust into another library I made in rust for wasm web. The first library is my UI library. The second library that depends on the UI library is my Game library.
the directories are:
make/ui/src/lib.rs
make/ui/Cargo.toml
make/game/src/lib.rs
make/game/Cargo.toml
My UI library builds without error. and has the following Cargo.toml
[package]
name = "ui"
version = "0.1.0"
edition = "2021"
[lib]
name = "ui"
crate-type = ["cdylib"]
I link my Game library to my local UI library in my Game library's Cargo.toml with
[dependencies]
ui = {path = "../ui/", version="0.1.0"}
The following build command executed in make/game:
wasm-pack build --release --target web
gives the compilation error: in make/game/src/lib.rs
use ui::*;
error[E0432]: unresolved import ui
^^^^^ use of undeclared crate or module `ui
the make/ui/src/lib.rs begins like this
pub mod ui
{
struct UI_A {...}
impl UI_A {...}
//etc...
}
What's missing?
UPDATE I am able to get Game library to build if I replace 'use ui' with
use crate::ui::*;
#[path = "../../ui/src/lib.rs"] mod ui;
and if I also remove pub mod ui from make/ui/src/lib.rs so I just have
struct UI_A {...}
impl UI_A {...}
//etc...
(from one of the answers posted here: How can I include a module from another file from the same project?)
I just find this a bit odd, since the path is already described in Cargo.toml. Also, although 'it works' the way I'm using it depends on having access to the source code - so not ideal if I wanted to divy up work to a team of developers to just 'use' the library without having access to the library source code.
If this is the way, please let me know.