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

Updated dependencies to the latest stable versions #9

Merged
merged 28 commits into from
Nov 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c7b955b
Update graphql
iPhaeton Oct 25, 2017
73b4f48
Update types
iPhaeton Oct 25, 2017
8c0af78
Update react
iPhaeton Oct 25, 2017
1e70c15
Fix tests by updating enzyme
iPhaeton Oct 25, 2017
781b6f2
Fix test warnings by installing raf
iPhaeton Oct 25, 2017
4267fe9
Update ramda
iPhaeton Oct 25, 2017
707f96c
Update styled-components
iPhaeton Oct 26, 2017
97927ad
Update babel-plugin-styled-components
iPhaeton Oct 26, 2017
b2a52bc
Update typescript
iPhaeton Oct 26, 2017
714a3cf
Require instaed of import for styled
iPhaeton Oct 27, 2017
66a7964
Add comment explaing use of require instead of import for styled
iPhaeton Oct 27, 2017
0889793
Update recompose
iPhaeton Oct 27, 2017
0f991d1
Update redux-saga
iPhaeton Oct 27, 2017
65f8b0b
Use react-redux Provider
iPhaeton Oct 27, 2017
462bb7c
Update react apollo
iPhaeton Oct 27, 2017
d41c616
Impoort gql from graphql-tag
iPhaeton Oct 27, 2017
0bd21f6
Remove apollo middleware and reducer
iPhaeton Oct 27, 2017
c5d3532
Denote apollo-client and apollo-cache-inmemory versions
iPhaeton Oct 27, 2017
054ec2c
Install apollo-fetch
iPhaeton Oct 27, 2017
4e61859
Update dev dependencies
iPhaeton Oct 27, 2017
55ef4b7
Merge branch 'update-deps' into update-react-apollo
iPhaeton Oct 27, 2017
200c5d0
Update pacjage.json to accept minor releases
iPhaeton Oct 30, 2017
f2d51aa
Update version to 0.0.4
iPhaeton Oct 30, 2017
32bfc70
Don't need apollo to create store
iPhaeton Oct 27, 2017
e070013
Merge branch 'update-react-apollo' into update-deps
iPhaeton Oct 30, 2017
fcf19ed
Update version to 1.0.0
iPhaeton Oct 30, 2017
0a8def0
Define IProps for Layout
iPhaeton Oct 30, 2017
9e14b79
CHORE Updated few minor dependencies
shaleynikov Nov 17, 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
17 changes: 10 additions & 7 deletions app/client/apollo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { ApolloClient, createNetworkInterface } from 'react-apollo';
import fetch from 'isomorphic-fetch';
import ApolloClient from 'apollo-client';
import { HttpLink } from 'apollo-link-http';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { createApolloFetch } from 'apollo-fetch';

const fetch = createApolloFetch({ uri: 'http://localhost:3000/graphql' });

