@farmfe/runtime
Advanced tools
Comparing version 0.7.0 to 0.7.1
# @farmfe/runtime | ||
## 0.7.1 | ||
### Patch Changes | ||
- Fix bugs that dev server should only try read local file system resources for images and fonts | ||
## 0.7.0 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "@farmfe/runtime", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"description": "Runtime of Farm", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -133,14 +133,21 @@ import { Module } from './module'; | ||
resources.map((resource) => this.resourceLoader.load(resource)) | ||
).then(() => { | ||
const result = this.require(moduleId); | ||
// if the module is async, return the default export, the default export should be a promise | ||
if (result.__farm_async) { | ||
return result.default; | ||
} else { | ||
return result; | ||
} | ||
}); | ||
) | ||
.then(() => { | ||
const result = this.require(moduleId); | ||
// if the module is async, return the default export, the default export should be a promise | ||
if (result.__farm_async) { | ||
return result.default; | ||
} else { | ||
return result; | ||
} | ||
}) | ||
.catch((err) => { | ||
console.error(`[Farm] Error loading dynamic module "${moduleId}"`, err); | ||
// reload the page if the dynamic module loading failed | ||
window.location.reload(); | ||
}); | ||
} | ||
register(moduleId: string, initializer: ModuleInitialization): void { | ||
// console.log(`[Farm] register module "${moduleId}"`, console.trace()); | ||
if (this.modules[moduleId]) { | ||
@@ -147,0 +154,0 @@ // throw new Error( |
@@ -24,2 +24,3 @@ // using native ability to load resources if target env is node. | ||
private _loadedResources: Record<string, boolean> = {}; | ||
private _loadingResources: Record<string, Promise<void>> = {}; | ||
@@ -49,3 +50,6 @@ publicPaths: string[]; | ||
return; | ||
} else if (this._loadingResources[resource.path]) { | ||
return this._loadingResources[resource.path]; | ||
} | ||
let promise = Promise.resolve(); | ||
@@ -59,2 +63,4 @@ try { | ||
this._loadingResources[resource.path] = promise; | ||
promise.then(() => { | ||
@@ -61,0 +67,0 @@ this._loadedResources[resource.path] = true; |
18058
451