8000 Fix a crash with older Node.js versions by philipp-spiess · Pull Request #14342 · tailwindlabs/tailwindcss · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
- Don’t 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

Expand Down
6 changes: 5 additions & 1 deletion packages/@tailwindcss-node/src/index.cts
Original file line number Diff line number Diff line change
Expand Up @@ -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')))
}
7 changes: 6 additions & 1 deletion packages/@tailwindcss-node/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')))
}