let apolloClient: any = null;
const proc = process as any;
Expand All @@ -13,12 +17,11 @@ if (!proc.browser) {
function create() {
return new ApolloClient({
ssrMode: !proc.browser, // Disables forceFetch on the server (so queries are only run once)
networkInterface: createNetworkInterface({
link: new HttpLink({
uri: 'http://localhost:3000/graphql', // Server URL (must be absolute)
opts: { // Additional fetch() options like `credentials` or `headers`
credentials: 'same-origin'
}
})
credentials: 'same-origin'
}),
cache: new InMemoryCache()
});
}

Expand Down
21 changes: 11 additions & 10 deletions app/client/data.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import { Provider } from 'react-redux';
import Head from 'next/head';
import { ApolloProvider, getDataFromTree } from 'react-apollo';
import { initApollo } from './apollo';
Expand Down Expand Up @@ -31,17 +32,17 @@ export default (ComposedComponent) => {
// and extract the resulting data
if (!proc.browser) {
const apollo = initApollo();
const redux = initRedux(apollo);
const redux = initRedux();
// Provide the `url` prop data in case a GraphQL query uses it
const url = {query: ctx.query, pathname: ctx.pathname};

try {
// Run all GraphQL queries
await getDataFromTree(
// No need to use the Redux Provider
// because Apollo sets up the store for us
<ApolloProvider client={apollo} store={redux}>
<ComposedComponent url={url} {...composedInitialProps} />
<ApolloProvider client={apollo}>
<Provider store={redux}>
<ComposedComponent url={url} {...composedInitialProps} />
</Provider>
</ApolloProvider>
);
} catch (error) {
Expand Down Expand Up @@ -76,15 +77,15 @@ export default (ComposedComponent) => {
const { serverState }: any = this.props;

this.apollo = initApollo();
this.redux = initRedux(this.apollo, serverState);
this.redux = initRedux(serverState);
}

public render() {
return (
// No need to use the Redux Provider
// because Apollo sets up the store for us
<ApolloProvider client={this.apollo} store={this.redux}>
<ComposedComponent {...this.props} />
<ApolloProvider client={this.apollo}>
<Provider store={this.redux}>
<ComposedComponent {...this.props} />
</Provider>
</ApolloProvider>
);
}
Expand Down
2 changes: 1 addition & 1 deletion app/client/queries/fetchMarvelCharacters.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { gql } from 'react-apollo';
import gql from 'graphql-tag';

export const fetchMarvelCharacters = gql`
query($endpoint: String!, $params: MarvelParams) {
Expand Down
2 changes: 1 addition & 1 deletion app/client/queries/fetchPosts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { gql } from 'react-apollo';
import gql from 'graphql-tag';

export const fetchPosts = gql`
query {
Expand Down
16 changes: 6 additions & 10 deletions app/client/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@ let reduxStore = null;
const proc = process as any;
const sagaMiddleware = createSagaMiddleware();

function create(apollo, initialState) {
function create(initialState) {
const middlewares = [
sagaMiddleware,
apollo.middleware()
sagaMiddleware
];

const store: any = createStore(
combineReducers({
...reducers,
apollo: apollo.reducer()
}),
combineReducers({...reducers}),
initialState,
composeWithDevTools(applyMiddleware(...middlewares))
);
Expand All @@ -27,14 +23,14 @@ function create(apollo, initialState) {
return store;
}

export function initRedux(apollo, initialState = {}) {
export function initRedux(initialState = {}) {
if (!proc.browser) {
return create(apollo, initialState);
return create(initialState);
}

// Reuse store on the client-side
if (!reduxStore) {
reduxStore = create(apollo, initialState);
reduxStore = create(initialState);
}

return reduxStore;
Expand Down
5 changes: 4 additions & 1 deletion app/components/Counter/tests/component.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as React from 'react';
import { shallow } from 'enzyme';
import { shallow, configure } from 'enzyme';
import { Counter } from '../component';
import Adapter from 'enzyme-adapter-react-16';

configure({ adapter: new Adapter() });

const counter = shallow(<Counter />);

Expand Down
2 changes: 1 addition & 1 deletion app/components/Footer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import styled from 'styled-components';
const styled = require('styled-components').default;

const Foot = styled.footer`
position: absolute;
Expand Down
2 changes: 1 addition & 1 deletion app/components/Header/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import Link from 'next/link';
import styled from 'styled-components';
const styled = require('styled-components').default;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure const styled = require('styled-components').default is a good approach. Why exactly import styled from 'styled-components' doesn't work?

Copy link
Contributor Author

@iPhaeton iPhaeton Oct 31, 2017

Choose a reason for hiding this comment

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

Looks like it has to do with this issue
styled-components/babel-plugin-styled-components#41 (comment)
When we use import styled from 'styled-components', it gets transformed to styled_components_1.default by typescript compiler which is not recognized as a styled component helper by babel-plugin-styled-components.
I believe, this issue was present before, but wasn't obvious, because react 15 just replaced the mismatched server-generated markup.
Since react 16 doesn't do this anymore, it becomes evident in development mode. When a page gets loaded, the styles don't apply to the components because of className mismatch.


const Nav = styled.nav`
display: flex;
Expand Down
8 changes: 6 additions & 2 deletions app/components/Layout/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import * as React from 'react';
import { Header } from '../Header';
import { Footer } from '../Footer';
import styled from 'styled-components';
const styled = require('styled-components').default;

const Layout: React.StatelessComponent<any> = ({ children }): JSX.Element => (
interface IProps {
children: React.ReactNode;
}

const Layout: React.StatelessComponent<IProps> = ({ children }): JSX.Element => (
<section>
<Header />
<Content>
Expand Down
3 changes: 2 additions & 1 deletion app/components/Spinner/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import styled, { keyframes } from 'styled-components';
const styled = require('styled-components').default;
const { keyframes } = require('styled-components');

const pulse = keyframes`
0%, 40%, 100% { transform: scaleY(0.4) }
Expand Down
2 changes: 1 addition & 1 deletion app/modules/Marvel/components/MarvelHero.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import styled from 'styled-components';
const styled = require('styled-components').default;

const Header = styled.h1`
text-align: center;
Expand Down
2 changes: 1 addition & 1 deletion app/modules/Marvel/components/MarvelHeroes.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import styled from 'styled-components';
const styled = require('styled-components').default;
import MarvelPager from '../containers/MarvelPager';

const { Link } = require('client/routes');
Expand Down
2 changes: 1 addition & 1 deletion app/modules/Marvel/components/MarvelLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import styled from 'styled-components';
const styled = require('styled-components').default;
import MarvelSearchHero from '../containers/MarvelSearchHero';
import MarvelHeroes from '../containers/MarvelHeroes';

Expand Down
2 changes: 1 addition & 1 deletion app/modules/Marvel/components/MarvelPager.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import styled from 'styled-components';
const styled = require('styled-components').default;

interface IProps {
total: number;
Expand Down
2 changes: 1 addition & 1 deletion app/modules/Marvel/components/MarvelSearchHero.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import styled from 'styled-components';
const styled = require('styled-components').default;

interface IProps {
search: string;
Expand Down
2 changes: 1 addition & 1 deletion app/modules/SupaModule/components/SupaItem.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import styled from 'styled-components';
const styled = require('styled-components').default;

interface IProps {
id: number;
Expand Down
2 changes: 1 addition & 1 deletion app/modules/SupaModule/components/SupaLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SupaAddItem from '../containers/SupaAddItem';
import SupaItemsRestore from '../containers/SupaItemsRestore';
import SupaItem from '../containers/SupaItem';
import SupaItemSearch from '../containers/SupaItemSearch';
import styled from 'styled-components';
const styled = require('styled-components').default;

interface IProps {
list: [object];
Expand Down
3 changes: 2 additions & 1 deletion app/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as React from 'react';
import styled from 'styled-components';
// Require styled to avoid the issue https://github.com/styled-components/styled-components/issues/1168 on page reload
const styled = require('styled-components').default;
import Layout from 'components/Layout';

const Image = styled.div`
Expand Down
5 changes: 4 additions & 1 deletion app/pages/tests/about.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import * as React from 'react';
import { shallow } from 'enzyme';
import { shallow, configure } from 'enzyme';
import About from '../about';
import Adapter from 'enzyme-adapter-react-16';

configure({ adapter: new Adapter() });

describe('About page', () => {
it('should render <h1> tag with text', () => {
Expand Down
5 changes: 4 additions & 1 deletion app/pages/tests/component.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import * as React from 'react';
import { shallow } from 'enzyme';
import { shallow, configure } from 'enzyme';
import Component from '../component';
import Counter from '../../components/Counter';
import Adapter from 'enzyme-adapter-react-16';

configure({ adapter: new Adapter() });

describe('Component page', () => {
it('should render <Counter /> component', () => {
Expand Down
5 changes: 4 additions & 1 deletion app/pages/tests/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import * as React from 'react';
import { shallow } from 'enzyme';
import { shallow, configure } from 'enzyme';
import Home from '../index';
import Layout from '../../components/Layout';
import Adapter from 'enzyme-adapter-react-16';

configure({ adapter: new Adapter() });

describe('Home page', () => {
it('should render Layout wrapper', () => {
Expand Down
64 changes: 37 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "react-hipstaplate",
"version": "0.0.3",
"version": "1.0.0",
"description": "Modern ReactJS/express full-stack boilerplate",
"repository": {
"type": "git",
"url": "https://github.com/DashBouquet/react-hipstaplate.git"
},
"engines": {
"npm": ">=3",
"node": "6.11.1"
"node": ">=6"
},
"author": "Vitali Shalak",
"license": "MIT",
Expand Down Expand Up @@ -39,57 +39,67 @@
"^.+\\.js$": "<rootDir>/node_modules/babel-jest",
"^.+\\.(ts|tsx)$": "<rootDir>/node_modules/ts-jest/preprocessor.js"
},
"testRegex": "tests/.*\\.test\\.(j|t)sx?$"
"testRegex": "tests/.*\\.test\\.(j|t)sx?$",
"setupFiles": [
"raf/polyfill"
]
},
"dependencies": {
"@types/enzyme": "^2.8.4",
"@types/enzyme": "^3.1.1",
"@types/jasmine": "^2.5.53",
"@types/jest": "^20.0.6",
"@types/jest": "^21.1.5",
"@types/next": "^2.4.2",
"@types/ramda": "^0.24.5",
"@types/ramda": "^0.25.6",
"@types/react": "^16.0.0",
"@types/react-redux": "^5.0.2",
"@types/recompose": "^0.23.2",
"@types/recompose": "^0.24.2",
"apollo-cache-inmemory": "1.1.1",
"apollo-client": "^2.x.x",
"apollo-fetch": "^0.6.0",
"apollo-link-http": "^1.x.x",
"body-parser": "^1.17.2",
"cross-env": "^5.0.1",
"express": "^4.15.3",
"express-session": "^1.15.4",
"graphql": "^0.10.5",
"graphql-server-express": "^1.0.5",
"graphql-tools": "^1.1.0",
"graphql": "^0.11.7",
"graphql-server-express": "^1.2.0",
"graphql-tag": "^2.5.0",
"graphql-tools": "2.7.2",
"isomorphic-fetch": "^2.2.1",
"next": "^3.0.3",
"next": "^4.1.3",
"next-redux-saga": "^1.0.1",
"next-redux-wrapper": "^1.3.2",
"next-routes": "^1.0.40",
"ramda": "^0.24.1",
"react": "^15.6.1",
"react-apollo": "^1.4.10",
"react-dom": "^15.6.1",
"raf": "^3.4.0",
"ramda": "^0.25.0",
"react": "^16.0.0",
"react-apollo": "^2.0.0",
"react-dom": "^16.0.0",
"react-redux": "^5.0.5",
"recompose": "^0.24.0",
"recompose": "^0.26.0",
"redux": "^3.7.2",
"redux-saga": "^0.15.6",
"styled-components": "^2.1.1"
"redux-saga": "^0.16.0",
"styled-components": "^2.2.2"
},
"devDependencies": {
"@types/node": "^8.0.17",
"babel-jest": "^20.0.3",
"babel-plugin-module-resolver": "^2.7.1",
"babel-plugin-styled-components": "^1.1.7",
"babel-jest": "^21.2.0",
"babel-plugin-module-resolver": "^3.0.0",
"babel-plugin-styled-components": "^1.2.1",
"babel-plugin-transform-es2015-modules-commonjs": "^6.24.1",
"concurrently": "^3.5.0",
"copy-webpack-plugin": "^4.0.1",
"enzyme": "^2.9.1",
"jest": "^20.0.4",
"jest-cli": "^20.0.4",
"enzyme": "^3.1.0",
"enzyme-adapter-react-16": "^1.0.2",
"jest": "^21.2.1",
"jest-cli": "^21.2.1",
"nodemon": "^1.11.0",
"react-test-renderer": "^15.6.1",
"react-test-renderer": "^16.0.0",
"redux-devtools-extension": "^2.13.2",
"rimraf": "^2.6.1",
"ts-jest": "^20.0.8",
"ts-jest": "^21.1.4",
"tslint": "^5.5.0",
"tslint-react": "^3.2.0",
"typescript": "^2.4.2"
"typescript": "^2.6.1"
}
}
7 changes: 6 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
"inlineSources": false,
"preserveConstEnums": true,
"moduleResolution": "node",
"strictNullChecks": true,

/*
This is requred to resolve https://github.com/apollographql/apollo-client/issues/2503
Will be removed after the issue is resolved
*/
"strictNullChecks": false,
"skipLibCheck": true,
"allowJs": false,
"experimentalDecorators": true,
Expand Down
Loading