move import cache busted into importUrl

This commit is contained in:
Chris Wanstrath 2025-10-07 20:13:52 -07:00
parent 81b8a40070
commit ea5b33c5bd
5 changed files with 6 additions and 4 deletions

View File

@ -82,7 +82,7 @@ export async function commandSource(name: string): Promise<string> {
export async function loadCommandModule(cmd: string) {
const path = commandPath(cmd)
if (!path) return
return await importUrl(path + "?t=" + Date.now())
return await importUrl(path)
}
let noseDirWatcher

View File

@ -35,7 +35,7 @@ export async function handleGameStart(msg: GameStartMessage) {
let game
try {
game = await importUrl(`/source/${name}?session=${sessionId}&t=${Date.now()}`)
game = await importUrl(`/source/${name}?session=${sessionId}}`)
} catch (err: any) {
setStatus(msgId, "error")
addOutput(msgId, `Error: ${err.message ? err.message : err}`)

View File

@ -25,7 +25,7 @@ export async function runCommand(input: string, showInput = true) {
const [cmd = "", ...args] = input.split(" ")
if (commands[cmd]?.type === "browser") {
const mod = await importUrl(`/source/${cmd}?t=${Date.now()}`)
const mod = await importUrl(`/source/${cmd}`)
if (!mod.default) {
addOutput(id, `no default export in ${cmd}`)
setStatus(id, "error")

View File

@ -41,6 +41,8 @@ export function unique<T>(array: T[]): T[] {
}
export async function importUrl(url: string) {
url += url.includes("?") ? "&" : "?"
url += "t=" + Date.now()
console.log("-> import", url)
return import(url)
}

View File

@ -74,7 +74,7 @@ async function findApp(name: string): Promise<App | undefined> {
async function loadApp(path: string): Promise<App | undefined> {
if (!await Bun.file(path).exists()) return
const mod = await importUrl(path + `?t=${Date.now()}`)
const mod = await importUrl(path)
if (mod?.default)
return mod.default as App
}