| [9af201e] | 1 | export const env =
|
|---|
| 2 | typeof process !== 'undefined'
|
|---|
| 3 | ? {
|
|---|
| 4 | NODE_ENV: process.env.NODE_ENV,
|
|---|
| 5 | DEBUG: resolveDebug(process.env.DEBUG),
|
|---|
| 6 | }
|
|---|
| 7 | : {
|
|---|
| 8 | NODE_ENV: 'production',
|
|---|
| 9 | DEBUG: false,
|
|---|
| 10 | }
|
|---|
| 11 |
|
|---|
| 12 | export const contextMap = new Map()
|
|---|
| 13 | export const configContextMap = new Map()
|
|---|
| 14 | export const contextSourcesMap = new Map()
|
|---|
| 15 | export const sourceHashMap = new Map()
|
|---|
| 16 | export const NOT_ON_DEMAND = new String('*')
|
|---|
| 17 |
|
|---|
| 18 | export const NONE = Symbol('__NONE__')
|
|---|
| 19 |
|
|---|
| 20 | export function resolveDebug(debug) {
|
|---|
| 21 | if (debug === undefined) {
|
|---|
| 22 | return false
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | // Environment variables are strings, so convert to boolean
|
|---|
| 26 | if (debug === 'true' || debug === '1') {
|
|---|
| 27 | return true
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | if (debug === 'false' || debug === '0') {
|
|---|
| 31 | return false
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | // Keep the debug convention into account:
|
|---|
| 35 | // DEBUG=* -> This enables all debug modes
|
|---|
| 36 | // DEBUG=projectA,projectB,projectC -> This enables debug for projectA, projectB and projectC
|
|---|
| 37 | // DEBUG=projectA:* -> This enables all debug modes for projectA (if you have sub-types)
|
|---|
| 38 | // DEBUG=projectA,-projectB -> This enables debug for projectA and explicitly disables it for projectB
|
|---|
| 39 |
|
|---|
| 40 | if (debug === '*') {
|
|---|
| 41 | return true
|
|---|
| 42 | }
|
|---|
| 43 |
|
|---|
| 44 | let debuggers = debug.split(',').map((d) => d.split(':')[0])
|
|---|
| 45 |
|
|---|
| 46 | // Ignoring tailwindcss
|
|---|
| 47 | if (debuggers.includes('-tailwindcss')) {
|
|---|
| 48 | return false
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | // Including tailwindcss
|
|---|
| 52 | if (debuggers.includes('tailwindcss')) {
|
|---|
| 53 | return true
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | return false
|
|---|
| 57 | }
|
|---|