Skip to content

Commit a3a16e6

Browse files
Fix a crash with older Node.js versions (#14342)
Closes #14341 --------- Co-authored-by: Jordan Pittman <[email protected]>
1 parent 2dd52f5 commit a3a16e6

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121
- Evaluate theme functions in plugins and JS config files ([#14326](https://github.com/tailwindlabs/tailwindcss/pull/14326))
2222
- Ensure theme values overridden with `reference` values don't generate stale CSS variables ([#14327](https://github.com/tailwindlabs/tailwindcss/pull/14327))
2323
- Don’t suggest named opacity modifiers in intellisense ([#14339](https://github.com/tailwindlabs/tailwindcss/pull/14339))
24+
- Fix a crash with older Node.js versions ([#14342](https://github.com/tailwindlabs/tailwindcss/pull/14342))
2425

2526
## [4.0.0-alpha.21] - 2024-09-02
2627

packages/@tailwindcss-node/src/index.cts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@ export * from './compile'
55
// In Bun, ESM modules will also populate `require.cache`, so the module hook is
66
// not necessary.
77
if (!process.versions.bun) {
8-
Module.register(pathToFileURL(require.resolve('@tailwindcss/node/esm-cache-loader')))
8+
// `Module#register` was added in Node v18.19.0 and v20.6.0
9+
//
10+
// Not calling it means that while ESM dependencies don't get reloaded, the
11+
// actual included files will because they cache bust directly via `?id=…`
12+
Module.register?.(pathToFileURL(require.resolve('@tailwindcss/node/esm-cache-loader')))
913
}

packages/@tailwindcss-node/src/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,10 @@ export * from './compile'
66
// not necessary.
77
if (!process.versions.bun) {
88
let localRequire = Module.createRequire(import.meta.url)
9-
Module.register(pathToFileURL(localRequire.resolve('@tailwindcss/node/esm-cache-loader')))
9+
10+
// `Module#register` was added in Node v18.19.0 and v20.6.0
11+
//
12+
// Not calling it means that while ESM dependencies don't get reloaded, the
13+
// actual included files will because they cache bust directly via `?id=…`
14+
Module.register?.(pathToFileURL(localRequire.resolve('@tailwindcss/node/esm-cache-loader')))
1015
}

0 commit comments

Comments
 (0)