Skip to content

Commit 15a860e

Browse files
committed
upgrade to v16.8.0+ react and v3.0.1+ react-scripts
1 parent e36e417 commit 15a860e

File tree

9 files changed

+2358
-2543
lines changed

9 files changed

+2358
-2543
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ Starting point for a Typescript, React (v16.8.0-alpha.0), Yarn & Lerna monorepo
77
This project is initialized with [Create React App](https://github.com/facebook/create-react-app) consisting of:
88

99
- TypeScript
10-
- React (v16.8.0-alpha.0)
11-
- react-scripts (react-scripts v2.1.3 from createReactApp)
10+
- React (v16.8.0)
11+
- react-scripts (react-scripts v3.0.1+ from createReactApp)
1212
- react-testing-library (not Enzyme)
1313
- Yarn Workspaces (multiple packages architecture)
1414
- Lerna (tool for managing the monorepo packages)
@@ -20,8 +20,8 @@ This project is initialized with [Create React App](https://github.com/facebook/
2020

2121
The project now consists of 3 packages.
2222

23-
- **www**: create-react-app with TypeScript (react v16.8.0-alpha.0, react-scripts v2.1.3)
24-
- **shared**: react components with TypeScript (react v16.8.0-alpha.0)
23+
- **www**: create-react-app with TypeScript (react v16.8.0, react-scripts v3.0.1+)
24+
- **shared**: react components with TypeScript (react v16.8.0)
2525
- **utils**: shared functions with TypeScript
2626

2727
## Get Started

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@
2121
"clean": "lerna clean"
2222
},
2323
"devDependencies": {
24-
"@types/jest": "23.3.12",
25-
"@types/node": "10.12.18",
26-
"@types/react": "^16.7.18",
27-
"@types/react-dom": "^16.0.11",
28-
"@typescript-eslint/eslint-plugin": "^2.30.0",
29-
"@typescript-eslint/parser": "^2.30.0",
30-
"eslint-config-prettier": "^6.7.0",
31-
"eslint-plugin-prettier": "^3.1.1",
32-
"eslint-plugin-simple-import-sort": "^5.0.0",
24+
"@types/jest": "^25.2.1",
25+
"@types/node": "^13.13.5",
26+
"@types/react": "^16.8.0",
27+
"@types/react-dom": "^16.8.0",
28+
"@typescript-eslint/eslint-plugin": "^2.31.0",
29+
"@typescript-eslint/parser": "^2.31.0",
30+
"eslint-config-prettier": "^6.11.0",
31+
"eslint-plugin-prettier": "^3.1.3",
32+
"eslint-plugin-simple-import-sort": "^5.0.3",
3333
"lerna": "^3.20.2",
34-
"node-sass": "^4.14.0",
34+
"node-sass": "^4.14.1",
3535
"prettier": "^2.0.5",
36-
"react": "^16.8.0-alpha.0",
37-
"react-dom": "^16.8.0-alpha.0",
38-
"react-scripts": "2.1.3",
36+
"react": "^16.8.0",
37+
"react-dom": "^16.8.0",
38+
"react-scripts": "3.0.1",
3939
"typescript": "~3.7.2"
4040
},
4141
"workspaces": {

packages/shared/package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@
1616
"lint:fix": "eslint --fix . --ignore-path ../../.eslintignore --ext ts --ext tsx --ext js --ext jsx"
1717
},
1818
"peerDependencies": {
19-
"@types/jest": ">=23.3.12",
20-
"@types/node": ">=10.12.18",
21-
"@types/react": ">=16.7.18",
22-
"@types/react-dom": ">=16.0.11",
23-
"@typescript-eslint/eslint-plugin": "^2.30.0",
24-
"@typescript-eslint/parser": "^2.30.0",
25-
"eslint-config-prettier": "^6.7.0",
26-
"eslint-plugin-prettier": "^3.1.1",
27-
"eslint-plugin-simple-import-sort": "^5.0.0",
28-
"react": ">=16.8.0-alpha.0",
29-
"react-dom": ">=16.8.0-alpha.0",
19+
"@types/jest": ">=24.0.0",
20+
"@types/node": ">=13.0.0",
21+
"@types/react": ">=16.8.0",
22+
"@types/react-dom": ">=16.8.0",
23+
"@typescript-eslint/eslint-plugin": "^2.31.0",
24+
"@typescript-eslint/parser": "^2.31.0",
25+
"eslint-config-prettier": "^6.11.0",
26+
"eslint-plugin-prettier": "^3.1.3",
27+
"eslint-plugin-simple-import-sort": "^5.0.3",
28+
"react": ">=16.8.0",
29+
"react-dom": ">=16.8.0",
3030
"typescript": ">=3.7.2"
3131
},
3232
"dependencies": {},
3333
"devDependencies": {}
34-
}
34+
}

