Skip to content
This repository was archived by the owner on Oct 14, 2024. It is now read-only.

Commit d4e4241

Browse files
author
Alan Agius
committed
feat: update to Angular 8
The main noticeable change in the removal of `@nguniversal/module-map-ngfactory-loader`. This is because now in Angular 8 we support standard import syntax which no longer require custom logic to support lazy loading. Example ```ts loadChildren: () => import('./lazy/lazy.module').then(m => m.LazyModule) ``` instead of ```ts loadChildren: './lazy/lazy.module#LazyModule' ```
1 parent 184d8a4 commit d4e4241

13 files changed

+1200
-1971
lines changed

angular.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,12 @@
119119
"replace": "src/environments/environment.ts",
120120
"with": "src/environments/environment.prod.ts"
121121
}
122-
]
122+
],
123+
"sourceMap": false,
124+
"optimization": {
125+
"scripts": false,
126+
"styles": true
127+
}
123128
}
124129
}
125130
}

browserslist

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2+
# For additional information regarding the format and rule options, please see:
3+
# https://github.com/browserslist/browserslist#queries
4+
5+
# You can see what browsers were selected by your queries by running:
6+
# npx browserslist
7+
8+
> 0.5%
9+
last 2 versions
10+
Firefox ESR
11+
not dead
12+
not IE 9-11 # For IE 9-11 support, remove 'not'.

package.json

+21-24
Original file line numberDiff line numberDiff line change
@@ -31,36 +31,33 @@
3131
"pre-commit": [],
3232
"private": true,
3333
"dependencies": {
34-
"@angular/animations": "7.1.4",
35-
"@angular/common": "7.1.4",
36-
"@angular/compiler": "7.1.4",
37-
"@angular/core": "7.1.4",
38-
"@angular/forms": "7.1.4",
39-
"@angular/http": "7.1.4",
40-
"@angular/platform-browser": "7.1.4",
41-
"@angular/platform-browser-dynamic": "7.1.4",
42-
"@angular/platform-server": "7.1.4",
43-
"@angular/router": "7.1.4",
44-
"@nguniversal/common": "^6.0.0",
45-
"@nguniversal/express-engine": "^6.0.0",
46-
"@nguniversal/module-map-ngfactory-loader": "^6.0.0",
47-
"core-js": "^2.4.1",
48-
"express": "^4.15.2",
34+
"@angular/animations": "8.0.0",
35+
"@angular/common": "8.0.0",
36+
"@angular/compiler": "8.0.0",
37+
"@angular/core": "8.0.0",
38+
"@angular/forms": "8.0.0",
39+
"@angular/platform-browser": "8.0.0",
40+
"@angular/platform-browser-dynamic": "8.0.0",
41+
"@angular/platform-server": "8.0.0",
42+
"@angular/router": "8.0.0",
43+
"@nguniversal/common": "^7.1.1",
44+
"@nguniversal/express-engine": "^7.1.1",
45+
"express": "^4.17.1",
4946
"reflect-metadata": "^0.1.10",
50-
"rxjs": "6.3.3",
51-
"zone.js": "^0.8.26"
47+
"rxjs": "6.5.2",
48+
"zone.js": "~0.9.1"
5249
},
5350
"devDependencies": {
54-
"@angular-devkit/build-angular": "0.11.4",
55-
"@angular/cli": "7.1.4",
56-
"@angular/compiler-cli": "7.1.4",
57-
"@angular/language-service": "7.1.4",
51+
"@angular-devkit/build-angular": "~0.800.0",
52+
"@angular/cli": "8.0.1",
53+
"@angular/compiler-cli": "8.0.0",
54+
"@angular/language-service": "8.0.0",
5855
"@types/node": "^8.0.30",
59-
"codelyzer": "^4.0.2",
56+
"codelyzer": "^5.1.0",
6057
"http-server": "^0.10.0",
6158
"pre-commit": "^1.2.2",
6259
"ts-loader": "^4.2.0",
63-
"tslint": "^5.7.0",
64-
"typescript": "3.1.6"
60+
"tslint": "^5.17.0",
61+
"typescript": "3.4.5"
6562
}
6663
}

prerender.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,11 @@ import {enableProdMode} from '@angular/core';
88
// Faster server renders w/ Prod mode (dev mode never needed)
99
enableProdMode();
1010

