diff --git a/.changeset/eight-mice-march.md b/.changeset/eight-mice-march.md
new file mode 100644
index 000000000..045b8da9a
--- /dev/null
+++ b/.changeset/eight-mice-march.md
@@ -0,0 +1,8 @@
+---
+"@farmfe/js-plugin-postcss": patch
+"@farmfe/js-plugin-less": patch
+"@farmfe/js-plugin-sass": patch
+"@farmfe/core": patch
+---
+
+Fix persistent cache panic when using addFileWatchFile with query #2067
diff --git a/crates/compiler/src/build/module_cache.rs b/crates/compiler/src/build/module_cache.rs
index 205097bae..baf558b74 100644
--- a/crates/compiler/src/build/module_cache.rs
+++ b/crates/compiler/src/build/module_cache.rs
@@ -305,9 +305,8 @@ fn is_watch_dependencies_timestamp_changed(
"is_watch_dependencies_timestamp_changed: {:?}",
cached_module.module.id
));
- let module_id = cached_module.module.id.clean_id();
let watch_graph = context.watch_graph.read();
- let relation_dependencies = watch_graph.relation_dependencies(&module_id);
+ let relation_dependencies = watch_graph.relation_dependencies(&cached_module.module.id);
if relation_dependencies.is_empty() {
return false;
@@ -342,9 +341,8 @@ fn is_watch_dependencies_content_hash_changed(
"is_watch_dependencies_content_hash_changed: {:?}",
cached_module.module.id
));
- let module_id = cached_module.module.id.clean_id();
let watch_graph = context.watch_graph.read();
- let relation_dependencies = watch_graph.relation_dependencies(&module_id);
+ let relation_dependencies = watch_graph.relation_dependencies(&cached_module.module.id);
if relation_dependencies.is_empty() {
return false;
diff --git a/crates/core/src/module/mod.rs b/crates/core/src/module/mod.rs
index c16abac18..0f8272514 100644
--- a/crates/core/src/module/mod.rs
+++ b/crates/core/src/module/mod.rs
@@ -712,14 +712,6 @@ impl ModuleId {
(p.to_string(), query.to_string())
}
-
- // path without query
- pub fn clean_id(&self) -> ModuleId {
- Self {
- relative_path: self.relative_path.clone(),
- query_string: "".to_string(),
- }
- }
}
impl From<&str> for ModuleId {
diff --git a/examples/react/src/index.module.scss b/examples/react/src/index.module.scss
new file mode 100644
index 000000000..8cfca002f
--- /dev/null
+++ b/examples/react/src/index.module.scss
@@ -0,0 +1,11 @@
+@import './variables.scss';
+
+:global {
+ body {
+ background-color: $primaryColor;
+ }
+}
+
+.main {
+ display: block;
+}
\ No newline at end of file
diff --git a/examples/react/src/index.scss b/examples/react/src/index.scss
deleted file mode 100644
index 47179691a..000000000
--- a/examples/react/src/index.scss
+++ /dev/null
@@ -1,5 +0,0 @@
-@import './variables.scss';
-
-body {
- background-color: $primaryColor;
-}
diff --git a/examples/react/src/index.tsx b/examples/react/src/index.tsx
index fe84e5270..4ef1fe7ed 100644
--- a/examples/react/src/index.tsx
+++ b/examples/react/src/index.tsx
@@ -1,16 +1,14 @@
-import { Provider } from 'react-redux';
-import React from 'react';
-import { createRoot } from 'react-dom/client';
-import { Main } from './main';
-import { store } from './store';
+import { Provider } from "react-redux";
+import React from "react";
+import { createRoot } from "react-dom/client";
+import { Main } from "./main";
+import { store } from "./store";
-import './index.scss';
-
-const container = document.querySelector('#root');
+const container = document.querySelector("#root");
const root = createRoot(container);
root.render(