Skip to content

Commit ea577e2

Browse files
committed
build(lib): improve the build process
BREAKING CHANGE: removed the alternative es5 builds
1 parent 94510d8 commit ea577e2

File tree

88 files changed

+99831
-15792
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+99831
-15792
lines changed

.prettierignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
11
README.md
2+
CONTRIBUTING.md
3+
package-lock.json
4+
node_modules
5+
dist
6+
build
7+
coverage
8+
.vscode
9+
.github
10+
.git
11+
.circleci
12+

README.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
* [Articles :loudspeaker:](#articles-loudspeaker)
3737
* [Performance :rocket:](#performance-rocket)
3838
* [Platform support :computer:](#platform-support-computer)
39-
* [Alternative builds :wrench:](#alternative-builds-wrench)
4039
* [Contributors :sparkles:](#contributors-sparkles)
4140

4241
<!-- tocstop -->
@@ -844,17 +843,6 @@ You can compare Easy State with plain React and other state management libraries
844843

845844
_This library is based on non polyfillable ES6 Proxies. Because of this, it will never support IE._
846845

847-
## Alternative builds :wrench:
848-
849-
This library detects if you use ES6 or commonJS modules and serve the right format to you. The default bundles use ES6 features, which may not yet be supported by some minifier tools. If you experience issues during the build process, you can switch to one of the ES5 builds from below.
850-
851-
- `@risingstack/react-easy-state/dist/es.es6.js` exposes an ES6 build with ES6 modules.
852-
- `@risingstack/react-easy-state/dist/es.es5.js` exposes an ES5 build with ES6 modules.
853-
- `@risingstack/react-easy-state/dist/cjs.es6.js` exposes an ES6 build with commonJS modules.
854-
- `@risingstack/react-easy-state/dist/cjs.es5.js` exposes an ES5 build with commonJS modules.
855-
856-
If you use a bundler, set up an alias for `@risingstack/react-easy-state` to point to your desired build. You can learn how to do it with webpack [here](https://webpack.js.org/configuration/resolve/#resolve-alias) and with rollup [here](https://github.com/rollup/rollup-plugin-alias#usage).
857-
858846
## Contributors :sparkles:
859847

860848
Contributions are always welcome, please read our [contributing documentation](CONTRIBUTING.md).

__tests__/batching.test.jsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ describe('batching', () => {
272272
expect(renderCount).toBe(1);
273273
expect(container).toHaveTextContent('Bob');
274274
await new Promise(
275-
resolve =>
275+
(resolve) =>
276276
setTimeout(() => {
277277
person.name = 'Ann';
278278
person.name = 'Rick';
@@ -295,7 +295,7 @@ describe('batching', () => {
295295
const { container } = render(<MyComp />);
296296
expect(renderCount).toBe(1);
297297
expect(container).toHaveTextContent('Bob');
298-
await new Promise(resolve =>
298+
await new Promise((resolve) =>
299299
// eslint-disable-next-line
300300
requestAnimationFrame(() => {
301301
person.name = 'Ann';
@@ -418,18 +418,18 @@ describe('batching', () => {
418418

419419
test('should not break Promises', async () => {
420420
await Promise.resolve(12)
421-
.then(value => {
421+
.then((value) => {
422422
expect(value).toBe(12);
423423
// eslint-disable-next-line
424424
throw 15;
425425
})
426-
.catch(err => {
426+
.catch((err) => {
427427
expect(err).toBe(15);
428428
});
429429
});
430430

431431
test('should not break setTimeout', async () => {
432-
await new Promise(resolve => {
432+
await new Promise((resolve) => {
433433
setTimeout(
434434
(arg1, arg2, arg3) => {
435435
expect(arg1).toBe('Hello');
@@ -459,10 +459,10 @@ describe('batching', () => {
459459
expect(callCount).toBe(1);
460460
});
461461

462-
test('should not break method this value and args', done => {
462+
test('should not break method this value and args', (done) => {
463463
const socket = new WebSocket('ws://www.example.com');
464464

465-
socket.onclose = function(ev) {
465+
socket.onclose = function (ev) {
466466
expect(ev).toBeDefined();
467467
expect(this).toBe(socket);
468468
done();
@@ -471,11 +471,11 @@ describe('batching', () => {
471471
socket.close();
472472
});
473473

474-
test('should not break callback this value and args', done => {
474+
test('should not break callback this value and args', (done) => {
475475
const ctx = {};
476476

477477
setTimeout(
478-
function(arg1, arg2) {
478+
function (arg1, arg2) {
479479
expect(arg1).toBe('Test');
480480
expect(arg2).toBe('Test2');
481481
expect(this).toBe(ctx);

__tests__/edgeCases.test.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('edge cases', () => {
5757
state = { counter: 0 };
5858

5959
handleIncrement = () => {
60-
this.setState(prevState => ({
60+
this.setState((prevState) => ({
6161
counter: prevState.counter + 1,
6262
}));
6363
};
@@ -84,7 +84,7 @@ describe('edge cases', () => {
8484
state = { counter: 0 };
8585

8686
handleIncrement = () => {
87-
this.setState(prevState => ({
87+
this.setState((prevState) => ({
8888
counter: prevState.counter + 1,
8989
}));
9090
};

__tests__/staticProps.test.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('static props', () => {
2626
});
2727

2828
test('view() should proxy defaultProps for functional components', () => {
29-
const MyCustomCompName = props => {
29+
const MyCustomCompName = (props) => {
3030
return <div>{props.name}</div>;
3131
};
3232

@@ -54,7 +54,7 @@ describe('static props', () => {
5454

5555
const errorSpy = jest
5656
.spyOn(console, 'error')
57-
.mockImplementation(message =>
57+
.mockImplementation((message) =>
5858
expect(message.indexOf('Failed prop type')).not.toBe(-1),
5959
);
6060
render(<ViewComp number="Bob" />);
@@ -63,7 +63,7 @@ describe('static props', () => {
6363
});
6464

6565
test('view() should proxy propTypes for functional components', () => {
66-
const MyCustomCompName = props => {
66+
const MyCustomCompName = (props) => {
6767
return <div>{props.number}</div>;
6868
};
6969

@@ -75,7 +75,7 @@ describe('static props', () => {
7575

7676
const errorSpy = jest
7777
.spyOn(console, 'error')
78-
.mockImplementation(message =>
78+
.mockImplementation((message) =>
7979
expect(message.indexOf('Failed prop type')).not.toBe(-1),
8080
);
8181
render(<ViewComp number="Bob" />);

babel.config.js

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,14 @@
11
const development = {
2-
plugins: [
3-
'@babel/plugin-proposal-export-default-from',
4-
'@babel/plugin-proposal-class-properties',
5-
'@babel/plugin-proposal-object-rest-spread',
6-
],
2+
// the library itself has no jsx code inside it
3+
// so it does not need preset-react
4+
presets: ['@babel/preset-env'],
75
};
6+
87
const test = {
9-
presets: ['@babel/preset-react'],
10-
plugins: [
11-
'@babel/plugin-proposal-export-default-from',
12-
'@babel/plugin-proposal-class-properties',
13-
'@babel/plugin-transform-async-to-generator',
14-
'@babel/plugin-transform-modules-commonjs',
15-
'@babel/plugin-proposal-object-rest-spread',
16-
],
8+
// the tests include jsx code and require preset-react
9+
presets: ['@babel/preset-react', '@babel/preset-env'],
1710
};
1811

19-
const bundle = process.env.BUNDLE;
20-
if (bundle && bundle.indexOf('es5') !== -1) {
21-
test.presets.push('@babel/preset-env');
22-
}
23-
2412
module.exports = {
2513
env: { development, test },
2614
};

examples/beer-finder/build/asset-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
"static/css/main.150d374a.chunk.css",
2020
"static/js/main.1d6354db.chunk.js"
2121
]
22-
}
22+
}

examples/beer-finder/build/index.html

Lines changed: 134 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,134 @@
1-
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><link rel="manifest" href="/react-easy-state/examples/beer-finder/build/manifest.json"><link rel="shortcut icon" href="/react-easy-state/examples/beer-finder/build/favicon.ico"><title>React App</title><link href="/react-easy-state/examples/beer-finder/build/static/css/main.150d374a.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,i,l=r[0],a=r[1],f=r[2],c=0,s=[];c<l.length;c++)i=l[c],Object.prototype.hasOwnProperty.call(o,i)&&o[i]&&s.push(o[i][0]),o[i]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(p&&p(r);s.length;)s.shift()();return u.push.apply(u,f||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,l=1;l<t.length;l++){var a=t[l];0!==o[a]&&(n=!1)}n&&(u.splice(r--,1),e=i(i.s=t[0]))}return e}var n={},o={1:0},u=[];function i(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,i),t.l=!0,t.exports}i.m=e,i.c=n,i.d=function(e,r,t){i.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,r){if(1&r&&(e=i(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(i.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)i.d(t,n,function(r){return e[r]}.bind(null,n));return t},i.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(r,"a",r),r},i.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},i.p="/react-easy-state/examples/beer-finder/build/";var l=this["webpackJsonpbeer-finder"]=this["webpackJsonpbeer-finder"]||[],a=l.push.bind(l);l.push=r,l=l.slice();for(var f=0;f<l.length;f++)r(l[f]);var p=a;t()}([])</script><script src="/react-easy-state/examples/beer-finder/build/static/js/2.1dd53533.chunk.js"></script><script src="/react-easy-state/examples/beer-finder/build/static/js/main.1d6354db.chunk.js"></script></body></html>
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta
6+
name="viewport"
7+
content="width=device-width,initial-scale=1,shrink-to-fit=no"
8+
/>
9+
<meta name="theme-color" content="#000000" />
10+
<link
11+
rel="manifest"
12+
href="/react-easy-state/examples/beer-finder/build/manifest.json"
13+
/>
14+
<link
15+
rel="shortcut icon"
16+
href="/react-easy-state/examples/beer-finder/build/favicon.ico"
17+
/>
18+
<title>React App</title>
19+
<link
20+
href="/react-easy-state/examples/beer-finder/build/static/css/main.150d374a.chunk.css"
21+
rel="stylesheet"
22+
/>
23+
</head>
24+
<body>
25+
<noscript
26+
>You need to enable JavaScript to run this app.</noscript
27+
>
28+
<div id="root"></div>
29+
<script>
30+
!(function (e) {
31+
function r(r) {
32+
for (
33+
var n, i, l = r[0], a = r[1], f = r[2], c = 0, s = [];
34+
c < l.length;
35+
c++
36+
)
37+
(i = l[c]),
38+
Object.prototype.hasOwnProperty.call(o, i) &&
39+
o[i] &&
40+
s.push(o[i][0]),
41+
(o[i] = 0);
42+
for (n in a)
43+
Object.prototype.hasOwnProperty.call(a, n) &&
44+
(e[n] = a[n]);
45+
for (p && p(r); s.length; ) s.shift()();
46+
return u.push.apply(u, f || []), t();
47+
}
48+
function t() {
49+
for (var e, r = 0; r < u.length; r++) {
50+
for (var t = u[r], n = !0, l = 1; l < t.length; l++) {
51+
var a = t[l];
52+
0 !== o[a] && (n = !1);
53+
}
54+
n && (u.splice(r--, 1), (e = i((i.s = t[0]))));
55+
}
56+
return e;
57+
}
58+
var n = {},
59+
o = { 1: 0 },
60+
u = [];
61+
function i(r) {
62+
if (n[r]) return n[r].exports;
63+
var t = (n[r] = { i: r, l: !1, exports: {} });
64+
return (
65+
e[r].call(t.exports, t, t.exports, i),
66+
(t.l = !0),
67+
t.exports
68+
);
69+
}
70+
(i.m = e),
71+
(i.c = n),
72+
(i.d = function (e, r, t) {
73+
i.o(e, r) ||
74+
Object.defineProperty(e, r, { enumerable: !0, get: t });
75+
}),
76+
(i.r = function (e) {
77+
'undefined' != typeof Symbol &&
78+
Symbol.toStringTag &&
79+
Object.defineProperty(e, Symbol.toStringTag, {
80+
value: 'Module',
81+
}),
82+
Object.defineProperty(e, '__esModule', { value: !0 });
83+
}),
84+
(i.t = function (e, r) {
85+
if ((1 & r && (e = i(e)), 8 & r)) return e;
86+
if (4 & r && 'object' == typeof e && e && e.__esModule)
87+
return e;
88+
var t = Object.create(null);
89+
if (
90+
(i.r(t),
91+
Object.defineProperty(t, 'default', {
92+
enumerable: !0,
93+
value: e,
94+
}),
95+
2 & r && 'string' != typeof e)
96+
)
97+
for (var n in e)
98+
i.d(
99+
t,
100+
n,
101+
function (r) {
102+
return e[r];
103+
}.bind(null, n),
104+
);
105+
return t;
106+
}),
107+
(i.n = function (e) {
108+
var r =
109+
e && e.__esModule
110+
? function () {
111+
return e.default;
112+
}
113+
: function () {
114+
return e;
115+
};
116+
return i.d(r, 'a', r), r;
117+
}),
118+
(i.o = function (e, r) {
119+
return Object.prototype.hasOwnProperty.call(e, r);
120+
}),
121+
(i.p = '/react-easy-state/examples/beer-finder/build/');
122+
var l = (this['webpackJsonpbeer-finder'] =
123+
this['webpackJsonpbeer-finder'] || []),
124+
a = l.push.bind(l);
125+
(l.push = r), (l = l.slice());
126+
for (var f = 0; f < l.length; f++) r(l[f]);
127+
var p = a;
128+
t();
129+
})([]);
130+
</script>
131+
<script src="/react-easy-state/examples/beer-finder/build/static/js/2.1dd53533.chunk.js"></script>
132+
<script src="/react-easy-state/examples/beer-finder/build/static/js/main.1d6354db.chunk.js"></script>
133+
</body>
134+
</html>
Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
11
self.__precacheManifest = (self.__precacheManifest || []).concat([
22
{
3-
"revision": "00784bd91d5b8e277e5dfb166760dd39",
4-
"url": "/react-easy-state/examples/beer-finder/build/index.html"
3+
revision: '00784bd91d5b8e277e5dfb166760dd39',
4+
url: '/react-easy-state/examples/beer-finder/build/index.html',
55
},
66
{
7-
"revision": "d9941695e22b868af942",
8-
"url": "/react-easy-state/examples/beer-finder/build/static/css/main.150d374a.chunk.css"
7+
revision: 'd9941695e22b868af942',
8+
url:
9+
'/react-easy-state/examples/beer-finder/build/static/css/main.150d374a.chunk.css',
910
},
1011
{
11-
"revision": "e3d522a2ec82f007c3a8",
12-
"url": "/react-easy-state/examples/beer-finder/build/static/js/2.1dd53533.chunk.js"
12+
revision: 'e3d522a2ec82f007c3a8',
13+
url:
14+
'/react-easy-state/examples/beer-finder/build/static/js/2.1dd53533.chunk.js',
1315
},
1416
{
15-
"revision": "5e9b6f5c16b720e8a86875f97734673e",
16-
"url": "/react-easy-state/examples/beer-finder/build/static/js/2.1dd53533.chunk.js.LICENSE.txt"
17+
revision: '5e9b6f5c16b720e8a86875f97734673e',
18+
url:
19+
'/react-easy-state/examples/beer-finder/build/static/js/2.1dd53533.chunk.js.LICENSE.txt',
1720
},
1821
{
19-
"revision": "d9941695e22b868af942",
20-
"url": "/react-easy-state/examples/beer-finder/build/static/js/main.1d6354db.chunk.js"
22+
revision: 'd9941695e22b868af942',
23+
url:
24+
'/react-easy-state/examples/beer-finder/build/static/js/main.1d6354db.chunk.js',
2125
},
2226
{
23-
"revision": "a82e0e9f7581a49002d1",
24-
"url": "/react-easy-state/examples/beer-finder/build/static/js/runtime-main.5a628cab.js"
25-
}
26-
]);
27+
revision: 'a82e0e9f7581a49002d1',
28+
url:
29+
'/react-easy-state/examples/beer-finder/build/static/js/runtime-main.5a628cab.js',
30+
},
31+
]);

0 commit comments

Comments
 (0)