Skip to content

Commit 66f655d

Browse files
feat(Angular 5.0): update engine-etc for angular 5.0 & Domino (TrilonIO#437)
* feat(5.0): update engine-etc for angular 5.0-rc1 WIP - More updates to come * remove ng 4 references * update source maps for faster HMR builds * use aspnetcore-engine & misc updates and fixes * update to 5.0 official Closes TrilonIO#434 Closes TrilonIO#435 Closes TrilonIO#430 Closes TrilonIO#424
1 parent 82afbb5 commit 66f655d

10 files changed

+73
-90
lines changed

ClientApp/app/app.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { LinkService } from './shared/link.service';
77

88
// i18n support
99
import { TranslateService } from '@ngx-translate/core';
10-
import { REQUEST } from '@nguniversal/aspnetcore-engine/tokens';
10+
import { REQUEST } from '@nguniversal/aspnetcore-engine';
1111

1212
@Component({
1313
selector: 'app-root',

ClientApp/app/app.module.browser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { BrowserModule } from '@angular/platform-browser';
33
import { APP_BASE_HREF } from '@angular/common';
44
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
55

6-
import { ORIGIN_URL, REQUEST } from '@nguniversal/aspnetcore-engine/tokens';
6+
import { ORIGIN_URL, REQUEST } from '@nguniversal/aspnetcore-engine';
77
import { AppModuleShared } from './app.module';
88
import { AppComponent } from './app.component';
99
import { BrowserTransferStateModule } from '@angular/platform-browser';

ClientApp/app/app.module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { NgxBootstrapComponent } from './containers/ngx-bootstrap-demo/ngx-boots
2424

2525
import { LinkService } from './shared/link.service';
2626
import { UserService } from './shared/user.service';
27-
import { ORIGIN_URL } from '@nguniversal/aspnetcore-engine/tokens';
27+
import { ORIGIN_URL } from '@nguniversal/aspnetcore-engine';
2828

2929
export function createTranslateLoader(http: HttpClient, baseHref) {
3030
// Temporary Azure hack

ClientApp/app/containers/users/users.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ <h2>Users</h2>
2626
</button>
2727
</li>
2828
</ul>
29-
<app-user-detail (userUpdate)="onUserUpdate($event)" [user]="selectedUser"></app-user-detail>
29+
<app-user-detail [user]="selectedUser"></app-user-detail>

ClientApp/app/containers/users/users.component.ts

+48-59
Original file line numberDiff line numberDiff line change
@@ -7,75 +7,64 @@ import { IUser } from '../../models/User';
77
import { UserService } from '../../shared/user.service';
88

99
@Component({
10-
selector: 'app-users',
11-
templateUrl: './users.component.html',
12-
styleUrls: ['./users.component.css'],
13-
animations: [
14-
// Animation example
15-
// Triggered in the ngFor with [@flyInOut]
16-
trigger('flyInOut', [
17-
state('in', style({ transform: 'translateY(0)' })),
18-
transition('void => *', [
19-
style({ transform: 'translateY(-100%)' }),
20-
animate(1000)
21-
]),
22-
transition('* => void', [
23-
animate(1000, style({ transform: 'translateY(100%)' }))
24-
])
25-
])
26-
]
10+
selector: 'app-users',
11+
templateUrl: './users.component.html',
12+
styleUrls: ['./users.component.css'],
13+
animations: [
14+
// Animation example
15+
// Triggered in the ngFor with [@flyInOut]
16+
trigger('flyInOut', [
17+
state('in', style({ transform: 'translateY(0)' })),
18+
transition('void => *', [
19+
style({ transform: 'translateY(-100%)' }),
20+
animate(1000)
21+
]),
22+
transition('* => void', [
23+
animate(1000, style({ transform: 'translateY(100%)' }))
24+
])
25+
])
26+
]
2727
})
2828
export class UsersComponent implements OnInit {
2929

3030
users: IUser[];
3131
selectedUser: IUser;
3232

33-
// Use "constructor"s only for dependency injection
34-
constructor(
35-
private userService: UserService
36-
) { }
33+
// Use "constructor"s only for dependency injection
34+
constructor(
35+
private userService: UserService
36+
) { }
3737

38-
// Here you want to handle anything with @Input()'s @Output()'s
39-
// Data retrieval / etc - this is when the Component is "ready" and wired up
40-
ngOnInit() {
41-
this.userService.getUsers().subscribe(result => {
42-
console.log('HttpClient [GET] /api/users/allresult', result);
43-
this.users = result;
44-
});
45-
}
46-
47-
onSelect(user: IUser): void {
48-
this.selectedUser = user;
49-
}
50-
51-
deleteUser(user) {
52-
this.clearUser();
53-
this.userService.deleteUser(user).subscribe(result => {
54-
console.log('Delete user result: ', result);
55-
let position = this.users.indexOf(user);
56-
this.users.splice(position, 1);
57-
}, error => {
58-
console.log(`There was an issue. ${error._body}.`);
59-
});
60-
}
38+
// Here you want to handle anything with @Input()'s @Output()'s
39+
// Data retrieval / etc - this is when the Component is "ready" and wired up
40+
ngOnInit() {
41+
this.userService.getUsers().subscribe(result => {
42+
console.log('HttpClient [GET] /api/users/allresult', result);
43+
this.users = result;
44+
});
45+
}
6146

62-
onUserUpdate(event) {
63-
this.clearUser();
64-
}
47+
onSelect(user: IUser): void {
48+
this.selectedUser = user;
49+
}
6550

66-
addUser(newUserName) {
67-
this.clearUser();
68-
this.userService.addUser(newUserName).subscribe(result => {
69-
console.log('Post user result: ', result);
70-
this.users.push(result);
71-
}, error => {
72-
console.log(`There was an issue. ${error._body}.`);
73-
});
74-
}
51+
deleteUser(user) {
52+
this.userService.deleteUser(user).subscribe(result => {
53+
console.log('Delete user result: ', result);
54+
let position = this.users.indexOf(user);
55+
this.users.splice(position, 1);
56+
}, error => {
57+
console.log(`There was an issue. ${error._body}.`);
58+
});
59+
}
7560

76-
clearUser() {
77-
if (this.selectedUser) {
78-
this.selectedUser = null;
61+
addUser(newUserName) {
62+
this.userService.addUser(newUserName).subscribe(result => {
63+
console.log('Post user result: ', result);
64+
this.users.push(result);
65+
}, error => {
66+
console.log(`There was an issue. ${error._body}.`);
67+
});
7968
}
8069
}
8170
}

ClientApp/app/shared/user.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { HttpClient } from '@angular/common/http';
33
import { Http, URLSearchParams } from '@angular/http';
44
import { APP_BASE_HREF } from '@angular/common';
5-
import { ORIGIN_URL } from '@nguniversal/aspnetcore-engine/tokens';
5+
import { ORIGIN_URL } from '@nguniversal/aspnetcore-engine';
66
import { IUser } from '../models/User';
77
import { Observable } from 'rxjs/Observable';
88

ClientApp/boot.server.ts

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ enableProdMode();
1111

1212
export default createServerRenderer((params) => {
1313

14+
console.log('server ?');
15+
1416
// Platform-server provider configuration
1517
const setupOptions: IEngineOptions = {
1618
appSelector: '<app-root></app-root>',
@@ -24,6 +26,9 @@ export default createServerRenderer((params) => {
2426

2527
return ngAspnetCoreEngine(setupOptions).then(response => {
2628

29+
// console.log('\n\n\naspnet-engine!!!\n\n\n')
30+
console.log(response)
31+
2732
// Apply your transferData to response.globals
2833
response.globals.transferData = createTransferScript({
2934
someData: 'Transfer this to the client on the window.TRANSFER_CACHE {} object',

README.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# ASP.NET Core 2.0 & Angular 5(+) Advanced Starter - with Server-side prerendering (for Angular SEO)!
1+
# ASP.NET Core 2.0 & Angular 5 (+) advanced starter - with Server-side prerendering (for Angular SEO)!
22

33
## By [DevHelp.Online](http://www.DevHelp.Online)
44

@@ -339,10 +339,6 @@ Well now, your Client-side Angular will take over, and you'll have a fully funct
339339

340340
> When building components in Angular 5 there are a few things to keep in mind.
341341

342-
- Make sure you provide Absolute URLs when calling any APIs. (The server can't understand relative paths, so `/api/whatever` will fail).
343-
344-
- API calls will be ran during a server, and once again during the client render, so make sure you're using transfering data that's important to you so that you don't see a flicker.
345-
346342
- **`window`**, **`document`**, **`navigator`**, and other browser types - _do not exist on the server_ - so using them, or any library that uses them (jQuery for example) will not work. You do have some options, if you truly need some of this functionality:
347343
- If you need to use them, consider limiting them to only your client and wrapping them situationally. You can use the Object injected using the PLATFORM_ID token to check whether the current platform is browser or server.
348344

package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@
1919
"@angular/animations": "^5.0.0",
2020
"@angular/common": "^5.0.0",
2121
"@angular/compiler": "^5.0.0",
22+
"@angular/compiler-cli": "^5.0.0",
2223
"@angular/core": "^5.0.0",
2324
"@angular/forms": "^5.0.0",
2425
"@angular/http": "^5.0.0",
2526
"@angular/platform-browser": "^5.0.0",
2627
"@angular/platform-browser-dynamic": "^5.0.0",
2728
"@angular/platform-server": "^5.0.0",
2829
"@angular/router": "^5.0.0",
29-
"@nguniversal/aspnetcore-engine": "^5.0.0-beta.8",
30-
"@nguniversal/common": "^5.0.0-beta.8",
30+
"@nguniversal/aspnetcore-engine": "^5.0.0-beta.5",
31+
"@nguniversal/common": "^5.0.0-beta.5",
3132
"@ngx-translate/core": "^8.0.0",
3233
"@ngx-translate/http-loader": "^2.0.0",
3334
"@types/node": "^7.0.12",
@@ -59,17 +60,16 @@
5960
"sass-loader": "^6.0.6",
6061
"style-loader": "^0.18.2",
6162
"to-string-loader": "^1.1.5",
62-
"typescript": "~2.5.0",
63+
"typescript": "2.5.3",
6364
"url-loader": "^0.5.7",
6465
"webpack": "^3.6.0",
6566
"webpack-hot-middleware": "^2.19.1",
6667
"webpack-merge": "^4.1.0",
6768
"zone.js": "^0.8.17"
6869
},
6970
"devDependencies": {
70-
"@angular/cli": "^1.7.0-beta.1",
71-
"@angular/compiler-cli": "^5.2.1",
72-
"@ngtools/webpack": "^1.9.0",
71+
"@angular/cli": "^1.5.0",
72+
"@ngtools/webpack": "^1.8.0",
7373
"@types/chai": "^3.4.34",
7474
"@types/jasmine": "^2.5.37",
7575
"chai": "^3.5.0",

webpack.config.js

+8-15
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,13 @@ module.exports = (env) => {
5959
] : [
6060
// new BundleAnalyzerPlugin(),
6161
// Plugins that apply in production builds only
62-
new AngularCompilerPlugin({
63-
mainPath: path.join(__dirname, 'ClientApp/boot.browser.ts'),
64-
tsConfigPath: './tsconfig.json',
65-
entryModule: path.join(__dirname, 'ClientApp/app/app.module.browser#AppModule'),
66-
exclude: ['./**/*.server.ts']
67-
}),
68-
new webpack.optimize.UglifyJsPlugin({
69-
output: {
70-
ascii_only: true,
71-
}
72-
}),
73-
]),
62+
new webpack.optimize.UglifyJsPlugin(),
63+
new AotPlugin({
64+
tsConfigPath: './tsconfig.json',
65+
entryModule: path.join(__dirname, 'ClientApp/app/app.module.browser#AppModule'),
66+
exclude: ['./**/*.server.ts']
67+
})
68+
]),
7469
devtool: isDevBuild ? 'cheap-eval-source-map' : false,
7570
node: {
7671
fs: "empty"
@@ -90,8 +85,7 @@ module.exports = (env) => {
9085
manifest: require('./ClientApp/dist/vendor-manifest.json'),
9186
sourceType: 'commonjs2',
9287
name: './vendor'
93-
})
94-
].concat(isDevBuild ? [
88+
}),
9589
new webpack.ContextReplacementPlugin(
9690
// fixes WARNING Critical dependency: the request of a dependency is an expression
9791
/(.+)?angular(\\|\/)core(.+)?/,
@@ -104,7 +98,6 @@ module.exports = (env) => {
10498
path.join(__dirname, 'src'),
10599
{}
106100
)
107-
] : [
108101
new webpack.optimize.UglifyJsPlugin({
109102
mangle: false,
110103
compress: false,

0 commit comments

Comments
 (0)