@farmfe/runtime
Advanced tools
Comparing version 0.3.4 to 0.4.0
# @farmfe/runtime | ||
## 0.4.0 | ||
### Minor Changes | ||
- a5364b5: Extract plugin react into a single plugin | ||
## 0.3.4 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "@farmfe/runtime", | ||
"version": "0.3.4", | ||
"version": "0.4.0", | ||
"description": "Runtime of Farm", | ||
@@ -15,4 +15,5 @@ "author": { | ||
"scripts": { | ||
"build": "tsc -p tsconfig.json --noEmit" | ||
"build": "tsc -p tsconfig.json --noEmit", | ||
"type-check": "tsc -p tsconfig.json --noEmit" | ||
} | ||
} |
@@ -6,3 +6,3 @@ import { Module } from './module'; | ||
/* eslint-disable @typescript-eslint/no-explicit-any */ | ||
type ModuleInitialization = ( | ||
export type ModuleInitialization = ( | ||
module: Module, | ||
@@ -27,6 +27,9 @@ exports: any, | ||
pluginContainer: FarmRuntimePluginContainer; | ||
//cache may clear In applyHotUpdates. We need another constructor to cache module in temporary | ||
//after `module.meta.hot.tap`, clear hmrCache | ||
hmrCacheTemporary: Map<string, Module>; | ||
constructor() { | ||
this.modules = {}; | ||
this.cache = {}; | ||
this.hmrCacheTemporary = new Map(); | ||
this.publicPaths = []; | ||
@@ -143,2 +146,13 @@ this.dynamicModuleResourcesMap = {}; | ||
setHmrCacheTemporary(moduleId: string) { | ||
if (!this.hmrCacheTemporary.has(moduleId) && this.cache[moduleId]) { | ||
return this.hmrCacheTemporary.set(moduleId, this.cache[moduleId]); | ||
} | ||
return null; | ||
} | ||
clearHmrCacheTemporary() { | ||
this.hmrCacheTemporary.clear(); | ||
} | ||
update(moduleId: string, init: ModuleInitialization): void { | ||
@@ -161,2 +175,3 @@ this.modules[moduleId] = init; | ||
if (this.modules[moduleId]) { | ||
this.setHmrCacheTemporary(moduleId); | ||
delete this.cache[moduleId]; | ||
@@ -163,0 +178,0 @@ return true; |
16361
433