Merge pull request #442 from lbryio/12-conditional-compiltion

12 - dynamic imports of custom components
This commit is contained in:
Bill Bittner 2018-05-15 09:07:38 -07:00 committed by GitHub
commit a720f569ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 4 additions and 57 deletions

View file

@ -1,17 +0,0 @@
function ViewsConfig () {
this.components = {};
this.containers = {};
this.pages = {};
this.update = (config) => {
if (!config) {
return console.log('No components config received.');
}
const { components, containers, pages } = config;
console.log('Configuring custom components ...');
this.components = components;
this.containers = containers;
this.pages = pages;
};
}
module.exports = new ViewsConfig();

View file

@ -13,14 +13,12 @@ const loggerConfig = require('./config/loggerConfig.js');
const mysqlConfig = require('./config/mysqlConfig.js'); const mysqlConfig = require('./config/mysqlConfig.js');
const siteConfig = require('./config/siteConfig.js'); const siteConfig = require('./config/siteConfig.js');
const slackConfig = require('./config/slackConfig.js'); const slackConfig = require('./config/slackConfig.js');
const viewsConfig = require('./config/viewsConfig.js');
function Server () { function Server () {
this.configureLogger = loggerConfig.update; this.configureLogger = loggerConfig.update;
this.configureMysql = mysqlConfig.update; this.configureMysql = mysqlConfig.update;
this.configureSite = siteConfig.update; this.configureSite = siteConfig.update;
this.configureSlack = slackConfig.update; this.configureSlack = slackConfig.update;
this.configureViews = viewsConfig.update;
this.createApp = () => { this.createApp = () => {
// create an Express application // create an Express application
const app = express(); const app = express();

View file

@ -18,22 +18,13 @@ var _reactHelmet = _interopRequireDefault(require("react-helmet"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/*
^ note: to do this right, maybe
these should be passed in from the implementation (www.spee.ch) itself,
so that there are no conflicts between the SSR here and
the bundle sent to the server?
there might also be issues if this package uses a different version of spee.ch-components than www.spee.ch does?
*/
var siteConfig = require('../../../config/siteConfig.js'); var siteConfig = require('../../../config/siteConfig.js');
var viewsConfig = require('../../../config/viewsConfig.js');
module.exports = function (req, res) { module.exports = function (req, res) {
var context = {}; // customize the reducer by passing in intial state configs var context = {}; // customize the reducer by passing in intial state configs
var MyReducers = (0, _spee.Reducers)(siteConfig); var MyReducers = (0, _spee.Reducers)(siteConfig);
var MyApp = (0, _spee.App)(viewsConfig); var MyApp = _spee.App;
var MyGAListener = (0, _spee.GAListener)(siteConfig); // create a new Redux store instance var MyGAListener = (0, _spee.GAListener)(siteConfig); // create a new Redux store instance
var store = (0, _redux.createStore)(MyReducers); // render component to a string var store = (0, _redux.createStore)(MyReducers); // render component to a string

View file

@ -22,17 +22,8 @@ var _reactHelmet = _interopRequireDefault(require("react-helmet"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/*
^ note: to do this right, maybe
these should be passed in from the implementation (www.spee.ch) itself,
so that there are no conflicts between the SSR here and
the bundle sent to the server?
there might also be issues if this package uses a different version of spee.ch-components than www.spee.ch does?
*/
var siteConfig = require('../../../config/siteConfig.js'); var siteConfig = require('../../../config/siteConfig.js');
var viewsConfig = require('../../../config/viewsConfig.js');
var returnSagaWithParams = function returnSagaWithParams(saga, params) { var returnSagaWithParams = function returnSagaWithParams(saga, params) {
return ( return (
/*#__PURE__*/ /*#__PURE__*/
@ -58,7 +49,7 @@ module.exports = function (req, res) {
var context = {}; // configure the reducers by passing initial state configs var context = {}; // configure the reducers by passing initial state configs
var MyReducers = (0, _spee.Reducers)(siteConfig); var MyReducers = (0, _spee.Reducers)(siteConfig);
var MyApp = (0, _spee.App)(viewsConfig); var MyApp = _spee.App;
var MyGAListener = (0, _spee.GAListener)(siteConfig); // create and apply middleware var MyGAListener = (0, _spee.GAListener)(siteConfig); // create and apply middleware
var sagaMiddleware = (0, _reduxSaga.default)(); var sagaMiddleware = (0, _reduxSaga.default)();

View file

@ -4,25 +4,17 @@ import { createStore } from 'redux';
import { Provider } from 'react-redux'; import { Provider } from 'react-redux';
import { StaticRouter } from 'react-router-dom'; import { StaticRouter } from 'react-router-dom';
import { Reducers, GAListener, App } from 'spee.ch-components'; import { Reducers, GAListener, App } from 'spee.ch-components';
/*
^ note: to do this right, maybe
these should be passed in from the implementation (www.spee.ch) itself,
so that there are no conflicts between the SSR here and
the bundle sent to the server?
there might also be issues if this package uses a different version of spee.ch-components than www.spee.ch does?
*/
import renderFullPage from '../renderFullPage.js'; import renderFullPage from '../renderFullPage.js';
import Helmet from 'react-helmet'; import Helmet from 'react-helmet';
const siteConfig = require('../../../config/siteConfig.js'); const siteConfig = require('../../../config/siteConfig.js');
const viewsConfig = require('../../../config/viewsConfig.js');
module.exports = (req, res) => { module.exports = (req, res) => {
let context = {}; let context = {};
// customize the reducer by passing in intial state configs // customize the reducer by passing in intial state configs
const MyReducers = Reducers(siteConfig); const MyReducers = Reducers(siteConfig);
const MyApp = App(viewsConfig); const MyApp = App;
const MyGAListener = GAListener(siteConfig); const MyGAListener = GAListener(siteConfig);
// create a new Redux store instance // create a new Redux store instance

View file

@ -7,17 +7,9 @@ import renderFullPage from '../renderFullPage';
import createSagaMiddleware from 'redux-saga'; import createSagaMiddleware from 'redux-saga';
import { call } from 'redux-saga/effects'; import { call } from 'redux-saga/effects';
import { Reducers, GAListener, App, Sagas, Actions } from 'spee.ch-components'; import { Reducers, GAListener, App, Sagas, Actions } from 'spee.ch-components';
/*
^ note: to do this right, maybe
these should be passed in from the implementation (www.spee.ch) itself,
so that there are no conflicts between the SSR here and
the bundle sent to the server?
there might also be issues if this package uses a different version of spee.ch-components than www.spee.ch does?
*/
import Helmet from 'react-helmet'; import Helmet from 'react-helmet';
const siteConfig = require('../../../config/siteConfig.js'); const siteConfig = require('../../../config/siteConfig.js');
const viewsConfig = require('../../../config/viewsConfig.js');
const returnSagaWithParams = (saga, params) => { const returnSagaWithParams = (saga, params) => {
return function * () { return function * () {
@ -30,7 +22,7 @@ module.exports = (req, res) => {
// configure the reducers by passing initial state configs // configure the reducers by passing initial state configs
const MyReducers = Reducers(siteConfig); const MyReducers = Reducers(siteConfig);
const MyApp = App(viewsConfig); const MyApp = App;
const MyGAListener = GAListener(siteConfig); const MyGAListener = GAListener(siteConfig);
// create and apply middleware // create and apply middleware