packages/utils/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@
1616
"lint:fix": "eslint --fix . --ignore-path ../../.eslintignore --ext ts --ext tsx --ext js --ext jsx"
1717
},
1818
"peerDependencies": {
19-
"@types/node": ">=10.12.18",
20-
"@typescript-eslint/eslint-plugin": "^2.30.0",
21-
"@typescript-eslint/parser": "^2.30.0",
22-
"eslint-config-prettier": "^6.7.0",
23-
"eslint-plugin-prettier": "^3.1.1",
24-
"eslint-plugin-simple-import-sort": "^5.0.0",
19+
"@types/node": ">=13.0.0",
20+
"@typescript-eslint/eslint-plugin": "^2.31.0",
21+
"@typescript-eslint/parser": "^2.31.0",
22+
"eslint-config-prettier": "^6.11.0",
23+
"eslint-plugin-prettier": "^3.1.3",
24+
"eslint-plugin-simple-import-sort": "^5.0.3",
2525
"typescript": ">=3.7.2"
2626
},
2727
"dependencies": {},
2828
"devDependencies": {}
29-
}
29+
}

packages/www/package.json

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,36 @@
1616
"lint:fix": "eslint --fix . --ignore-path ../../.eslintignore --ext ts --ext tsx --ext js --ext jsx"
1717
},
1818
"peerDependencies": {
19-
"@types/jest": ">=23.3.12",
20-
"@types/node": ">=10.12.18",
21-
"@types/react": ">=16.7.18",
22-
"@types/react-dom": ">=16.0.11",
23-
"@typescript-eslint/eslint-plugin": "^2.30.0",
24-
"@typescript-eslint/parser": "^2.30.0",
25-
"eslint-config-prettier": "^6.7.0",
26-
"eslint-plugin-prettier": "^3.1.1",
27-
"eslint-plugin-simple-import-sort": "^5.0.0",
28-
"node-sass": ">=4.14.0",
29-
"react": ">=16.8.0-alpha.0",
30-
"react-dom": ">=16.8.0-alpha.0",
31-
"react-scripts": ">=2.1.3",
19+
"@types/jest": ">=24.0.0",
20+
"@types/node": ">=13.0.0",
21+
"@types/react": ">=16.8.0",
22+
"@types/react-dom": ">=16.8.0",
23+
"@typescript-eslint/eslint-plugin": "^2.31.0",
24+
"@typescript-eslint/parser": "^2.31.0",
25+
"eslint-config-prettier": "^6.11.0",
26+
"eslint-plugin-prettier": "^3.1.3",
27+
"eslint-plugin-simple-import-sort": "^5.0.3",
28+
"node-sass": ">=4.14.1",
29+
"react": ">=16.8.0",
30+
"react-dom": ">=16.8.0",
31+
"react-scripts": ">=3.0.1",
3232
"typescript": ">=3.7.2"
3333
},
3434
"dependencies": {},
3535
"devDependencies": {
3636
"@web/shared": "*",
3737
"@web/utils": "*"
3838
},
39-
"browserslist": [
40-
">0.2%",
41-
"not dead",
42-
"not ie <= 11",
43-
"not op_mini all"
44-
]
39+
"browserslist": {
40+
"production": [
41+
">0.2%",
42+
"not dead",
43+
"not op_mini all"
44+
],
45+
"development": [
46+
"last 1 chrome version",
47+
"last 1 firefox version",
48+
"last 1 safari version"
49+
]
50+
}
4551
}

