Skip to content

Commit ed72b10

Browse files
committed
fix(build): remove import.meta usage from loader dev detection
1 parent 12900f5 commit ed72b10

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/loader.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,18 @@ function isDevRuntime(): boolean {
6262
return explicitDevFlag
6363
}
6464

65-
const metaEnv = (import.meta as unknown as { env?: Record<string, unknown> }).env
66-
if (metaEnv && typeof metaEnv.DEV === 'boolean') {
67-
return metaEnv.DEV
65+
if (typeof process !== 'undefined') {
66+
const nodeEnv = process.env?.NODE_ENV
67+
if (nodeEnv) {
68+
return nodeEnv !== 'production'
69+
}
6870
}
69-
if (metaEnv && typeof metaEnv.MODE === 'string') {
70-
return metaEnv.MODE !== 'production'
71+
72+
if (typeof document !== 'undefined') {
73+
return Boolean(document.querySelector('script[src*="/@vite/client"]'))
7174
}
7275

73-
if (typeof process === 'undefined') return false
74-
const nodeEnv = process.env?.NODE_ENV
75-
if (!nodeEnv) return false
76-
return nodeEnv !== 'production'
76+
return false
7777
}
7878

7979
const warnedImmutableAttrs = new WeakMap<HTMLElement, Set<string>>()

0 commit comments

Comments
 (0)