-
Notifications
You must be signed in to change notification settings - Fork 3.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
lens: migrates from react-scripts to vite #3506
Conversation
Sure. Vite is the intended way to run a modern react application. React scripts from Facebook is very bloated and contains more than 1000 packages in the standard configuration. It doesn't support lazy loading resources and takes forever to start in dev mode. Vite solves this issue with a modern API and a nearly instant start. I just finished implementing language changing. You can start the project by starting the jar which runs at port 9411 and then start the dev mode of the frontend with |
I am nearly done. The only failing test is UIConfig.test.jsx. What should the base url of the UIConfig.test.js file be? |
Feel free to review this pr. |
Could somebody please approve running workflows? I'd like to check if the pipeline is working. @jcchavezs @tacigar |
Hopefully this is the last round of workflows. Could you please trigger them again? @jcchavezs @tacigar |
The relevant checks are working. I have no clue why the mysql build should fail when I only change the UI or why the IT test takes so long @jcchavezs @tacigar ? |
Any chance to get this merged with higher priority @jcchavezs @tacigar ? |
Please rebase |
Done. |
Is the pull request so far okay or are there changes necessary? |
zipkin-lens/.env.production
Outdated
@@ -0,0 +1,2 @@ | |||
VITE_UI_URL=/zipkin |
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 don't think it is a good idea to check in env specific files.
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 actually sets the ui url for the frontend. I'm not sure what you mean with "check in env specific files".
Do you mind checking @tacigar ? Pinging @wu-sheng as @skywalking also uses lens. |
Any update @jcchavezs ? |
@SamTV12345 would this sort out the dead react-scripts problem? It seems like it would. If so, would you be inclined to rebase? #3713 |
@codefromthecrypt I rebased the master branch. |
Seems like eslint is not configured yet correctly. |
Thanks @SamTV12345, can you run |
I ran the command. |
If you'd like to you can start testing and reviewing the commit. |
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.
Thanks for the progress! I made some notes as I think we want to keep variable names the same, so that there is less change to developers. Also I think you may need to run npm run lint
to fix that, possibly you'll have to run the ./mvnw com.mycila:license-maven-plugin:format
after
In general, to know what the PR will pass or fail, run ./mvnw clean install -pl ./zipkin/zipkin-lens
.. this may save you time from testing with github
zipkin-lens/.env.test
Outdated
@@ -0,0 +1,2 @@ | |||
VITE_UI_URL=http://localhost:51204/zipkin |
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.
So, in our README, we have instructions to set API_BASE env when building, and this is used for npm start
to use a different base path for the target. I wonder if this is what you are doing here? If so, maybe rename the variable to API_BASE? If this can take from the env variable, then maybe we don't need these files, and things work the same?
"react-redux": "^7.1.0", | ||
"react-router-dom": "^5.0.1", | ||
"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.
glad this is gone ;)
@@ -116,7 +116,7 @@ | |||
<goal>npm</goal> | |||
</goals> | |||
<configuration> | |||
<arguments>install</arguments> | |||
<arguments>install --legacy-peer-deps</arguments> |
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.
need a comment above why
@@ -262,7 +262,7 @@ | |||
<configuration> | |||
<executable>npm</executable> | |||
<arguments> | |||
<argument>install</argument> | |||
<argument>install --legacy-peer-deps</argument> |
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.
same here
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.
npm introduced this in Version 7 to restore compability with the program. To cite stackoverflow:
Due to the large number of modules that haven't specifically added React v17 (or more recently, React 18) as a peerDependency, it's now commonplace to encounter the unable to resolve dependency tree error when running npm installs within a v17 React application.
So it is pretty much required to use this flag. It does not break installations. It just makes sure that installation goes as smooth as possible. We could switch to pnpm which is more modern than npm. But I wouldn't introduce this in this pr.
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.
so maybe make an XML comment similarly? I'm not contesting it, just why should stay in the source tree.
e.g.
<!-- A large number of modules haven't specifically added React as a peerDependency.
This flag is a norm and keeps the installation smooth.
See https://the/so/link -->
|
||
render( | ||
<LookbackMenu close={close} onChange={onChange} lookback={lookback} />, | ||
); | ||
|
||
// Click outside of the component. | ||
fireEvent.click(document); | ||
|
||
// TODO: Should comment out this line. |
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'm ok removing this note as it doesn't explain why it should be uncommented.. and possibly it isn't valid anymore anyway. confusing comments are worse than none
zipkin-lens/src/index.css
Outdated
@@ -11,5 +11,4 @@ | |||
* or implied. See the License for the specific language governing permissions and limitations under | |||
* the License. | |||
*/ | |||
|
|||
@import '~vizceral-react/dist/vizceral.css'; | |||
/*@import '~vizceral-react/dist/vizceral.css';*/ |
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.
why is this commented out?
* the License. | ||
*/ | ||
|
||
import { getLocale, setLocale } from './locale'; |
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 make something like this for i18s.test.ts?
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.
Could be beneficial to do.
zipkin-lens/vite.config.ts
Outdated
|
||
/* eslint-disable global-require */ | ||
|
||
describe('BASE_PATH', () => { |
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.
so we used to have instructions for setting BASE_PATH.. I think it is now VITE_API_URL? Is it possible to restore BASE_PATH as this feature was requested by users and better to keep name and instructions the same if possible
<meta charset="utf-8" /> | ||
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" /> |
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 guess you are removing this because there is nothing in vite like PUBLIC_URL in react-scripts?
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.
Yes exactly. The base path for vite needs to be set in the vite config ts. Then all paths are prepended with the correct url.
component={DependenciesPage} | ||
/> | ||
)} | ||
<BrowserRouter basename={import.meta.env.VITE_UI_URL}> |
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.
lets keep the variable names the same, as it is less for people to understand, unless literally VITE_UI_URL
is the required name.
<BrowserRouter basename={import.meta.env.VITE_UI_URL}> | |
<BrowserRouter basename={import.meta.env.BASE_PATH}> |
@SamTV12345 because you raised this PR from the branch named master, I won't be able to rebase it without closing this PR. Let us know if you have time to complete this, or if someone else should create a new PR |
Hi @codefromthecrypt , sorry for the silence. I'm studying CS for masters degree. I have time from today till end of march. So it should be pretty likely to get this pull request merged till then. I'll continue working on it this evening. |
@SamTV12345 epic! thanks for the context and your help! |
@codefromthecrypt The pipelines are passing. There is a regression in the tests but doesn't seem to be introduced by me: |
A rebase solved that issue too. So all pipelines are green. If you need more help or other code changes just ask. I've got now a lot of time till the next semester starts. |
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.
great progress and I think we are very close!
@@ -0,0 +1 @@ | |||
BASE_PATH=/zipkin |
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.
So, I think there are two concepts going on
- what is the base path of the UI (to override in case it isn't "/zipkin"
- how do you get to the API server (formerly
API_BASE
which is a URI)
Can you separate these out, and then try to match up the README with whatever the outcome is?
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 separated the two variables API_BASE and BASE_PATH. You are definetely right. It is best to separate the two.
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.
So, the README says this:
By default, API requests are proxied to
http://localhost:9411
. You can change this target using
theAPI_BASE
environment variable, e.g.,API_BASE=http://tracing.company.com npm start
.
So being user-empathetic, best to check the README works or change the readme. I think API_BASE
should be defaulted to http://localhost:9411
and BASE_PATH should be a path (like /zipkin), not a URI like BASE_PATH
in the .env.test file.
Can you think through this, and converge with the README or change it and update? If BASE_PATH
must be a URI not a path, then, we need to note that in the release notes and change the variable to BASE_URI
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.
The BASE_PATH variable can be anything. I changed it to correctly reflect the values described in the README.
Loving that green build! fyi @tacigar I will merge sam's work when he finishes unless you scream! |
@SamTV12345 In case you are interested in a varied experience our JS/TS tracing library is in dire need of help. If no one helps get it back into shape, we'll have to kill the project. If you have some time to polish it up, I'm sure you'll make a lot of friends openzipkin/zipkin-js#536 |
Thanks for the invite. Sure I'll take a look at the JavaScript repository. Maybe I can polish this up. I've been maintaining Etherpad for 1 1/2 years so shouldn't be a problem to find my way through the code :). |
@codefromthecrypt Should I just fork the js repository, make the changes and create a pull request? |
for starters, yep! and please make one not off the "master" branch, rather a change-specific one as that makes it easier for us to contribute to the PR if needed. Cheers! |
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.
Last comment I think. If there's nothing left in the README that is out-of-date, once addressed, let's merge!
@@ -0,0 +1,2 @@ | |||
BASE_PATH=/zipkin | |||
API_BASE=http://localhost:51204/zipkin |
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.
is this .env.test file used anywhere? if not, maybe we can delete it to remove questions about it or possible port conflicts. if this actually used in tests, I guess there's no way to have it use a random port e.g. by specifying port zero?
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.
It is used during the tests so the test Browserrouter knows where to find the routes etc. I don't really know what happens if I skip the API_BASE variable. If you ever start with E2E tests you can then simply start Zipkin on port 51204.
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.
good enough for me!
Thanks. I'll take a look at it and see what can be improved. |
Thanks for all the work and patience @SamTV12345! |
You're welcome @codefromthecrypt . It's been great working with you on this pull request :). |
This pr introduces vite a very fast bundling tool for react and other languages. It contains a modern API, live reloading, env variables and many more features.
Once this pr is merged I will add some of these features like dynamic imports.