wishawa / async_ui

Lifetime-Friendly, Component-Based, Retained-Mode UI Powered by Async Rust
Mozilla Public License 2.0
551 stars 11 forks source link

can't compile examples #8

Open wiiznokes opened 1 year ago

wiiznokes commented 1 year ago

hi, newbie here. I saw in an issue that i needed wasm-pack. So i installed it with this.

But now, i have this error:

lenaic@pop-os:~/Documents/dev/async_ui/examples/web-todomvc$ wasm-pack build --target web
[INFO]: 🎯  Checking for the Wasm target...
[INFO]: 🌀  Compiling to Wasm...
warning: some crates are on edition 2021 which defaults to `resolver = "2"`, but virtual workspaces default to `resolver = "1"`
note: to keep the current resolver, specify `workspace.resolver = "1"` in the workspace root's manifest
note: to use the edition 2021 resolver, specify `workspace.resolver = "2"` in the workspace root's manifest
   Compiling js-sys v0.3.64
   Compiling async_ui_web_macros v0.1.0 (/home/lenaic/Documents/dev/async_ui/async_ui_web_macros)
error[E0432]: unresolved import `cssparser::RuleListParser`
  --> async_ui_web_macros/src/css.rs:79:30
   |
79 |         QualifiedRuleParser, RuleListParser, Token,
   |                              ^^^^^^^^^^^^^^
   |                              |
   |                              no `RuleListParser` in the root
   |                              help: a similar name exists in the module: `RuleBodyParser`

For more information about this error, try `rustc --explain E0432`.
error: could not compile `async_ui_web_macros` (lib) due to previous error
warning: build failed, waiting for other jobs to finish...
Error: Compiling your crate to WebAssembly failed
Caused by: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit status: 101
  full command: cd "/home/lenaic/Documents/dev/async_ui/examples/web-todomvc" && "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"

Also, is this library only available for web with wasm or it also works on desktop ?

wishawa commented 1 year ago

Hi! The issue seems to be coming from wrong cssparser version. I incorrectly had the version set at 0.31.* instead of to 0.31.0. I've made a fix and pushed to main. Please try again!

Also, the examples are now made to be built with trunk rather than directly with wasm-pack. Trunk is very simple; just install it and do

cd examples/web-todomvc
trunk serve

is this library only available for web with wasm or it also works on desktop ?

In the beginning there was a GTK4 version too. However, I decided to remove that for the time being. The concept behind Async UI is still quite new so I want to have one platform working well first.

wiiznokes commented 1 year ago

I still get an error :cry:

lenaic@pop-os:~/Documents/dev/async_ui/examples/web-todomvc$ trunk serve
2023-07-06T00:03:29.635696Z  INFO 📦 starting build
2023-07-06T00:03:29.636350Z  INFO spawning asset pipelines
2023-07-06T00:03:29.697966Z  INFO building web-todomvc
warning: some crates are on edition 2021 which defaults to `resolver = "2"`, but virtual workspaces default to `resolver = "1"`
note: to keep the current resolver, specify `workspace.resolver = "1"` in the workspace root's manifest
note: to use the edition 2021 resolver, specify `workspace.resolver = "2"` in the workspace root's manifest
   Compiling async_ui_web_macros v0.1.0 (/home/lenaic/Documents/dev/async_ui/async_ui_web_macros)
   Compiling web-sys v0.3.64
error[E0432]: unresolved import `cssparser::RuleListParser`
  --> async_ui_web_macros/src/css.rs:79:30
   |
79 |         QualifiedRuleParser, RuleListParser, Token,
   |                              ^^^^^^^^^^^^^^
   |                              |
   |                              no `RuleListParser` in the root
   |                              help: a similar name exists in the module: `RuleBodyParser`

For more information about this error, try `rustc --explain E0432`.
error: could not compile `async_ui_web_macros` (lib) due to previous error
warning: build failed, waiting for other jobs to finish...
2023-07-06T00:03:33.630323Z ERROR ❌ error
error from HTML pipeline

Caused by:
    0: error from asset pipeline
    1: error during cargo build execution
    2: cargo call returned a bad status
2023-07-06T00:03:33.630513Z  INFO 📡 serving static assets at -> /
2023-07-06T00:03:33.630539Z  INFO 📡 server listening at http://127.0.0.1:8080
wishawa commented 1 year ago

Very strange. Can you make sure again that you have pulled the latest change (commit 3ab00b0), and that the file async_ui_web_macros/Cargo.toml has the line

cssparser = "0.31.0"

at the end?

If the error still persist, maybe try cargo clean?

wiiznokes commented 1 year ago

I made git pull so I should be fine. cargo clean show this:

cargo clean
warning: some crates are on edition 2021 which defaults to `resolver = "2"`, but virtual workspaces default to `resolver = "1"`
note: to keep the current resolver, specify `workspace.resolver = "1"` in the workspace root's manifest
note: to use the edition 2021 resolver, specify `workspace.resolver = "2"` in the workspace root's manifest

but it seems to work because i need to recompile the crates after. But i still get this error. Very strange indeed.

wishawa commented 1 year ago

I misunderstood how cargo handles semantic versioning. Commit fd8158f889fe22b9bf641cb26718ced0471238bc should fix the issue. Please try it!

wiiznokes commented 1 year ago

well, i have this new error now :smile: (even with the last commit)

lenaic@pop-os:~/Documents/dev/async_ui/examples/web-todomvc$ trunk serve
2023-07-11T17:49:53.298965Z  INFO 📦 starting build
2023-07-11T17:49:53.299232Z  INFO spawning asset pipelines
2023-07-11T17:49:53.364523Z  INFO building web-todomvc
warning: some crates are on edition 2021 which defaults to `resolver = "2"`, but virtual workspaces default to `resolver = "1"`
note: to keep the current resolver, specify `workspace.resolver = "1"` in the workspace root's manifest
note: to use the edition 2021 resolver, specify `workspace.resolver = "2"` in the workspace root's manifest
    Finished dev [unoptimized + debuginfo] target(s) in 0.03s
2023-07-11T17:49:53.426108Z  INFO fetching cargo artifacts
2023-07-11T17:49:53.488682Z ERROR ❌ error
error from HTML pipeline

Caused by:
    0: error from asset pipeline
    1: cargo artifacts not found for target crate
2023-07-11T17:49:53.488866Z  INFO 📡 serving static assets at -> /
2023-07-11T17:49:53.488889Z  INFO 📡 server listening at http://127.0.0.1:8080
wishawa commented 1 year ago

Seems to be a trunk issue. Can you try wasm-pack instead?

To build with wasm-pack, replace the content of index.html with this

<!DOCTYPE html>
<html>
<head>
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
</head>
<body>
    <script type="module">
        import init from './pkg/web_todomvc.js';
        init();
    </script>
</body>
</html>

Then run

wasm-pack build --dev --target web

Then you will have to serve the built content. I usually use microserver.

cargo install microserver
microserver
ChocolateLoverRaj commented 4 months ago

trunk serve works for me