Intermediate commit:

- webpack build does not run successfully, typescript errors out, saying
  "TS2304: Cannot find name 'module'." or 'require' or 'process' in
  certain .ts files.
This commit is contained in:
Manuel Friedli 2017-03-14 15:42:11 +01:00
parent d6604351fe
commit be51aab2ee
43 changed files with 213 additions and 53 deletions

5
.gitignore vendored
View file

@ -4,6 +4,7 @@
atlassian-ide-plugin.xml atlassian-ide-plugin.xml
node_modules/ node_modules/
typings/ typings/
app/**/*.js src/**/*.js
app/**/*.js.map src/**/*.js.map
npm-debug.log npm-debug.log
dist/

7
config/helpers.js Normal file
View file

@ -0,0 +1,7 @@
var path = require('path');
var _root = path.resolve(__dirname, '..');
function root(args) {
args = Array.prototype.slice.call(arguments, 0);
return path.join.apply(path, [_root].concat(args));
}
exports.root = root;

76
config/webpack.common.js Normal file
View file

@ -0,0 +1,76 @@
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var helpers = require('./helpers');
module.exports = {
entry: {
'polyfills': './src/polyfills.ts',
'vendor': './src/vendor.ts',
'app': './src/main.ts'
},
resolve: {
extensions: ['.ts', '.js']
},
module: {
rules: [
{
test: /\.ts$/,
loaders: [
{
loader: 'awesome-typescript-loader',
options: {
configFileName: helpers.root('src', 'tsconfig.json')
}
},
'angular2-template-loader'
]
},
{
test: /\.html$/,
use: 'html-loader'
},
{
test: /\.(png|jpe?g|gif|svg|woff|woff2|ttf|eot|ico)$/,
use: 'file-loader?name=assets/[name].[hash].[ext]'
},
// {
// test: /\.css$/,
// exclude: helpers.root('src', 'app'),
// use: ExtractTextPlugin.extract({
// fallback: 'style-loader',
// use: 'css-loader?sourceMap'
// })
// },
{
test: /\.css$/,
include: helpers.root('src', 'app'),
use: 'raw-loader'
}
]
},
plugins: [
// Workaround for angular/angular#11580
new webpack.ContextReplacementPlugin(
// The (\\|\/) piece accounts for path separators in *nix and Windows
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
helpers.root('./src'), // location of your src
{} // a map of your routes
),
new webpack.optimize.CommonsChunkPlugin({
name: ['app', 'vendor', 'polyfills']
}),
new HtmlWebpackPlugin({
template: 'src/index.html'
}),
new webpack.optimize.UglifyJsPlugin({
comments: false
})
]
};

24
config/webpack.dev.js Normal file
View file

@ -0,0 +1,24 @@
var webpackMerge = require('webpack-merge');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var commonConfig = require('./webpack.common.js');
var helpers = require('./helpers');
module.exports = webpackMerge(commonConfig, {
devtool: 'cheap-module-eval-source-map',
output: {
path: helpers.root('dist'),
publicPath: 'http://localhost:8080/',
filename: '[name].js',
chunkFilename: '[id].chunk.js'
},
plugins: [
new ExtractTextPlugin('[name].css')
],
devServer: {
historyApiFallback: true,
stats: 'minimal'
}
});

1
karma.conf.js Normal file
View file

@ -0,0 +1 @@
module.exports = require('./config/karma.conf.js');

View file

