From 595aec79a8e200452b51593c5d3311c7846f4cc0 Mon Sep 17 00:00:00 2001 From: Binbin Ye Date: Tue, 7 Oct 2025 18:13:58 +0900 Subject: [PATCH 1/4] fix: fix import.meta compatibility issue in rsbuild rsbuild requires directly property access otherwise it will throw: Accessing import.meta directly is unsupported (only property access or destructuring is supported) --- packages/devtools/src/context/pip-context.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/devtools/src/context/pip-context.tsx b/packages/devtools/src/context/pip-context.tsx index a9ab18b2..13e6cfcc 100644 --- a/packages/devtools/src/context/pip-context.tsx +++ b/packages/devtools/src/context/pip-context.tsx @@ -55,9 +55,7 @@ export const PiPProvider = (props: PiPProviderProps) => { ) } - const meta = typeof import.meta !== 'undefined' ? import.meta : null - - meta?.hot?.on('vite:beforeUpdate', () => { + import.meta?.hot?.on('vite:beforeUpdate', () => { localStorage.setItem('pip_open', 'false') closePipWindow() }) From 20ee35261891d1696bce91420ccc85cb36c16b38 Mon Sep 17 00:00:00 2001 From: Binbin Ye Date: Tue, 7 Oct 2025 18:24:48 +0900 Subject: [PATCH 2/4] add changeset --- .changeset/soft-peas-turn.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/soft-peas-turn.md diff --git a/.changeset/soft-peas-turn.md b/.changeset/soft-peas-turn.md new file mode 100644 index 00000000..89498708 --- /dev/null +++ b/.changeset/soft-peas-turn.md @@ -0,0 +1,5 @@ +--- +'@tanstack/devtools': patch +--- + +fix import.meta usage in rsbuild From 83acd049c0bf7d1a915cf74fe3f6b98211935a3b Mon Sep 17 00:00:00 2001 From: Alem Tuzlak Date: Tue, 7 Oct 2025 14:51:11 +0200 Subject: [PATCH 3/4] update optional issue --- packages/devtools/src/context/pip-context.tsx | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/packages/devtools/src/context/pip-context.tsx b/packages/devtools/src/context/pip-context.tsx index 13e6cfcc..8a4b9581 100644 --- a/packages/devtools/src/context/pip-context.tsx +++ b/packages/devtools/src/context/pip-context.tsx @@ -55,7 +55,7 @@ export const PiPProvider = (props: PiPProviderProps) => { ) } - import.meta?.hot?.on('vite:beforeUpdate', () => { + import.meta.hot?.on('vite:beforeUpdate', () => { localStorage.setItem('pip_open', 'false') closePipWindow() }) @@ -77,39 +77,39 @@ export const PiPProvider = (props: PiPProviderProps) => { closePipWindow() }) - // It is important to copy all parent window styles. Otherwise, there would be no CSS available at all - // https://developer.chrome.com/docs/web-platform/document-picture-in-picture/#copy-style-sheets-to-the-picture-in-picture-window - ;[...document.styleSheets].forEach((styleSheet) => { - try { - const cssRules = [...styleSheet.cssRules] - .map((rule) => rule.cssText) - .join('') - const style = document.createElement('style') - const style_node = styleSheet.ownerNode - let style_id = '' - - if (style_node && 'id' in style_node) { - style_id = style_node.id + // It is important to copy all parent window styles. Otherwise, there would be no CSS available at all + // https://developer.chrome.com/docs/web-platform/document-picture-in-picture/#copy-style-sheets-to-the-picture-in-picture-window + ;[...document.styleSheets].forEach((styleSheet) => { + try { + const cssRules = [...styleSheet.cssRules] + .map((rule) => rule.cssText) + .join('') + const style = document.createElement('style') + const style_node = styleSheet.ownerNode + let style_id = '' + + if (style_node && 'id' in style_node) { + style_id = style_node.id + } + + if (style_id) { + style.setAttribute('id', style_id) + } + style.textContent = cssRules + pip.document.head.appendChild(style) + } catch (e) { + const link = document.createElement('link') + if (styleSheet.href == null) { + return + } + + link.rel = 'stylesheet' + link.type = styleSheet.type + link.media = styleSheet.media.toString() + link.href = styleSheet.href + pip.document.head.appendChild(link) } - - if (style_id) { - style.setAttribute('id', style_id) - } - style.textContent = cssRules - pip.document.head.appendChild(style) - } catch (e) { - const link = document.createElement('link') - if (styleSheet.href == null) { - return - } - - link.rel = 'stylesheet' - link.type = styleSheet.type - link.media = styleSheet.media.toString() - link.href = styleSheet.href - pip.document.head.appendChild(link) - } - }) + }) delegateEvents( [ 'focusin', From 35488186ec9e54870233878c0d40bed1868bb256 Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Tue, 7 Oct 2025 12:52:15 +0000 Subject: [PATCH 4/4] ci: apply automated fixes --- packages/devtools/src/context/pip-context.tsx | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/packages/devtools/src/context/pip-context.tsx b/packages/devtools/src/context/pip-context.tsx index 8a4b9581..3166b59d 100644 --- a/packages/devtools/src/context/pip-context.tsx +++ b/packages/devtools/src/context/pip-context.tsx @@ -77,39 +77,39 @@ export const PiPProvider = (props: PiPProviderProps) => { closePipWindow() }) - // It is important to copy all parent window styles. Otherwise, there would be no CSS available at all - // https://developer.chrome.com/docs/web-platform/document-picture-in-picture/#copy-style-sheets-to-the-picture-in-picture-window - ;[...document.styleSheets].forEach((styleSheet) => { - try { - const cssRules = [...styleSheet.cssRules] - .map((rule) => rule.cssText) - .join('') - const style = document.createElement('style') - const style_node = styleSheet.ownerNode - let style_id = '' - - if (style_node && 'id' in style_node) { - style_id = style_node.id - } - - if (style_id) { - style.setAttribute('id', style_id) - } - style.textContent = cssRules - pip.document.head.appendChild(style) - } catch (e) { - const link = document.createElement('link') - if (styleSheet.href == null) { - return - } - - link.rel = 'stylesheet' - link.type = styleSheet.type - link.media = styleSheet.media.toString() - link.href = styleSheet.href - pip.document.head.appendChild(link) + // It is important to copy all parent window styles. Otherwise, there would be no CSS available at all + // https://developer.chrome.com/docs/web-platform/document-picture-in-picture/#copy-style-sheets-to-the-picture-in-picture-window + ;[...document.styleSheets].forEach((styleSheet) => { + try { + const cssRules = [...styleSheet.cssRules] + .map((rule) => rule.cssText) + .join('') + const style = document.createElement('style') + const style_node = styleSheet.ownerNode + let style_id = '' + + if (style_node && 'id' in style_node) { + style_id = style_node.id } - }) + + if (style_id) { + style.setAttribute('id', style_id) + } + style.textContent = cssRules + pip.document.head.appendChild(style) + } catch (e) { + const link = document.createElement('link') + if (styleSheet.href == null) { + return + } + + link.rel = 'stylesheet' + link.type = styleSheet.type + link.media = styleSheet.media.toString() + link.href = styleSheet.href + pip.document.head.appendChild(link) + } + }) delegateEvents( [ 'focusin',