-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Fix require.cache error when loaded through a typescript file in Node 22.18+
#18665
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
Conversation
|
Sharing here my colleague's @pcaillaudm theory on the root cause:
And indeed, the bug does not trigger when running nodejs 22.18 with the option |
|
Looks like this happens because Node.js loaded a Typescript postcss config file. Your original repo appeared to work fine if the postcss config was named Minimal repro: // file.mjs
import postcss from "postcss";
import config from "./postcss.config.ts";
await postcss(config.plugins).process("");// postcss.config.ts
module.exports = {
plugins: [require("tailwindcss")],
};I'm gonna do a bit more poking around to see what happens when things are required through the typescript loader but this fix/workaround seems reasonable. |
The real issue is that `require.cache` itself is undefined. Also
require.cache error when loaded through a typescript file in Node 22.18+
|
Minimal no Tailwind CSS repro: // test.mjs
import "./file-1.ts";// file-1.ts
require("./file-2.cjs");// file-2.cjs
delete require.cache["foo"];Only happens if the typescript file is loaded via |
|
Thanks! I'll likely tag a v3 release sometime next week. |
This fixes this bug:
Not sure why we end up in this situation. It typically triggers when everything has been cleaned (
rm -rf node_modules && npm ci && npm run build) in my project.EDIT: On our side we have found out that this issue popped up with node 22.18 and was not present in 22.17.