Skip to content

Commit 42b1ba0

Browse files
authored
Merge pull request #7 from itReverie/deployment
Improving deployment production by: - Separating vendor files - Minifying bundles - Building different configurations of Node for server and webpack with the help of Babel. - Running multiple instances of node per processor
2 parents 56591ac + 62637e9 commit 42b1ba0

File tree

9 files changed

+629
-811
lines changed

9 files changed

+629
-811
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ coverage
2424
.lock-wscript
2525

2626
# Compiled binary addons (http://nodejs.org/api/addons.html)
27-
build/Release
27+
build
2828

2929
# Dependency directories
3030
node_modules

lib/bundle.js

Whitespace-only changes.

lib/components/App.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,20 @@ class App extends React.PureComponent {
5555
//TODO: Leaving this purposely uncommented. Be aware that in production this has to be commented.
5656
//We need consistent measures that's why we need to add this lines so we messure the components at the same point
5757
//Those numbers need to be the same every time we refresh
58-
setImmediate(()=>{Perf.start();});
59-
setTimeout(()=>{ Perf.stop();
60-
Perf.printWasted();},5000);
58+
//setImmediate(()=>{Perf.start();});
59+
//setTimeout(()=>{ Perf.stop();
60+
//Perf.printWasted();},5000);
6161
}
6262

6363
componentWillUnmount() {
6464
this.props.store.unsubscribe(this.subscriptionId);
6565
}
6666

67-
componentWillUpdate(nextProps, nextState)
68-
{
69-
console.log('Updating TimeStamp');
70-
}
67+
//This life cylce method can help us to identify where can we improve our optimization
68+
// componentWillUpdate(nextProps, nextState)
69+
// {
70+
// console.log('Updating TimeStamp');
71+
// }
7172

7273
//In react we cannot return two elements unless
7374
//Option 1. is in an array so we need to pass a Key elements
Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,26 @@
11
import React from 'react';
2-
//import ArticleList from '../ArticleList';
3-
//import renderer from 'react-test-renderer';
42
import ArticleList from '../ArticleList';
5-
import { configure, shallow } from 'enzyme';
6-
import Adapter from 'enzyme-adapter-react-15';
7-
8-
configure({ adapter: new Adapter() });
9-
3+
import { shallow } from 'enzyme';
104

