Fix a crash with older Node.js versions (#14342)

Closes #14341

---------

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
This commit is contained in:
Philipp Spiess 2024-09-04 19:43:18 +02:00 committed by GitHub
parent 2dd52f5a0f
commit a3a16e64d2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 2 deletions

View File

@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Evaluate theme functions in plugins and JS config files ([#14326](https://github.com/tailwindlabs/tailwindcss/pull/14326))
- Ensure theme values overridden with `reference` values don't generate stale CSS variables ([#14327](https://github.com/tailwindlabs/tailwindcss/pull/14327))
- Dont suggest named opacity modifiers in intellisense ([#14339](https://github.com/tailwindlabs/tailwindcss/pull/14339))
- Fix a crash with older Node.js versions ([#14342](https://github.com/tailwindlabs/tailwindcss/pull/14342))
## [4.0.0-alpha.21] - 2024-09-02

View File

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

View File

@ -6,5 +6,10 @@ export * from './compile'
// not necessary.
if (!process.versions.bun) {
let localRequire = Module.createRequire(import.meta.url)
Module.register(pathToFileURL(localRequire.resolve('@tailwindcss/node/esm-cache-loader')))
// `Module#register` was added in Node v18.19.0 and v20.6.0
//
// Not calling it means that while ESM dependencies don't get reloaded, the
// actual included files will because they cache bust directly via `?id=…`
Module.register?.(pathToFileURL(localRequire.resolve('@tailwindcss/node/esm-cache-loader')))
}