move import cache busted into importUrl
This commit is contained in:
parent
81b8a40070
commit
ea5b33c5bd
|
|
@ -82,7 +82,7 @@ export async function commandSource(name: string): Promise<string> {
|
||||||
export async function loadCommandModule(cmd: string) {
|
export async function loadCommandModule(cmd: string) {
|
||||||
const path = commandPath(cmd)
|
const path = commandPath(cmd)
|
||||||
if (!path) return
|
if (!path) return
|
||||||
return await importUrl(path + "?t=" + Date.now())
|
return await importUrl(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
let noseDirWatcher
|
let noseDirWatcher
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ export async function handleGameStart(msg: GameStartMessage) {
|
||||||
|
|
||||||
let game
|
let game
|
||||||
try {
|
try {
|
||||||
game = await importUrl(`/source/${name}?session=${sessionId}&t=${Date.now()}`)
|
game = await importUrl(`/source/${name}?session=${sessionId}}`)
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
setStatus(msgId, "error")
|
setStatus(msgId, "error")
|
||||||
addOutput(msgId, `Error: ${err.message ? err.message : err}`)
|
addOutput(msgId, `Error: ${err.message ? err.message : err}`)
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ export async function runCommand(input: string, showInput = true) {
|
||||||
const [cmd = "", ...args] = input.split(" ")
|
const [cmd = "", ...args] = input.split(" ")
|
||||||
|
|
||||||
if (commands[cmd]?.type === "browser") {
|
if (commands[cmd]?.type === "browser") {
|
||||||
const mod = await importUrl(`/source/${cmd}?t=${Date.now()}`)
|
const mod = await importUrl(`/source/${cmd}`)
|
||||||
if (!mod.default) {
|
if (!mod.default) {
|
||||||
addOutput(id, `no default export in ${cmd}`)
|
addOutput(id, `no default export in ${cmd}`)
|
||||||
setStatus(id, "error")
|
setStatus(id, "error")
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,8 @@ export function unique<T>(array: T[]): T[] {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function importUrl(url: string) {
|
export async function importUrl(url: string) {
|
||||||
|
url += url.includes("?") ? "&" : "?"
|
||||||
|
url += "t=" + Date.now()
|
||||||
console.log("-> import", url)
|
console.log("-> import", url)
|
||||||
return import(url)
|
return import(url)
|
||||||
}
|
}
|
||||||
|
|
@ -74,7 +74,7 @@ async function findApp(name: string): Promise<App | undefined> {
|
||||||
async function loadApp(path: string): Promise<App | undefined> {
|
async function loadApp(path: string): Promise<App | undefined> {
|
||||||
if (!await Bun.file(path).exists()) return
|
if (!await Bun.file(path).exists()) return
|
||||||
|
|
||||||
const mod = await importUrl(path + `?t=${Date.now()}`)
|
const mod = await importUrl(path)
|
||||||
if (mod?.default)
|
if (mod?.default)
|
||||||
return mod.default as App
|
return mod.default as App
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user