Skip to content

Commit 188094d

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 188094d

File tree

10 files changed

+81
-47
lines changed

10 files changed

+81
-47
lines changed

ClientApp/app/app.component.ts

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,30 @@ 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+
<<<<<<< HEAD
3334
// Use "constructor"s only for dependency injection
3435
constructor(
3536
private userService: UserService
@@ -43,11 +44,27 @@ export class UsersComponent implements OnInit {
4344
this.users = result;
4445
});
4546
}
47+
=======
48+
// Use "constructor"s only for dependency injection
49+
constructor(
50+
private userService: UserService
51+
) { }
52+
53+
// Here you want to handle anything with @Input()'s @Output()'s
54+
// Data retrieval / etc - this is when the Component is "ready" and wired up
55+
ngOnInit() {
56+
this.userService.getUsers().subscribe(result => {
57+
console.log('HttpClient [GET] /api/users/allresult', result);
58+
this.users = result;
59+
});
60+
}
61+
>>>>>>> feat(Angular 5.0): update engine-etc for angular 5.0 & Domino (#437)
4662

4763
onSelect(user: IUser): void {
4864
this.selectedUser = user;
4965
}
5066

67+
<<<<<<< HEAD
5168
deleteUser(user) {
5269
this.clearUser();
5370
this.userService.deleteUser(user).subscribe(result => {
@@ -76,6 +93,25 @@ export class UsersComponent implements OnInit {
7693
clearUser() {
7794
if (this.selectedUser) {
7895
this.selectedUser = null;
96+
=======
97+
deleteUser(user) {
98+
this.userService.deleteUser(user).subscribe(result => {
99+
console.log('Delete user result: ', result);
100+
let position = this.users.indexOf(user);
101+
this.users.splice(position, 1);
102+
}, error => {
103+
console.log(`There was an issue. ${error._body}.`);
104+
});
105+
}
106+
107+
addUser(newUserName) {
108+
this.userService.addUser(newUserName).subscribe(result => {
109+
console.log('Post user result: ', result);
110+
this.users.push(result);
111+
}, error => {
112+
console.log(`There was an issue. ${error._body}.`);
113+
});
114+
>>>>>>> feat(Angular 5.0): update engine-etc for angular 5.0 & Domino (#437)
79115
}
80116
}
81117
}

ClientApp/app/shared/user.service.ts

Lines changed: 1 addition & 1 deletion
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
<<<<<<< HEAD
12
# ASP.NET Core 2.0 & Angular 5(+) Advanced Starter - with Server-side prerendering (for Angular SEO)!
3+
=======
4+
# ASP.NET Core 2.0 & Angular 5 (+) advanced starter - with Server-side prerendering (for Angular SEO)!
5+
>>>>>>> feat(Angular 5.0): update engine-etc for angular 5.0 & Domino (#437)
26
37
## By [DevHelp.Online](http://www.DevHelp.Online)
48

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

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

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-
346346
- **`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:
347347
- 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.
348348

package.json

Lines changed: 6 additions & 6 deletions
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

Lines changed: 8 additions & 15 deletions
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)