From a6daa134e8a2b6b2196810759336729c16c0ff19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=90=91=E5=A4=9C?= Date: Thu, 11 Jul 2024 17:24:53 +0800 Subject: [PATCH 1/3] fix(hmr): fix config reload --- packages/core/src/config/index.ts | 5 ++++- packages/core/src/index.ts | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/core/src/config/index.ts b/packages/core/src/config/index.ts index 51c7ad7b8..a5ae0ddc3 100644 --- a/packages/core/src/config/index.ts +++ b/packages/core/src/config/index.ts @@ -101,7 +101,10 @@ async function getDefaultConfig( logger ); - resolvedUserConfig.server = normalizeDevServerConfig(inlineOptions, mode); + resolvedUserConfig.server = normalizeDevServerConfig( + inlineOptions.server, + mode + ); resolvedUserConfig.compilation = await normalizeUserCompilationConfig( resolvedUserConfig, diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 43ebc4170..7abaee03e 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -427,7 +427,18 @@ export async function createFileWatcher( await devServer.close(); __FARM_GLOBAL__.__FARM_RESTART_DEV_SERVER__ = true; - await start(resolvedUserConfig as FarmCLIOptions & UserConfig); + + const defaultOptions = { + root: resolvedUserConfig.root, + compilation: { + lazyCompilation: resolvedUserConfig.compilation.lazyCompilation + }, + server: resolvedUserConfig.server, + clearScreen: resolvedUserConfig.clearScreen, + configPath: path.dirname(resolvedUserConfig.configFilePath), + mode: resolvedUserConfig.envMode + }; + await start(defaultOptions as FarmCLIOptions & UserConfig); }); }); return fileWatcher; From ef0ff03c5408aa71829598a4cfa3daa385f03319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=90=91=E5=A4=9C?= Date: Thu, 11 Jul 2024 17:25:57 +0800 Subject: [PATCH 2/3] chore(changeset): add changeset --- .changeset/five-dolls-burn.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/five-dolls-burn.md diff --git a/.changeset/five-dolls-burn.md b/.changeset/five-dolls-burn.md new file mode 100644 index 000000000..420b91e5e --- /dev/null +++ b/.changeset/five-dolls-burn.md @@ -0,0 +1,5 @@ +--- +"@farmfe/core": patch +--- + +Fix config reload From 630bdaf0dd851030030ff864ed48af68b2899670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=90=91=E5=A4=9C?= Date: Fri, 12 Jul 2024 10:33:42 +0800 Subject: [PATCH 3/3] refactor(core): remove pure restart --- packages/core/src/index.ts | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 7abaee03e..43ebc4170 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -427,18 +427,7 @@ export async function createFileWatcher( await devServer.close(); __FARM_GLOBAL__.__FARM_RESTART_DEV_SERVER__ = true; - - const defaultOptions = { - root: resolvedUserConfig.root, - compilation: { - lazyCompilation: resolvedUserConfig.compilation.lazyCompilation - }, - server: resolvedUserConfig.server, - clearScreen: resolvedUserConfig.clearScreen, - configPath: path.dirname(resolvedUserConfig.configFilePath), - mode: resolvedUserConfig.envMode - }; - await start(defaultOptions as FarmCLIOptions & UserConfig); + await start(resolvedUserConfig as FarmCLIOptions & UserConfig); }); }); return fileWatcher;