Skip to content

Commit 92f1019

Browse files
authored
Merge pull request #256 from BobbieGoede/fix/meta-env-undefined
fix: access `meta.env.X` with optional chaining
2 parents f1d52d3 + fb9ede7 commit 92f1019

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/plugin/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const MotionPlugin = {
3232
const variants = options.directives[key] as MotionVariants<any>
3333

3434
// Development warning, showing definitions missing `initial` key
35-
if (!variants.initial && import.meta.env.MODE === 'development') {
35+
if (!variants.initial && import.meta.env?.MODE === 'development') {
3636
console.warn(
3737
`Your directive v-motion-${key} is missing initial variant!`,
3838
)

src/utils/component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ export function setupMotionComponent(
195195
})
196196

197197
// Replay animations on component update Vue
198-
if (import.meta.env.MODE === 'development') {
198+
if (import.meta.env?.MODE === 'development') {
199199
// Validate passed preset
200200
if (
201201
props.preset != null

src/utils/events.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const isBrowser = typeof window !== 'undefined'
22

3-
export const supportsPointerEvents = () => isBrowser && (window.onpointerdown === null || import.meta.env.TEST)
3+
export const supportsPointerEvents = () => isBrowser && (window.onpointerdown === null || import.meta.env?.TEST)
44

5-
export const supportsTouchEvents = () => isBrowser && (window.ontouchstart === null || import.meta.env.TEST)
5+
export const supportsTouchEvents = () => isBrowser && (window.ontouchstart === null || import.meta.env?.TEST)
66

7-
export const supportsMouseEvents = () => isBrowser && (window.onmousedown === null || import.meta.env.TEST)
7+
export const supportsMouseEvents = () => isBrowser && (window.onmousedown === null || import.meta.env?.TEST)

src/utils/keys.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export const CUSTOM_PRESETS = Symbol(
2-
import.meta.env.MODE === 'development' ? 'motionCustomPresets' : '',
2+
import.meta.env?.MODE === 'development' ? 'motionCustomPresets' : '',
33
)

0 commit comments

Comments
 (0)