Skip to content

Commit

Permalink
[FEATURE] add memory cache to @salesforce/pwa-kit-runtime/utils/ssr-c…
Browse files Browse the repository at this point in the history
…onfig getConfig function SalesforceCommerceCloud#1620
  • Loading branch information
lizzo-tlg committed Dec 15, 2023
1 parent 90a97db commit 1b51d6c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/pwa-kit-runtime/src/utils/ssr-config.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const SUPPORTED_FILE_TYPES = ['js', 'yml', 'yaml', 'json']

const IS_REMOTE = Object.prototype.hasOwnProperty.call(process.env, 'AWS_LAMBDA_FUNCTION_NAME')

const CONFIG_CACHE = new Map();

/**
* Returns the express app configuration file in object form. The file will be resolved in the
* the following order:
Expand Down Expand Up @@ -37,6 +39,11 @@ const IS_REMOTE = Object.prototype.hasOwnProperty.call(process.env, 'AWS_LAMBDA_
/* istanbul ignore next */
export const getConfig = (opts = {}) => {
const {buildDirectory} = opts

if (CONFIG_CACHE.has(buildDirectory)) {
return CONFIG_CACHE.get(buildDirectory);
}

const configDirBase = IS_REMOTE ? 'build' : ''
let targetName = process?.env?.DEPLOY_TARGET || ''

Expand Down Expand Up @@ -85,5 +92,7 @@ export const getConfig = (opts = {}) => {
)
}

CONFIG_CACHE.set(buildDirectory, config);

return config
}

0 comments on commit 1b51d6c

Please sign in to comment.