From 94e47d716aa5cbc1b2d33242b70b951c5bfc1fb5 Mon Sep 17 00:00:00 2001 From: Jerry_Wu <409187100@qq.com> Date: Fri, 11 Apr 2025 14:28:55 +0800 Subject: [PATCH 1/2] fix(repl): improve deepUpdate logic for array item matching --- packages/docs/src/repl/repl-output-update.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/docs/src/repl/repl-output-update.ts b/packages/docs/src/repl/repl-output-update.ts index 408f785c58b..d8e544d61a9 100644 --- a/packages/docs/src/repl/repl-output-update.ts +++ b/packages/docs/src/repl/repl-output-update.ts @@ -13,7 +13,10 @@ const deepUpdate = (prev: any, next: any) => { } if (Array.isArray(prev)) { for (const item of prev) { - if (!next.includes(item)) { + // can't use Object as a matcher + // because it will be a different object + // so we need to use the path or code + if (!next.map((item: any) => item.path || item.code).includes(item.path || item.code)) { prev.splice(prev.indexOf(item), 1); } } @@ -33,6 +36,7 @@ export const updateReplOutput = async (store: ReplStore, result: ReplResult) => if (store.html !== result.html) { store.html = result.html; } + deepUpdate(store.transformedModules, result.transformedModules); deepUpdate(store.clientBundles, result.clientBundles); deepUpdate(store.ssrModules, result.ssrModules); From 69dd8fb148cf4889c57cbf4aab0738094ee29ca5 Mon Sep 17 00:00:00 2001 From: Jerry_Wu <409187100@qq.com> Date: Tue, 22 Apr 2025 19:36:12 +0800 Subject: [PATCH 2/2] fix it --- packages/docs/src/repl/repl-output-update.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/docs/src/repl/repl-output-update.ts b/packages/docs/src/repl/repl-output-update.ts index d8e544d61a9..4f288d71881 100644 --- a/packages/docs/src/repl/repl-output-update.ts +++ b/packages/docs/src/repl/repl-output-update.ts @@ -16,7 +16,10 @@ const deepUpdate = (prev: any, next: any) => { // can't use Object as a matcher // because it will be a different object // so we need to use the path or code - if (!next.map((item: any) => item.path || item.code).includes(item.path || item.code)) { + + if ( + next.some((nextItem: any) => (nextItem.path || nextItem.code) === (item.path || item.code)) + ) { prev.splice(prev.indexOf(item), 1); } }