dioxus
dioxus copied to clipboard
Contents of Javascript files being erased in bundle when functions are called from `document::eval`
Problem
Javascript files included with document::Script that have their contents called from document::eval will be added to the bundle, but with its contents removed. Per my conversation on discord with @ealmloff this would appear to be fixed by #4450
Steps To Reproduce
Steps to reproduce the behavior:
Create a minimum dioxus project with the following content.
use dioxus::prelude::*;
const TEST_JS: Asset = asset!("/assets/test.js");
fn main() {
dioxus::launch(App);
}
#[component]
fn App() -> Element {
rsx! {
document::Script { src: TEST_JS }
button {
onclick: move |_| {
document::eval(r#"testFunc("Clicked the button");"#);
},
"Test"
}
}
}
And test.js
function testFunc(e) {
alert(e);
}
Expected behavior
The contents should not be removed, if the following line is added to test.js normal behavior is observed and the minified version of test.js is present in the bundle.
testFunc("Hello from Javascript");
Screenshots
Environment:
- Dioxus version: 0.7.2
- Rust version: 1.91.1 stable-x86_64-pc-windows-msvc
- OS info: Windows 11 24H2
- App platform: Web and Desktop
Questionnaire
It seems a fix is already in the works for this, but am happy to help wherever needed