perf: cache

This commit is contained in:
cha0s 2022-05-04 02:55:53 -05:00
parent 7646f8507e
commit c012ee7faf
2 changed files with 10 additions and 9 deletions

View File

@ -1,12 +1,18 @@
import {Flecks, Hooks} from '@flecks/core';
import globals from './globals';
import {cache} from './resources/script';
export default {
[Hooks]: {
'@avocado/behavior.globals': globals,
'@avocado/resource.resources': Flecks.provide(require.context('./resources', false, /\.js$/)),
'@avocado/traits.traits': Flecks.provide(require.context('./traits', false, /\.js$/)),
'@flecks/core.hmr': (path) => {
if ('@avocado/behavior' === path) {
cache.reset();
}
},
'@flecks/core.starting': async (flecks) => {
flecks.set('$avocado/behavior.globals', flecks.invokeMerge('@avocado/behavior.globals'));
},

View File

@ -7,15 +7,10 @@ import LRU from 'lru-cache';
const Populated = Symbol.for('@avocado/behavior.populated');
const cache = 'production' === process.env.NODE_ENV
? new LRU({
export const cache = new LRU({
max: 128,
maxAge: Infinity,
})
: {
has: () => {},
set: () => {},
};
});
const empty = {
type: 'File',