diff --git a/.changeset/ready-peas-do.md b/.changeset/ready-peas-do.md new file mode 100644 index 00000000..f3868b02 --- /dev/null +++ b/.changeset/ready-peas-do.md @@ -0,0 +1,5 @@ +--- +'@tanstack/devtools': patch +--- + +fix issue with popups in non-vite environments diff --git a/packages/devtools/src/context/pip-context.tsx b/packages/devtools/src/context/pip-context.tsx index cbaf3a0e..fc605808 100644 --- a/packages/devtools/src/context/pip-context.tsx +++ b/packages/devtools/src/context/pip-context.tsx @@ -54,12 +54,13 @@ export const PiPProvider = (props: PiPProviderProps) => { 'Failed to open popup. Please allow popups for this site to view the devtools in picture-in-picture mode.', ) } - // can be run outside of vite so we ignore the rule - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition - import.meta?.hot?.on('vite:beforeUpdate', () => { - localStorage.setItem('pip_open', 'false') - closePipWindow() - }) + + if (import.meta.hot && typeof import.meta.hot.on === 'function') { + import.meta.hot.on('vite:beforeUpdate', () => { + localStorage.setItem('pip_open', 'false') + closePipWindow() + }) + } window.addEventListener('beforeunload', () => { localStorage.setItem('pip_open', 'false') closePipWindow()