Skip to content
This repository has been archived by the owner on Jun 3, 2019. It is now read-only.

next -> redux opinionated #366

Merged
merged 113 commits into from
Jun 21, 2017
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
e2d449f
Adds modernizr with illustrative example. closes #256
ctrlplusb Jan 13, 2017
c379c86
Linting now occurs on config, src and tools. closes #314
ctrlplusb Jan 13, 2017
5665b31
Updates dependencies.
ctrlplusb Jan 13, 2017
c22814f
update broken feature/flow link in docs
markyfyi Jan 14, 2017
28769d1
Merge pull request #324 from markshlick/patch-1
codepunkt Jan 14, 2017
97b0468
Merge branch 'master' into next
ctrlplusb Jan 17, 2017
4602df1
Updates dependencies.
ctrlplusb Jan 20, 2017
2438517
Updated CSP to add backwards compatibility to nonce. (#344)
rlindskog Jan 23, 2017
c2bec1c
- Renamed environment variables:
ctrlplusb Jan 23, 2017
fd693c8
Merge branch 'master' into next
ctrlplusb Jan 23, 2017
0b47de6
fix sw to exclude directory (#305)
diondirza Jan 23, 2017
8f319b3
Merge branch 'master' into next
ctrlplusb Jan 23, 2017
ae7249c
Adds Dion Dirza as a contributor 🎉
ctrlplusb Jan 23, 2017
2de7d2e
Fixes analyze.
ctrlplusb Jan 23, 2017
6721603
Docs and cleaning up.
ctrlplusb Jan 23, 2017
d79d624
Updates docs and version.
ctrlplusb Jan 23, 2017
8452f77
Removes code-split-component.
ctrlplusb Jan 23, 2017
eebd879
Updates deps and fixes config refs.
ctrlplusb Jan 23, 2017
dc24183
Huuuuuge refactor of project structure. The 'src/' was always unnece…
ctrlplusb Jan 23, 2017
4593e9d
Fixes offline page.
ctrlplusb Jan 24, 2017
d0ba64e
Cleans up and centralises util functions.
ctrlplusb Jan 24, 2017
66260b7
Minor fixes.
ctrlplusb Jan 24, 2017
ba2af33
Renames config/get to config/getConfig
ctrlplusb Feb 7, 2017
2180d3f
fixes typo: laoder -> loader (#353)
tyler-dot-earth Feb 12, 2017
22e6958
fixes typo: server -> serve (#354)
tyler-dot-earth Feb 12, 2017
db371ec
Huuuuuuuge update. Getting closer to v13.
ctrlplusb Feb 17, 2017
e3b99f6
Fixes incorrect import path in Menu.test.js (#360)
datoml Feb 19, 2017
e8f027e
Updates Error 404 component so that we can set 404 status on SSR rend…
diondirza Feb 19, 2017
f8e7fe5
Updates dependencies.
ctrlplusb Feb 20, 2017
dfd9426
Updates contributors and comments.
ctrlplusb Feb 20, 2017
29c8971
Merge branch 'next' of https://github.com/ctrlplusb/react-universally…
ctrlplusb Feb 20, 2017
18ff787
Restructures and fixes tests.
ctrlplusb Feb 20, 2017
f09a296
Cleaning up comments and docs.
ctrlplusb Feb 20, 2017
9451cbe
Fixes deprecated fallbackLoader (#365)
Feb 21, 2017
3d5f310
Changes default host config to bind to all hosts (0.0.0.0) by default…
birkir Feb 21, 2017
032abed
merge with next
sergiokopplin Feb 21, 2017
ccabc32
fix typo flag (#369)
diondirza Feb 24, 2017
4bd221b
removing flow from branch
sergiokopplin Feb 27, 2017
f802485
Missing default polyfill.io features
birkir Mar 1, 2017
3aae79f
Updated react-router-dom to beta 7 (#381)
datoml Mar 4, 2017
be004b8
Updates node version.
ctrlplusb Mar 4, 2017
28d36e6
Merge branch 'next' of https://github.com/ctrlplusb/react-universally…
ctrlplusb Mar 4, 2017
00479ef
Synchronises the react-router-dom dep into yarn.lock
ctrlplusb Mar 4, 2017
3237343
Updates dependencies.
ctrlplusb Mar 5, 2017
2e79a47
Removes onlyIf and replaces with ifElse helper. fixes #362
ctrlplusb Mar 5, 2017
cda183b
Update README.md
ctrlplusb Mar 5, 2017
6e9553a
Update README.md
ctrlplusb Mar 5, 2017
deb41e5
Fixes breaking context changes in RR4
birkir Mar 6, 2017
8a774bf
Rollback disableSSR. TODO: EnvVars this
birkir Mar 6, 2017
26daddf
Changes polyfill.io into a features array specification.
ctrlplusb Mar 13, 2017
98d968e
Upgrade react-router-dom@4.0.0 and other deps (#396)
diondirza Mar 13, 2017
38e6495
Syncs yarn.lock with package.json
ctrlplusb Mar 13, 2017
e95fe97
Fix Error404 test
birkir Mar 14, 2017
6e329f5
Upgrades to latest react-async-component.
ctrlplusb Apr 3, 2017
179f8d5
Adds 'es6' features to polyfill.io config.
ctrlplusb Apr 3, 2017
8b18f91
Removes aliasing of React libs and instead makes NODE_ENV get set to …
ctrlplusb Apr 3, 2017
35256c7
Updates comments.
ctrlplusb Apr 3, 2017
c3d8846
Removes babel-preset-latest.
ctrlplusb Apr 3, 2017
c75f781
staticContext on 404 route not required.
ctrlplusb Apr 4, 2017
ae3fa8e
Refactors async components structure.
ctrlplusb Apr 4, 2017
57367aa
Adds prettier 💄
ctrlplusb Apr 4, 2017
3bec7c6
Updates nvm
ctrlplusb Apr 4, 2017
0179f3c
Adds prepush hook to run jest.
ctrlplusb Apr 4, 2017
0e77a71
Fixes prettier config to use prettier-eslint. Woops\!
ctrlplusb Apr 4, 2017
c15e8b6
Removes unused eslint-flowtype plugin.
ctrlplusb Apr 4, 2017
579a57b
Updates dependencies.
ctrlplusb Apr 5, 2017
5dc5bc1
Updates docs
ctrlplusb Apr 5, 2017
fbac4a4
Moves all html page elements to DemoApp component. closes #390
ctrlplusb Apr 5, 2017
7c5338b
Removes 'host' from server start. closes #398
ctrlplusb Apr 5, 2017
e977ce2
Changes process.env build flags to be inline with expected string typ…
ctrlplusb Apr 5, 2017
6cb1651
Merge branch 'master' of https://github.com/ctrlplusb/react-universally
ctrlplusb Apr 5, 2017
d71b1e4
Preps v13 release
ctrlplusb Apr 5, 2017
9c4c902
Update README.md
ctrlplusb Apr 6, 2017
71f7c4d
Update README.md
ctrlplusb Apr 6, 2017
a25a5d3
Updates dependencies.
ctrlplusb Apr 6, 2017
a97f6de
Merge branch 'master' of https://github.com/ctrlplusb/react-universally
ctrlplusb Apr 6, 2017
0e6642d
Update breaking changes
ctrlplusb Apr 7, 2017
ebee892
Adds birkir to contributors list
ctrlplusb Apr 7, 2017
d1f6f5b
Adds @birkir to contributors on about us route.
ctrlplusb Apr 7, 2017
f4f3766
Changes over to all-contributors
ctrlplusb Apr 7, 2017
db284ea
Orders contributors by name
ctrlplusb Apr 7, 2017
dbb8d0e
fix the "collectCoverageFrom" config of jest
ChinW Apr 13, 2017
ab73cb3
Merge pull request #418 from ChinW/master
birkir Apr 13, 2017
4cd7850
[merge next] solving conflicts
sergiokopplin Apr 13, 2017
c838107
updating asyncPosts
sergiokopplin Apr 14, 2017
09c2d0f
Prepare React 15.5 (#413)
birkir Apr 15, 2017
7ee3d42
Updates deps.
ctrlplusb Apr 15, 2017
94a61ec
Another bug fixes, tweaks (#422)
diondirza Apr 21, 2017
ef35285
Add es6 back by default. (#429)
birkir Apr 21, 2017
1f26e01
Windows (#415)
Apr 21, 2017
c991cad
dev server host always 0.0.0.0, not host config
kdavh Apr 25, 2017
cc28bb0
merge with universally/master
sergiokopplin Apr 28, 2017
6d3bb1f
merge with universally/master - updating snapshots
sergiokopplin Apr 28, 2017
01b2fb1
merge/next - adding async posts
sergiokopplin Apr 29, 2017
9afd8b0
merge/next - updating dependencies + updating async components + remo…
sergiokopplin Apr 29, 2017
a6f6ec6
merge/next - updating server side state
sergiokopplin Apr 29, 2017
d173af3
merge/next - fixing server async functions
sergiokopplin Apr 30, 2017
a73f171
universally/merge - fixing async posts route
sergiokopplin May 2, 2017
04b0d23
chore: add redux, react-redux, redux-thunk to vendorDLL
May 2, 2017
865a972
Merge pull request #1 from strues/feature/redux-opinionated
sergiokopplin May 2, 2017
4335ac4
Fix configuration for extracted style hash (#438)
diondirza May 3, 2017
19b749c
Fix broken link to Feature Branches docs. (#419)
threehams May 3, 2017
550e809
Fix CORS host (#432)
diondirza May 3, 2017
dbb0d3a
Merge pull request #433 from kdavh/public-dev-server-fix
birkir May 3, 2017
e589803
Removes reference to deprecated react PropTypes import and replaces w…
May 3, 2017
912216e
update snapshot
May 3, 2017
c74fece
Merge pull request #2 from strues/feature/redux-opinionated
sergiokopplin May 3, 2017
422f05a
Fix Router v2 Implementation
brianfeister May 5, 2017
4bbcec6
Merge pull request #3 from brianfeister/patch-1
sergiokopplin May 5, 2017
bcdce08
Add color support for stdout (#443)
birkir May 7, 2017
20ede0e
Merge remote-tracking branch 'upstream/master' into feature/redux-opi…
sergiokopplin May 12, 2017
7d808de
master -> redux: fixing store problem
sergiokopplin May 25, 2017
cfa8da0
fixing stores
sergiokopplin May 31, 2017
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
6 changes: 3 additions & 3 deletions .env_example
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
# ==============================================================================

# The host on which to run the server.
SERVER_HOST=localhost
HOST=localhost

# The port on which to run the server.
SERVER_PORT=1337
PORT=1337

# The port on which to run the client bundle dev server (i.e. used during
# development only).
CLIENT_DEVSERVER_PORT=7331
CLIENT_DEV_PORT=7331
2 changes: 0 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
flow-typed/
tools/flow/
node_modules/
build/
9 changes: 0 additions & 9 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"parser": "babel-eslint",
"extends": "airbnb",
"plugins": [
"flowtype"
],
"env": {
"browser": true,
"es6": true,
Expand All @@ -14,14 +11,8 @@
"defaultParams": true
},
"rules": {
// We use the 'import' plugin which allows for cases "flow" awareness.
"no-duplicate-imports": 0,
// A .jsx extension is not required for files containing jsx.
"react/jsx-filename-extension": 0,
// This rule struggles with flow and class properties.
"react/sort-comp": 0,
// This rule struggles with flow.
"react/prop-types": 0,
// We use global requires in various places, e.g. code splitting instances.
"global-require": 0
}
Expand Down
35 changes: 0 additions & 35 deletions .flowconfig

This file was deleted.

9 changes: 3 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ npm-debug.log
.vscode
.history

# flow-typed Lib Defs
flow-typed/

# Flow Coverage Report
flow-coverage/

# Happypack
.happypack

# OSX Files
.DS_Store
7 changes: 7 additions & 0 deletions .modernizrrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"minify": true,
"options": [],
"feature-detects": [
"elem/picture"
]
}
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v6.9.2
v6.9.4
40 changes: 40 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,46 @@ I'll map them as follows:
- Minor: New features or changes to the build tools. Could contain some things that are traditionally know as breaking changes, however, I believe the upgrade path to minor.
- Patch: Small(ish) fixes/restructuring that I expect will take minimal effort to merge in.

# [13.0.0] - 2017-01-23

### BREAKING

- Big folder structure refactor, moving items from src/* into the root of the project.
- Removes the CONF_ENV variable and instead relies on NODE_ENV for runtime env specification on executing server.
- Upgrades to `react-router` v4 beta.
- Replaces `code-split-component` with `react-async-component`
- Removed `react-hot-loader` as it doesn't play nicely with `react-async-component`, but we still have webpack's default hot module reloading.
- Complete restructure of the DefinePlugin special flags, they have been prefixed with "BUILD_FLAG_" to make them more obvious when used in the code. This also helps us distinguish these build-time values from other runtime provided process.env values.
- We no longer rely on NODE_ENV to include an optimized version of React/ReactDOM - this caused confusion with booting an application to target a specific NODE_ENV like "staging" or whatever. Now we use webpack's alias feature to resolve React/ReactDOM imports to the correct optimized version of React.
- Removes cross-env and refactors the script commands. You can assign NODE_ENV as and when you need now (for example, to target a .env.production environment configuration file).
- Renamed environment variables:
- `SERVER_PORT` to `PORT`
- `SERVER_HOST` to `HOST`
- `CLIENT_DEVSERVER_PORT` to `CLIENT_DEV_PORT`
- Renames the `nodeBundlesIncludeNodeModuleFileTypes` config property to `nodeExternalsFileTypeWhitelist`
- Refactors the server and serviceworker offline page generation. We now use a set of React components (`ServerHTML` and `HTML`) to manage our HTML in a uniform fashion.
- Refactors how we resolve environment specific configuration values. `NODE_ENV` is reserved for specifying a `development` or `production` build now. Use `CONF_ENV` to specify a target environment if you would like to resolve an environment specific .env file.
- All config reads are now done through the centralised `config/index.js` helper.
- Refactors the client configuration filter rule to be contained within the main configuration and moves the configuration object creation into the server middleware.
- Refactors the config folder in various ways. Cleaning up, restructuring, etc.
- Renames the `environmentVars` file and helpers.

### Changed

- All server/client/shared code all use the shared config helper.
- Updated dependencies, including to the latest Webpack official 2 release.

### Added

- New babel plugins to optimise React production build performance.
- Adds new icon sets.

### Fixed

- Chrome favicon request issue.
- Cleans up the package scripts.
- Service worker would fail if a subfolder was added to the public folder.

# [12.0.0] - 2017-01-09

### BREAKING
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 Sean Matheson
Copyright (c) 2017 Sean Matheson

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Note: This is a feature branch of `react-universally`. Please see the [`FEATURE_
<p align='center'>
<h1 align='center'>React, Universally</h1>
<p align='center'><img width='150' src='https://raw.githubusercontent.com/ctrlplusb/assets/master/logos/react-universally.png' /></p>
<p align='center'>A starter kit giving you the minimum requirements for a modern universal React application.</p>
<p align='center'>A starter kit for universal react applications.</p>
</p>

## About
Expand All @@ -21,13 +21,13 @@ This starter kit contains all the build tooling and configuration you need to ki
- 🚄 `express` server.
- 🎭 `jest` as the test framework.
- 🖌 Very basic CSS support - it's up to you to extend it with CSS Modules etc.
- ✂️ Code splitting - easily define code split points in your source using `code-split-component`.
- ✂️ Code splitting - easily define code split points in your source using `react-async-component`.
- 🌍 Server Side Rendering.
- 😎 Progressive Web Application ready, with offline support, via a Service Worker.
- 🐘 Long term browser caching of assets with automated cache invalidation.
- 📦 All source is bundled using Webpack v2.
- 🚀 Full ES2017+ support - use the exact same JS syntax across the entire project (src/tools/config). No more folder context switching! We also only use syntax that is stage-3 or later in the TC39 process.
- 🔧 Centralised application configuration with helpers to avoid boilerplate in your code.
- 🚀 Full ES2017+ support - use the exact same JS syntax across the entire project. No more folder context switching! We also only use syntax that is stage-3 or later in the TC39 process.
- 🔧 Centralised application configuration with helpers to avoid boilerplate in your code. Also has support for environment specific configuration files.
- 🔥 Extreme live development - hot reloading of ALL changes to client/server source, with auto development server restarts when your application configuration changes. All this with a high level of error tolerance and verbose logging to the console.
- ⛑ SEO friendly - `react-helmet` provides control of the page title/meta/styles/scripts from within your components.
- 🤖 Optimised Webpack builds via HappyPack and an auto generated Vendor DLL for smooth development experiences.
Expand Down Expand Up @@ -64,10 +64,10 @@ Now go make some changes to the `Home` component to see the tooling in action.

## Docs

- [Project Overview](/docs/PROJECT_OVERVIEW.md)
- [Application Configuration](/docs/APPLICATION_CONFIG.md)
- [Package Script Commands](/docs/PKG_SCRIPTS.md)
- [Feature Branches](/docs/FEATURE_BRANCHES.md)
- [Deploy your very own Server Side Rendering React App in 5 easy steps](/docs/DEPLOY_TO_NOW.md)
- [FAQ](/docs/FAQ.md)
- [Project Overview](/internal/docs/PROJECT_OVERVIEW.md)
- [Project Configuration](/internal/docs/PROJECT_CONFIG.md)
- [Package Script Commands](/internal/docs/PKG_SCRIPTS.md)
- [FAQ](/internal/docs/FAQ.md)
- [Feature Branches](/internal/docs/FEATURE_BRANCHES.md)
- [Deploy your very own Server Side Rendering React App in 5 easy steps](/internal/docs/DEPLOY_TO_NOW.md)
- [Changelog](/CHANGELOG.md)
67 changes: 67 additions & 0 deletions client/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/* eslint-disable global-require */

import React from 'react';
import { render } from 'react-dom';
import { Provider as ReduxProvider } from 'react-redux';
import { rehydrateJobs } from 'react-jobs/ssr';
import BrowserRouter from 'react-router-dom/BrowserRouter';
import { withAsyncComponents } from 'react-async-component';
import { configureStore } from '../shared/redux/configureStore';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shoudn't configureStore be imported as a default import ?

import configureStore from '../shared/redux/configureStore';


import './polyfills';

import DemoApp from '../shared/components/DemoApp';

// Get the DOM Element that will host our React application.
const container = document.querySelector('#app');

// Create our Redux store.
const store = configureStore(
// Server side rendering would have mounted our state on this global.
window.__APP_STATE__, // eslint-disable-line no-underscore-dangle
);

/**
* Renders the given React Application component.
*/
function renderApp(TheApp) {
// Firstly, define our full application component, wrapping the given
// component app with a browser based version of react router.
const app = (
<ReduxProvider store={store}>
<BrowserRouter>
<TheApp />
</BrowserRouter>
</ReduxProvider>
);

// We use the react-async-component in order to support code splitting of
// our bundle output. It's important to use this helper.
// @see https://github.com/ctrlplusb/react-async-component
withAsyncComponents(app).then(({ appWithAsyncComponents }) =>
render(appWithAsyncComponents, container),
);

rehydrateJobs(app).then(({ appWithJobs }) =>
render(appWithJobs, container),
);
}

// Execute the first render of our app.
renderApp(DemoApp);

// This registers our service worker for asset caching and offline support.
// Keep this as the last item, just in case the code execution failed (thanks
// to react-boilerplate for that tip.)
require('./registerServiceWorker');

// The following is needed so that we can support hot reloading our application.
if (process.env.BUILD_FLAG_IS_DEV && module.hot) {
// Accept changes to this file for hot reloading.
module.hot.accept('./index.js');
// Any changes to our App will cause a hotload re-render.
module.hot.accept(
'../shared/components/DemoApp',
() => renderApp(require('../shared/components/DemoApp').default),
);
}
18 changes: 18 additions & 0 deletions client/polyfills/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* eslint-disable no-console */

import Modernizr from 'modernizr';

// This is just an illustrative example. Here you are testing the client's
// support for the "picture" element, and if it isn't supported then you
// load a polyfill.
if (!Modernizr.picture) {
console.log('Client does not support "picture", polyfilling it...');
// If you want to use the below do a `yarn add picturefill --exact` and then
// uncomment the lines below:
/*
require('picturefill');
require('picturefill/dist/plugins/mutation/pf.mutation');
*/
} else {
console.log('Client has support for "picture".');
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
// We use the offline-plugin to generate a service worker. See the webpack
// config for more details.
//
// We need to ensure that the runtime is installed so that the generated
// service worker is executed.
//
// We will only be doing this for production builds.
/**
* We use the offline-plugin to generate a service worker. See the webpack
* config for more details.
*
* We need to ensure that the runtime is installed so that the generated
* service worker is executed.
*
* NOTE: We only enable the service worker for non-development environments.
*/

import { safeConfigGet } from '../shared/utils/config';
import config from '../config';

if (process.env.NODE_ENV === 'production') {
if (!process.env.BUILD_FLAG_IS_DEV) {
// We check the shared config, ensuring that the service worker has been
// enabled.
if (safeConfigGet(['serviceWorker', 'enabled'])) {
if (config('serviceWorker.enabled')) {
const OfflinePluginRuntime = require('offline-plugin/runtime');

// Install the offline plugin, which instantiates our service worker and app
Expand Down
41 changes: 41 additions & 0 deletions config/components/ClientConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react';
import serialize from 'serialize-javascript';
import filterWithRules from '../../shared/utils/objects/filterWithRules';
import values from '../values';

// Filter the config down to the properties that are allowed to be included
// in the HTML response.
const clientConfig = filterWithRules(
// These are the rules used to filter the config.
values.clientConfigFilter,
// The config values to filter.
values,
);

const serializedClientConfig = serialize(clientConfig);

/**
* A react component that generates a script tag that binds the allowed
* values to the window so that config values can be read within the
* browser.
*
* They get bound to window.__CLIENT_CONFIG__
*/
function ClientConfig({ nonce }) {
return (
<script
type="text/javascript"
nonce={nonce}
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{
__html: `window.__CLIENT_CONFIG__=${serializedClientConfig}`,
}}
/>
);
}

ClientConfig.propTypes = {
nonce: React.PropTypes.string.isRequired,
};

export default ClientConfig;
Loading