From 99effc4caac1f430fb6a3fc5b667d0d05cc3007c Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Mon, 3 Mar 2025 21:28:15 +0800 Subject: [PATCH 1/3] fix: load correct tailwind config in monorepo --- lib/util/customConfig.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/util/customConfig.js b/lib/util/customConfig.js index 1ab15994..cc946deb 100644 --- a/lib/util/customConfig.js +++ b/lib/util/customConfig.js @@ -48,7 +48,7 @@ function loadConfig(config) { if (stats === null) { // Default to no config loadedConfig = {}; - } else if (lastModifiedDate !== mtime) { + } else if (lastModifiedDate !== mtime || previousConfig !== config) { // Load the config based on path lastModifiedDate = mtime; loadedConfig = requireUncached(resolvedPath); @@ -86,13 +86,13 @@ function resolve(twConfig) { const now = Date.now(); const expired = now - lastCheck > CHECK_REFRESH_RATE; if (newConfig || expired) { - previousConfig = twConfig; - lastCheck = now; const userConfig = loadConfig(twConfig); // userConfig is null when config file was not modified if (userConfig !== null) { mergedConfig = resolveConfig(userConfig); } + previousConfig = twConfig; + lastCheck = now; } return mergedConfig; } From 167c3e4dae5d7081e267c80add94a027ff7a3119 Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Sun, 9 Mar 2025 20:49:46 +0800 Subject: [PATCH 2/3] update --- lib/util/customConfig.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/util/customConfig.js b/lib/util/customConfig.js index cc946deb..8bee7957 100644 --- a/lib/util/customConfig.js +++ b/lib/util/customConfig.js @@ -14,8 +14,8 @@ try { const CHECK_REFRESH_RATE = 1_000; let previousConfig = null; let lastCheck = null; -let mergedConfig = null; -let lastModifiedDate = null; +let mergedConfig = new Map(); +let lastModifiedDate = new Map(); /** * @see https://stackoverflow.com/questions/9210542/node-js-require-cache-possible-to-invalidate @@ -48,9 +48,9 @@ function loadConfig(config) { if (stats === null) { // Default to no config loadedConfig = {}; - } else if (lastModifiedDate !== mtime || previousConfig !== config) { + } else if (lastModifiedDate.get(resolvedPath) !== mtime) { // Load the config based on path - lastModifiedDate = mtime; + lastModifiedDate.set(resolvedPath, mtime); loadedConfig = requireUncached(resolvedPath); } else { // Unchanged config @@ -86,15 +86,15 @@ function resolve(twConfig) { const now = Date.now(); const expired = now - lastCheck > CHECK_REFRESH_RATE; if (newConfig || expired) { + previousConfig = twConfig; + lastCheck = now; const userConfig = loadConfig(twConfig); // userConfig is null when config file was not modified if (userConfig !== null) { - mergedConfig = resolveConfig(userConfig); + mergedConfig.set(twConfig, resolveConfig(userConfig)); } - previousConfig = twConfig; - lastCheck = now; } - return mergedConfig; + return mergedConfig.get(twConfig); } module.exports = { From 11dff9259c270cf8988934e46cb4c5744f5acd86 Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Sun, 9 Mar 2025 23:49:14 +0800 Subject: [PATCH 3/3] update --- lib/util/customConfig.js | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/lib/util/customConfig.js b/lib/util/customConfig.js index 8bee7957..ccc4dc92 100644 --- a/lib/util/customConfig.js +++ b/lib/util/customConfig.js @@ -12,7 +12,6 @@ try { } const CHECK_REFRESH_RATE = 1_000; -let previousConfig = null; let lastCheck = null; let mergedConfig = new Map(); let lastModifiedDate = new Map(); @@ -70,23 +69,11 @@ function loadConfig(config) { } } -function convertConfigToString(config) { - switch (typeof config) { - case 'string': - return config; - case 'object': - return JSON.stringify(config); - default: - return config.toString(); - } -} - function resolve(twConfig) { - const newConfig = convertConfigToString(twConfig) !== convertConfigToString(previousConfig); + const newConfig = mergedConfig.get(twConfig) === undefined; const now = Date.now(); const expired = now - lastCheck > CHECK_REFRESH_RATE; if (newConfig || expired) { - previousConfig = twConfig; lastCheck = now; const userConfig = loadConfig(twConfig); // userConfig is null when config file was not modified