From ba63227be354529a760b8995284a8c1d7a9c3229 Mon Sep 17 00:00:00 2001 From: Gustaf Dalemar Date: Tue, 28 Nov 2017 12:42:18 +0100 Subject: [PATCH] fix(roc-package-web-app-react): Pre-transpile universal-config This will make it easier when testing amongst other things. --- .../app/shared/universal-config.js | 26 +------------------ .../src/app/shared/universal-config.js | 25 ++++++++++++++++++ 2 files changed, 26 insertions(+), 25 deletions(-) mode change 100755 => 100644 packages/roc-package-web-app-react/app/shared/universal-config.js create mode 100755 packages/roc-package-web-app-react/src/app/shared/universal-config.js diff --git a/packages/roc-package-web-app-react/app/shared/universal-config.js b/packages/roc-package-web-app-react/app/shared/universal-config.js old mode 100755 new mode 100644 index a499c95..37f8055 --- a/packages/roc-package-web-app-react/app/shared/universal-config.js +++ b/packages/roc-package-web-app-react/app/shared/universal-config.js @@ -1,25 +1 @@ -/* globals window */ - /** - * Universal Configuration Manager - * - * Manages both __application__ configuration and __Roc__ configuration. - * On the server the configurations will be fetched directly and on the client it's expected that the configuration - * is available on `window` as `ROC_CONFIG` and `APP_CONFIG`. - * - * appConfig will only contain what has been selected by `runtime.configWhitelistProperty`. That means if you want - * to read the full configuration on the server you will need to read it directly from node-config. - */ - -export const rocConfig = (function getRocConfig() { - return typeof window !== 'undefined' ? window.ROC_CONFIG : require('roc').getSettings(); // eslint-disable-line -}()); - -const whiteListed = () => ( - rocConfig.runtime.configWhitelistProperty ? - require('config')[rocConfig.runtime.configWhitelistProperty] : // eslint-disable-line - undefined -); - -export const appConfig = (function getAppConfig() { - return typeof window !== 'undefined' ? window.APP_CONFIG : whiteListed(); -}()); +module.exports = require('../../lib/app/shared/universal-config'); diff --git a/packages/roc-package-web-app-react/src/app/shared/universal-config.js b/packages/roc-package-web-app-react/src/app/shared/universal-config.js new file mode 100755 index 0000000..a499c95 --- /dev/null +++ b/packages/roc-package-web-app-react/src/app/shared/universal-config.js @@ -0,0 +1,25 @@ +/* globals window */ + /** + * Universal Configuration Manager + * + * Manages both __application__ configuration and __Roc__ configuration. + * On the server the configurations will be fetched directly and on the client it's expected that the configuration + * is available on `window` as `ROC_CONFIG` and `APP_CONFIG`. + * + * appConfig will only contain what has been selected by `runtime.configWhitelistProperty`. That means if you want + * to read the full configuration on the server you will need to read it directly from node-config. + */ + +export const rocConfig = (function getRocConfig() { + return typeof window !== 'undefined' ? window.ROC_CONFIG : require('roc').getSettings(); // eslint-disable-line +}()); + +const whiteListed = () => ( + rocConfig.runtime.configWhitelistProperty ? + require('config')[rocConfig.runtime.configWhitelistProperty] : // eslint-disable-line + undefined +); + +export const appConfig = (function getAppConfig() { + return typeof window !== 'undefined' ? window.APP_CONFIG : whiteListed(); +}());