115
describe('ArticleList', () => {
126

13-
it('renders correctly', () => {
14-
15-
//with jest.fn we are mocking data
16-
const testProps={
17-
articles: { a:{id:'a'},
18-
b:{id:'b'}
19-
}
20-
};
7+
const testProps = {
8+
articles: {
9+
a: { id: 'a' },
10+
b: { id: 'b' },
11+
},
12+
};
2113

22-
//It will render the full tree
23-
const wrapper= shallow(<ArticleList {...testProps}/>);
24-
25-
console.log(wrapper.find('Article'));//.getElement().node.props.children
14+
it('renders correctly', () => {
15+
const wrapper = shallow(
16+
<ArticleList
17+
{...testProps}
18+
/>
19+
);
2620

27-
expect(wrapper.find('Article').length).toBe(2);
28-
expect(wrapper).toMatchSnapshot();
21+
expect(wrapper.find('ArticleContainer').length).toBe(2);
2922

23+
expect(wrapper).toMatchSnapshot();
3024
});
3125

32-
3326
});
Lines changed: 146 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,156 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

33
exports[`ArticleList renders correctly 1`] = `
4-
<div>
5-
<div
6-
style={
7-
Object {
8-
"borderBottomColor": "#aaa",
9-
"borderBottomStyle": "solid",
10-
"borderBottomWidth": 1,
11-
"marginBottom": 10,
12-
"paddingBottom": 10,
13-
}
14-
}
15-
>
16-
<div
17-
style={
18-
Object {
19-
"fontWeight": "bold",
4+
ShallowWrapper {
5+
"complexSelector": ComplexSelector {
6+
"buildPredicate": [Function],
7+
"childrenOfNode": [Function],
8+
"findWhereUnwrapped": [Function],
9+
},
10+
"length": 1,
11+
"node": <div>
12+
<ArticleContainer
13+
article={
14+
Object {
15+
"id": "a",
16+
}
2017
}
21-
}
2218
/>
23-
<div
24-
style={
25-
Object {
26-
"color": "#888",
27-
"fontSize": "0.85em",
28-
}
29-
}
30-
>
31-
Invalid Date
32-
</div>
33-
<div
34-
style={
35-
Object {
36-
"paddingBottom": 10,
37-
"paddingTop": 10,
19+
<ArticleContainer
20+
article={
21+
Object {
22+
"id": "b",
23+
}
3824
}
39-
}
40-
>
41-
<a
42-
href={undefined}
43-
>
44-
45-
</a>
46-
</div>
47-
<div
48-
style={
49-
Object {
50-
"paddingLeft": 20,
51-
}
52-
}
5325
/>
54-
</div>
55-
<div
56-
style={
57-
Object {
58-
"borderBottomColor": "#aaa",
59-
"borderBottomStyle": "solid",
60-
"borderBottomWidth": 1,
61-
"marginBottom": 10,
62-
"paddingBottom": 10,
63-
}
64-
}
65-
>
66-
<div
67-
style={
68-
Object {
69-
"fontWeight": "bold",
26+
</div>,
27+
"nodes": Array [
28+
<div>
29+
<ArticleContainer
30+
article={
31+
Object {
32+
"id": "a",
33+
}
34+
}
35+
/>
36+
<ArticleContainer
37+
article={
38+
Object {
39+
"id": "b",
40+
}
41+
}
42+
/>
43+
</div>,
44+
],
45+
"options": Object {},
46+
"renderer": ReactShallowRenderer {
47+
"_instance": ShallowComponentWrapper {
48+
"_calledComponentWillUnmount": false,
49+
"_compositeType": 1,
50+
"_context": Object {},
51+
"_currentElement": <ArticleList
52+
articles={
53+
Object {
54+
"a": Object {
55+
"id": "a",
56+
},
57+
"b": Object {
58+
"id": "b",
59+
},
60+
}
7061
}
71-
}
72-
/>
73-
<div
74-
style={
75-
Object {
76-
"color": "#888",
77-
"fontSize": "0.85em",
78-
}
79-
}
80-
>
81-
Invalid Date
82-
</div>
83-
<div
84-
style={
85-
Object {
86-
"paddingBottom": 10,
87-
"paddingTop": 10,
88-
}
89-
}
90-
>
91-
<a
92-
href={undefined}
93-
>
94-
95-
</a>
96-
</div>
97-
<div
98-
style={
62+
/>,
63+
"_debugID": 1,
64+
"_hostContainerInfo": null,
65+
"_hostParent": null,
66+
"_instance": ArticleList {
67+
"_reactInternalInstance": [Circular],
68+
"context": Object {},
69+
"props": Object {
70+
"articles": Object {
71+
"a": Object {
72+
"id": "a",
73+
},
74+
"b": Object {
75+
"id": "b",
76+
},
77+
},
78+
},
79+
"refs": Object {},
80+
"state": null,
81+
"updater": Object {
82+
"enqueueCallback": [Function],
83+
"enqueueCallbackInternal": [Function],
84+
"enqueueElementInternal": [Function],
85+
"enqueueForceUpdate": [Function],
86+
"enqueueReplaceState": [Function],
87+
"enqueueSetState": [Function],
88+
"isMounted": [Function],
89+
"validateCallback": [Function],
90+
},
91+
},
92+
"_mountOrder": 1,
93+
"_pendingCallbacks": null,
94+
"_pendingElement": null,
95+
"_pendingForceUpdate": false,
96+
"_pendingReplaceState": false,
97+
"_pendingStateQueue": null,
98+
"_renderedComponent": NoopInternalComponent {
99+
"_currentElement": <div>
100+
<ArticleContainer
101+
article={
102+
Object {
103+
"id": "a",
104+
}
105+
}
106+
/>
107+
<ArticleContainer
108+
article={
109+
Object {
110+
"id": "b",
111+
}
112+
}
113+
/>
114+
</div>,
115+
"_debugID": 2,
116+
"_renderedOutput": <div>
117+
<ArticleContainer
118+
article={
119+
Object {
120+
"id": "a",
121+
}
122+
}
123+
/>
124+
<ArticleContainer
125+
article={
126+
Object {
127+
"id": "b",
128+
}
129+
}
130+
/>
131+
</div>,
132+
},
133+
"_renderedNodeType": 0,
134+
"_rootNodeID": 0,
135+
"_topLevelWrapper": null,
136+
"_updateBatchNumber": null,
137+
"_warnedAboutRefsInRender": false,
138+
},
139+
"getRenderOutput": [Function],
140+
"render": [Function],
141+
},
142+
"root": [Circular],
143+
"unrendered": <ArticleList
144+
articles={
99145
Object {
100-
"paddingLeft": 20,
101-
}
102-
}
103-
/>
104-
</div>
105-
</div>
146+
"a": Object {
147+
"id": "a",
148+
},
149+
"b": Object {
150+
"id": "b",
151+
},
152+
}
153+
}
154+
/>,
155+
}
106156
`;

0 commit comments

Comments
 (0)