UNPKG

@quasar/app-vite

Version:

Quasar Framework App CLI with Vite

33 lines (28 loc) 813 B
/** * @param {import('../../types/configuration/context').InternalQuasarContext} ctx * * @returns {import('../../types/configuration/context').CacheProxy} */ export function createCacheProxy(ctx) { const runtimeCache = {} const moduleCache = {} return { getRuntime: (key, getInitialValue) => { const value = runtimeCache[key] return value !== void 0 ? value : (runtimeCache[key] = getInitialValue()) }, setRuntime: (key, value) => { runtimeCache[key] = value }, getModule: key => { const value = moduleCache[key] if (value !== void 0) return value return import(`./module.${key}.js`) .then(({ createInstance }) => createInstance(ctx)) .then(val => { moduleCache[key] = val return val }) } } }