hmr.ts 536 B

1234567891011121314151617181920212223
  1. import type { Plugin } from 'vite';
  2. /**
  3. * TODO
  4. * Temporarily solve the Vite circular dependency problem, and wait for a better solution to fix it later. I don't know what problems this writing will bring.
  5. * @returns
  6. */
  7. export function configHmrPlugin(): Plugin {
  8. return {
  9. name: 'singleHMR',
  10. handleHotUpdate({ modules, file }) {
  11. if (file.match(/xml$/)) return [];
  12. modules.forEach((m) => {
  13. m.importedModules = new Set();
  14. m.importers = new Set();
  15. });
  16. return modules;
  17. },
  18. };
  19. }