-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesprima.mjs
42 lines (35 loc) · 877 Bytes
/
esprima.mjs
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import jitiFactory from 'jiti'
import { transform } from 'sucrase'
import { fileURLToPath } from 'url'
const __filename = fileURLToPath(import.meta.url)
let jiti = null
// @internal
// This WILL be removed in some future release
// If you rely on this your stuff WILL break
export function useCustomJiti(_jiti) {
jiti = _jiti()
}
function lazyJiti() {
return (
jiti ??
(jiti = jitiFactory(__filename, {
interopDefault: true,
transform: (opts) => {
return transform(opts.source, {
transforms: ['typescript', 'imports'],
})
},
}))
)
}
export function loadConfig(path) {
let config = (function () {
try {
return path ? require(path) : {}
} catch {
return lazyJiti()(path)
}
})()
return config.default ?? config
}
console.log(loadConfig('./tailwind.config.js').theme.extend.colors)