@ -3,7 +3,10 @@
"version": "1.0.0-alpha.1", "version": "1.0.0-alpha.1",
"description": "Convert to and fro!", "description": "Convert to and fro!",
"keywords": [ "keywords": [
"dencode", "conversion", "converter", "convert" "dencode",
"conversion",
"converter",
"convert"
], ],
"author": { "author": {
"name": "Manuel Friedli", "name": "Manuel Friedli",
@ -13,35 +16,48 @@
"homepage": "https://test.friedli.info/~manuel/dencode", "homepage": "https://test.friedli.info/~manuel/dencode",
"repository": "https://gittr.ch/manuel/dencode.org.git", "repository": "https://gittr.ch/manuel/dencode.org.git",
"dependencies": { "dependencies": {
"@angular/common": "2.0.0", "@angular/common": "~2.4.0",
"@angular/compiler": "2.0.0", "@angular/compiler": "~2.4.0",
"@angular/core": "2.0.0", "@angular/core": "~2.4.0",
"@angular/forms": "2.0.0", "@angular/forms": "~2.4.0",
"@angular/platform-browser": "2.0.0", "@angular/platform-browser": "~2.4.0",
"@angular/platform-browser-dynamic": "2.0.0", "@angular/platform-browser-dynamic": "~2.4.0",
"@angular/upgrade": "2.0.0", "core-js": "^2.4.1",
"bootstrap": "^3.3.6", "rxjs": "5.0.1",
"core-js": "^2.4.0", "zone.js": "^0.7.4",
"reflect-metadata": "^0.1.3", "bootstrap": "^3.3.0",
"rxjs": "5.0.0-beta.12",
"systemjs": "^0.19.27",
"zone.js": "^0.6.12",
"quoted-printable": "^1.0.0", "quoted-printable": "^1.0.0",
"utf8": "^2.1.1", "utf8": "^2.1.0",
"punycode": "1.4.1" "punycode": "^1.4.0"
}, },
"devDependencies": { "devDependencies": {
"concurrently": "^2.2.0", "@types/node": "^6.0.45",
"lite-server": "^2.2.0", "@types/jasmine": "2.5.36",
"typescript": "^2.0.2", "angular2-template-loader": "^0.6.0",
"typings": "^1.3.2" "awesome-typescript-loader": "^3.0.4",
"css-loader": "^0.26.1",
"extract-text-webpack-plugin": "2.0.0-beta.5",
"file-loader": "^0.9.0",
"html-loader": "^0.4.3",
"html-webpack-plugin": "^2.16.1",
"jasmine-core": "^2.4.1",
"karma": "^1.2.0",
"karma-chrome-launcher": "^2.0.0",
"karma-jasmine": "^1.0.2",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.1",
"null-loader": "^0.1.1",
"raw-loader": "^0.5.1",
"rimraf": "^2.5.2",
"style-loader": "^0.13.1",
"typescript": "~2.0.10",
"webpack": "2.2.1",
"webpack-dev-server": "2.4.1",
"webpack-merge": "^3.0.0"
}, },
"scripts": { "scripts": {
"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\"", "start": "webpack-dev-server --inline --progress --port 8080",
"lite": "lite-server", "test": "karma start",
"postinstall": "typings install", "build": "rimraf dist && webpack --config config/webpack.prod.js --progress --profile --bail"
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings"
} }
} }

View file

