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

Development: Update to Angular 16 and speedup the build process #6546

Merged
merged 92 commits into from
May 23, 2023

Conversation

pal03377
Copy link
Contributor

@pal03377 pal03377 commented May 7, 2023

based on #6544

Checklist

General

Client

  • Important: I implemented the changes with a very good performance, prevented too many (unnecessary) REST calls and made sure the UI is responsive, even with large data.

Motivation and Context

Angular 16 is here! With it it brings a new Vite development server. This development server is much faster than the current one - which will drastically increase developer productivity! 🚀

Description

First of all, this PR updates Angular to version 16.
Also, we drop BrowserSync because of low usage among developers. Routes in the navbar are now coded as absolute paths, because otherwise they didn't work.

To be able to leverage the new Angular Build capabilities, I had to remove the current Webpack configuration because well, it's specific to Webpack. Instead, now all configuration should happen in angular.json. This was not possible for

  • dynamic environment variables and
  • merging the i18n json files

Because of this, I introduced a prebuild.mjs script. It creates the merged i18n json files as well as an environment.override.ts file to customize some variables.

Because the webpack bundle size analyzer is now dropped from the webpack config (which doesn't exist anymore), I integrated it as a separate step of the production build.

Steps for Testing

  • pull from the branch
  • npm install (you might have to delete node_modules first if it errors)
  • start the server and the client
  • try the live reload functionality
  • click around in the web app to see whether anything is broken

Running the tests locally on Windows

Does not apply any more, it should work just fine!
Currently, there is an issue with jest-preset-angular which causes the tests to fail on Windows. Until a proper fix is generally available, you can manually replace node_modules/jest-preset-angular/build/utils/ngcc-jest-processor.js before running the test commands with this file: https://gist.github.com/pal03377/a3d85176de1b2ac54a0679283e084fe9

Client test justification

Usually, you would expect an update to roughly keep all tests intact. However, ~60 of 5400 client tests broke with this update. Because of this, this PR includes a bunch of in-part random-looking changes to client tests. There are good reasons behind those changes, but they might not be immediately obvious. The following table helps explaining. Use it to look up the reason for a change when you don't understand it from the code.

You don't have to read it all, just look up the file when you are wondering about it in code review.

Here is a table of the changes (pdf): Angular 16 Build Client Test Table.pdf

Review Progress

Code Review

  • Code Review 1
  • Code Review 2

Manual Tests

  • Test 1
  • Test 2

Screenshots

Screen recording of me removing and re-adding the refresh button on the course page. Previously, my build times were around 16x as long (4x with some build speed improvement tricks):

artemis-client-build-angular-vite.mp4

@pal03377 pal03377 added client Pull requests that update TypeScript code. (Added Automatically!) build system labels May 7, 2023
@pal03377 pal03377 self-assigned this May 7, 2023
prebuild.mjs Fixed Show fixed Hide fixed
prebuild.mjs Fixed Show fixed Hide fixed
prebuild.mjs Fixed Show fixed Hide fixed
prebuild.mjs Fixed Show fixed Hide fixed
tobias-lippert
tobias-lippert previously approved these changes May 17, 2023
Copy link
Contributor

@tobias-lippert tobias-lippert left a comment

Choose a reason for hiding this comment

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

Tested again locally, running tests on windows works now flawlessly without any workaround

julian-christl
julian-christl previously approved these changes May 18, 2023
Copy link
Member

@julian-christl julian-christl left a comment

Choose a reason for hiding this comment

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

Code looks good

Copy link
Contributor

@JohannesStoehr JohannesStoehr left a comment

Choose a reason for hiding this comment

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

Tested locally and on TS2.
Code changes look good as well

Copy link
Contributor

@tobias-lippert tobias-lippert left a comment

Choose a reason for hiding this comment

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

Tested locally and on ts2. Everything, especially navigating works.
Latest code changes look good.

@krusche krusche changed the title Development: Fast Angular 16 build Development: Update to Angular 16 and speedup the build process May 23, 2023
Copy link
Member

@krusche krusche left a comment

Choose a reason for hiding this comment

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

Code looks good 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client Pull requests that update TypeScript code. (Added Automatically!) documentation ready for review tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.