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

Templates: (JS/TS) change ' to " #360

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
26 changes: 13 additions & 13 deletions templates/Angular2Spa/ClientApp/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import { UniversalModule } from 'angular2-universal';
import { AppComponent } from './components/app/app.component'
import { NavMenuComponent } from './components/navmenu/navmenu.component';
import { HomeComponent } from './components/home/home.component';
import { FetchDataComponent } from './components/fetchdata/fetchdata.component';
import { CounterComponent } from './components/counter/counter.component';
import { NgModule } from "@angular/core";
import { RouterModule } from "@angular/router";
import { UniversalModule } from "angular2-universal";
import { AppComponent } from "./components/app/app.component";
import { NavMenuComponent } from "./components/navmenu/navmenu.component";
import { HomeComponent } from "./components/home/home.component";
import { FetchDataComponent } from "./components/fetchdata/fetchdata.component";
import { CounterComponent } from "./components/counter/counter.component";

@NgModule({
bootstrap: [ AppComponent ],
Expand All @@ -19,11 +19,11 @@ import { CounterComponent } from './components/counter/counter.component';
imports: [
UniversalModule, // Must be first import. This automatically imports BrowserModule, HttpModule, and JsonpModule too.
RouterModule.forRoot([
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
{ path: 'counter', component: CounterComponent },
{ path: 'fetch-data', component: FetchDataComponent },
{ path: '**', redirectTo: 'home' }
{ path: "", redirectTo: "home", pathMatch: "full" },
{ path: "home", component: HomeComponent },
{ path: "counter", component: CounterComponent },
{ path: "fetch-data", component: FetchDataComponent },
{ path: "**", redirectTo: "home" }
])
]
})
Expand Down
20 changes: 10 additions & 10 deletions templates/Angular2Spa/ClientApp/boot-client.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import 'angular2-universal-polyfills/browser';
import { enableProdMode } from '@angular/core';
import { platformUniversalDynamic } from 'angular2-universal';
import { AppModule } from './app/app.module';
import 'bootstrap';
import "angular2-universal-polyfills/browser";
import { enableProdMode } from "@angular/core";
import { platformUniversalDynamic } from "angular2-universal";
import { AppModule } from "./app/app.module";
import "bootstrap";

