fix: scripts HMR

This commit is contained in:
cha0s 2024-11-05 19:24:39 -06:00
parent ceaa7c1287
commit 324123df14
4 changed files with 7 additions and 7 deletions

View File

@ -56,7 +56,7 @@ export async function get() {
const cache = new Map();
export async function loadResources(resources) {
Script.registerScriptsModule(await import('@/lib/scripts.js'));
await Script.registerScriptsModule();
for (const path in resources) {
cache.set(path, resources[path].asset);
}

View File

@ -45,7 +45,8 @@ export default class Script {
this.registered[path] = fn;
}
static registerScriptsModule({default: scripts}) {
static async registerScriptsModule() {
const {default: scripts} = await import('./scripts.js');
for (const path in scripts) {
Script.register(path, scripts[path]);
}
@ -107,7 +108,7 @@ export default class Script {
}
if (import.meta.hot) {
import.meta.hot.accept('./scripts.js', (M) => {
Script.registerScriptsModule(M);
import.meta.hot.accept('./scripts.js', () => {
Script.registerScriptsModule();
});
}

View File

@ -2,4 +2,3 @@ export default import.meta.glob(
'%/**/*.js',
{eager: true, import: 'default'},
);

View File

@ -359,7 +359,7 @@ export default class Engine {
}
async load() {
Script.registerScriptsModule(await import('@/lib/scripts.js'));
await Script.registerScriptsModule();
await this.server.load();
let townData;
try {