Skip to content

fix: load correct tailwind config in monorepo #389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/util/customConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ try {
const CHECK_REFRESH_RATE = 1_000;
let previousConfig = null;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hyoban I guess previousConfig should not be needed anymore if we keep a cache of all the configs we find?

also this part

const newConfig = convertConfigToString(twConfig) !== convertConfigToString(previousConfig);

it's probably also not necessary and we could check if the config is in the cache?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is better, thanks for your review!

Copy link
Contributor Author

@hyoban hyoban Mar 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code has been updated to apply your suggestion

11dff92 (#389)

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
Expand Down Expand Up @@ -48,9 +48,9 @@ function loadConfig(config) {
if (stats === null) {
// Default to no config
loadedConfig = {};
} else if (lastModifiedDate !== mtime) {
} else if (lastModifiedDate.get(resolvedPath) !== mtime) {
// Load the config based on path
lastModifiedDate = mtime;
lastModifiedDate.set(resolvedPath, mtime);
loadedConfig = requireUncached(resolvedPath);
} else {
// Unchanged config
Expand Down Expand Up @@ -91,10 +91,10 @@ function resolve(twConfig) {
const userConfig = loadConfig(twConfig);
// userConfig is null when config file was not modified
if (userConfig !== null) {
mergedConfig = resolveConfig(userConfig);
mergedConfig.set(twConfig, resolveConfig(userConfig));
}
}
return mergedConfig;
return mergedConfig.get(twConfig);
}

module.exports = {
Expand Down