Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/orange-towns-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@vingy/vuebugger": patch
---

fix: import.meta.ENV not being optional

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changeset message says import.meta.ENV, but the actual property is import.meta.env (lowercase). Updating the text will make the release note accurate and easier to understand.

Suggested change
fix: import.meta.ENV not being optional
fix: import.meta.env not being optional

Copilot uses AI. Check for mistakes.
2 changes: 1 addition & 1 deletion packages/vuebugger/src/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const debug = <T extends Record<string, any>>(
groupId: VuebuggerEntry['groupId'],
state: T,
): T => {
if (!import.meta.env.DEV) return state
if (!import.meta.env?.DEV) return state

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using optional chaining on import.meta.env?.DEV may prevent Vite from statically replacing import.meta.env.DEV and applying dead-code elimination, leaving this debug path (and its imports) in production bundles. Prefer a guard that first checks import.meta.env exists but still references import.meta.env.DEV normally after that check.

Suggested change
if (!import.meta.env?.DEV) return state
if (
typeof import.meta === 'undefined' ||
!import.meta.env ||
!import.meta.env.DEV
) {
return state
}

Copilot uses AI. Check for mistakes.

const instance = getCurrentInstance()

Expand Down
2 changes: 1 addition & 1 deletion packages/vuebugger/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export { debug } from './debug'

const plugin: Plugin<[PluginOptions?]> = {
install: (app: App, options?: PluginOptions) => {
if (!import.meta.env.DEV) return
if (!import.meta.env?.DEV) return

Copilot AI Mar 3, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using optional chaining on import.meta.env?.DEV may prevent Vite from doing its usual static replacement / dead-code elimination for import.meta.env.DEV, which can cause the devtools code (and its imports) to remain in production bundles. Consider switching to a short-circuit guard that keeps a plain import.meta.env.DEV access (e.g., check import.meta.env first, then import.meta.env.DEV).

Suggested change
if (!import.meta.env?.DEV) return
if (!import.meta.env || !import.meta.env.DEV) return

Copilot uses AI. Check for mistakes.
if (options?.uidFn) setUidGenerator(options.uidFn)
setupComposableDevtools(app)
},
Expand Down