Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] - search route lazily executed #73

Merged
merged 5 commits into from
Dec 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@
"node": "current"
}
}
],
"react"
],
"plugins": [
"transform-react-jsx-source"
]
],
"env": {
"coverage": {
Expand All @@ -27,6 +23,9 @@
"react"
],
"plugins": [
"dynamic-import-node",
"syntax-dynamic-import",
"transform-react-jsx-source",
[
"istanbul",
{
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ Optimized for use with:

[Node Inspector Manager](https://chrome.google.com/webstore/detail/nodejs-inspector-manager/bnmjajghllhhhgiaeipaibfmnjnponhd?hl=en)

[React Performance Devtool](https://chrome.google.com/webstore/detail/react-performance-devtool/fcombecpigkkfcbfaeikoeegkmkjfbfm)

[React-Sight](https://chrome.google.com/webstore/detail/react-sight/aalppolilappfakpmdfdkpppdnhpgifn)

### Server Side Unit Tests:

npm run server-unit-test
Expand Down
2 changes: 2 additions & 0 deletions gulpfile.babel.js/configs/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"parser": "babel-eslint",
"extends": [
"airbnb",
"prettier",
"prettier/react"
],
"plugins": ["prettier"],
"rules": {
"import/first": ["off"],
"comma-dangle": [2, "never"],
"react/jsx-filename-extension": [0, { "extensions": [".js"] }],
"prefer-arrow-callback": ["error", { "allowNamedFunctions": true }],
Expand Down
2 changes: 2 additions & 0 deletions gulpfile.babel.js/configs/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const config = {
server: {
integration: {
src: [
'test/server/utils/babel-register.js',
'test/server/utils/test_initializer_util.js',
'test/server/integration/**/*.js',
'test/shared/integration/**/*.js',
Expand All @@ -39,6 +40,7 @@ const config = {
},
unit: {
src: [
'test/server/utils/babel-register.js',
'test/server/utils/test_initializer_utils.js',
'test/server/utils/enzyme_initializer.js',
'test/shared/utils/**/*.js',
Expand Down
6 changes: 5 additions & 1 deletion gulpfile.babel.js/configs/karma.conf.coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ module.exports = function karmaConfIntegration(config) {
}
]
],
plugins: ['istanbul']
plugins: [
'istanbul',
'syntax-dynamic-import',
'transform-react-jsx-source'
]
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.babel.js/configs/karma.conf.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ module.exports = function karmaConfIntegration(config) {
]
],
plugins: [
'react-hot-loader/babel',
'syntax-dynamic-import',
'transform-react-jsx-source'
]
}
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.babel.js/configs/karma.conf.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ module.exports = function karmaConfUnit(config) {
]
],
plugins: [
'react-hot-loader/babel',
'syntax-dynamic-import',
'transform-react-jsx-source'
]
}
Expand Down
15 changes: 10 additions & 5 deletions gulpfile.babel.js/configs/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
'fontfaceobserver',
'react',
'react-dom',
'react-loadable',
'bluebird',
'history/createBrowserHistory',
'react-router-config',
Expand All @@ -29,7 +30,7 @@ module.exports = {
'exenv',
'scriptjs'
],
app: [
bundle: [
'react-hot-loader/patch',
// activate HMR for React

Expand All @@ -46,7 +47,7 @@ module.exports = {
},
output: {
path: path.join(__dirname, '../../dist'),
filename: 'bundle.js',
filename: '[name].js',
publicPath: 'http://localhost:3001/static'
},
devServer: {
Expand All @@ -64,14 +65,14 @@ module.exports = {
new ManifestPlugin({ writeToFileEmit: true }),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
chunks: ['app'],
chunks: ['app', 'search'],
minChunks(module /* , count */) {
const { context } = module;
return context && context.indexOf('node_modules') >= 0;
},
filename: 'vendor.js'
}),
new webpack.optimize.ModuleConcatenationPlugin(),
// new webpack.optimize.ModuleConcatenationPlugin(),
new webpack.HotModuleReplacementPlugin(),
// enable HMR globally

Expand Down Expand Up @@ -100,7 +101,11 @@ module.exports = {
}
]
],
plugins: ['react-hot-loader/babel', 'transform-react-jsx-source']
plugins: [
'syntax-dynamic-import',
'react-hot-loader/babel',
'transform-react-jsx-source'
]
}
}
],
Expand Down
10 changes: 6 additions & 4 deletions gulpfile.babel.js/configs/webpack.config.production.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module.exports = {
'fontfaceobserver',
'react',
'react-dom',
'react-loadable',
'bluebird',
'history/createBrowserHistory',
'react-router-config',
Expand All @@ -34,7 +35,8 @@ module.exports = {
},
output: {
path: path.join(__dirname, '../../dist/static/js'),
filename: 'bundle.[hash].js'
publicPath: '/js/',
filename: '[name].[hash].js'
},
plugins: [
new webpack.HashedModuleIdsPlugin({
Expand All @@ -51,8 +53,7 @@ module.exports = {
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
chunks: ['app'],
async: false,
chunks: ['app', 'search'],
minChunks(module /* , count */) {
const { context } = module;
return context && context.indexOf('node_modules') >= 0;
Expand Down Expand Up @@ -94,7 +95,8 @@ module.exports = {
}
}
]
]
],
plugins: ['syntax-dynamic-import']
}
}
],
Expand Down
9 changes: 8 additions & 1 deletion gulpfile.babel.js/tasks/gulp_babel_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import babel from 'gulp-babel';
import config from './../configs/config';

gulp.task('babel-server', function babelServer() {
const env = process.env.NODE_ENV;
const plugins =
env === 'production'
? ['dynamic-import-node']
: ['dynamic-import-node', 'transform-react-jsx-source'];

const babelStream = babel({
sourceMaps: 'inline',
presets: [
Expand All @@ -17,7 +23,8 @@ gulp.task('babel-server', function babelServer() {
}
}
]
]
],
plugins
});

babelStream.on('error', function handleError(err) {
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.babel.js/tasks/gulp_server_integration_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ gulp.task('server-integration-test', function serverIntegrationTest() {
.src(config.test.server.integration.src, {
read: false
})
.pipe(mocha({ require: 'babel-register' }))
.pipe(mocha())
.once('error', function handleError(err) {
log(err);
});
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.babel.js/tasks/gulp_server_unit_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ gulp.task('server-unit-test', function serverUnitTeset() {
.src(config.test.server.unit.src, {
read: false
})
.pipe(mocha({ require: 'babel-register' }))
.pipe(mocha())
.once('error', function handleError(err) {
log(err);
});
Expand Down
31 changes: 27 additions & 4 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"style-lint-fix": "stylelint ./src/**/*.scss --syntax scss --config gulpfile.babel.js/configs/.stylelintrc --fix",
"fix-all": "npm run js-lint-fix && npm run style-lint-fix",
"svg-min": "gulp svg-min",
"test": "gulp test",
"test": "NODE_ENV=test gulp test",
"ci-test": "gulp ci-test",
"prod-server": "pm2 reload pm2/pm2.json5",
"build-prod": "NODE_ENV=production gulp build-prod",
Expand Down Expand Up @@ -68,6 +68,7 @@
"react-dom": "16.2.0",
"react-error-boundary": "1.2.0",
"react-helmet": "5.2.0",
"react-loadable": "5.3.1",
"react-redux": "5.0.6",
"react-router": "4.2.0",
"react-router-config": "1.0.0-beta.4",
Expand All @@ -93,10 +94,13 @@
"babel-core": "6.26.0",
"babel-eslint": "8.0.2",
"babel-loader": "7.1.2",
"babel-plugin-dynamic-import-node": "1.2.0",
"babel-plugin-istanbul": "4.1.5",
"babel-plugin-syntax-dynamic-import": "6.18.0",
"babel-plugin-transform-react-jsx-source": "6.22.0",
"babel-preset-env": "1.6.1",
"babel-preset-react": "6.24.1",
"babel-register": "6.26.0",
"babel-runtime": "6.26.0",
"bunyan-prettystream": "0.1.3",
"chai": "4.1.2",
Expand Down
34 changes: 24 additions & 10 deletions src/views/containers/layouts/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,30 @@ import log from '../../../services/logger_service';
const renderRoutes = (routes, location) =>
routes ? (
<Switch key={location.key} location={location}>
{routes.map(route => (
<Route
key={location.key}
location={location}
path={route.path}
exact={route.exact}
strict={route.strict}
component={route.component}
/>
))}
{routes.map(route => {
if (route.component) {
return (
<Route
key={location.key}
location={location}
path={route.path}
exact={route.exact}
strict={route.strict}
component={route.component}
/>
);
}
return (
<Route
key={location.key}
location={location}
path={route.path}
exact={route.exact}
strict={route.strict}
render={route.render}
/>
);
})}
</Switch>
) : null;

Expand Down
Loading