mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-14 16:37:14 +00:00
Don't rebuild when the code is in an invalid intermediate state (#2848)
* don't rebuild when the code is invalid * Fix comment
This commit is contained in:
parent
ecb077d734
commit
40dc14389e
1 changed files with 16 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::{fs, path::PathBuf, time::Duration};
|
use std::{fs, path::PathBuf, time::Duration};
|
||||||
|
|
||||||
|
use super::hot_reloading_file_map::HotreloadError;
|
||||||
use crate::serve::hot_reloading_file_map::FileMap;
|
use crate::serve::hot_reloading_file_map::FileMap;
|
||||||
use crate::{cli::serve::Serve, dioxus_crate::DioxusCrate};
|
use crate::{cli::serve::Serve, dioxus_crate::DioxusCrate};
|
||||||
use dioxus_hot_reload::HotReloadMsg;
|
use dioxus_hot_reload::HotReloadMsg;
|
||||||
|
@ -246,12 +247,21 @@ impl Watcher {
|
||||||
}
|
}
|
||||||
|
|
||||||
for rust_file in edited_rust_files {
|
for rust_file in edited_rust_files {
|
||||||
let hotreloaded_templates = self
|
match self.file_map.update_rsx::<HtmlCtx>(&rust_file, &crate_dir) {
|
||||||
.file_map
|
Ok(hotreloaded_templates) => {
|
||||||
.update_rsx::<HtmlCtx>(&rust_file, &crate_dir)
|
templates.extend(hotreloaded_templates);
|
||||||
.ok()?;
|
}
|
||||||
|
// If the file is not reloadable, we need to rebuild
|
||||||
templates.extend(hotreloaded_templates);
|
Err(HotreloadError::Notreloadable) => return None,
|
||||||
|
// The rust file may have failed to parse, but that is most likely
|
||||||
|
// because the user is in the middle of adding new code
|
||||||
|
// We just ignore the error and let Rust analyzer warn about the problem
|
||||||
|
Err(HotreloadError::Parse) => {}
|
||||||
|
// Otherwise just log the error
|
||||||
|
Err(err) => {
|
||||||
|
tracing::error!("Error hotreloading file {rust_file:?}: {err}")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let msg = HotReloadMsg {
|
let msg = HotReloadMsg {
|
||||||
|
|
Loading…
Reference in a new issue