Skip to content

Commit 706809d

Browse files
committed
fix(build): fix major build and run-time errors
closes #680
1 parent c212c17 commit 706809d

12 files changed

+66
-40
lines changed

ClientApp/app/app.module.server.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { PrebootModule } from 'preboot';
55
import { AppComponent } from './app.component';
66
import { AppModuleShared } from './app.module';
77

8+
import { TransferHttpCacheModule, StateTransferInitializerModule } from '@nguniversal/common';
9+
810
@NgModule({
911
bootstrap: [AppComponent],
1012
imports: [
@@ -13,12 +15,12 @@ import { AppModuleShared } from './app.module';
1315

1416
ServerModule,
1517
PrebootModule.withConfig({ appRoot: 'app-root' }),
16-
NoopAnimationsModule
18+
NoopAnimationsModule,
1719

18-
// HttpTransferCacheModule still needs fixes for 5.0
20+
TransferHttpCacheModule, // still needs fixes for 5.0
1921
// Leave this commented out for now, as it breaks Server-renders
2022
// Looking into fixes for this! - @MarkPieszak
21-
// ServerTransferStateModule // <-- broken for the time-being with ASP.NET
23+
// StateTransferInitializerModule // <-- broken for the time-being with ASP.NET
2224
]
2325
})
2426
export class AppModule {

ClientApp/app/containers/counter/counter.component.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
22
import { CounterComponent } from './counter.component';
33

4+
import {} from 'jasmine';
5+
46
let fixture: ComponentFixture<CounterComponent>;
57

68
describe('Counter component', () => {

ClientApp/boot.browser.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import './polyfills/browser.polyfills';
12
import { enableProdMode } from '@angular/core';
23
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
34
import { AppModule } from './app/app.module.browser';
4-
import './polyfills/browser.polyfills';
55

66
// // Enable either Hot Module Reloading or production mode
77
if (module['hot']) {

ClientApp/boot.server.PRODUCTION.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
import { enableProdMode } from '@angular/core';
2-
import {
3-
createTransferScript,
4-
IEngineOptions,
5-
ngAspnetCoreEngine
6-
} from '@nguniversal/aspnetcore-engine';
7-
import { createServerRenderer } from 'aspnet-prerendering';
8-
import 'zone.js/dist/zone-node';
1+
import 'zone.js/dist/zone-node';
92
import './polyfills/server.polyfills';
3+
import { enableProdMode } from '@angular/core';
4+
import { createServerRenderer } from 'aspnet-prerendering';
105

116
// Grab the (Node) server-specific NgModule
127
const { AppModuleNgFactory } = require('./app/app.module.server.ngfactory'); // <-- ignore this - this is Production only
8+
import { ngAspnetCoreEngine, IEngineOptions, createTransferScript } from '@nguniversal/aspnetcore-engine';
139

1410
enableProdMode();
1511

ClientApp/boot.server.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { enableProdMode } from '@angular/core';
1+
import 'zone.js/dist/zone-node';
2+
import './polyfills/server.polyfills';
3+
4+
import { enableProdMode } from '@angular/core';
25
import { createTransferScript, IEngineOptions, ngAspnetCoreEngine } from '@nguniversal/aspnetcore-engine';
36
import { createServerRenderer } from 'aspnet-prerendering';
4-
import 'zone.js/dist/zone-node';
7+
58
// Grab the (Node) server-specific NgModule
69
import { AppModule } from './app/app.module.server';
7-
import './polyfills/server.polyfills';
8-
910

1011
enableProdMode();
1112

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
// Note: * The order is IMPORTANT! *
2+
3+
import './polyfills.ts';
4+
15
import 'reflect-metadata';
26
import 'zone.js/dist/zone';
3-
import './polyfills.ts';
47

58
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.

ClientApp/polyfills/polyfills.ts

+18-14
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1+
// Note: * The order is IMPORTANT! *
2+
13
/***************************************************************************************************
24
* BROWSER POLYFILLS
35
*/
46

57
/** IE9, IE10 and IE11 requires all of the following polyfills. **/
6-
import 'core-js/es6/array';
7-
import 'core-js/es6/date';
8-
import 'core-js/es6/function';
9-
import 'core-js/es6/map';
10-
import 'core-js/es6/math';
11-
import 'core-js/es6/number';
8+
import 'core-js/es6/symbol';
129
import 'core-js/es6/object';
13-
import 'core-js/es6/parse-float';
10+
import 'core-js/es6/function';
1411
import 'core-js/es6/parse-int';
15-
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
16-
// import 'classlist.js'; // Run `npm install --save classlist.js`.
17-
/** Evergreen browsers require these. **/
18-
import 'core-js/es6/reflect';
12+
import 'core-js/es6/parse-float';
13+
import 'core-js/es6/number';
14+
import 'core-js/es6/math';
15+
import 'core-js/es6/string';
16+
import 'core-js/es6/date';
17+
import 'core-js/es6/array';
1918
import 'core-js/es6/regexp';
19+
import 'core-js/es6/map';
2020
import 'core-js/es6/set';
21-
import 'core-js/es6/string';
22-
import 'core-js/es6/symbol';
23-
import 'core-js/es7/reflect';
21+
2422
/** */
2523
import 'reflect-metadata';
24+
25+
/** IE10 and IE11 requires the following for NgClass support on SVG elements */
26+
// import 'classlist.js'; // Run `npm install --save classlist.js`.
27+
/** Evergreen browsers require these. **/
28+
import 'core-js/es6/reflect';
29+
import 'core-js/es7/reflect';
+3-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
import 'zone.js';
1+
// Note: * The order is IMPORTANT! *
22
import './polyfills.ts';
3+
4+
import 'zone.js';

ClientApp/tsconfig.app.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,9 @@
66
"baseUrl": "",
77
"types": []
88
},
9-
"exclude": ["test.ts", "**/*.spec.ts", "boot.server.PRODUCTION.ts"]
9+
"exclude": [
10+
"test.ts",
11+
"**/*.spec.ts",
12+
"boot.server.PRODUCTION.ts"
13+
]
1014
}

Views/Home/Index.cshtml

+1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
<!-- Our webpack bundle -->
1010
<script src="~/dist/main-client.js" asp-append-version="true"></script>
1111
}
12+
1213
@Html.Raw(ViewData["ServiceWorker"])

package.json

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
{
2-
"name": "angular4-aspnetcore-universal",
3-
"version": "1.0.0-rc3",
2+
"name": "angular6-aspnetcore-universal",
3+
"author": {
4+
"name": "Mark Pieszak",
5+
"email": "hello@devhelp.online",
6+
"url": "http://DevHelp.Online"
7+
},
8+
"version": "1.0.0-rc4",
49
"scripts": {
5-
"clean:install": "npm run clean && rimraf ./node_modules ./bin ./obj ./package-lock.json && dotnet restore && npm i",
10+
"clean:install": "npm run clean && rimraf ./node_modules ./bin ./obj ./package-lock.json && dotnet restore Asp2017.csproj && npm i",
611
"lint": "tslint -p tsconfig.json",
712
"test": "npm run build:vendor && karma start ClientApp/test/karma.conf.js",
813
"test:watch": "npm run test -- --auto-watch --no-single-run",
@@ -92,5 +97,11 @@
9297
"uglifyjs-webpack-plugin": "^1.2.5",
9398
"webpack-bundle-analyzer": "^2.13.1",
9499
"webpack-cli": "^2.1.4"
95-
}
100+
},
101+
"license": "MIT",
102+
"repository": {
103+
"type": "github",
104+
"url": "https://github.com/MarkPieszak/aspnetcore-angular2-universal"
105+
},
106+
"readme": "https://github.com/MarkPieszak/aspnetcore-angular2-universal/blob/master/README.md"
96107
}

webpack.config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module.exports = env => {
3838
module: {
3939
rules: [
4040
{
41-
test: /\.ts$/,
41+
test: /^(?!.*\.spec\.ts$).*\.ts$/,
4242
use: isDevBuild
4343
? [
4444
'awesome-typescript-loader?silent=true',
@@ -99,7 +99,7 @@ module.exports = env => {
9999
// Plugins that apply in production builds only
100100
new AngularCompilerPlugin({
101101
mainPath: path.join(__dirname, 'ClientApp/boot.browser.ts'),
102-
tsConfigPath: './tsconfig.json',
102+
tsConfigPath: './ClientApp/tsconfig.app.json',
103103
entryModule: path.join(
104104
__dirname,
105105
'ClientApp/app/app.module.browser#AppModule'
@@ -174,7 +174,7 @@ module.exports = env => {
174174
__dirname,
175175
'ClientApp/boot.server.PRODUCTION.ts'
176176
),
177-
tsConfigPath: './tsconfig.json',
177+
tsConfigPath: './ClientApp/tsconfig.app.json',
178178
entryModule: path.join(
179179
__dirname,
180180
'ClientApp/app/app.module.server#AppModule'

0 commit comments

Comments
 (0)