This documents all decisions made while updating the MifosX Web App from Angular 8 to Angular 9 following the official Angular update guide.
✔️ Anywhere you use Renderer, now use Renderer2
- Only Renderer2 is being used in the app
✔️ Instead of importing from @angular/material
, you should import deeply from the specific component. E.g. @angular/material/button
. ng update
will do this automatically for you.
✔️ For lazy loaded modules via the router, make sure you are using dynamic imports. Importing via string is removed in v9. ng update
should take care of this automatically.
✔️ We are deprecating support for @angular/platform-webworker
, as it has been incompatible with the CLI. Running Angular's rendering architecture in a web worker did not meet developer needs. You can still use web workers with Angular.
- No instance of web-workers found.
✔️ Support for web tracing framework in Angular was deprecated in version 8. You should stop using any of the wtf*
APIs.
- App doesn't use
wtf*
APIs
✔️ Remove any es5BrowserSupport
flags in your angular.json
and set your target to es2015
in your tsconfig.json
. Angular now uses your browserslist to determine if an ES5 build is needed. ng update
will migrate you automatically.
- No
es5BrowserSupport
flag found. Target set toes5
intsconfig.json
to disable differential loading.
✔️ Make sure you are using Node 10.13 or later.
Run ng update @angular/core@8 @angular/cli@8
in your workspace directory to update to the latest 8.x version of @angular/core and @angular/cli and commit these changes.
- App uses
Node 12.x
environment and PR is already on latest version of Angular 8
✔️ You can optionally pass the --create-commits (or -C) flag to ng update commands to create a git commit per individual migration.
✔️ Run ng update @angular/core@9 @angular/cli@9
which should bring you to version 9 of Angular.
- In code optional chaining could help improve logic in
.ts
files. Need to check the app for any code breakage, although the app compiles.
✔️ Run ng update @angular/material@9
.
- Need to run similar command as in Angular 8 upgrade (
ng update @angular/material@9 @angular/cdk@9 @angular/flex-layout@9.0.0-beta.31
). - This resolves flex layout bug after initial compilation.
- There were some
e2e
warnings, which are not relevant as we havent initialized testing yet. hammerjs
import inmain.ts
has been removed and hammer module has been added toapp.module.ts
for gesture support see this thread.
✔️ If you use Angular Universal, run ng update @nguniversal/hapi-engine or ng update @nguniversal/express-engine depending on the engine you use. This step may require the --force flag if any of your third-party dependencies have not updated the Angular version of their peer dependencies.
- We dont use Angular Universal.
- Angular Fontawesome broke as expected, updated it to
v0.6.1
as in compatibility guide, Since we were usingv0.3.0
a change in API usage [1] had been introduced inv0.5.0
which caused code breakage, - Resolved by modifying
icon.module.ts
in shared module - Other dependencies
chart.js
andckEditor5
are working fine in development build, need to test for production build.
✔️ During the update to version 9, your project was transformed as necessary via code migrations in order to remove any incompatible or deprecated API calls from your code base. You can now review these changes, and consult the Updating to version 9 guide to learn more about the changes.
- See last point.
- Need to check the project for styling malfunctionality.
✔️ If you are a library author and you had a method returning ModuleWithProviders (typically via a method named forRoot()), you will need to specify the generic type. Learn more angular.io
- See last point.
- Yes we use
ngForm
[1] selector at certain places, It didn't break the functionality here, however when I replaced all instances withng-form
, app failed to compile.
✔️ We have updated the tsconfig.app.json to limit the files compiled. If you rely on other files being included in the compilation, such as a typings.d.ts file, you need to manually add it to the compilation.
- Yes we rely on
typings.d.ts
file, it contains declarations forckEditor5
as well aschart.js
. - Updated
tsconfig.app.json
as well astsconfig.json
to includetypings.d.ts
[1] - This resolves
cannot find module...
bugs after initial compilation. - For some unknown reason
i18n
errors also disappeared after this change.
✔️ If you use Angular Universal with @nguniversal/express-engine or @nguniversal/hapi-engine, several backup files will be created. One of them for server.ts. If this file defers from the default one, you may need to copy some changes from the server.ts.bak to server.ts manually.
- We dont use Angular Universal.
✔️ With Angular 9 Ivy is now the default rendering engine, for any compatibility problems that might arise, read the Ivy compatibility guide.
- Haven't faced any issue in building or compiling the app as of now though there was this warning everytime I ran
ng serve
: - Currently I have just silenced the warning by adding a
ngcc.config.js
file [1], There is no runtime issue withckEditor
however need to check if it works in production build. - Reason for such warnings can be found in this thread.
✔️ If you depend on many Angular libraries you may consider speeding up your build by invoking the ngcc (Angular Compatibility Compiler) in an npm postinstall script via small change to your package.json.
- Added postinstall script in
package.json
.[file]
✔️ Angular 9 introduced a global $localize() function that needs to be loaded if you depend on Angular's internationalization (i18n). Run ng add @angular/localize
to add the necessary packages and code modifications. Consult the $localize Global Import Migration guide to learn more about the changes.
- Ran
ng add @angular/localize
added@angular/localize-v9
inpackage.json
. - App didn't break before this nor did this help in resolving errors, but updated as we use
i18n
.
✔️ If you have specified any entryComponents in your NgModules or had any uses of ANALYZE_FOR_ENTRY_COMPONENTS, you can remove them. They are no longer required with the Ivy compiler and runtime.
- Removed
entryComponents
from all modules wherever present,entryComponents
are now deprecated. Although they don't break functionality if present.
✔️ If you use TestBed.get, you should instead use TestBed.inject. This new method has the same behavior, but is type safe.
- Replaced all instances of
TestBed.get
withTestBed.inject
, this silencedng lint
warnings as well.
✔️ If you use Angular's i18n support, you will need to begin using @angular/localize. Learn more about the $localize Global Import Migration.
- Yes we use
i18n
particularly to translate page titles. - Added localize import in
polyfills.ts
. [file]. - We can have runtime translations if we use i18n.
✔️ In version 10, classes that use Angular features and do not have an Angular decorator are no longer supported. Read more. ng update
will migrate you automatically.
- See last point.
✔️ As of Angular 9, enforcement of @Injectable decorators for DI is stricter and incomplete provider definitions behave differently. Read more. ng update
will migrate you automatically.
- The following is migrations log, I have checked all listed features.
Type Checking
- Angular 9 has new template checking features coming along with Ivy, this can help us spot errors at compile time rather than at build time. [Details]
- Currently I have configured the least strict option ie: similar to Angular 7/8 doesn't type check the template.
- Setting
"fullTemplateTypeCheck"
option totrue
inangularCompilerOptions
can improve debugging as well as code maintainability. - There are
~15
bugs in the arising in the app if I enable type checking, eg: - These can be resolved later, but this option will reduce code flexibility.
Runtime Translations can be enabled
- https://blog.ninja-squad.com/2019/12/10/angular-localize/
- https://groups.google.com/forum/#!msg/mifosdeveloper/hGNPkkab458/QffzwAaNBwAJ
- I am not sure about entire context but i think
json
files can be converted toXML
[1] fori18n
.
Build
- App builds within 20 minutes probably because of Ivy, No need to disable webpack plugins.
- Differential Loading is still disabled although app compiles and builds with it, my browser is giving off pollyfiling bugs with it.