Skip to content

Commit

Permalink
feat: memo the getThemeConfig method
Browse files Browse the repository at this point in the history
the internal module resolution is smh taking ages
  • Loading branch information
ubermanu committed Nov 22, 2022
1 parent 2703abd commit 0e98f9a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import path from 'path'
import glob from 'fast-glob'
import memo from 'memoizee'

import { getThemes, MagentoTheme } from './magento/theme'
import type { Plugin } from './plugin'
Expand Down Expand Up @@ -75,7 +76,7 @@ export const getConfigFromFile = async () => {
* The theme config is passed to the plugins.
* Prepend `presets` plugins to the root plugins.
*/
export const getThemeConfig = async (themeName: string) => {
export const getThemeConfig = memo(async (themeName: string) => {
const theme: MagentoTheme | undefined = getThemes().find((t: MagentoTheme) => t.name === themeName)

if (!theme) {
Expand Down Expand Up @@ -120,7 +121,7 @@ export const getThemeConfig = async (themeName: string) => {

// TODO: Clean up the config object
return { theme: themeName, src, dest, plugins } as ThemeConfig
}
})

/**
* Transform the plugin to a function if it is not already.
Expand Down

0 comments on commit 0e98f9a

Please sign in to comment.