From ea252ea40602a5f855ab26e6b98dc82bbb71e035 Mon Sep 17 00:00:00 2001 From: isaurssaurav Date: Sat, 28 Oct 2023 11:53:19 +0200 Subject: [PATCH 1/2] fix(#2): add buffer time to reload the extension --- src/main.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index fde6634..861af35 100644 --- a/src/main.ts +++ b/src/main.ts @@ -50,9 +50,11 @@ const hotReloadExtension = (options: hotReloadExtensionOptions): Plugin => { chalkLogger.red('Load extension to browser...'); return; } - // TODO BUG: when user triggers watch before previous build is completed, the extension crashes - ws?.send(Message.FILE_CHANGE); - if (log) chalkLogger.green('Extension Reloaded...'); + + setTimeout(()=>{ + ws?.send(Message.FILE_CHANGE); + if (log) chalkLogger.green('Extension Reloaded...'); + }, 1000) } }; }; From 4e4a8b0f8e8d94f34025d0a30772912f444d0749 Mon Sep 17 00:00:00 2001 From: isaurssaurav Date: Sat, 28 Oct 2023 11:54:52 +0200 Subject: [PATCH 2/2] refactor(#2): code --- .gitignore | 3 ++- src/main.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 76add87..c2dd9a5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules -dist \ No newline at end of file +dist +.vscode \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 861af35..a181125 100644 --- a/src/main.ts +++ b/src/main.ts @@ -51,10 +51,10 @@ const hotReloadExtension = (options: hotReloadExtensionOptions): Plugin => { return; } - setTimeout(()=>{ + setTimeout(() => { ws?.send(Message.FILE_CHANGE); if (log) chalkLogger.green('Extension Reloaded...'); - }, 1000) + }, 1000); } }; };