Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Update all projects to TypeScript 2.0 - remove typings - etc #362

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions templates/Angular2Spa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
"name": "Angular2Spa",
"version": "0.0.0",
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0",
"@angular/platform-server": "2.0.0",
"@angular/router": "3.0.0",
"@types/node": "^6.0.38",
"angular2-platform-node": "~2.0.10",
"angular2-universal": "~2.0.10",
"angular2-universal-polyfills": "~2.0.10",
"aspnet-prerendering": "^1.0.6",
"aspnet-webpack": "^1.0.11",
"@angular/common": "2.0.1",
"@angular/compiler": "2.0.1",
"@angular/core": "2.0.1",
"@angular/forms": "2.0.1",
"@angular/http": "2.0.1",
"@angular/platform-browser": "2.0.1",
"@angular/platform-browser-dynamic": "2.0.1",
"@angular/platform-server": "2.0.1",
"@angular/router": "3.0.1",
"@types/node": "^6.0.42",
"angular2-platform-node": "~2.0.11",
"angular2-universal": "~2.0.11",
"angular2-universal-polyfills": "~2.0.11",
"aspnet-prerendering": "^1.0.7",
"aspnet-webpack": "^1.0.17",
"bootstrap": "^3.3.7",
"css": "^2.2.1",
"css-loader": "^0.25.0",
Expand All @@ -29,15 +29,15 @@
"preboot": "^4.5.2",
"raw-loader": "^0.5.1",
"rxjs": "5.0.0-beta.12",
"style-loader": "^0.13.0",
"style-loader": "^0.13.1",
"to-string-loader": "^1.1.5",
"ts-loader": "^0.8.2",
"typescript": "^2.0.0",
"typescript": "^2.0.3",
"url-loader": "^0.5.7",
"webpack": "^1.12.14",
"webpack": "^1.13.2",
"webpack-externals-plugin": "^1.0.0",
"webpack-hot-middleware": "^2.10.0",
"webpack-hot-middleware": "^2.12.2",
"webpack-merge": "^0.14.1",
"zone.js": "^0.6.21"
"zone.js": "^0.6.25"
}
}
4 changes: 2 additions & 2 deletions templates/Angular2Spa/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var sharedConfig = {

// Configuration for client-side bundle suitable for running in browsers
var clientBundleConfig = merge(sharedConfig, {
entry: { 'main-client': './ClientApp/boot-client.ts' },
entry: { 'main-client': './ClientApp/main-client.ts' },
output: { path: path.join(__dirname, './wwwroot/dist') },
devtool: isDevBuild ? 'inline-source-map' : null,
plugins: [
Expand All @@ -41,7 +41,7 @@ var clientBundleConfig = merge(sharedConfig, {

// Configuration for server-side (prerendering) bundle suitable for running in Node
var serverBundleConfig = merge(sharedConfig, {
entry: { 'main-server': './ClientApp/boot-server.ts' },
entry: { 'main-server': './ClientApp/main-server.ts' },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep renaming separate from this PR. Can you revert the names?

Copy link
Contributor Author

@MarkPieszak MarkPieszak Oct 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was breaking since webpack (#363) is looking for a file by that name, want me to change it there instead? @SteveSandersonMS

output: {
libraryTarget: 'commonjs',
path: path.join(__dirname, './ClientApp/dist')
Expand Down
2 changes: 1 addition & 1 deletion templates/KnockoutSpa/ClientApp/boot.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import './css/site.css';
import * as ko from 'knockout';
import { createHistory } from 'history';
import './webpack-component-loader';
import AppRootComponent from './components/app-root/app-root';
var createHistory = require('history').createBrowserHistory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change deliberate? Could you clarify why it would be needed (hopefully it isn't), and if it is, change the var to const and add the semicolon at the end of the line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be back shortly and i'll talk to you about this one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it needs to be updated because when the previous import {} way was done, with the new History, it doesn't call the correct methods and ends up erroring that "createBrowserHistory" doesn't exist. I've tried the other ways suggested on the packages readme (https://github.com/mjackson/history) but only this one works). Updating it to const now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be connected to tsconfig.json "target": "es5". Switching to es6 results in an error with crossroads.


// Load and register the <app-root> component
ko.components.register('app-root', AppRootComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import navMenu from '../nav-menu/nav-menu';

// Declare the client-side routing configuration
const routes: Route[] = [
{ url: '', params: { page: 'home-page' } },
{ url: '/', params: { page: 'home-page' } },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you clarify why this change is needed? If it is (hopefully not), can you make the other lines consistent with it too (i.e., URLs also start with a slash, and make the params line up vertically).

Copy link
Contributor Author

@MarkPieszak MarkPieszak Oct 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an attempt to fix a knockout issue, I can revert this change!
reverted

{ url: 'counter', params: { page: 'counter-example' } },
{ url: 'fetch-data', params: { page: 'fetch-data' } }
];
Expand All @@ -13,7 +13,7 @@ class AppRootViewModel {
public route: KnockoutObservable<Route>;
private _router: Router;

constructor(params: { history: HistoryModule.History }) {
constructor(params: { history: History.History }) {
// Activate the client-side router
this._router = new Router(params.history, routes)
this.route = this._router.currentRoute;
Expand All @@ -40,4 +40,4 @@ class AppRootViewModel {
}
}

export default { viewModel: AppRootViewModel, template: require('./app-root.html') };
export default { viewModel: AppRootViewModel, componentName: 'Home', template: require('./app-root.html') };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure this shouldn't be added. What's the intention here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might of been accidental, Knockout is giving me a minor :
Any idea what that might be? @SteveSandersonMS

Uncaught Error: Unable to process binding 
"component: function (){return { name:route().page,params:route} }"
Message: No component name specified```

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like the URL isn't matching any route, so route() is an empty object, so route().page is undefined, so you're returning nothing for the name of the component.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So when a refresh is done it doesn't load that routed content, but when the link is clicked, it works fine. Any idea what could be causing this?

2 changes: 1 addition & 1 deletion templates/KnockoutSpa/ClientApp/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class Router {
private disposeHistory: () => void;
private clickEventListener: EventListener;

constructor(history: HistoryModule.History, routes: Route[]) {
constructor(history: History.History, routes: Route[]) {
// Reset and configure Crossroads so it matches routes and updates this.currentRoute
crossroads.removeAllRoutes();
crossroads.resetState();
Expand Down
27 changes: 18 additions & 9 deletions templates/KnockoutSpa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,32 @@
"name": "WebApplicationBasic",
"version": "0.0.0",
"devDependencies": {
"aspnet-webpack": "^1.0.6",
"@types/core-js": "^0.9.34",
"@types/crossroads": "0.0.29",
"@types/history": "^2.0.38",
"@types/jquery": "^2.0.32",
"@types/knockout": "^3.4.35",
"@types/react-router": "^2.0.37",
"@types/requirejs": "^2.1.26",
"@types/signals": "0.0.16",
"@types/whatwg-fetch": "0.0.30",
"aspnet-webpack": "^1.0.17",
"bootstrap": "^3.3.6",
"bundle-loader": "^0.5.4",
"crossroads": "^0.12.2",
"css-loader": "^0.23.1",
"css-loader": "^0.25.0",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.8.5",
"history": "^2.0.1",
"file-loader": "^0.9.0",
"history": "^4.3.0",
"isomorphic-fetch": "^2.2.1",
"jquery": "^2.2.1",
"knockout": "^3.4.0",
"raw-loader": "^0.5.1",
"style-loader": "^0.13.0",
"ts-loader": "^0.8.1",
"typescript": "^1.8.2",
"style-loader": "^0.13.1",
"ts-loader": "^0.8.2",
"typescript": "^2.0.3",
"url-loader": "^0.5.7",
"webpack": "^1.12.14",
"webpack-hot-middleware": "^2.10.0"
"webpack": "^1.13.2",
"webpack-hot-middleware": "^2.12.2"
}
}
7 changes: 6 additions & 1 deletion templates/KnockoutSpa/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
"moduleResolution": "node",
"target": "es5",
"sourceMap": true,
"skipDefaultLibCheck": true
"skipDefaultLibCheck": true,
"typeRoots": [ "node_modules/@types" ],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the typeRoots part: (node_modules/@types) is default.
The part where types:[] is set is needed otherwise it won't make them necessary during compilation.

"types": ["core-js", "crossroads", "history", "knockout",
"requirejs", "signals", "whatwg-fetch" ]
},
"compileOnSave": false,
"buildOnSave": false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these two lines really needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are just helpful depending on certain IDE's to disable automatic tsc compilation / etc.
Do you want me to remove them? Just thought they were helpful to ensure webpack handles everything.

Copy link
Contributor

@stephtr stephtr Oct 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are they only in one template and not all? (As far as I know the default value of buildOnSave is already false.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have removed them

"exclude": [
"bin",
"node_modules"
Expand Down
36 changes: 0 additions & 36 deletions templates/KnockoutSpa/tsd.json

This file was deleted.

Loading