diff --git a/jest.config.js b/jest.config.js index 19e22c1..57b22a3 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,5 +1,3 @@ -// Jest configuration -// https://facebook.github.io/jest/docs/en/configuration.html module.exports = { verbose: true, automock: false, @@ -11,6 +9,11 @@ module.exports = { '!src/public/**', '!src/tools/**' ], + env: { + production: { + plugins: ['transform-es2015-modules-commonjs'] + } + }, coverageDirectory: '/coverage', globals: { window: true, diff --git a/src/render.js b/src/render.js index 4bf7c8b..4b75aef 100644 --- a/src/render.js +++ b/src/render.js @@ -2,7 +2,7 @@ import xss from 'xss'; import { matchUrlInRouteConfigs } from './universal/core/route/routeUtils'; import Preview from './universal/components/Preview'; -import { HTTP_STATUS_CODES } from './universal/utils/constants'; +import { BLACKLIST_OUTPUT, HTTP_STATUS_CODES } from './universal/utils/constants'; import metrics from './metrics'; import { renderComponent, @@ -13,6 +13,7 @@ import { } from './universal/service/RenderService'; import Component from './universal/model/Component'; import logger from './universal/utils/logger'; +import omit from 'lodash/omit'; const appConfig = require('__APP_CONFIG__'); @@ -60,9 +61,9 @@ const render = async (req, res) => { scripts, activeComponent, componentName, - seoState, isPreviewQuery, - responseOptions + responseOptions, + ...responseData } = renderResponse; const statusCode = responseOptions?.isPartialContent @@ -71,8 +72,8 @@ const render = async (req, res) => { if (!isPreview(context.query)) { const html = renderLinksAndScripts(output, '', ''); - - res.status(statusCode).json({ html, scripts, style: links, activeComponent, seoState }); + const otherParams = omit(responseData, BLACKLIST_OUTPUT); + res.status(statusCode).json({ html, scripts, style: links, activeComponent, ...otherParams }); metrics.fragmentRequestDurationMicroseconds .labels(componentName, isWithoutHTML(context.query) ? '1' : '0') diff --git a/src/universal/model/Renderer.js b/src/universal/model/Renderer.js index 1809867..731737e 100644 --- a/src/universal/model/Renderer.js +++ b/src/universal/model/Renderer.js @@ -1,13 +1,7 @@ import omit from 'lodash/omit'; import { isPreview, renderComponent, renderLinksAndScripts } from '../service/RenderService'; +import { BLACKLIST_OUTPUT } from '../utils/constants'; -const blacklistOutput = [ - 'componentName', - 'fullWidth', - 'isMobileComponent', - 'isPreviewQuery', - 'responseOptions' -]; export default class Renderer { constructor(component, context) { this.component = component; @@ -47,7 +41,7 @@ export default class Renderer { return new Promise(resolve => { renderComponent(this.component, this.context, this.initialState).then(response => { const { output, links, fullHtml, ...rest } = response; - const otherParams = omit(rest, blacklistOutput); + const otherParams = omit(rest, BLACKLIST_OUTPUT); const html = renderLinksAndScripts(output, '', ''); resolve({ diff --git a/src/universal/partials/Welcome/PartialList.js b/src/universal/partials/Welcome/PartialList.js index b406108..f227c18 100644 --- a/src/universal/partials/Welcome/PartialList.js +++ b/src/universal/partials/Welcome/PartialList.js @@ -16,7 +16,7 @@ const Welcome = () => { {item.name} {item.url} -