Skip to content

Commit ff52f8c

Browse files
Fix require.cache error when loaded through a typescript file in Node 22.18+ (#18665)
Co-authored-by: Jordan Pittman <[email protected]>
1 parent 40f506f commit ff52f8c

File tree

6 files changed

+33
-29
lines changed

6 files changed

+33
-29
lines changed

.github/workflows/ci-stable.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
push:
1111
branches: [main]
1212
pull_request:
13-
branches: [main, 3.3, 3.4]
13+
branches: [main, v3]
1414

1515
permissions:
1616
contents: read

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
push:
88
branches: [main]
99
pull_request:
10-
branches: [main, 3.3, 3.4]
10+
branches: [main, v3]
1111

1212
permissions:
1313
contents: read

.github/workflows/integration-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Integration Tests
22

33
on:
44
push:
5-
branches: [main, 3.3, 3.4]
5+
branches: [main, v3]
66
pull_request:
7-
branches: [main, 3.3, 3.4]
7+
branches: [main, v3]
88

99
permissions:
1010
contents: read

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111

1212
- Improve support for raw `supports-[…]` queries in arbitrary values ([#13605](https://github.com/tailwindlabs/tailwindcss/pull/13605))
13+
- Fix `require.cache` error when loaded through a TypeScript file in Node 22.18+ ([#18665](https://github.com/tailwindlabs/tailwindcss/pull/18665))
1314

1415
## [3.4.17] - 2024-12-17
1516

integrations/parcel/tests/integration.test.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('static build', () => {
2424
env: { NODE_ENV: 'production' },
2525
})
2626

27-
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css`
27+
expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css`
2828
.font-bold {
2929
font-weight: 700;
3030
}
@@ -71,7 +71,7 @@ describe('static build', () => {
7171
env: { NODE_ENV: 'production' },
7272
})
7373

74-
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css`
74+
expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css`
7575
.bg-primary {
7676
--tw-bg-opacity: 1;
7777
background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1));
@@ -121,7 +121,7 @@ describe('static build', () => {
121121
env: { NODE_ENV: 'production' },
122122
})
123123

124-
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css`
124+
expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css`
125125
.bg-primary {
126126
--tw-bg-opacity: 1;
127127
background-color: rgb(0 0 0 / var(--tw-bg-opacity, 1));
@@ -142,19 +142,19 @@ describe('watcher', () => {
142142

143143
let runningProcess = $('parcel watch ./src/index.html --no-cache')
144144

145-
await waitForOutputFileCreation(/index\.\w+\.css$/)
145+
await waitForOutputFileCreation(/parcel\.\w+\.css$/)
146146

147-
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css`
147+
expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css`
148148
.font-bold {
149149
font-weight: 700;
150150
}
151151
`)
152152

153-
await waitForOutputFileChange(/index\.\w+\.css$/, async () => {
153+
await waitForOutputFileChange(/parcel\.\w+\.css$/, async () => {
154154
await appendToInputFile('index.html', html`<div class="font-normal"></div>`)
155155
})
156156

157-
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css`
157+
expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css`
158158
.font-bold {
159159
font-weight: 700;
160160
}
@@ -163,11 +163,11 @@ describe('watcher', () => {
163163
}
164164
`)
165165

166-
await waitForOutputFileChange(/index\.\w+\.css$/, async () => {
166+
await waitForOutputFileChange(/parcel\.\w+\.css$/, async () => {
167167
await appendToInputFile('index.html', html`<div class="bg-red-500"></div>`)
168168
})
169169

170-
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css`
170+
expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css`
171171
.bg-red-500 {
172172
--tw-bg-opacity: 1;
173173
background-color: rgb(239 68 68 / var(--tw-bg-opacity, 1));
@@ -190,19 +190,19 @@ describe('watcher', () => {
190190

191191
let runningProcess = $('parcel watch ./src/index.html --no-cache')
192192

193-
await waitForOutputFileCreation(/index\.\w+\.css$/)
193+
await waitForOutputFileCreation(/parcel\.\w+\.css$/)
194194

195-
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css`
195+
expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css`
196196
.font-bold {
197197
font-weight: 700;
198198
}
199199
`)
200200

201-
await waitForOutputFileChange(/index\.\w+\.css$/, async () => {
201+
await waitForOutputFileChange(/parcel\.\w+\.css$/, async () => {
202202
await appendToInputFile('glob/index.html', html`<div class="font-normal"></div>`)
203203
})
204204

205-
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css`
205+
expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css`
206206
.font-bold {
207207
font-weight: 700;
208208
}
@@ -211,11 +211,11 @@ describe('watcher', () => {
211211
}
212212
`)
213213

214-
await waitForOutputFileChange(/index\.\w+\.css$/, async () => {
214+
await waitForOutputFileChange(/parcel\.\w+\.css$/, async () => {
215215
await appendToInputFile('glob/index.html', html`<div class="bg-red-500"></div>`)
216216
})
217217

218-
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css`
218+
expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css`
219219
.bg-red-500 {
220220
--tw-bg-opacity: 1;
221221
background-color: rgb(239 68 68 / var(--tw-bg-opacity, 1));
@@ -242,9 +242,9 @@ describe('watcher', () => {
242242

243243
let runningProcess = $('parcel watch ./src/index.html --no-cache')
244244

245-
await waitForOutputFileCreation(/index\.\w+\.css$/)
245+
await waitForOutputFileCreation(/parcel\.\w+\.css$/)
246246

247-
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css`
247+
expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css`
248248
.font-bold {
249249
font-weight: 700;
250250
}
@@ -255,7 +255,7 @@ describe('watcher', () => {
255255
}
256256
`)
257257

258-
await waitForOutputFileChange(/index\.\w+\.css$/, async () => {
258+
await waitForOutputFileChange(/parcel\.\w+\.css$/, async () => {
259259
await writeInputFile(
260260
'../tailwind.config.js',
261261
javascript`
@@ -280,7 +280,7 @@ describe('watcher', () => {
280280
)
281281
})
282282

283-
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css`
283+
expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css`
284284
.font-bold {
285285
font-weight: bold;
286286
}
@@ -305,15 +305,15 @@ describe('watcher', () => {
305305

306306
let runningProcess = $('parcel watch ./src/index.html --no-cache')
307307

308-
await waitForOutputFileCreation(/index\.\w+\.css$/)
308+
await waitForOutputFileCreation(/parcel\.\w+\.css$/)
309309

310-
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css`
310+
expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css`
311311
.font-bold {
312312
font-weight: 700;
313313
}
314314
`)
315315

316-
await waitForOutputFileChange(/index\.\w+\.css$/, async () => {
316+
await waitForOutputFileChange(/parcel\.\w+\.css$/, async () => {
317317
await writeInputFile(
318318
'index.css',
319319
css`
@@ -330,7 +330,7 @@ describe('watcher', () => {
330330
)
331331
})
332332

333-
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css`
333+
expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css`
334334
/* prettier-ignore */
335335
.btn {
336336
border-radius: .25rem;
@@ -341,7 +341,7 @@ describe('watcher', () => {
341341
}
342342
`)
343343

344-
await waitForOutputFileChange(/index\.\w+\.css$/, async () => {
344+
await waitForOutputFileChange(/parcel\.\w+\.css$/, async () => {
345345
await writeInputFile(
346346
'index.css',
347347
css`
@@ -358,7 +358,7 @@ describe('watcher', () => {
358358
)
359359
})
360360

361-
expect(await readOutputFile(/index\.\w+\.css$/)).toIncludeCss(css`
361+
expect(await readOutputFile(/parcel\.\w+\.css$/)).toIncludeCss(css`
362362
.btn {
363363
--tw-bg-opacity: 1;
364364
background-color: rgb(239 68 68 / var(--tw-bg-opacity, 1));

src/lib/setupTrackingContext.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ function getTailwindConfig(configOrPath) {
5454

5555
// It has changed (based on timestamps), or first run
5656
for (let file of newDeps) {
57+
// When loaded transitively through a TypeScript file `require.cache`
58+
// may be undefined. Happens in Node 22.18+.
59+
if (!require.cache) continue
5760
delete require.cache[file]
5861
}
5962
let newConfig = validateConfig(resolveConfig(loadConfig(userConfigPath)))

0 commit comments

Comments
 (0)