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

Commit af6cce7

Browse files
committed
refactor: convert app to latest Angular CLI format
fix some Ivy and TypeScript compilation and configuration issues add a `build:highmem` for use when the build fails due to memory usage update all dependencies that are supported remove unneeded polyfills now that differential loading is supported convert workspace to current format move and update tsconfigs to match current CLI format log errors on bootstrap enable some router quality of life options add a `Version` interface update StackBlitz - Copyright - major Angular version - dependencies fix build error for `setTimeout` - it was resolving to the NodeJS version rather than DOM version
1 parent 10441de commit af6cce7

26 files changed

+2594
-1616
lines changed

.gitignore

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,34 @@
33
# compiled output
44
/dist
55
/tmp
6+
/out-tsc
67
/src/assets/*.css
8+
# Only exists if Bazel was run
9+
/bazel-out
710

811
# dependencies
912
/node_modules
10-
/bower_components
13+
14+
# profiling files
15+
chrome-profiler-events*.json
16+
speed-measure-plugin*.json
1117

1218
# IDEs and editors
1319
/.idea
14-
/.vscode
1520
.project
1621
.classpath
22+
.c9/
1723
*.launch
1824
.settings/
25+
*.sublime-workspace
26+
27+
# IDE - VSCode
28+
.vscode/*
29+
!.vscode/settings.json
30+
!.vscode/tasks.json
31+
!.vscode/launch.json
32+
!.vscode/extensions.json
33+
.history/*
1934

2035
# misc
2136
/.sass-cache
@@ -27,10 +42,6 @@ yarn-error.log
2742
testem.log
2843
/typings
2944

30-
# e2e
31-
/e2e/*.js
32-
/e2e/*.map
33-
3445
#System Files
3546
.DS_Store
3647
Thumbs.db

angular.json

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
23
"version": 1,
34
"newProjectRoot": "projects",
45
"projects": {
56
"material-angular-io": {
67
"root": "",
78
"projectType": "application",
9+
"schematics": {
10+
"@schematics/angular:component": {
11+
"style": "scss"
12+
}
13+
},
814
"architect": {
915
"build": {
1016
"builder": "@angular-devkit/build-angular:browser",
@@ -14,7 +20,7 @@
1420
"outputPath": "dist",
1521
"index": "src/index.html",
1622
"main": "src/main.ts",
17-
"tsConfig": "src/tsconfig.json",
23+
"tsConfig": "tsconfig.app.json",
1824
"assets": [
1925
{
2026
"glob": "**/*",
@@ -104,8 +110,8 @@
104110
"options": {
105111
"main": "src/test.ts",
106112
"polyfills": "src/polyfills.ts",
107-
"karmaConfig": "./karma.conf.js",
108-
"tsConfig": "src/tsconfig.spec.json",
113+
"karmaConfig": "karma.conf.js",
114+
"tsConfig": "tsconfig.spec.json",
109115
"scripts": [],
110116
"styles": [
111117
{
@@ -153,38 +159,28 @@
153159
"builder": "@angular-devkit/build-angular:tslint",
154160
"options": {
155161
"tsConfig": [
156-
"src/tsconfig.json"
162+
"tsconfig.app.json",
163+
"tsconfig.spec.json",
164+
"e2e/tsconfig.json"
157165
],
158166
"exclude": [
159167
"**/node_modules/**"
160168
]
161169
}
162-
}
163-
}
164-
},
165-
"material-angular-io-e2e": {
166-
"root": "",
167-
"projectType": "application",
168-
"cli": {},
169-
"schematics": {},
170-
"architect": {
170+
},
171171
"e2e": {
172172
"builder": "@angular-devkit/build-angular:protractor",
173173
"options": {
174-
"protractorConfig": "./protractor.conf.js",
174+
"protractorConfig": "e2e/protractor.conf.js",
175175
"devServerTarget": "material-angular-io:serve"
176+
},
177+
"configurations": {
178+
"production": {
179+
"devServerTarget": "material-angular-io:serve:production"
180+
}
176181
}
177182
}
178183
}
179184
}
180-
},
181-
"schematics": {
182-
"@schematics/angular:component": {
183-
"prefix": "app",
184-
"styleext": "css"
185-
},
186-
"@schematics/angular:directive": {
187-
"prefix": "app"
188-
}
189185
}
190186
}

e2e/app.e2e-spec.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

e2e/app.po.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,37 @@
1+
// @ts-check
12
// Protractor configuration file, see link for more information
2-
// https://github.com/angular/protractor/blob/master/docs/referenceConf.js
3+
// https://github.com/angular/protractor/blob/master/lib/config.ts
34

4-
/*global jasmine */
5-
const SpecReporter = require('jasmine-spec-reporter');
5+
const {SpecReporter} = require('jasmine-spec-reporter');
66

