added dynamic imports of components
This commit is contained in:
parent
6713d660b3
commit
94d4626ccf
10 changed files with 798 additions and 1032 deletions
22
build/utils/importSubModules.js
Normal file
22
build/utils/importSubModules.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
const { lstatSync, readdirSync } = require('fs');
|
||||
const { join } = require('path');
|
||||
|
||||
const getSubDirectoryNames = (root) => {
|
||||
console.log('getting sub directories for:', root);
|
||||
return readdirSync(root)
|
||||
.filter(name => {
|
||||
console.log('module found:', name);
|
||||
let fullPath = join(root, name);
|
||||
return lstatSync(fullPath).isDirectory();
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = (root) => {
|
||||
let allModules = {};
|
||||
getSubDirectoryNames(root)
|
||||
.forEach((name) => {
|
||||
console.log('importing module:', name);
|
||||
allModules[name] = require(`./${name}`).default;
|
||||
});
|
||||
return allModules;
|
||||
};
|
|
@ -1,25 +1,4 @@
|
|||
import ActiveStatusBar from './ActiveStatusBar';
|
||||
import AssetPreview from './AssetPreview';
|
||||
import ExpandingTextArea from './ExpandingTextArea';
|
||||
import GAListener from './GAListener';
|
||||
import InactiveStatusBar from './InactiveStatusBar';
|
||||
import Logo from './Logo';
|
||||
import NavBarChannelOptionsDropdown from './NavBarChannelOptionsDropdown';
|
||||
import ProgressBar from './ProgressBar';
|
||||
import PublishPreview from './PublishPreview';
|
||||
import PublishUrlMiddleDisplay from './PublishUrlMiddleDisplay';
|
||||
import SEO from './SEO';
|
||||
|
||||
module.exports = {
|
||||
ActiveStatusBar,
|
||||
AssetPreview,
|
||||
ExpandingTextArea,
|
||||
GAListener,
|
||||
InactiveStatusBar,
|
||||
Logo,
|
||||
NavBarChannelOptionsDropdown,
|
||||
ProgressBar,
|
||||
PublishPreview,
|
||||
PublishUrlMiddleDisplay,
|
||||
SEO,
|
||||
};
|
||||
const Path = require('path');
|
||||
const importSubModules = require('build/utils/importSubModules');
|
||||
const thisFolder = Path.resolve(__dirname, 'client/components/');
|
||||
module.exports = importSubModules(thisFolder);
|
||||
|
|
4
client/containers/index.js
Normal file
4
client/containers/index.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
const Path = require('path');
|
||||
const importSubModules = require('build/utils/importSubModules');
|
||||
const thisFolder = Path.resolve(__dirname, 'client/containers/');
|
||||
module.exports = importSubModules(thisFolder);
|
4
client/pages/index.js
Normal file
4
client/pages/index.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
const Path = require('path');
|
||||
const importSubModules = require('build/utils/importSubModules');
|
||||
const thisFolder = Path.resolve(__dirname, 'client/pages/');
|
||||
module.exports = importSubModules(thisFolder);
|
1743
index.js
1743
index.js
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,4 @@
|
|||
const db = require('../models/index');
|
||||
const db = require('../models');
|
||||
const logger = require('winston');
|
||||
|
||||
module.exports = {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import React from 'react';
|
||||
import { renderToString } from 'react-dom/server';
|
||||
import { createStore } from 'redux';
|
||||
import Reducer from '../../client/reducers/index';
|
||||
import Reducer from 'client/reducers';
|
||||
import { Provider } from 'react-redux';
|
||||
import { StaticRouter } from 'react-router-dom';
|
||||
import GAListener from '../../client/components/GAListener/index';
|
||||
import App from '../../client/app';
|
||||
import GAListener from 'client/components/GAListener/';
|
||||
import App from 'client/app';
|
||||
import renderFullPage from './renderFullPage.js';
|
||||
import Helmet from 'react-helmet';
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const PassportLocalStrategy = require('passport-local').Strategy;
|
||||
const lbryApi = require('../helpers/lbryApi.js');
|
||||
const logger = require('winston');
|
||||
const db = require('../models/index');
|
||||
const db = require('../models');
|
||||
|
||||
module.exports = new PassportLocalStrategy(
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// load dependencies
|
||||
const logger = require('winston');
|
||||
const db = require('../models/index'); // require our models for syncing
|
||||
const db = require('../models'); // require our models for syncing
|
||||
// configure logging
|
||||
require('../helpers/configureLogger.js')(logger);
|
||||
|
||||
|
|
12
speech.js
12
speech.js
|
@ -1,13 +1,13 @@
|
|||
const Server = require('server/server.js');
|
||||
const Components = require('client/components');
|
||||
// const containers = require('client/containers');
|
||||
// const pages = require('client/pages');
|
||||
const Server = require('./server/server.js');
|
||||
const Components = require('./client/components');
|
||||
const Containers = require('./client/containers');
|
||||
const Pages = require('./client/pages');
|
||||
|
||||
const exports = {
|
||||
Server,
|
||||
Components,
|
||||
// containers,
|
||||
// pages,
|
||||
Containers,
|
||||
Pages,
|
||||
};
|
||||
|
||||
module.exports = exports;
|
||||
|
|
Loading…
Reference in a new issue