forked from tailwindlabs/tailwindcss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
27 lines (25 loc) · 986 Bytes
/
Copy pathindex.ts
File metadata and controls
27 lines (25 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import * as Module from 'node:module'
import { pathToFileURL } from 'node:url'
import * as env from './env'
export * from './compile'
export * from './instrumentation'
export * from './normalize-path'
export * from './optimize'
export * from './source-maps'
export { env }
// In Bun, ESM modules will also populate `require.cache`, so the module hook is
// not necessary.
if (!process.versions.bun) {
let localRequire = Module.createRequire(import.meta.url)
// `Module#register` was added in Node v18.19.0 and v20.6.0
// `Module#registerHooks` was added in Node v26.0.0 and is the preferred API
//
// Not calling it means that while ESM dependencies don't get reloaded, the
// actual included files will because they cache bust directly via `?id=…`
let loaderUrl = pathToFileURL(localRequire.resolve('@tailwindcss/node/esm-cache-loader'))
if (Module.registerHooks) {
Module.registerHooks({ resolve: loaderUrl })
} else {
Module.register?.(loaderUrl)
}
}