Skip to content
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

chore: Migrate maas-ui from CRA to Vite #5207

Merged
merged 94 commits into from
Jan 15, 2024

Conversation

ndv99
Copy link
Contributor

@ndv99 ndv99 commented Nov 10, 2023

This PR is work in progress, and will break a lot of things.

Done

  • Removed react-scripts
  • Installed Vite
  • Resolve absolute file paths with "@/"
  • Replaced process.env with import.meta.env
  • Replaced REACT_ in env vars with VITE_
  • Updated scripts in package to use vite
  • Replaced jest with vitest

To do

QA steps

  • [ ]

Fixes

Fixes:

Screenshots

Notes

@ndv99 ndv99 added Breaking Change 💣 Don't merge dependencies Pull requests that update a dependency file labels Nov 10, 2023
@webteam-app
Copy link

Demo starting at https://maas-ui-5207.demos.haus

@ndv99
Copy link
Contributor Author

ndv99 commented Jan 12, 2024

I've finally created a successful build check!

@petermakowski
Copy link
Contributor

I've finally created a successful build check!

OK, I'll update and remove run-dotrun from merge requirements for now.

@ndv99 ndv99 removed the Don't merge label Jan 15, 2024
@ndv99 ndv99 changed the title chore: Migrate maas-ui from CRA to Vite WIP chore: Migrate maas-ui from CRA to Vite Jan 15, 2024
@ndv99 ndv99 marked this pull request as ready for review January 15, 2024 09:49
@petermakowski petermakowski self-requested a review January 15, 2024 09:58
@petermakowski
Copy link
Contributor

petermakowski commented Jan 15, 2024

@ndv99 Running yarn start results in an error:

[0] [nodemon] starting `node ./scripts/proxy.js`
[0] require("dotenv-flow").config();
[0] ^
[0]
[0] ReferenceError: require is not defined in ES module scope, you can use import instead
[0] This file is being treated as an ES module because it has a '.js' file extension and 'maas-ui/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.

We should refactor both proxy.js and proxy-ready.js to use import.

@ndv99
Copy link
Contributor Author

ndv99 commented Jan 15, 2024

@ndv99 Running yarn start results in an error:

[0] [nodemon] starting `node ./scripts/proxy.js`
[0] require("dotenv-flow").config();
[0] ^
[0]
[0] ReferenceError: require is not defined in ES module scope, you can use import instead
[0] This file is being treated as an ES module because it has a '.js' file extension and 'maas-ui/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.

We should refactor both proxy.js and proxy-ready.js to use import.

Fixed!

vite.config.ts Outdated Show resolved Hide resolved
@petermakowski
Copy link
Contributor

There's a bunch of warnings around the basename when running tests: Warning: You are attempting to use a basename on a page whose URL path does not begin with the basename. Expected path "/" to begin with "/MAAS/r".

We're also getting a virsh memoised selector error on this PR which does not seem to happen on main (it might just be that it only surfaced now that we changed the build pipeline, but still worth investigating).

src/app/base/components/AppSideNavigation/AppSideNavigation.test.tsx > GlobalSideNav > persists collapsed state
Selector virsh returned a different result when called with the same parameters. This can lead to unnecessary rerenders.
Selectors that return a new reference (such as an object or an array) should be memoized: https://redux.js.org/usage/deriving-data-selectors#optimizing-selectors-with-memoization {

@ndv99
Copy link
Contributor Author

ndv99 commented Jan 15, 2024

There's a bunch of warnings around the basename when running tests: Warning: You are attempting to use a basename on a page whose URL path does not begin with the basename. Expected path "/" to begin with "/MAAS/r".

We're also getting a virsh memoised selector error on this PR which does not seem to happen on main (it might just be that it only surfaced now that we changed the build pipeline, but still worth investigating).

src/app/base/components/AppSideNavigation/AppSideNavigation.test.tsx > GlobalSideNav > persists collapsed state
Selector virsh returned a different result when called with the same parameters. This can lead to unnecessary rerenders.
Selectors that return a new reference (such as an object or an array) should be memoized: https://redux.js.org/usage/deriving-data-selectors#optimizing-selectors-with-memoization {

I've seen both of these - the first one, I'm fairly confident can be fixed pretty easily by setting "base" to "/" in vite.config.ts, but the second one I'm much less sure about

package.json Outdated Show resolved Hide resolved
Copy link
Contributor

@petermakowski petermakowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work @ndv99 👏
This is ready to go to main. Let's monitor for any issues closely in the following days.

@ndv99
Copy link
Contributor Author

ndv99 commented Jan 15, 2024

Great work @ndv99 👏 This is ready to go to main. Let's monitor for any issues closely in the following days.

Thank you so much!

@petermakowski petermakowski merged commit f718080 into canonical:main Jan 15, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants