Hi
I went through the upgrade steps as documented by angular.io and ionic, to move my Angular 7.2/Ionic 4 app to Angular 10/Ionic 5. Unfortunately, I still need to import '@angular/compiler';
in main.ts
otherwise the browser console.log complains about compiler not present and the app does not run. So I am running JIT whereas the docs says it should be AOT - seemingly.
I tried to compare angular.json of a new a10/I5 project but cant see the key differences. main.ts
is the same except for the import of the compiler.
How can I get rid of the angular compliler and truly run aot (even though it says aot:true)?
Steps I took to upgrade:
Go to Angular 8
- change tsconfig.json ->
"module": "esnext",
ng update @angular/cli@8 @angular/core@8
- As the routes are not migrated to dynamic imports, I run:
ng update @angular/cli --from 7 --to 8 --migrate-only
ng update @angular/core --from 7 --to 8 --migrate-only
Update latest Ionic 4 to see deprecated warnings:
6. npm i @ionic/angular@4.11.10 --save
(coming from 4.1.0)
Get rid of security warnings:
7. npm audit fix
(not earlier)
Go Ionic 5:
8. npm install @ionic/angular@latest @ionic/angular-toolkit@latest --save
9. Fix the breaking changes as per Ionic docs
EDIT: I overlooked breaking changes in Angularfire going to Angular 9 - Angularfire will go to 6. These steps not noted here, but necessary!
Go to Angular 9:
10. Remove any es5BrowserSupport
flags in your angular.json (as per update.angular.io)
11. ng update @angular/cli@9 @angular/core@9
12. Add zone-flags.ts
in files section of tsconfig.app.json
13. Add allowedCommonJsDependencies
in angular.json
14. import '@angular/compiler';
in main.ts
so the app does not break anymore
Go to Angular 10:
15. ng update @angular/cli@10 @angular/core@10
Upgrade of NGRX:
16. ng update @ngrx/store
FINISHED
My angular.json:
{
"$schema": "./node_modules/@angular-devkit/core/src/workspace/workspace-schema.json",
"version": 1,
"defaultProject": "app",
"newProjectRoot": "projects",
"projects": {
"app": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"allowedCommonJsDependencies": [
"chart.js",
"firebase/app",
"@firebase/performance",
"crypto-js",
"@firebase/firestore",
"@firebase/auth",
"@firebase/database"
],
"aot": true,
"outputPath": "www",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [{
"glob": "**/*",
"input": "src/assets",
"output": "assets"
},
{
"glob": "**/*.svg",
"input": "node_modules/ionicons/dist/ionicons/svg",
"output": "./svg"
},
"src/manifest.json"
],
"styles": [{
"input": "src/theme/variables.scss"
},
{
"input": "src/global.scss"
},
{
"input": "src/app/app.scss"
}
],
"scripts": []
},
"configurations": {
"production": {
"fileReplacements": [{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
"serviceWorker": true,
"ngswConfigPath": "src/ngsw-config.json"
},
"uat": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}
],
"serviceWorker": false,
"ngswConfigPath": "src/ngsw-config.json"
},
"ci": {
"budgets": [{
"type": "anyComponentStyle",
"maximumWarning": "6kb"
}],
"progress": false
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "app:build"
},
"configurations": {
"production": {
"browserTarget": "app:build:production"
},
"ci": {
"progress": false
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "app:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"karmaConfig": "src/karma.conf.js",
"styles": [],
"scripts": [],
"assets": [{
"glob": "favicon.ico",
"input": "src/",
"output": "/"
},
{
"glob": "**/*",
"input": "src/assets",
"output": "/assets"
},
"src/manifest.json"
]
},
"configurations": {
"ci": {
"progress": false,
"watch": false
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
},
"ionic-cordova-build": {
"builder": "@ionic/angular-toolkit:cordova-build",
"options": {
"browserTarget": "app:build"
},
"configurations": {
"production": {
"browserTarget": "app:build:production"
}
}
},
"ionic-cordova-serve": {
"builder": "@ionic/angular-toolkit:cordova-serve",
"options": {
"cordovaBuildTarget": "app:ionic-cordova-build",
"devServerTarget": "app:serve"
},
"configurations": {
"production": {
"cordovaBuildTarget": "app:ionic-cordova-build:production",
"devServerTarget": "app:serve:production"
}
}
}
}
},
"app-e2e": {
"root": "e2e/",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "app:serve"
},
"configurations": {
"production": {
"devServerTarget": "app:serve:production"
},
"ci": {
"devServerTarget": "app:serve:ci"
}
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"cli": {
"defaultCollection": "@ionic/angular-toolkit"
},
"schematics": {
"@ionic/angular-toolkit:component": {
"styleext": "scss"
},
"@ionic/angular-toolkit:page": {
"styleext": "scss"
}
}
}
Btw, in some point in time the ng cli says I need to remove some angular-devkit subpackages (core/schematics), and I changed the schema to "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
, but in vain…