From abc594718ad0950ff3c3511dd2aa2534d92fe406 Mon Sep 17 00:00:00 2001 From: Philippe Gaultier Date: Mon, 4 Aug 2025 17:02:15 +0200 Subject: [PATCH 1/6] fix: fix undefined error in getTailwindConfig --- src/lib/setupTrackingContext.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/setupTrackingContext.js b/src/lib/setupTrackingContext.js index 70e7cb684139..379f99ca994d 100644 --- a/src/lib/setupTrackingContext.js +++ b/src/lib/setupTrackingContext.js @@ -54,6 +54,9 @@ function getTailwindConfig(configOrPath) { // It has changed (based on timestamps), or first run for (let file of newDeps) { + if (!file || !require.cache || !require.cache[file]) { + continue + } delete require.cache[file] } let newConfig = validateConfig(resolveConfig(loadConfig(userConfigPath))) From 095017ad6c26481e0db9c6b86cc923dcfa650033 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Fri, 22 Aug 2025 10:03:46 -0400 Subject: [PATCH 2/6] wip --- .github/workflows/ci-stable.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-stable.yml b/.github/workflows/ci-stable.yml index 394bd6dda567..61ae38e6f415 100644 --- a/.github/workflows/ci-stable.yml +++ b/.github/workflows/ci-stable.yml @@ -10,7 +10,7 @@ on: push: branches: [main] pull_request: - branches: [main, 3.3, 3.4] + branches: [main, v3] permissions: contents: read From ae2e92ec7658df63629c14a39d51a6dd7de20cb3 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Fri, 22 Aug 2025 10:21:45 -0400 Subject: [PATCH 3/6] wip --- .github/workflows/ci.yml | 2 +- .github/workflows/integration-tests.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e5c0135fb3f5..71649f4bb099 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ on: push: branches: [main] pull_request: - branches: [main, 3.3, 3.4] + branches: [main, v3] permissions: contents: read diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index f0967175cc26..ff5a68df1740 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -2,9 +2,9 @@ name: Integration Tests on: push: - branches: [main, 3.3, 3.4] + branches: [main, v3] pull_request: - branches: [main, 3.3, 3.4] + branches: [main, v3] permissions: contents: read From fe31a821bba0b94c94b9746a32e3860573f1b425 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Fri, 22 Aug 2025 10:33:50 -0400 Subject: [PATCH 4/6] Fix parcel tests --- integrations/parcel/tests/integration.test.js | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/integrations/parcel/tests/integration.test.js b/integrations/parcel/tests/integration.test.js index beaf5e70d7dc..f0ae14a26354 100644 --- a/integrations/parcel/tests/integration.test.js +++ b/integrations/parcel/tests/integration.test.js @@ -24,7 +24,7 @@ describe('static build', () => { env: { NODE_ENV: 'production' }, }) - expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css` + expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css` .font-bold { font-weight: 700; } @@ -71,7 +71,7 @@ describe('static build', () => { env: { NODE_ENV: 'production' }, }) - expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css` + expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css` .bg-primary { --tw-bg-opacity: 1; background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1)); @@ -121,7 +121,7 @@ describe('static build', () => { env: { NODE_ENV: 'production' }, }) - expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css` + expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css` .bg-primary { --tw-bg-opacity: 1; background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1)); @@ -142,19 +142,19 @@ describe('watcher', () => { let runningProcess = $('parcel watch ./src/index.html --no-cache') - await waitForOutputFileCreation(/index\.\w+\.css$/) + await waitForOutputFileCreation(/parcel\.\w+\.css$/) - expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css` + expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css` .font-bold { font-weight: 700; } `) - await waitForOutputFileChange(/index\.\w+\.css$/, async () => { + await waitForOutputFileChange(/parcel\.\w+\.css$/, async () => { await appendToInputFile('index.html', html`
`) }) - expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css` + expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css` .font-bold { font-weight: 700; } @@ -163,11 +163,11 @@ describe('watcher', () => { } `) - await waitForOutputFileChange(/index\.\w+\.css$/, async () => { + await waitForOutputFileChange(/parcel\.\w+\.css$/, async () => { await appendToInputFile('index.html', html`
`) }) - expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css` + expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css` .bg-red-500 { --tw-bg-opacity: 1; background-color: rgb(239 68 68 / var(--tw-bg-opacity, 1)); @@ -190,19 +190,19 @@ describe('watcher', () => { let runningProcess = $('parcel watch ./src/index.html --no-cache') - await waitForOutputFileCreation(/index\.\w+\.css$/) + await waitForOutputFileCreation(/parcel\.\w+\.css$/) - expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css` + expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css` .font-bold { font-weight: 700; } `) - await waitForOutputFileChange(/index\.\w+\.css$/, async () => { + await waitForOutputFileChange(/parcel\.\w+\.css$/, async () => { await appendToInputFile('glob/index.html', html`
`) }) - expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css` + expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css` .font-bold { font-weight: 700; } @@ -211,11 +211,11 @@ describe('watcher', () => { } `) - await waitForOutputFileChange(/index\.\w+\.css$/, async () => { + await waitForOutputFileChange(/parcel\.\w+\.css$/, async () => { await appendToInputFile('glob/index.html', html`
`) }) - expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css` + expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css` .bg-red-500 { --tw-bg-opacity: 1; background-color: rgb(239 68 68 / var(--tw-bg-opacity, 1)); @@ -242,9 +242,9 @@ describe('watcher', () => { let runningProcess = $('parcel watch ./src/index.html --no-cache') - await waitForOutputFileCreation(/index\.\w+\.css$/) + await waitForOutputFileCreation(/parcel\.\w+\.css$/) - expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css` + expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css` .font-bold { font-weight: 700; } @@ -255,7 +255,7 @@ describe('watcher', () => { } `) - await waitForOutputFileChange(/index\.\w+\.css$/, async () => { + await waitForOutputFileChange(/parcel\.\w+\.css$/, async () => { await writeInputFile( '../tailwind.config.js', javascript` @@ -280,7 +280,7 @@ describe('watcher', () => { ) }) - expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css` + expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css` .font-bold { font-weight: bold; } @@ -305,15 +305,15 @@ describe('watcher', () => { let runningProcess = $('parcel watch ./src/index.html --no-cache') - await waitForOutputFileCreation(/index\.\w+\.css$/) + await waitForOutputFileCreation(/parcel\.\w+\.css$/) - expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css` + expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css` .font-bold { font-weight: 700; } `) - await waitForOutputFileChange(/index\.\w+\.css$/, async () => { + await waitForOutputFileChange(/parcel\.\w+\.css$/, async () => { await writeInputFile( 'index.css', css` @@ -330,7 +330,7 @@ describe('watcher', () => { ) }) - expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css` + expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css` /* prettier-ignore */ .btn { border-radius: .25rem; @@ -341,7 +341,7 @@ describe('watcher', () => { } `) - await waitForOutputFileChange(/index\.\w+\.css$/, async () => { + await waitForOutputFileChange(/parcel\.\w+\.css$/, async () => { await writeInputFile( 'index.css', css` @@ -358,7 +358,7 @@ describe('watcher', () => { ) }) - expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css` + expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css` .btn { --tw-bg-opacity: 1; background-color: rgb(239 68 68 / var(--tw-bg-opacity, 1)); From f083082001a17f7a6ce76d6ce3dff57bff10f948 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Fri, 22 Aug 2025 12:07:51 -0400 Subject: [PATCH 5/6] Improve fix a bit The real issue is that `require.cache` itself is undefined. Also --- src/lib/setupTrackingContext.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/setupTrackingContext.js b/src/lib/setupTrackingContext.js index 379f99ca994d..93df47200822 100644 --- a/src/lib/setupTrackingContext.js +++ b/src/lib/setupTrackingContext.js @@ -54,9 +54,9 @@ function getTailwindConfig(configOrPath) { // It has changed (based on timestamps), or first run for (let file of newDeps) { - if (!file || !require.cache || !require.cache[file]) { - continue - } + // When loaded transitively through a TypeScript file `require.cache` + // may be undefined. Happens in Node 22.18+. + if (!require.cache) continue delete require.cache[file] } let newConfig = validateConfig(resolveConfig(loadConfig(userConfigPath))) From e96fda6f5a7508047595e3999f1f00c92835ed5c Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Fri, 22 Aug 2025 12:38:34 -0400 Subject: [PATCH 6/6] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffcdd5bbd9f5..bd4b0197ddd6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Improve support for raw `supports-[…]` queries in arbitrary values ([#13605](https://github.com/tailwindlabs/tailwindcss/pull/13605)) +- Fix `require.cache` error when loaded through a TypeScript file in Node 22.18+ ([#18665](https://github.com/tailwindlabs/tailwindcss/pull/18665)) ## [3.4.17] - 2024-12-17