diff --git a/webapp/packages/product-base/src/manualChunks.ts b/webapp/packages/product-base/src/manualChunks.ts index 94e802fe24..16e0259041 100644 --- a/webapp/packages/product-base/src/manualChunks.ts +++ b/webapp/packages/product-base/src/manualChunks.ts @@ -20,65 +20,7 @@ export const manualChunks = (): PluginOption => [ ...config.build?.rollupOptions, output: { ...config.build?.rollupOptions?.output, - manualChunks(id, { getModuleInfo }) { - function isModuleSync(moduleId: string) { - // Use a non-recursive approach to detect circular dependencies - const visited = new Set(); - const queue = [moduleId]; - - // Track which modules we've already determined to be sync - const syncModules = new Set(); - - while (queue.length > 0) { - const currentId = queue.shift()!; - - // Skip if we've already processed this module in this traversal - if (visited.has(currentId)) { - continue; - } - - visited.add(currentId); - - const info = getModuleInfo(currentId); - - // No module info available, assume it's sync as a fallback - if (!info) { - syncModules.add(currentId); - continue; - } - - // Entry modules are always sync - if (info.isEntry) { - syncModules.add(currentId); - continue; - } - - // If there are no importers at all, it might be dynamically imported somewhere - if (!info.importers || info.importers.length === 0) { - // Not marking as sync - continue; - } - - // If dynamicImporters is undefined or not an array, handle safely - const dynamicImports = Array.isArray(info.dynamicImporters) ? info.dynamicImporters : []; - - // Check if any importer imports this module statically - let hasStaticImporter = false; - for (const importer of info.importers) { - if (!dynamicImports.includes(importer)) { - hasStaticImporter = true; - break; - } - } - - if (hasStaticImporter) { - syncModules.add(currentId); - } - } - - return syncModules.has(moduleId); - } - + manualChunks(id) { const langMatch = /[\\/]locales[\\/](\w+)\.js/.exec(id); if (langMatch) { const language = langMatch[1]; // e.g. "en" @@ -86,37 +28,22 @@ export const manualChunks = (): PluginOption => [ } if (id.includes('packages/core-')) { - if (!isModuleSync(id)) { - return 'core-async'; - } return 'core'; } if (id.includes('packages/plugin-')) { - if (!isModuleSync(id)) { - return 'plugins-async'; - } return 'plugins'; } if (id.includes('packages/product-')) { - if (!isModuleSync(id)) { - return 'products-async'; - } return 'products'; } if (id.includes('@dbeaver/')) { - if (!isModuleSync(id)) { - return 'dbeaver-async'; - } return 'dbeaver'; } if (id.includes('node_modules')) { - if (!isModuleSync(id)) { - return 'vendor-async'; - } return 'vendor'; }