Skip to content

Commit 53da641

Browse files
committed
Fix: replace dynamic import with static import in SqlLabPage
- Remove dynamic import of savedQueries API to fix Vite chunking warning - Add static import of getSavedQuery at top of file - Eliminates 'dynamically imported but also statically imported' warning - No change to functionality, improves bundle optimization
1 parent 314eb0e commit 53da641

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

exec/java-exec/src/main/resources/webapp/src/pages/SqlLabPage.tsx

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import { useProspector } from '../hooks/useProspector';
4141
import { useMonacoCompletion } from '../hooks/useMonacoCompletion';
4242
import { getAiStatus, getAiConfig, streamChat, transpileSql, convertDataType } from '../api/ai';
4343
import { getSchemaTree } from '../api/metadata';
44+
import { getSavedQuery } from '../api/savedQueries';
4445
import SchemaExplorer from '../components/schema-explorer/SchemaExplorer';
4546
import type { DatasetFilter } from '../components/schema-explorer/SchemaExplorer';
4647
import SqlEditor, { DEFAULT_EDITOR_SETTINGS } from '../components/query-editor/SqlEditor';
@@ -540,23 +541,20 @@ export default function SqlLabPage({ datasetFilter, headerContent, projectId, sa
540541
const firstSavedQueryId = savedQueryIds?.[0];
541542
useEffect(() => {
542543
if (projectId && firstSavedQueryId) {
543-
// Import here to avoid circular dependency
544-
import('../api/savedQueries').then(({ getSavedQuery }) => {
545-
getSavedQuery(firstSavedQueryId)
546-
.then((query) => {
547-
updateSql(query.sql);
548-
if (query.defaultSchema) {
549-
dispatch(setDefaultSchema({ tabId: activeTabId, schema: query.defaultSchema }));
550-
}
551-
// Rename tab to match the saved query name
552-
if (query.name) {
553-
dispatch(renameTab({ tabId: activeTabId, name: query.name }));
554-
}
555-
})
556-
.catch((error) => {
557-
console.warn('Failed to load project saved query:', error);
558-
});
559-
});
544+
getSavedQuery(firstSavedQueryId)
545+
.then((query) => {
546+
updateSql(query.sql);
547+
if (query.defaultSchema) {
548+
dispatch(setDefaultSchema({ tabId: activeTabId, schema: query.defaultSchema }));
549+
}
550+
// Rename tab to match the saved query name
551+
if (query.name) {
552+
dispatch(renameTab({ tabId: activeTabId, name: query.name }));
553+
}
554+
})
555+
.catch((error) => {
556+
console.warn('Failed to load project saved query:', error);
557+
});
560558
}
561559
}, [projectId, firstSavedQueryId, activeTabId, updateSql, dispatch]);
562560

0 commit comments

Comments
 (0)