Skip to content

Commit

Permalink
Merge pull request #29518 from IonianPlayboy/fix-vue3-vite-hmr-docgen
Browse files Browse the repository at this point in the history
Vue: Fix `vue-component-meta` docgen HMR not working
  • Loading branch information
kasperpeulen authored Nov 26, 2024
2 parents 91c76ac + b9ac9dd commit 965b4c1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion code/frameworks/vue3-vite/src/plugins/vue-component-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { dirname, join, parse, relative, resolve } from 'node:path';

import findPackageJson from 'find-package-json';
import MagicString from 'magic-string';
import type { PluginOption } from 'vite';
import type { ModuleNode, PluginOption } from 'vite';
import {
type ComponentMeta,
type MetaCheckerOptions,
Expand Down Expand Up @@ -146,6 +146,20 @@ export async function vueComponentMeta(tsconfigPath = 'tsconfig.json'): Promise<
return undefined;
}
},
// handle hot updates to update the component meta on file changes
async handleHotUpdate({ file, read, server, modules, timestamp }) {
const content = await read();
checker.updateFile(file, content);
// Invalidate modules manually
const invalidatedModules = new Set<ModuleNode>();

for (const mod of modules) {
server.moduleGraph.invalidateModule(mod, invalidatedModules, timestamp, true);
}

server.ws.send({ type: 'full-reload' });
return [];
},
};
}

Expand Down

0 comments on commit 965b4c1

Please sign in to comment.