Quickstart Simple example wont run on web #2945
-
|
Hi, im new with flutter_rust_bridge. Following the quickstart from document demo
I built with: wasm-pack build --release --target web --out-dir "$PROJECT_ROOT/web/pkg" When launching the web page, the console shows: Uncaught SyntaxError: Unexpected token 'export' I checked the generated JavaScript file (rust_lib.js) and noticed that it was loaded in HTML as: <script src="pkg/rust_lib.js"></script>but without type="module". This leads to the JS file being treated as classic script instead of ES module, which likely causes the export error.
To avoid the export issue, I tried compiling with: wasm-pack build --release --target no-modules --out-dir "$PROJECT_ROOT/web/pkg" The page loads, but clicking UI buttons (which call Rust functions) triggers the following error: 'Worker': # could not be cloned This prevents interaction with the Rust/WASM functions.
The same issue occurs on the official FRB demo: https://cjycode.com/flutter_rust_bridge/demo/ Clicking the “tap to start” button shows: 'Worker': # could not be cloned So it seems this is not caused by my project setup.
frb_example/gallery, master branch wasm-pack latest version Flutter Rust Bridge master Tested on Chrome & Safari (same result)
Is Web support currently broken on master? Any guidance would be appreciated. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi, could you please try the commands in quickstart and see whether it works:
|
Beta Was this translation helpful? Give feedback.



Hi, could you please try the commands in quickstart and see whether it works: