-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
🪟 🔧 Migrate from react-scripts to Vite #21421
Conversation
<ReactQueryDevtools | ||
initialIsOpen={false} | ||
position="bottom-right" | ||
toggleButtonProps={{ style: { transform: "translateX(-75px)" } }} |
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.
ℹ️ Running on HTTPS we'll now also get the intercom banner in development, so I moved the react query devtool widget over to not overlap it.
@@ -1,3 +1,5 @@ | |||
/// <reference types="@types/segment-analytics" /> |
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.
ℹ️ Without types
in the tsconfig.json
(which was the case beforehand) all @types/...
packages get automatically imported. That's not the case anymore now, so we'll reference the only missing one in this file explicitally.
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.
Any reason to use triple-slash syntax over adding "@types/segment-analytics"
to tsconfig.json
? Seems like tsconfig.json
might be a more centralized place to introduce 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.
My main reason was just, that this way it's closer to "where it's used", i.e. if we were to remove Segment I feel it's clearer that we include the reference here. Technically it should work the same if we add it to the tsconfig.json
. I don't have strong opinions either way though, so happy to have you make the call on this.
@@ -106,16 +106,8 @@ task copyNginx(type: Copy) { | |||
into "build/docker/bin/nginx" | |||
} | |||
|
|||
task stylelint(type: NpmTask) { |
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 now runs as part of the Vite (via the checker plugin). So it doesn't need a separate Gradle task anymore.
"meow": "^9.0.0", | ||
"node-fetch": "^2.6.7", | ||
"optionator": "^0.9.1", |
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.
ℹ️ Peer dependencies required by the styellint and eslint plugin for vite checker.
"orval": "^6.11.0-alpha.10", | ||
"prettier": "^2.6.2", | ||
"react-scripts": "^5.0.1", |
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.
👋 bye, bye, you will for sure not be missed.
Successfull failure on eslint warning: https://github.com/airbytehq/airbyte/actions/runs/3939246270/jobs/6738917898 |
Currently blocked on #20887 . End to end tests are failing due to change in class names, which should be solved by that PR (and not requiring classNames for testing). |
Unblocked - just merged #20887 🎉 |
I'm probably doing something wrong, but if that's the case it's easy to run into it. This is what I did:
|
Thanks for catching this. This is actually a valid thing I need to fix. Currently we set |
CORS issue is fixed in #21668, merged that in locally while I'm testing and request from |
@flash1293 This should be solved now. You'll need to rebuild the server though ( |
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 good to me! I tested locally in dev mode on https://localhost:3000
and everything worked smoothly. Same with a fresh build served via docker on http://localhost:8000
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.
LGTM; tested and seems to work fine.
I have one complaint, but I'm pretty sure that happened before, so no need to fix it on this PR: When defining a class in the scss module which is never referenced, it shows the expected error:
ERROR(ESLint) Unused classes found in BuilderField.module.scss: errorXXX, abc (css-modules/no-unused-class)
FILE /Users/joereuter/Clones/airbyte/airbyte-webapp/src/components/connectorBuilder/Builder/StreamReferenceField.tsx:10:8
8 |
9 | import { BuilderStream } from "../types";
> 10 | import styles from "./BuilderField.module.scss";
However, when fixing the problem, this error doesn't go away - it sticks around until I restart the dev server.
This is more related to eslint and indeed currently present. You should though not need to actually kill the dev server, but you'll need to save the TS file that includes that SASS again. Since this rule is part of ESLint, it won't rerun if something in the SASS file changes, only when the TS file actually has a change. |
The only check that failed, was tearing down the CI runner in the end, so treating this CI run as successful for merging. |
What
Removed react-scripts (Create React App) as a build system and instead use Vite.
Why?
Because it's ⚡ faster, ⚙️ more configurable and way better 👷 maintained.
How
I've tried to document most files inline to give context why changes have happened. Some general remarks:
🔐 HTTPS required
Since Vite loads modules as individual files during development, we want to make sure to use HTTP2 to not run into parallel file loading limits of HTTP1. Thus HTTPS is required now also during development, i.e. the development page will now be available via
https://localhost:3000
orhttps://127.0.0.1:3000
. Since this will use self-signed certificates you need to ignore an "unsecure" warning in your browser. Due to the way Vite does caching it's also not necessary to disable HTTP caching during development and will be faster if this setting is off in your Dev Tools.No code changes and further work
There has been no code change on actual source code for this. The only difference would be that Vite used
import.meta.env
instead ofprocess.env
. Since we still run tests via babel and Storybook via Webpack, I made sureprocess.env
continues to work. That allows us to migrate Storybook and Jest in separate PRs, since both of them are quiet a bit of work to convert (and for Storybook we likely want to wait for the 7.0 release).🔍 Code quality scans
Stylelint, ESLint and TypeScript runs in Vite (via the checker plugin) async in different workers. That means you might see warnings/errors coming from those in the UI with a bit of a delay, because the actual code already is delivered immediately, while the checks are still running. The new error overlay also doesn't pop up by default, but can be opened via a button on the bottom (Errors will still be printed to the terminal as well):
Testing
I've validated that ESLint (warnings as well as errors), Stylelint and TypeScript will fail the build with a non zero status code, to make sure they won't pass CI. Also tested Cloud mode and local development working, as well as OSS mode building proper docker images.