packages/www/src/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import './App.scss';
22

33
import { Header } from '@web/shared';
44
import { logger } from '@web/utils';
5-
import React, { useEffect, useState } from 'react';
5+
import React, { useEffect } from 'react';
66

77
import logo from './logo.svg';
88

@@ -16,7 +16,7 @@ const App = () => {
1616
<header className="App-header">
1717
<img src={logo} className="App-logo" alt="logo" />
1818
<Header>
19-
React (v16.8.0-alpha.0), Typescript, Yarn & Lerna Monorepo
19+
React (v16.8.0), Typescript, Yarn & Lerna Monorepo
2020
</Header>
2121
<p>
2222
Starting point for a Typescript, React, Yarn & Lerna monorepo project

packages/www/src/react-app-env.d.ts

100755100644
File mode changed.

packages/www/src/serviceWorker.ts

100755100644
Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
// resources are updated in the background.
99

1010
// To learn more about the benefits of this model and instructions on how to
11-
// opt-in, read http://bit.ly/CRA-PWA
11+
// opt-in, read https://bit.ly/CRA-PWA
1212

1313
const isLocalhost = Boolean(
1414
window.location.hostname === 'localhost' ||
1515
// [::1] is the IPv6 localhost address.
1616
window.location.hostname === '[::1]' ||
17-
// 127.0.0.1/8 is considered localhost for IPv4.
17+
// 127.0.0.0/8 are considered localhost for IPv4.
1818
window.location.hostname.match(
1919
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
2020
)
@@ -29,7 +29,7 @@ export function register(config?: Config) {
2929
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
3030
// The URL constructor is available in all browsers that support SW.
3131
const publicUrl = new URL(
32-
(process as { env: { [key: string]: string } }).env.PUBLIC_URL,
32+
process.env.PUBLIC_URL,
3333
window.location.href
3434
);
3535
if (publicUrl.origin !== window.location.origin) {
@@ -51,7 +51,7 @@ export function register(config?: Config) {
5151
navigator.serviceWorker.ready.then(() => {
5252
console.log(
5353
'This web app is being served cache-first by a service ' +
54-
'worker. To learn more, visit http://bit.ly/CRA-PWA'
54+
'worker. To learn more, visit https://bit.ly/CRA-PWA'
5555
);
5656
});
5757
} else {
@@ -79,7 +79,7 @@ function registerValidSW(swUrl: string, config?: Config) {
7979
// content until all client tabs are closed.
8080
console.log(
8181
'New content is available and will be used when all ' +
82-
'tabs for this page are closed. See http://bit.ly/CRA-PWA.'
82+
'tabs for this page are closed. See https://bit.ly/CRA-PWA.'
8383
);
8484

8585
// Execute callback
@@ -108,7 +108,9 @@ function registerValidSW(swUrl: string, config?: Config) {
108108

109109
function checkValidServiceWorker(swUrl: string, config?: Config) {
110110
// Check if the service worker can be found. If it can't reload the page.
111-
fetch(swUrl)
111+
fetch(swUrl, {
112+
headers: { 'Service-Worker': 'script' }
113+
})
112114
.then(response => {
113115
// Ensure service worker exists, and that we really are getting a JS file.
114116
const contentType = response.headers.get('content-type');
@@ -136,8 +138,12 @@ function checkValidServiceWorker(swUrl: string, config?: Config) {
136138

137139
export function unregister() {
138140
if ('serviceWorker' in navigator) {
139-
navigator.serviceWorker.ready.then(registration => {
140-
registration.unregister();
141-
});
141+
navigator.serviceWorker.ready
142+
.then(registration => {
143+
registration.unregister();
144+
})
145+
.catch(error => {
146+
console.error(error.message);
147+
});
142148
}
143149
}

0 commit comments

Comments
 (0)