@ -1,4 +1,5 @@
import {Converter} from "./converter"; import {Converter} from "./converter";
export class BinToDecConverter implements Converter { export class BinToDecConverter implements Converter {
getDisplayname():string { getDisplayname():string {
return "Convert binary to decimal"; return "Convert binary to decimal";

View file

@ -1,4 +1,5 @@
import {Converter} from "./converter"; import {Converter} from "./converter";
export class DecToBinConverter implements Converter { export class DecToBinConverter implements Converter {
getDisplayname():string { getDisplayname():string {
return "Convert decimal to binary"; return "Convert decimal to binary";

View file

@ -1,4 +1,5 @@
import {Converter} from "./converter"; import {Converter} from "./converter";
export class DecToHexConverter implements Converter { export class DecToHexConverter implements Converter {
getDisplayname():string { getDisplayname():string {
return "Convert decimal to hexadecimal"; return "Convert decimal to hexadecimal";

View file

@ -1,4 +1,5 @@
import {Converter} from "./converter"; import {Converter} from "./converter";
export class HexToDecConverter implements Converter { export class HexToDecConverter implements Converter {
getDisplayname():string { getDisplayname():string {
return "Convert hexadecimal to decimal"; return "Convert hexadecimal to decimal";

View file

@ -1,4 +1,5 @@
import {Converter} from "./converter/converter"; import {Converter} from "./converter/converter";
export class Step { export class Step {
public content:string = ""; public content:string = "";
public selectedConverter:Converter = undefined; public selectedConverter:Converter = undefined;

View file

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 75 KiB

View file

@ -1,23 +1,27 @@
<!DOCTYPE html> <!DOCTYPE html>
<!--
~ Copyright (C) Schweizerische Bundesbahnen SBB, 2017.
-->
<html> <html>
<head> <head>
<meta charset="UTF-8"/> <meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/> <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/>
<title>Decode? Encode? DENcode!</title> <title>Decode? Encode? DENcode!</title>
<script type="text/javascript" src="node_modules/core-js/client/shim.js"></script> <!--<script type="text/javascript" src="node_modules/core-js/client/shim.js"></script>-->
<script type="text/javascript" src="node_modules/zone.js/dist/zone.js"></script> <!--<script type="text/javascript" src="node_modules/zone.js/dist/zone.js"></script>-->
<script type="text/javascript" src="node_modules/reflect-metadata/Reflect.js"></script> <!--<script type="text/javascript" src="node_modules/reflect-metadata/Reflect.js"></script>-->
<script type="text/javascript" src="node_modules/systemjs/dist/system.src.js"></script> <!--<script type="text/javascript" src="node_modules/systemjs/dist/system.src.js"></script>-->
<script type="text/javascript" src="node_modules/utf8/utf8.js"></script> <!--<script type="text/javascript" src="node_modules/utf8/utf8.js"></script>-->
<script type="text/javascript" src="node_modules/quoted-printable/quoted-printable.js"></script> <!--<script type="text/javascript" src="node_modules/quoted-printable/quoted-printable.js"></script>-->
<script type="text/javascript" src="node_modules/punycode/punycode.js"></script> <!--<script type="text/javascript" src="node_modules/punycode/punycode.js"></script>-->
<script type="text/javascript" src="systemjs.config.js"></script> <!--<script type="text/javascript" src="systemjs.config.js"></script>-->
<script type="text/javascript"> <!--<script type="text/javascript">-->
System.import("app").catch(function (err) { <!--System.import("app").catch(function (err) {-->
console.log(err); <!--console.log(err);-->
}); <!--});-->
</script> <!--</script>-->
<style> <style>
@font-face { @font-face {
font-family: "ABeeZee"; font-family: "ABeeZee";

View file

@ -1,4 +1,4 @@
import {platformBrowserDynamic} from "@angular/platform-browser-dynamic"; import {platformBrowserDynamic} from "@angular/platform-browser-dynamic";
import {AppModule} from "./app.module"; import {AppModule} from "./app/app.module";
platformBrowserDynamic().bootstrapModule(AppModule); platformBrowserDynamic().bootstrapModule(AppModule);

12
src/polyfills.ts Normal file
View file

@ -0,0 +1,12 @@
import "core-js/es6";
import "core-js/es7/reflect";
import "zone.js/dist/zone";
require('zone.js/dist/zone');
if (process.env.ENV === 'production') {
// Production
} else {
// Development and test
Error['stackTraceLimit'] = Infinity;
require('zone.js/dist/long-stack-trace-zone');
}

View file

@ -1,12 +1,17 @@
{ {
"compilerOptions": { "compilerOptions": {
"alwaysStrict": true,
"target": "es5", "target": "es5",
"module": "commonjs", "module": "commonjs",
"moduleResolution": "node", "moduleResolution": "node",
"sourceMap": true, "sourceMap": true,
"emitDecoratorMetadata": true, "emitDecoratorMetadata": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"removeComments": false, "lib": [
"noImplicitAny": false "es2015",
"dom"
],
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
} }
} }

17
src/vendor.ts Normal file
View file

@ -0,0 +1,17 @@
import "@angular/core";
import "@angular/platform-browser";
import "@angular/platform-browser-dynamic";
import "@angular/forms";
// import {Component, Injectable, NgModule, OnInit} from "@angular/core";
// import {BrowserModule} from "@angular/platform-browser";
// import {platformBrowserDynamic} from "@angular/platform-browser-dynamic";
// import {FormsModule} from "@angular/forms";
// // Angular
// import '@angular/platform-browser-dynamic';
// import '@angular/common';
// import '@angular/http';
// import '@angular/router';
//
// // RxJS
// import 'rxjs';

View file

@ -1,9 +0,0 @@
{
"name": "dencode.org",
"dependencies": {},
"globalDependencies": {
"core-js": "registry:dt/core-js#0.0.0+20160914114559",
"jasmine": "registry:dt/jasmine#2.2.0+20160621224255",
"node": "registry:dt/node#6.0.0+20160915134512"
}
}

1
webpack.config.js Normal file
View file

@ -0,0 +1 @@
module.exports = require('./config/webpack.dev.js');