DioxusLabs / DioxusLabs/dioxus
Contents of Javascript files being erased in bundle when functions are called from `document::eval`
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
**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](https://discord.com/channels/899851952891002890/1457430723932852268) 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.
```rust
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`
```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.
```js
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
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.