11-
// Import module map for lazy loading
12-
import {provideModuleMap} from '@nguniversal/module-map-ngfactory-loader';
1311
import {renderModuleFactory} from '@angular/platform-server';
1412
import {ROUTES} from './static.paths';
1513

1614
// * NOTE :: leave this as require() since this file is built Dynamically from webpack
17-
const {AppServerModuleNgFactory, LAZY_MODULE_MAP} = require('./server/main');
15+
const {AppServerModuleNgFactory} = require('./server/main');
1816

1917
const BROWSER_FOLDER = join(process.cwd(), 'browser');
2018

@@ -36,8 +34,5 @@ ROUTES.forEach(route => {
3634
previousRender = previousRender.then(_ => renderModuleFactory(AppServerModuleNgFactory, {
3735
document: index,
3836
url: route,
39-
extraProviders: [
40-
provideModuleMap(LAZY_MODULE_MAP)
41-
]
4237
})).then(html => writeFileSync(join(fullPath, 'index.html'), html));
4338
});

server.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ import { enableProdMode } from '@angular/core';
33

44
// Express Engine
55
import { ngExpressEngine } from '@nguniversal/express-engine';
6-
// Import module map for lazy loading
7-
import { provideModuleMap } from '@nguniversal/module-map-ngfactory-loader';
8-
96
import * as express from 'express';
107
import { join } from 'path';
118

@@ -19,14 +16,11 @@ const PORT = process.env.PORT || 4000;
1916
const DIST_FOLDER = join(process.cwd(), 'dist');
2017

2118
// * NOTE :: leave this as require() since this file is built Dynamically from webpack
22-
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./server/main');
19+
const { AppServerModuleNgFactory } = require('./server/main');
2320

2421
// Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
2522
app.engine('html', ngExpressEngine({
26-
bootstrap: AppServerModuleNgFactory,
27-
providers: [
28-
provideModuleMap(LAZY_MODULE_MAP)
29-
]
23+
bootstrap: AppServerModuleNgFactory
3024
}));
3125

3226
app.set('view engine', 'html');

src/app/app.module.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import {TransferHttpCacheModule} from '@nguniversal/common';
1414
imports: [
1515
BrowserModule.withServerTransition({appId: 'my-app'}),
1616
RouterModule.forRoot([
17-
{ path: '', component: HomeComponent, pathMatch: 'full'},
18-
{ path: 'lazy', loadChildren: './lazy/lazy.module#LazyModule'},
19-
{ path: 'lazy/nested', loadChildren: './lazy/lazy.module#LazyModule'}
17+
{path: '', component: HomeComponent, pathMatch: 'full'},
18+
{path: 'lazy', loadChildren: () => import('./lazy/lazy.module').then(m => m.LazyModule)},
19+
{path: 'lazy/nested', loadChildren: () => import('./lazy/lazy.module').then(m => m.LazyModule)}
2020
]),
2121
TransferHttpCacheModule,
2222
],

src/app/app.server.module.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import {NgModule} from '@angular/core';
22
import {ServerModule, ServerTransferStateModule} from '@angular/platform-server';
3-
import {ModuleMapLoaderModule} from '@nguniversal/module-map-ngfactory-loader';
43

54
import {AppModule} from './app.module';
65
import {AppComponent} from './app.component';
@@ -11,7 +10,6 @@ import {AppComponent} from './app.component';
1110
// by the ServerModule from @angular/platform-server.
1211
AppModule,
1312
ServerModule,
14-
ModuleMapLoaderModule,
1513
ServerTransferStateModule,
1614
],
1715
// Since the bootstrapped component is not inherited from your

src/polyfills.ts

+29-38
Original file line numberDiff line numberDiff line change
@@ -11,62 +11,53 @@
1111
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
1212
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
1313
*
14-
* Learn more in https://angular.io/docs/ts/latest/guide/browser-support.html
14+
* Learn more in https://angular.io/guide/browser-support
1515
*/
1616

1717
/***************************************************************************************************
1818
* BROWSER POLYFILLS
1919
*/
2020

