fix(core): use query param instead of hash fragment for plugin cache-busting

Vite/Vitest's resolver treats `#` as part of the filesystem path in some
environments, causing ERR_MODULE_NOT_FOUND on plugin reload.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
gsxdsm
2026-04-23 20:44:33 -07:00
parent c36d16e87d
commit 3a39ad66b2
3 changed files with 149 additions and 80 deletions

View File

@@ -269,9 +269,10 @@ export class PluginLoader extends EventEmitter<{
// Dynamic import - use cache-busting for reload scenarios
let mod: unknown;
if (bypassCache) {
// Use a hash fragment for cache differentiation without affecting path resolution
// Node treats each distinct URL as a fresh import while resolving the same file path
const bustedPath = `${path}#${Date.now()}`;
// Use a query parameter for cache differentiation.
// Vite/Vitest's module resolver treats hash fragments as part of the
// filesystem path in some environments (causing ERR_MODULE_NOT_FOUND).
const bustedPath = `${path}?t=${Date.now()}`;
mod = await import(bustedPath);
} else {
mod = await import(path);