-
Notifications
You must be signed in to change notification settings - Fork 1
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
Upgrade to react-scripts 5 #249
Conversation
Still working on verifying that everything still works… Please let me know if you have suggestions of things to test. |
package.json
Outdated
@@ -3,43 +3,41 @@ | |||
"version": "0.1.0", | |||
"private": true, | |||
"dependencies": { | |||
"@types/node": "^16.11.11", | |||
"@types/react": "^17.0.37", | |||
"@types/node": "^17.0.8", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, I think this might need to track the current version of Node (16). I think the index.d.ts
for @types/node
should specify the Nodejs version.
package.json
Outdated
"serve": "^13.0.2", | ||
"typescript": "^4.5.4" | ||
"typescript": "^4.5.4", | ||
"web-vitals": "^2.1.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗒️ this is a new package, create-react-app adds it (and the required boilerplate) by default. With it you can report metrics like "first input delay", "time to first byte", etc from real users. I would use it on my next project, so I left it in. But maybe this warrants a separate PR? More info here: GooggleChrome/web-vitals
f59927a
to
eb310cf
Compare
}, | ||
"resolutions": { | ||
"@typescript-eslint/typescript-estree": "^5.6.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗒️ I dropped this resolution @typescript-eslint/typescript-estree
because I wasn't sure why it was in there, and getting rid of it didn't seem to have an effect.
}, | ||
"resolutions": { | ||
"@typescript-eslint/typescript-estree": "^5.6.0", | ||
"caniuse-lite": "^1.0.30001272" | ||
"caniuse-lite": "^1.0.30001299", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗒️ Updated the caniuse-lite def to match what was installed from scratch
"@typescript-eslint/typescript-estree": "^5.6.0", | ||
"caniuse-lite": "^1.0.30001272" | ||
"caniuse-lite": "^1.0.30001299", | ||
"mini-css-extract-plugin": "2.4.7" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦 This is a temporary workaround for this issue: facebook/create-react-app#11930
public/index.html
Outdated
<meta | ||
name="description" | ||
content="Web site created using create-react-app" | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❔ Should we remove this? Leave it in? change it to
<meta | |
name="description" | |
content="Web site created using create-react-app" | |
/> | |
<meta | |
name="description" | |
content="Web site created using spraygun" | |
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should take it out. It would be weird for that to go into production accidentally, and then you find out when someone shares your app on social and that description pop up 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -0,0 +1,3 @@ | |||
# https://www.robotstxt.org/robotstxt.html |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Not sure if this was intentionally omitted before, but it was generated by create-react-app
@@ -34,7 +34,7 @@ | |||
color: colors.$blue; | |||
} | |||
|
|||
@keyframes App-logo-spin { | |||
@keyframes app-logo-spin { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗒️ New stylelint
rule wants keyframes to be lower-kebab-case.
src/index.scss
Outdated
@@ -1,6 +1,5 @@ | |||
// index.scss is for CSS declarations that aren't specific to a component. | |||
// In practice, that means this file is used for two things: | |||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❔ New stylelint
rule doesn't want blank comments like this, I sorta disagree, but followed the rule to keep things as vanilla as possible. Should we disable this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, this rule seems a bit much. I vote to disable the rule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ disabled!
|
||
// If you want to start measuring performance in your app, pass a function | ||
// to log results (for example: reportWebVitals(console.log)) | ||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals | ||
reportWebVitals(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗒️ Here's the boilerplate for web-vitals. More info on the linked page.
@@ -0,0 +1,15 @@ | |||
import { ReportHandler } from "web-vitals"; | |||
|
|||
const reportWebVitals = (onPerfEntry?: ReportHandler) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤣 Would be funny if this code affected these metrics.
@@ -2,4 +2,4 @@ | |||
// allows you to do things like: | |||
// expect(element).toHaveTextContent(/react/i) | |||
// learn more: https://github.com/testing-library/jest-dom | |||
import "@testing-library/jest-dom/extend-expect"; | |||
import "@testing-library/jest-dom"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗒️ CRA generates this file with the shorter import (which matches the docs)
@use "sass:color"; | ||
$blue: #61dafb; | ||
$blue-darker: darken($blue, 30%); | ||
$blue-lighter: lighten($blue, 5%); | ||
$blue-darker: color.adjust($blue, $lightness: -30%); | ||
$blue-lighter: color.adjust($blue, $lightness: 5%); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗒️ stylelint
doesn't want you to use darken
/lighten
any more.
@@ -23,6 +23,7 @@ module.exports = { | |||
}, | |||
extends: [ | |||
"react-app", | |||
"react-app/jest", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗒️ CRA includes this extend now. I wonder if that includes plugin:jest/recommended
, which makes the below extend a dupe.
Was having problems maintaining the dependencies/devDependencies split, facebook/create-react-app#11956, merging dependencies into one group (as is the default w/ CRA) for now. |
@dylnclrk You can use the
|
Oh, sorry, I should have updated those instructions to get rid of that question. But yes, I tested it and even deployed the generated app to Heroku on Tuesday and everything seemed to work as expected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks for testing the Heroku deploy as well.
I tested locally with npx spraygun -p ...
and it worked great.
I noticed a deprecation warning when starting the dev server, but that seems to be a known CRA issue: facebook/create-react-app#11860. So I don't think that should block this PR.
🚀
src/index.scss
Outdated
@@ -1,6 +1,5 @@ | |||
// index.scss is for CSS declarations that aren't specific to a component. | |||
// In practice, that means this file is used for two things: | |||
// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, this rule seems a bit much. I vote to disable the rule.
I upgraded a couple dependencies to match |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💥
Problem
The CRA team released react-scripts 5.0.0 recently. Depfu opened #242 to address this, however, react-scripts is responsible for generating many of the files in this repo, so PR does the upgrade manually to capture those changes.
Solution
Create a new project using react-scrips 5.0.0, audit the differences in the generated files from those currently on
main
(which were generated by an older version of react-scripts). Copy over those changes and try to get rid of some of the cruft in this template (there wasn't much).Change summary
app-prototype
TODO
$ docker build . -t spraygun-react-ts:latest
, see comment)Things to manually verify:
yarn lint
yarn build
,serve
yarn test
yarn start
eslint
works as expected)docker build . -t spraygun-react-ts:latest && docker run -p 3000:3000 spraygun-react-ts:latest
)Steps to Verify
-p path/to/this/template
flag)yarn test
,lint
,start
,build
,yarn serve -s build
etc.)New Dependencies
Additions:
🙈 See the package.json diff for all of the upgraded dependencies.
Screenshots
Appears to work locally: