import type { PluginOption } from 'vite';

import { lazyImport, VxeResolver } from 'vite-plugin-lazy-import';

async function viteVxeTableImportsPlugin(): Promise<PluginOption> {
  return [
    lazyImport({
      // 仅处理源码，避免扫描工作区包的 dist 产物导致解析异常。
      include: [
        '**/src/**/*.vue',
        '**/src/**/*.ts',
        '**/src/**/*.js',
        '**/src/**/*.tsx',
        '**/src/**/*.jsx',
      ],
      exclude: ['**/node_modules/**', '**/dist/**'],
      resolvers: [
        VxeResolver({
          libraryName: 'vxe-table',
        }),
        VxeResolver({
          libraryName: 'vxe-pc-ui',
        }),
      ],
    }),
  ];
}

export { viteVxeTableImportsPlugin };
