From c8712447a296fc0e3e436536e983196be27ad388 Mon Sep 17 00:00:00 2001 From: Tamas Kovacs Date: Wed, 27 Nov 2024 15:50:14 +0100 Subject: [PATCH] fix(ui-source-code-editor): prevent Vite from erroring out during the build in React 16/17 Closes: INSTUI-4382 --- .../src/SourceCodeEditor/SearchPanel.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/ui-source-code-editor/src/SourceCodeEditor/SearchPanel.tsx b/packages/ui-source-code-editor/src/SourceCodeEditor/SearchPanel.tsx index fde519b2ee..d52241de78 100644 --- a/packages/ui-source-code-editor/src/SourceCodeEditor/SearchPanel.tsx +++ b/packages/ui-source-code-editor/src/SourceCodeEditor/SearchPanel.tsx @@ -144,8 +144,10 @@ export default function customSearch(searchConfig: SearchConfig | undefined) { dom.style.padding = '8px' const reactVersionMajor = Number(React.version.split('.')[0]) if (reactVersionMajor >= 18) { + const module = 'react-dom/client' // webpack tries to evaluate imports compile time which would lead to an error on older react versions - import(/* webpackIgnore: true */ 'react-dom/client') + // Vite errors out during build in React v16/17 + import(/* webpackIgnore: true */ /* @vite-ignore */ module) .then((r) => { const root = r.createRoot(dom) root.render(