// Enable either Hot Module Reloading or production mode
if (module['hot']) {
module['hot'].accept();
module['hot'].dispose(() => { platform.destroy(); });
if (module["hot"]) {
module["hot"].accept();
module["hot"].dispose(() => { platform.destroy(); });
} else {
enableProdMode();
}

// Boot the application, either now or when the DOM content is loaded
const platform = platformUniversalDynamic();
const bootApplication = () => { platform.bootstrapModule(AppModule); };
if (document.readyState === 'complete') {
if (document.readyState === "complete") {
bootApplication();
} else {
document.addEventListener('DOMContentLoaded', bootApplication);
document.addEventListener("DOMContentLoaded", bootApplication);
}
18 changes: 9 additions & 9 deletions templates/Angular2Spa/ClientApp/boot-server.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
import 'angular2-universal-polyfills';
import 'zone.js';
import { enableProdMode } from '@angular/core';
import { platformNodeDynamic } from 'angular2-universal';
import { AppModule } from './app/app.module';
import "angular2-universal-polyfills";
import "zone.js";
import { enableProdMode } from "@angular/core";
import { platformNodeDynamic } from "angular2-universal";
import { AppModule } from "./app/app.module";

enableProdMode();
const platform = platformNodeDynamic();

export default function (params: any) : Promise<{ html: string, globals?: any }> {
export default function (params: any): Promise<{ html: string, globals?: any }> {
return new Promise((resolve, reject) => {
const requestZone = Zone.current.fork({
name: 'angular-universal request',
name: "angular-universal request",
properties: {
baseUrl: '/',
baseUrl: "/",
requestUrl: params.url,
originUrl: params.origin,
preboot: false,
// TODO: Render just the <app> component instead of wrapping it inside an extra HTML document
// Waiting on https://github.com/angular/universal/issues/347
document: '<!DOCTYPE html><html><head></head><body><app></app></body></html>'
document: "<!DOCTYPE html><html><head></head><body><app></app></body></html>"
},
onHandleError: (parentZone, currentZone, targetZone, error) => {
// If any error occurs while rendering the module, reject the whole operation
Expand Down
42 changes: 21 additions & 21 deletions templates/Angular2Spa/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
var isDevBuild = process.argv.indexOf('--env.prod') < 0;
var path = require('path');
var webpack = require('webpack');
var nodeExternals = require('webpack-node-externals');
var merge = require('webpack-merge');
var isDevBuild = process.argv.indexOf("--env.prod") < 0;
var path = require("path");
var webpack = require("webpack");
var nodeExternals = require("webpack-node-externals");
var merge = require("webpack-merge");
var allFilenamesExceptJavaScript = /\.(?!js(\?|$))([^.]+(\?|$))/;

// Configuration in common to both client-side and server-side bundles
var sharedConfig = {
resolve: { extensions: [ '', '.js', '.ts' ] },
resolve: { extensions: [ "", ".js", ".ts" ] },
output: {
filename: '[name].js',
publicPath: '/dist/' // Webpack dev middleware, if enabled, handles requests for this URL prefix
filename: "[name].js",
publicPath: "/dist/" // Webpack dev middleware, if enabled, handles requests for this URL prefix
},
module: {
loaders: [
{ test: /\.ts$/, include: /ClientApp/, loader: 'ts', query: { silent: true } },
{ test: /\.html$/, loader: 'raw' },
{ test: /\.css$/, loader: 'to-string!css' },
{ test: /\.(png|jpg|jpeg|gif|svg)$/, loader: 'url', query: { limit: 25000 } }
{ test: /\.ts$/, include: /ClientApp/, loader: "ts", query: { silent: true } },
{ test: /\.html$/, loader: "raw" },
{ test: /\.css$/, loader: "to-string!css" },
{ test: /\.(png|jpg|jpeg|gif|svg)$/, loader: "url", query: { limit: 25000 } }
]
}
};

// Configuration for client-side bundle suitable for running in browsers
var clientBundleConfig = merge(sharedConfig, {
entry: { 'main-client': './ClientApp/boot-client.ts' },
output: { path: path.join(__dirname, './wwwroot/dist') },
devtool: isDevBuild ? 'inline-source-map' : null,
entry: { "main-client": "./ClientApp/boot-client.ts" },
output: { path: path.join(__dirname, "./wwwroot/dist") },
devtool: isDevBuild ? "inline-source-map" : null,
plugins: [
new webpack.DllReferencePlugin({
context: __dirname,
manifest: require('./wwwroot/dist/vendor-manifest.json')
manifest: require("./wwwroot/dist/vendor-manifest.json")
})
].concat(isDevBuild ? [] : [
// Plugins that apply in production builds only
Expand All @@ -41,13 +41,13 @@ 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/boot-server.ts" },
output: {
libraryTarget: 'commonjs',
path: path.join(__dirname, './ClientApp/dist')
libraryTarget: "commonjs",
path: path.join(__dirname, "./ClientApp/dist")
},
target: 'node',
devtool: 'inline-source-map',
target: "node",
devtool: "inline-source-map",
externals: [nodeExternals({ whitelist: [allFilenamesExceptJavaScript] })] // Don't bundle .js files from node_modules
});

Expand Down
60 changes: 30 additions & 30 deletions templates/Angular2Spa/webpack.config.vendor.js
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
var isDevBuild = process.argv.indexOf('--env.prod') < 0;
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var extractCSS = new ExtractTextPlugin('vendor.css');
var isDevBuild = process.argv.indexOf("--env.prod") < 0;
var path = require("path");
var webpack = require("webpack");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var extractCSS = new ExtractTextPlugin("vendor.css");

module.exports = {
resolve: {
extensions: [ '', '.js' ]
extensions: [ "", ".js" ]
},
module: {
loaders: [
{ test: /\.(png|woff|woff2|eot|ttf|svg)(\?|$)/, loader: 'url-loader?limit=100000' },
{ test: /\.css(\?|$)/, loader: extractCSS.extract(['css']) }
{ test: /\.(png|woff|woff2|eot|ttf|svg)(\?|$)/, loader: "url-loader?limit=100000" },
{ test: /\.css(\?|$)/, loader: extractCSS.extract(["css"]) }
]
},
entry: {
vendor: [
'@angular/common',
'@angular/compiler',
'@angular/core',
'@angular/http',
'@angular/platform-browser',
'@angular/platform-browser-dynamic',
'@angular/router',
'@angular/platform-server',
'angular2-universal',
'angular2-universal-polyfills',
'bootstrap',
'bootstrap/dist/css/bootstrap.css',
'es6-shim',
'es6-promise',
'jquery',
'zone.js',
"@angular/common",
"@angular/compiler",
"@angular/core",
"@angular/http",
"@angular/platform-browser",
"@angular/platform-browser-dynamic",
"@angular/router",
"@angular/platform-server",
"angular2-universal",
"angular2-universal-polyfills",
"bootstrap",
"bootstrap/dist/css/bootstrap.css",
"es6-shim",
"es6-promise",
"jquery",
"zone.js",
]
},
output: {
path: path.join(__dirname, 'wwwroot', 'dist'),
filename: '[name].js',
library: '[name]_[hash]',
path: path.join(__dirname, "wwwroot", "dist"),
filename: "[name].js",
library: "[name]_[hash]",
},
plugins: [
extractCSS,
new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery' }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable)
new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery" }), // Maps these identifiers to the jQuery package (because Bootstrap expects it to be a global variable)
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.DllPlugin({
path: path.join(__dirname, 'wwwroot', 'dist', '[name]-manifest.json'),
name: '[name]_[hash]'
path: path.join(__dirname, "wwwroot", "dist", "[name]-manifest.json"),
name: "[name]_[hash]"
})
].concat(isDevBuild ? [] : [
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } })
Expand Down
12 changes: 6 additions & 6 deletions templates/KnockoutSpa/ClientApp/boot.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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';
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";

// Load and register the <app-root> component
ko.components.register('app-root', AppRootComponent);
ko.components.register("app-root", AppRootComponent);

// Tell Knockout to start up an instance of your application
ko.applyBindings({ history: createHistory() });
Expand Down
26 changes: 13 additions & 13 deletions templates/KnockoutSpa/ClientApp/components/app-root/app-root.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as ko from 'knockout';
import { Route, Router } from '../../router';
import navMenu from '../nav-menu/nav-menu';
import * as ko from "knockout";
import { Route, Router } from "../../router";
import navMenu from "../nav-menu/nav-menu";

// Declare the client-side routing configuration
const routes: Route[] = [
{ url: '', params: { page: 'home-page' } },
{ url: 'counter', params: { page: 'counter-example' } },
{ url: 'fetch-data', params: { page: 'fetch-data' } }
{ url: "", params: { page: "home-page" } },
{ url: "counter", params: { page: "counter-example" } },
{ url: "fetch-data", params: { page: "fetch-data" } }
];

class AppRootViewModel {
Expand All @@ -15,17 +15,17 @@ class AppRootViewModel {

constructor(params: { history: HistoryModule.History }) {
// Activate the client-side router
this._router = new Router(params.history, routes)
this._router = new Router(params.history, routes);
this.route = this._router.currentRoute;

// Load and register all the KO components needed to handle the routes
// The optional 'bundle?lazy!' prefix is a Webpack feature that causes the referenced modules
// The optional "bundle?lazy!" prefix is a Webpack feature that causes the referenced modules
// to be split into separate files that are then loaded on demand.
// For docs, see https://github.com/webpack/bundle-loader
ko.components.register('nav-menu', navMenu);
ko.components.register('home-page', require('bundle?lazy!../home-page/home-page'));
ko.components.register('counter-example', require('bundle?lazy!../counter-example/counter-example'));
ko.components.register('fetch-data', require('bundle?lazy!../fetch-data/fetch-data'));
ko.components.register("nav-menu", navMenu);
ko.components.register("home-page", require("bundle?lazy!../home-page/home-page"));
ko.components.register("counter-example", require("bundle?lazy!../counter-example/counter-example"));
ko.components.register("fetch-data", require("bundle?lazy!../fetch-data/fetch-data"));
}

// To support hot module replacement, this method unregisters the router and KO components.
Expand All @@ -40,4 +40,4 @@ class AppRootViewModel {
}
}

export default { viewModel: AppRootViewModel, template: require('./app-root.html') };
export default { viewModel: AppRootViewModel, template: require("./app-root.html") };
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as ko from 'knockout';
import * as ko from "knockout";

class CounterExampleViewModel {
public currentCount = ko.observable(0);
Expand All @@ -9,4 +9,4 @@ class CounterExampleViewModel {
}
}

export default { viewModel: CounterExampleViewModel, template: require('./counter-example.html') };
export default { viewModel: CounterExampleViewModel, template: require("./counter-example.html") };
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ko from 'knockout';
import 'isomorphic-fetch';
import * as ko from "knockout";
import "isomorphic-fetch";

interface WeatherForecast {
dateFormatted: string;
Expand All @@ -12,12 +12,12 @@ class FetchDataViewModel {
public forecasts = ko.observableArray<WeatherForecast>();

constructor() {
fetch('/api/SampleData/WeatherForecasts')
fetch("/api/SampleData/WeatherForecasts")
.then(response => response.json())
.then((data: WeatherForecast[]) => {
this.forecasts(data);
});
}
}

export default { viewModel: FetchDataViewModel, template: require('./fetch-data.html') };
export default { viewModel: FetchDataViewModel, template: require("./fetch-data.html") };
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as ko from 'knockout';
import * as ko from "knockout";

class HomePageViewModel {
}

export default { viewModel: HomePageViewModel, template: require('./home-page.html') };
export default { viewModel: HomePageViewModel, template: require("./home-page.html") };
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as ko from 'knockout';
import { Route } from '../../router';
import * as ko from "knockout";
import { Route } from "../../router";

interface NavMenuParams {
route: KnockoutObservable<Route>;
Expand All @@ -16,4 +16,4 @@ class NavMenuViewModel {
}
}

export default { viewModel: NavMenuViewModel, template: require('./nav-menu.html') };
export default { viewModel: NavMenuViewModel, template: require("./nav-menu.html") };
Loading