7+
/**
8+
* @type { import("protractor").Config }
9+
*/
710
let config = {
811
allScriptsTimeout: 11000,
912
specs: [
10-
'./e2e/**/*.e2e-spec.ts'
13+
'./src/**/*.e2e-spec.ts'
1114
],
1215
capabilities: {
1316
'browserName': 'chrome'
1417
},
18+
directConnect: true,
1519
baseUrl: 'http://localhost:4200/',
1620
framework: 'jasmine',
1721
jasmineNodeOpts: {
1822
showColors: true,
1923
defaultTimeoutInterval: 30000,
2024
print: function() {}
2125
},
22-
useAllAngular2AppRoots: true,
23-
beforeLaunch: function() {
26+
onPrepare() {
2427
require('ts-node').register({
25-
project: 'e2e'
28+
project: require('path').join(__dirname, './tsconfig.json')
2629
});
27-
},
28-
onPrepare: function() {
29-
jasmine.getEnv().addReporter(new SpecReporter());
30+
jasmine.getEnv().addReporter(new SpecReporter({spec: {displayStacktrace: true}}));
3031
}
3132
};
3233

33-
3434
if (process.env['TRAVIS']) {
35-
3635
config.sauceUser = process.env['SAUCE_USERNAME'];
3736
config.sauceKey = process.env['SAUCE_ACCESS_KEY'].split('').reverse().join('');
3837

@@ -42,7 +41,6 @@ if (process.env['TRAVIS']) {
4241
'build': process.env['TRAVIS_JOB_NUMBER'],
4342
'name': 'Material Docs E2E'
4443
};
45-
4644
}
4745

4846
exports.config = config;

e2e/src/app.e2e-spec.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import {MaterialDocsAppPage} from './app.po';
2+
import {browser, logging} from 'protractor';
3+
4+
describe('Material Docs App', () => {
5+
let page: MaterialDocsAppPage;
6+
7+
beforeEach(() => {
8+
page = new MaterialDocsAppPage();
9+
});
10+
11+
it('should display welcome message', () => {
12+
page.navigateTo();
13+
page.getTitleText().then((title: string) => {
14+
expect(title).toEqual('Angular Material');
15+
});
16+
});
17+
18+
afterEach(async () => {
19+
// Assert that there are no errors emitted from the browser
20+
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
21+
expect(logs).not.toContain(jasmine.objectContaining({
22+
level: logging.Level.SEVERE,
23+
} as logging.Entry));
24+
});
25+
});

e2e/src/app.po.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {browser, by, element} from 'protractor';
2+
3+
export class MaterialDocsAppPage {
4+
navigateTo() {
5+
return browser.get(browser.baseUrl) as Promise<any>;
6+
}
7+
8+
getTitleText() {
9+
return element(by.css('app-homepage header .docs-header-headline .mat-h1'))
10+
.getText() as Promise<string>;
11+
}
12+
}

e2e/tsconfig.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
{
2-
"compileOnSave": false,
2+
"extends": "../tsconfig.json",
33
"compilerOptions": {
4-
"declaration": false,
5-
"emitDecoratorMetadata": true,
6-
"experimentalDecorators": true,
4+
"outDir": "../out-tsc/e2e",
75
"module": "commonjs",
8-
"moduleResolution": "node",
9-
"outDir": "../dist/out-tsc-e2e",
10-
"sourceMap": true,
116
"target": "es5",
12-
"typeRoots": [
13-
"../node_modules/@types"
7+
"types": [
8+
"jasmine",
9+
"jasminewd2",
10+
"node"
1411
]
1512
}
1613
}

package.json

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,60 +4,65 @@
44
"license": "MIT",
55
"angular-cli": {},
66
"scripts": {
7+
"ng": "ng",
78
"start": "yarn build-themes && ng serve",
89
"start-jit": "yarn build-themes && ng serve --aot=false",
9-
"lint": "tslint -p src/tsconfig.json",
10+
"start:prod": "yarn build-themes && ng serve --prod",
11+
"lint": "tslint -p tsconfig.json",
1012
"test": "yarn build-themes && ng test",
1113
"pree2e": "webdriver-manager update",
12-
"e2e": "protractor",
14+
"e2e": "yarn build-themes && ng e2e",
15+
"build": "yarn build-themes && ng build",
16+
"build:highmem": "yarn build-themes && node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng build",
17+
"build:sm": "ng build --prod --source-map",
1318
"build-themes": "bash ./tools/build-themes.sh",
14-
"prod-build": "yarn build-themes && ng build --aot --prod",
19+
"prod-build": "yarn build-themes && ng build --prod",
1520
"postinstall": "webdriver-manager update --gecko false && yarn build-themes",
1621
"publish-prod": "bash ./tools/deploy.sh stable prod",
1722
"publish-dev": "bash ./tools/deploy.sh",
1823
"publish-beta": "bash ./tools/deploy.sh stable beta"
1924
},
2025
"private": true,
2126
"dependencies": {
22-
"@angular/animations": "^8.0.0",
23-
"@angular/cdk": "^8.1.4",
24-
"@angular/cdk-experimental": "^8.1.1",
25-
"@angular/common": "^8.0.0",
26-
"@angular/compiler": "^8.0.0",
27-
"@angular/core": "^8.0.0",
28-
"@angular/forms": "^8.0.0",
29-
"@angular/material": "^8.1.4",
27+
"@angular/animations": "^8.2.8",
28+
"@angular/cdk": "^8.2.2",
29+
"@angular/cdk-experimental": "^8.2.2",
30+
"@angular/common": "^8.2.8",
31+
"@angular/compiler": "^8.2.8",
32+
"@angular/core": "^8.2.8",
33+
"@angular/forms": "^8.2.8",
34+
"@angular/material": "^8.2.2",
3035
"@angular/material-examples": "angular/material2-docs-content#8.1.x",
31-
"@angular/material-experimental": "^8.1.1",
32-
"@angular/material-moment-adapter": "^8.1.4",
33-
"@angular/platform-browser": "^8.0.0",
34-
"@angular/platform-browser-dynamic": "^8.0.0",
35-
"@angular/router": "^8.0.0",
36-
"core-js": "^2.6.1",
36+
"@angular/material-experimental": "^8.2.2",
37+
"@angular/material-moment-adapter": "^8.2.2",
38+
"@angular/platform-browser": "^8.2.8",
39+
"@angular/platform-browser-dynamic": "^8.2.8",
40+
"@angular/router": "^8.2.8",
41+
"core-js": "^2.6.9",
3742
"hammerjs": "^2.0.8",
38-
"material-components-web": "^1.1.1",
39-
"moment": "^2.23.0",
40-
"rxjs": "^6.5.1",
41-
"zone.js": "^0.9.0"
43+
"material-components-web": "^4.0.0-alpha.0",
44+
"moment": "^2.24.0",
45+
"rxjs": "^6.5.3",
46+
"zone.js": "^0.9.1"
4247
},
4348
"devDependencies": {
44-
"@angular-devkit/build-angular": "^0.800.0",
45-
"@angular/cli": "^8.0.0",
46-
"@angular/compiler-cli": "^8.0.0",
47-
"@types/jasmine": "^3.3.5",
48-
"@types/node": "^10.12.18",
49-
"firebase-tools": "^6.2.2",
50-
"jasmine-core": "~2.99.1",
49+
"@angular-devkit/build-angular": "^0.803.6",
50+
"@angular/cli": "^8.3.6",
51+
"@angular/compiler-cli": "^8.2.8",
52+
"@types/jasmine": "^3.4.1",
53+
"@types/node": "^12.7.8",
54+
"firebase-tools": "^7.4.0",
55+
"jasmine-core": "^3.5.0",
5156
"jasmine-spec-reporter": "~4.2.1",
52-
"karma": "^3.1.4",
53-
"karma-chrome-launcher": "^2.2.0",
57+
"karma": "^4.3.0",
58+
"karma-chrome-launcher": "^3.1.0",
5459
"karma-firefox-launcher": "^1.1.0",
55-
"karma-jasmine": "^1.1.2",
56-
"karma-jasmine-html-reporter": "^0.2.2",
60+
"karma-jasmine": "^2.0.1",
61+
"karma-jasmine-html-reporter": "^1.4.2",
5762
"node-sass": "^4.11.0",
58-
"protractor": "~5.3.0",
59-
"ts-node": "^6.0.3",
60-
"tslint": "^5.10.0",
61-
"typescript": "3.4"
63+
"protractor": "^5.4.2",
64+
"ts-node": "^8.4.1",
65+
"tslint": "^5.20.0",
66+
"typescript": "3.5.3"
6267
}
6368
}

src/app/app-module.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ import {GaService} from './shared/ga/ga';
4242
FormsModule,
4343
HttpClientModule,
4444
MatNativeDateModule,
45-
RouterModule.forRoot(MATERIAL_DOCS_ROUTES),
45+
RouterModule.forRoot(MATERIAL_DOCS_ROUTES, {
46+
scrollPositionRestoration: 'enabled',
47+
anchorScrolling: 'enabled',
48+
relativeLinkResolution: 'corrected'
49+
}),
4650
ComponentCategoryListModule,
4751
ComponentHeaderModule,
4852
ComponentListModule,

0 commit comments

Comments
 (0)