21-
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
22-
// import 'core-js/es6/symbol';
23-
// import 'core-js/es6/object';
24-
// import 'core-js/es6/function';
25-
// import 'core-js/es6/parse-int';
26-
// import 'core-js/es6/parse-float';
27-
// import 'core-js/es6/number';
28-
// import 'core-js/es6/math';
29-
// import 'core-js/es6/string';
30-
// import 'core-js/es6/date';
31-
// import 'core-js/es6/array';
32-
// import 'core-js/es6/regexp';
33-
// import 'core-js/es6/map';
34-
// import 'core-js/es6/weak-map';
35-
// import 'core-js/es6/set';
36-
3721
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
3822
// import 'classlist.js'; // Run `npm install --save classlist.js`.
3923

40-
/** Evergreen browsers require these. **/
41-
import 'core-js/es6/reflect';
42-
import 'core-js/es7/reflect';
43-
44-
4524
/**
46-
* Required to support Web Animations `@angular/animation`.
47-
* Needed for: All but Chrome, Firefox and Opera. http://caniuse.com/#feat=web-animation
48-
**/
25+
* Web Animations `@angular/platform-browser/animations`
26+
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
27+
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
28+
*/
4929
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.
5030

51-
31+
/**
32+
* By default, zone.js will patch all possible macroTask and DomEvents
33+
* user can disable parts of macroTask/DomEvents patch by setting following flags
34+
* because those flags need to be set before `zone.js` being loaded, and webpack
35+
* will put import in the top of bundle, so user need to create a separate file
36+
* in this directory (for example: zone-flags.ts), and put the following flags
37+
* into that file, and then add the following code before importing zone.js.
38+
* import './zone-flags.ts';
39+
*
40+
* The flags allowed in zone-flags.ts are listed here.
41+
*
42+
* The following flags will work for all browsers.
43+
*
44+
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
45+
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
46+
* (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
47+
*
48+
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
49+
* with the following flag, it will bypass `zone.js` patch for IE/Edge
50+
*
51+
* (window as any).__Zone_enable_cross_context_check = true;
52+
*
53+
*/
5254

5355
/***************************************************************************************************
54-
* Zone JS is required by Angular itself.
56+
* Zone JS is required by default for Angular itself.
5557
*/
5658
import 'zone.js/dist/zone'; // Included with Angular CLI.
5759

5860

59-
6061
/***************************************************************************************************
6162
* APPLICATION IMPORTS
6263
*/
63-
64-
/**
65-
* Date, currency, decimal and percent pipes.
66-
* Needed for: All but Chrome, Firefox, Edge, IE11 and Safari 10
67-
*/
68-
// import 'intl'; // Run `npm install --save intl`.
69-
/**
70-
* Need to import at least one locale-data with intl.
71-
*/
72-
// import 'intl/locale-data/jsonp/en';

src/tsconfig.app.json

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
"extends": "../tsconfig.json",
33
"compilerOptions": {
44
"outDir": "../out-tsc/app",
5-
"baseUrl": "./",
6-
"module": "es2015",
75
"types": [
86
"node"
97
]

src/tsconfig.server.json

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"extends": "../tsconfig.json",
33
"compilerOptions": {
44
"outDir": "../out-tsc/app",
5-
"baseUrl": "./",
65
// Set the module format to "commonjs":
76
"module": "commonjs",
87
"types": [

tsconfig.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
{
22
"compileOnSave": false,
33
"compilerOptions": {
4+
"baseUrl": "./",
5+
"module": "esnext",
46
"outDir": "./dist/out-tsc",
57
"sourceMap": true,
68
"declaration": false,
79
"moduleResolution": "node",
810
"emitDecoratorMetadata": true,
911
"experimentalDecorators": true,
10-
"target": "es5",
12+
"target": "es2015",
1113
"typeRoots": [
1214
"node_modules/@types"
1315
],

tslint.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@
131131
"kebab-case"
132132
],
133133
"no-output-on-prefix": true,
134-
"use-input-property-decorator": true,
135-
"use-output-property-decorator": true,
136-
"use-host-property-decorator": true,
134+
"no-inputs-metadata-property": true,
135+
"no-outputs-metadata-property": true,
136+
"no-host-metadata-property": true,
137137
"no-input-rename": true,
138138
"no-output-rename": true,
139-
"use-life-cycle-interface": true,
139+
"use-lifecycle-interface": true,
140140
"use-pipe-transform-interface": true,
141141
"component-class-suffix": true,
142142
"directive-class-suffix": true

0 commit comments

Comments
 (0)