fix: scripts HMR
This commit is contained in:
parent
ceaa7c1287
commit
324123df14
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -45,12 +45,13 @@ 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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
reset() {
|
||||
this.iterator = null;
|
||||
this.$$ticker = null;
|
||||
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,4 +2,3 @@ export default import.meta.glob(
|
|||
'%/**/*.js',
|
||||
{eager: true, import: 'default'},
|
||||
);
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue
Block a user