Client: add basic aot support
This commit is contained in:
parent
80deae8d19
commit
c16ce1de8e
|
@ -1,2 +1,4 @@
|
||||||
/dist/
|
/dist/
|
||||||
/node_modules
|
/node_modules
|
||||||
|
/compiled
|
||||||
|
/stats.json
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
module.exports = {
|
||||||
|
NgProbeToken: {},
|
||||||
|
HmrState: function () {},
|
||||||
|
_createConditionalRootRenderer: function (rootRenderer, extraTokens, coreTokens) {
|
||||||
|
return rootRenderer
|
||||||
|
},
|
||||||
|
__platform_browser_private__: {}
|
||||||
|
}
|
|
@ -1,13 +1,17 @@
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
|
||||||
|
// Helper functions
|
||||||
const ROOT = path.resolve(__dirname, '..')
|
const ROOT = path.resolve(__dirname, '..')
|
||||||
|
const EVENT = process.env.npm_lifecycle_event || ''
|
||||||
console.log('root directory:', root() + '\n')
|
|
||||||
|
|
||||||
function hasProcessFlag (flag) {
|
function hasProcessFlag (flag) {
|
||||||
return process.argv.join('').indexOf(flag) > -1
|
return process.argv.join('').indexOf(flag) > -1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hasNpmFlag (flag) {
|
||||||
|
return EVENT.includes(flag)
|
||||||
|
}
|
||||||
|
|
||||||
function isWebpackDevServer () {
|
function isWebpackDevServer () {
|
||||||
return process.argv[1] && !!(/webpack-dev-server$/.exec(process.argv[1]))
|
return process.argv[1] && !!(/webpack-dev-server$/.exec(process.argv[1]))
|
||||||
}
|
}
|
||||||
|
@ -18,5 +22,6 @@ function root (args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.hasProcessFlag = hasProcessFlag
|
exports.hasProcessFlag = hasProcessFlag
|
||||||
|
exports.hasNpmFlag = hasNpmFlag
|
||||||
exports.isWebpackDevServer = isWebpackDevServer
|
exports.isWebpackDevServer = isWebpackDevServer
|
||||||
exports.root = root
|
exports.root = root
|
||||||
|
|
|
@ -1,17 +1,20 @@
|
||||||
const webpack = require('webpack')
|
|
||||||
const helpers = require('./helpers')
|
const helpers = require('./helpers')
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Webpack Plugins
|
* Webpack Plugins
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
|
||||||
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
|
||||||
const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin
|
|
||||||
const AssetsPlugin = require('assets-webpack-plugin')
|
const AssetsPlugin = require('assets-webpack-plugin')
|
||||||
|
const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin')
|
||||||
const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin')
|
const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin')
|
||||||
|
const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin')
|
||||||
|
const CopyWebpackPlugin = require('copy-webpack-plugin')
|
||||||
|
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin
|
||||||
|
const HtmlWebpackPlugin = require('html-webpack-plugin')
|
||||||
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin')
|
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin')
|
||||||
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin')
|
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin')
|
||||||
|
const ngcWebpack = require('ngc-webpack')
|
||||||
|
|
||||||
const WebpackNotifierPlugin = require('webpack-notifier')
|
const WebpackNotifierPlugin = require('webpack-notifier')
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -29,7 +32,8 @@ const METADATA = {
|
||||||
* See: http://webpack.github.io/docs/configuration.html#cli
|
* See: http://webpack.github.io/docs/configuration.html#cli
|
||||||
*/
|
*/
|
||||||
module.exports = function (options) {
|
module.exports = function (options) {
|
||||||
var isProd = options.env === 'production'
|
const isProd = options.env === 'production'
|
||||||
|
const AOT = isProd
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
||||||
|
@ -49,9 +53,10 @@ module.exports = function (options) {
|
||||||
* See: http://webpack.github.io/docs/configuration.html#entry
|
* See: http://webpack.github.io/docs/configuration.html#entry
|
||||||
*/
|
*/
|
||||||
entry: {
|
entry: {
|
||||||
'polyfills': './src/polyfills.ts',
|
'polyfills': './src/polyfills.browser.ts',
|
||||||
'vendor': './src/vendor.ts',
|
'main': AOT
|
||||||
'main': './src/main.ts'
|
? './src/main.browser.aot.ts'
|
||||||
|
: './src/main.browser.ts'
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -67,7 +72,7 @@ module.exports = function (options) {
|
||||||
*/
|
*/
|
||||||
extensions: [ '.ts', '.js', '.json', '.scss' ],
|
extensions: [ '.ts', '.js', '.json', '.scss' ],
|
||||||
|
|
||||||
modules: [helpers.root('src'), 'node_modules'],
|
modules: [ helpers.root('src'), helpers.root('node_modules') ],
|
||||||
|
|
||||||
alias: {
|
alias: {
|
||||||
'video.js': 'video.js/dist/alt/video.novtt'
|
'video.js': 'video.js/dist/alt/video.novtt'
|
||||||
|
@ -90,10 +95,18 @@ module.exports = function (options) {
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
test: /\.ts$/,
|
test: /\.ts$/,
|
||||||
loaders: [
|
use: [
|
||||||
'@angularclass/hmr-loader?pretty=' + !isProd + '&prod=' + isProd,
|
'@angularclass/hmr-loader?pretty=' + !isProd + '&prod=' + isProd,
|
||||||
'awesome-typescript-loader',
|
'awesome-typescript-loader?{configFileName: "tsconfig.webpack.json"}',
|
||||||
'angular2-template-loader'
|
'angular2-template-loader',
|
||||||
|
{
|
||||||
|
loader: 'ng-router-loader',
|
||||||
|
options: {
|
||||||
|
loader: 'async-system',
|
||||||
|
genDir: 'compiled',
|
||||||
|
aot: AOT
|
||||||
|
}
|
||||||
|
}
|
||||||
],
|
],
|
||||||
exclude: [/\.(spec|e2e)\.ts$/]
|
exclude: [/\.(spec|e2e)\.ts$/]
|
||||||
},
|
},
|
||||||
|
@ -110,10 +123,11 @@ module.exports = function (options) {
|
||||||
|
|
||||||
{
|
{
|
||||||
test: /\.(sass|scss)$/,
|
test: /\.(sass|scss)$/,
|
||||||
loaders: ['css-to-string-loader', 'css-loader?sourceMap', 'resolve-url', 'sass-loader?sourceMap']
|
use: ['css-to-string-loader', 'css-loader?sourceMap', 'resolve-url-loader', 'sass-loader?sourceMap'],
|
||||||
|
exclude: [ helpers.root('src', 'styles') ]
|
||||||
},
|
},
|
||||||
{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url?limit=10000&minetype=application/font-woff' },
|
{ test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, use: 'url-loader?limit=10000&minetype=application/font-woff' },
|
||||||
{ test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'file' },
|
{ test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, use: 'file-loader' },
|
||||||
|
|
||||||
/* Raw loader support for *.html
|
/* Raw loader support for *.html
|
||||||
* Returns file content as string
|
* Returns file content as string
|
||||||
|
@ -148,7 +162,7 @@ module.exports = function (options) {
|
||||||
*
|
*
|
||||||
* See: https://github.com/s-panferov/awesome-typescript-loader#forkchecker-boolean-defaultfalse
|
* See: https://github.com/s-panferov/awesome-typescript-loader#forkchecker-boolean-defaultfalse
|
||||||
*/
|
*/
|
||||||
new ForkCheckerPlugin(),
|
new CheckerPlugin(),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Plugin: CommonsChunkPlugin
|
* Plugin: CommonsChunkPlugin
|
||||||
|
@ -158,8 +172,21 @@ module.exports = function (options) {
|
||||||
* See: https://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin
|
* See: https://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin
|
||||||
* See: https://github.com/webpack/docs/wiki/optimization#multi-page-app
|
* See: https://github.com/webpack/docs/wiki/optimization#multi-page-app
|
||||||
*/
|
*/
|
||||||
new webpack.optimize.CommonsChunkPlugin({
|
new CommonsChunkPlugin({
|
||||||
name: [ 'polyfills', 'vendor' ].reverse()
|
name: 'polyfills',
|
||||||
|
chunks: ['polyfills']
|
||||||
|
}),
|
||||||
|
|
||||||
|
// This enables tree shaking of the vendor modules
|
||||||
|
new CommonsChunkPlugin({
|
||||||
|
name: 'vendor',
|
||||||
|
chunks: ['main'],
|
||||||
|
minChunks: module => /node_modules\//.test(module.resource)
|
||||||
|
}),
|
||||||
|
|
||||||
|
// Specify the correct order the scripts will be injected in
|
||||||
|
new CommonsChunkPlugin({
|
||||||
|
name: ['polyfills', 'vendor'].reverse()
|
||||||
}),
|
}),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -171,8 +198,11 @@ module.exports = function (options) {
|
||||||
*/
|
*/
|
||||||
new ContextReplacementPlugin(
|
new ContextReplacementPlugin(
|
||||||
// The (\\|\/) piece accounts for path separators in *nix and Windows
|
// The (\\|\/) piece accounts for path separators in *nix and Windows
|
||||||
/angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/,
|
/angular(\\|\/)core(\\|\/)src(\\|\/)linker/,
|
||||||
helpers.root('src') // location of your src
|
helpers.root('src'), // location of your src
|
||||||
|
{
|
||||||
|
// your Angular Async Route paths relative to this root directory
|
||||||
|
}
|
||||||
),
|
),
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -255,6 +285,34 @@ module.exports = function (options) {
|
||||||
precision: 10
|
precision: 10
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
|
// Fix Angular 2
|
||||||
|
new NormalModuleReplacementPlugin(
|
||||||
|
/facade(\\|\/)async/,
|
||||||
|
helpers.root('node_modules/@angular/core/src/facade/async.js')
|
||||||
|
),
|
||||||
|
new NormalModuleReplacementPlugin(
|
||||||
|
/facade(\\|\/)collection/,
|
||||||
|
helpers.root('node_modules/@angular/core/src/facade/collection.js')
|
||||||
|
),
|
||||||
|
new NormalModuleReplacementPlugin(
|
||||||
|
/facade(\\|\/)errors/,
|
||||||
|
helpers.root('node_modules/@angular/core/src/facade/errors.js')
|
||||||
|
),
|
||||||
|
new NormalModuleReplacementPlugin(
|
||||||
|
/facade(\\|\/)lang/,
|
||||||
|
helpers.root('node_modules/@angular/core/src/facade/lang.js')
|
||||||
|
),
|
||||||
|
new NormalModuleReplacementPlugin(
|
||||||
|
/facade(\\|\/)math/,
|
||||||
|
helpers.root('node_modules/@angular/core/src/facade/math.js')
|
||||||
|
),
|
||||||
|
|
||||||
|
new ngcWebpack.NgcWebpackPlugin({
|
||||||
|
disabled: !AOT,
|
||||||
|
tsConfig: helpers.root('tsconfig.webpack.json'),
|
||||||
|
resourceOverride: helpers.root('config/resource-override.js')
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
|
|
||||||
|
@ -270,7 +328,9 @@ module.exports = function (options) {
|
||||||
process: true,
|
process: true,
|
||||||
module: false,
|
module: false,
|
||||||
clearImmediate: false,
|
clearImmediate: false,
|
||||||
setImmediate: false
|
setImmediate: false,
|
||||||
|
setInterval: false,
|
||||||
|
setTimeout: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const helpers = require('./helpers')
|
const helpers = require('./helpers')
|
||||||
const webpackMerge = require('webpack-merge') // used to merge webpack configs
|
const webpackMerge = require('webpack-merge') // used to merge webpack configs
|
||||||
const commonConfig = require('./webpack.common.js') // the settings that are common to prod and dev
|
const commonConfig = require('./webpack.common.js') // the settings that are common to prod and dev
|
||||||
|
const path = require('path')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Webpack Plugins
|
* Webpack Plugins
|
||||||
|
@ -29,7 +30,7 @@ const METADATA = webpackMerge(commonConfig({env: ENV}).metadata, {
|
||||||
* See: http://webpack.github.io/docs/configuration.html#cli
|
* See: http://webpack.github.io/docs/configuration.html#cli
|
||||||
*/
|
*/
|
||||||
module.exports = function (env) {
|
module.exports = function (env) {
|
||||||
return webpackMerge(commonConfig({env: ENV}), {
|
return webpackMerge(commonConfig({ env: ENV }), {
|
||||||
/**
|
/**
|
||||||
* Developer tool to enhance debugging
|
* Developer tool to enhance debugging
|
||||||
*
|
*
|
||||||
|
|
|
@ -9,14 +9,15 @@ const commonConfig = require('./webpack.common.js') // the settings that are com
|
||||||
/**
|
/**
|
||||||
* Webpack Plugins
|
* Webpack Plugins
|
||||||
*/
|
*/
|
||||||
// const ProvidePlugin = require('webpack/lib/ProvidePlugin')
|
|
||||||
const DefinePlugin = require('webpack/lib/DefinePlugin')
|
const DefinePlugin = require('webpack/lib/DefinePlugin')
|
||||||
const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin')
|
const ExtractTextPlugin = require('extract-text-webpack-plugin')
|
||||||
|
const IgnorePlugin = require('webpack/lib/IgnorePlugin')
|
||||||
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin')
|
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin')
|
||||||
// const IgnorePlugin = require('webpack/lib/IgnorePlugin')
|
const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin')
|
||||||
// const DedupePlugin = require('webpack/lib/optimize/DedupePlugin')
|
const ProvidePlugin = require('webpack/lib/ProvidePlugin')
|
||||||
const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin')
|
const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin')
|
||||||
const WebpackMd5Hash = require('webpack-md5-hash')
|
const WebpackMd5Hash = require('webpack-md5-hash')
|
||||||
|
const V8LazyParseWebpackPlugin = require('v8-lazy-parse-webpack-plugin')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Webpack Constants
|
* Webpack Constants
|
||||||
|
@ -154,22 +155,67 @@ module.exports = function (env) {
|
||||||
// comments: true, //debug
|
// comments: true, //debug
|
||||||
|
|
||||||
beautify: false, // prod
|
beautify: false, // prod
|
||||||
|
output: {
|
||||||
|
comments: false
|
||||||
|
}, // prod
|
||||||
mangle: {
|
mangle: {
|
||||||
screw_ie8: true,
|
screw_ie8: true
|
||||||
keep_fnames: true
|
|
||||||
}, // prod
|
}, // prod
|
||||||
compress: {
|
compress: {
|
||||||
screw_ie8: true,
|
screw_ie8: true,
|
||||||
warnings: false
|
warnings: false,
|
||||||
}, // prod
|
conditionals: true,
|
||||||
comments: false // prod
|
unused: true,
|
||||||
|
comparisons: true,
|
||||||
|
sequences: true,
|
||||||
|
dead_code: true,
|
||||||
|
evaluate: true,
|
||||||
|
if_return: true,
|
||||||
|
join_vars: true,
|
||||||
|
negate_iife: false // we need this for lazy v8
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
new NormalModuleReplacementPlugin(
|
new NormalModuleReplacementPlugin(
|
||||||
/angular2-hmr/,
|
/angular2-hmr/,
|
||||||
helpers.root('config/modules/angular2-hmr-prod.js')
|
helpers.root('config/empty.js')
|
||||||
),
|
),
|
||||||
|
|
||||||
|
new NormalModuleReplacementPlugin(
|
||||||
|
/zone\.js(\\|\/)dist(\\|\/)long-stack-trace-zone/,
|
||||||
|
helpers.root('config/empty.js')
|
||||||
|
),
|
||||||
|
|
||||||
|
// AoT
|
||||||
|
// new NormalModuleReplacementPlugin(
|
||||||
|
// /@angular(\\|\/)upgrade/,
|
||||||
|
// helpers.root('config/empty.js')
|
||||||
|
// ),
|
||||||
|
// new NormalModuleReplacementPlugin(
|
||||||
|
// /@angular(\\|\/)compiler/,
|
||||||
|
// helpers.root('config/empty.js')
|
||||||
|
// ),
|
||||||
|
// new NormalModuleReplacementPlugin(
|
||||||
|
// /@angular(\\|\/)platform-browser-dynamic/,
|
||||||
|
// helpers.root('config/empty.js')
|
||||||
|
// ),
|
||||||
|
// new NormalModuleReplacementPlugin(
|
||||||
|
// /dom(\\|\/)debug(\\|\/)ng_probe/,
|
||||||
|
// helpers.root('config/empty.js')
|
||||||
|
// ),
|
||||||
|
// new NormalModuleReplacementPlugin(
|
||||||
|
// /dom(\\|\/)debug(\\|\/)by/,
|
||||||
|
// helpers.root('config/empty.js')
|
||||||
|
// ),
|
||||||
|
// new NormalModuleReplacementPlugin(
|
||||||
|
// /src(\\|\/)debug(\\|\/)debug_node/,
|
||||||
|
// helpers.root('config/empty.js')
|
||||||
|
// ),
|
||||||
|
// new NormalModuleReplacementPlugin(
|
||||||
|
// /src(\\|\/)debug(\\|\/)debug_renderer/,
|
||||||
|
// helpers.root('config/empty.js')
|
||||||
|
// ),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin: IgnorePlugin
|
* Plugin: IgnorePlugin
|
||||||
* Description: Don’t generate modules for requests matching the provided RegExp.
|
* Description: Don’t generate modules for requests matching the provided RegExp.
|
||||||
|
@ -228,7 +274,7 @@ module.exports = function (env) {
|
||||||
[/\*/, /(?:)/],
|
[/\*/, /(?:)/],
|
||||||
[/\[?\(?/, /(?:)/]
|
[/\[?\(?/, /(?:)/]
|
||||||
],
|
],
|
||||||
customAttrAssign: [/\)?]?=/]
|
customAttrAssign: [/\)?\]?=/]
|
||||||
},
|
},
|
||||||
|
|
||||||
// FIXME: Remove
|
// FIXME: Remove
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular/common": "~2.4.1",
|
"@angular/common": "~2.4.1",
|
||||||
"@angular/compiler": "~2.4.1",
|
"@angular/compiler": "~2.4.1",
|
||||||
|
"@angular/compiler-cli": "^2.4.3",
|
||||||
"@angular/core": "~2.4.1",
|
"@angular/core": "~2.4.1",
|
||||||
"@angular/forms": "~2.4.1",
|
"@angular/forms": "~2.4.1",
|
||||||
"@angular/http": "~2.4.1",
|
"@angular/http": "~2.4.1",
|
||||||
|
@ -33,12 +34,13 @@
|
||||||
"@types/source-map": "^0.1.26",
|
"@types/source-map": "^0.1.26",
|
||||||
"@types/uglify-js": "^2.0.27",
|
"@types/uglify-js": "^2.0.27",
|
||||||
"@types/videojs": "0.0.30",
|
"@types/videojs": "0.0.30",
|
||||||
"@types/webpack": "^1.12.29",
|
"@types/webpack": "^2.0.0",
|
||||||
"angular-pipes": "^5.0.0",
|
"angular-pipes": "^5.0.0",
|
||||||
"angular2-template-loader": "^0.6.0",
|
"angular2-template-loader": "^0.6.0",
|
||||||
"assets-webpack-plugin": "^3.4.0",
|
"assets-webpack-plugin": "^3.4.0",
|
||||||
"awesome-typescript-loader": "^2.2.1",
|
"awesome-typescript-loader": "~3.0.0-beta.17",
|
||||||
"bootstrap-loader": "^2.0.0-beta.11",
|
"bootstrap": "^3.3.6",
|
||||||
|
"bootstrap-loader": "2.0.0-beta.18",
|
||||||
"bootstrap-sass": "^3.3.6",
|
"bootstrap-sass": "^3.3.6",
|
||||||
"copy-webpack-plugin": "^4.0.0",
|
"copy-webpack-plugin": "^4.0.0",
|
||||||
"core-js": "^2.4.1",
|
"core-js": "^2.4.1",
|
||||||
|
@ -52,9 +54,11 @@
|
||||||
"intl": "^1.2.4",
|
"intl": "^1.2.4",
|
||||||
"json-loader": "^0.5.4",
|
"json-loader": "^0.5.4",
|
||||||
"ng2-bootstrap": "1.1.16-10",
|
"ng2-bootstrap": "1.1.16-10",
|
||||||
"ng2-file-upload": "^1.1.0",
|
"ng2-file-upload": "^1.1.4-2",
|
||||||
"ng2-meta": "^2.0.0",
|
"ng2-meta": "^2.0.0",
|
||||||
"node-sass": "^3.10.0",
|
"ng-router-loader": "^1.0.2",
|
||||||
|
"ngc-webpack": "^1.1.0",
|
||||||
|
"node-sass": "^4.1.1",
|
||||||
"normalize.css": "^5.0.0",
|
"normalize.css": "^5.0.0",
|
||||||
"raw-loader": "^0.5.1",
|
"raw-loader": "^0.5.1",
|
||||||
"reflect-metadata": "0.1.8",
|
"reflect-metadata": "0.1.8",
|
||||||
|
@ -68,13 +72,14 @@
|
||||||
"ts-helpers": "^1.1.1",
|
"ts-helpers": "^1.1.1",
|
||||||
"tslint": "3.15.1",
|
"tslint": "3.15.1",
|
||||||
"tslint-loader": "^2.1.4",
|
"tslint-loader": "^2.1.4",
|
||||||
"typescript": "~2.0.9",
|
"typescript": "~2.1.0",
|
||||||
"url-loader": "^0.5.7",
|
"url-loader": "^0.5.7",
|
||||||
|
"v8-lazy-parse-webpack-plugin": "^0.3.0",
|
||||||
"video.js": "^5.11.9",
|
"video.js": "^5.11.9",
|
||||||
"videojs-dock": "^2.0.2",
|
"videojs-dock": "^2.0.2",
|
||||||
"webpack": "2.1.0-beta.25",
|
"webpack": "2.2.0-rc.3",
|
||||||
"webpack-md5-hash": "0.0.5",
|
"webpack-md5-hash": "0.0.5",
|
||||||
"webpack-merge": "^0.15.0",
|
"webpack-merge": "~2.3.1",
|
||||||
"webpack-notifier": "^1.3.0",
|
"webpack-notifier": "^1.3.0",
|
||||||
"webtorrent": "^0.98.0",
|
"webtorrent": "^0.98.0",
|
||||||
"zone.js": "~0.7.2"
|
"zone.js": "~0.7.2"
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import 'rxjs/add/operator/catch';
|
||||||
|
import 'rxjs/add/operator/map';
|
||||||
|
|
||||||
import { AuthService } from '../core';
|
import { AuthService } from '../core';
|
||||||
import { AuthHttp, RestExtractor } from '../shared';
|
import { AuthHttp, RestExtractor } from '../shared';
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
import 'rxjs/add/operator/catch';
|
||||||
|
import 'rxjs/add/operator/map';
|
||||||
|
|
||||||
import { Friend } from './friend.model';
|
import { Friend } from './friend.model';
|
||||||
import { AuthHttp, RestExtractor, ResultList } from '../../../shared';
|
import { AuthHttp, RestExtractor, ResultList } from '../../../shared';
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { setInterval } from 'timers'
|
||||||
import { Component, OnInit, OnDestroy } from '@angular/core';
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||||
|
|
||||||
import { RequestService, RequestStats } from '../shared';
|
import { RequestService, RequestStats } from '../shared';
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
import 'rxjs/add/operator/catch';
|
||||||
|
import 'rxjs/add/operator/map';
|
||||||
|
|
||||||
import { RequestStats } from './request-stats.model';
|
import { RequestStats } from './request-stats.model';
|
||||||
import { AuthHttp, RestExtractor } from '../../../shared';
|
import { AuthHttp, RestExtractor } from '../../../shared';
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
import 'rxjs/add/operator/catch';
|
||||||
|
import 'rxjs/add/operator/map';
|
||||||
|
|
||||||
import { AuthHttp, RestExtractor, ResultList, User } from '../../../shared';
|
import { AuthHttp, RestExtractor, ResultList, User } from '../../../shared';
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Component, ViewContainerRef } from '@angular/core';
|
import { Component, ViewContainerRef } from '@angular/core';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
|
|
||||||
import { MetaService } from 'ng2-meta';
|
import { MetaService } from 'ng2-meta/src';
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'my-app',
|
selector: 'my-app',
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
|
|
|
@ -2,7 +2,8 @@ import { ApplicationRef, NgModule } from '@angular/core';
|
||||||
import { BrowserModule } from '@angular/platform-browser';
|
import { BrowserModule } from '@angular/platform-browser';
|
||||||
import { removeNgStyles, createNewHosts } from '@angularclass/hmr';
|
import { removeNgStyles, createNewHosts } from '@angularclass/hmr';
|
||||||
|
|
||||||
import { MetaModule, MetaConfig } from 'ng2-meta';
|
import { MetaModule, MetaConfig } from 'ng2-meta/src';
|
||||||
|
import 'bootstrap-loader';
|
||||||
|
|
||||||
import { ENV_PROVIDERS } from './environment';
|
import { ENV_PROVIDERS } from './environment';
|
||||||
import { AppRoutingModule } from './app-routing.module';
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
|
|
|
@ -1,35 +1,35 @@
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
export type InternalStateType = {
|
||||||
|
[key: string]: any
|
||||||
|
};
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class AppState {
|
export class AppState {
|
||||||
_state = { };
|
|
||||||
|
|
||||||
constructor() { ; }
|
public _state: InternalStateType = { };
|
||||||
|
|
||||||
// already return a clone of the current state
|
// already return a clone of the current state
|
||||||
get state() {
|
public get state() {
|
||||||
return this._state = this._clone(this._state);
|
return this._state = this._clone(this._state);
|
||||||
}
|
}
|
||||||
// never allow mutation
|
// never allow mutation
|
||||||
set state(value) {
|
public set state(value) {
|
||||||
throw new Error('do not mutate the `.state` directly');
|
throw new Error('do not mutate the `.state` directly');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get(prop?: any) {
|
||||||
get(prop?: any) {
|
|
||||||
// use our state getter for the clone
|
// use our state getter for the clone
|
||||||
const state = this.state;
|
const state = this.state;
|
||||||
return state.hasOwnProperty(prop) ? state[prop] : state;
|
return state.hasOwnProperty(prop) ? state[prop] : state;
|
||||||
}
|
}
|
||||||
|
|
||||||
set(prop: string, value: any) {
|
public set(prop: string, value: any) {
|
||||||
// internally mutate our state
|
// internally mutate our state
|
||||||
return this._state[prop] = value;
|
return this._state[prop] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _clone(object: InternalStateType) {
|
||||||
_clone(object) {
|
|
||||||
// simple object clone
|
// simple object clone
|
||||||
return JSON.parse(JSON.stringify( object ));
|
return JSON.parse(JSON.stringify( object ));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ import { Headers, Http, Response, URLSearchParams } from '@angular/http';
|
||||||
import { Router } from '@angular/router';
|
import { Router } from '@angular/router';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { Subject } from 'rxjs/Subject';
|
import { Subject } from 'rxjs/Subject';
|
||||||
|
import 'rxjs/add/operator/map';
|
||||||
|
import 'rxjs/add/operator/mergeMap';
|
||||||
|
|
||||||
// Do not use the barrel (dependency loop)
|
// Do not use the barrel (dependency loop)
|
||||||
import { AuthStatus } from '../../shared/auth/auth-status.model';
|
import { AuthStatus } from '../../shared/auth/auth-status.model';
|
||||||
|
|
|
@ -4,19 +4,24 @@
|
||||||
import { enableDebugTools, disableDebugTools } from '@angular/platform-browser';
|
import { enableDebugTools, disableDebugTools } from '@angular/platform-browser';
|
||||||
import { enableProdMode, ApplicationRef } from '@angular/core';
|
import { enableProdMode, ApplicationRef } from '@angular/core';
|
||||||
// Environment Providers
|
// Environment Providers
|
||||||
let PROVIDERS = [
|
let PROVIDERS: any[] = [
|
||||||
// common env directives
|
// common env directives
|
||||||
];
|
];
|
||||||
|
|
||||||
// Angular debug tools in the dev console
|
// Angular debug tools in the dev console
|
||||||
// https://github.com/angular/angular/blob/86405345b781a9dc2438c0fbe3e9409245647019/TOOLS_JS.md
|
// https://github.com/angular/angular/blob/86405345b781a9dc2438c0fbe3e9409245647019/TOOLS_JS.md
|
||||||
let _decorateModuleRef = function identity(value) { return value; };
|
let _decorateModuleRef = function identity<T>(value: T): T { return value; };
|
||||||
|
|
||||||
if ('production' === ENV) {
|
if ('production' === ENV) {
|
||||||
// Production
|
|
||||||
disableDebugTools();
|
|
||||||
enableProdMode();
|
enableProdMode();
|
||||||
|
|
||||||
|
// Production
|
||||||
|
_decorateModuleRef = (modRef: any) => {
|
||||||
|
disableDebugTools();
|
||||||
|
|
||||||
|
return modRef;
|
||||||
|
};
|
||||||
|
|
||||||
PROVIDERS = [
|
PROVIDERS = [
|
||||||
...PROVIDERS,
|
...PROVIDERS,
|
||||||
// custom providers in production
|
// custom providers in production
|
||||||
|
|
|
@ -80,12 +80,14 @@ export class AuthHttp extends Http {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useFactory(backend: XHRBackend, defaultOptions: RequestOptions, authService: AuthService) {
|
||||||
|
return new AuthHttp(backend, defaultOptions, authService);
|
||||||
|
}
|
||||||
|
|
||||||
export const AUTH_HTTP_PROVIDERS = [
|
export const AUTH_HTTP_PROVIDERS = [
|
||||||
{
|
{
|
||||||
provide: AuthHttp,
|
provide: AuthHttp,
|
||||||
useFactory: (backend: XHRBackend, defaultOptions: RequestOptions, authService: AuthService) => {
|
useFactory,
|
||||||
return new AuthHttp(backend, defaultOptions, authService);
|
|
||||||
},
|
|
||||||
deps: [ XHRBackend, RequestOptions, AuthService ]
|
deps: [ XHRBackend, RequestOptions, AuthService ]
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Http } from '@angular/http';
|
import { Http } from '@angular/http';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
import 'rxjs/add/operator/catch';
|
||||||
|
import 'rxjs/add/operator/map';
|
||||||
|
|
||||||
import { Search } from '../../shared';
|
import { Search } from '../../shared';
|
||||||
import { SortField } from './sort-field.type';
|
import { SortField } from './sort-field.type';
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<div class="modal-content modal-lg">
|
<div class="modal-content modal-lg">
|
||||||
|
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<button type="button" class="close" aria-label="Close" (click)="hideModal()">
|
<button type="button" class="close" aria-label="Close" (click)="hide()">
|
||||||
<span aria-hidden="true">×</span>
|
<span aria-hidden="true">×</span>
|
||||||
</button>
|
</button>
|
||||||
<h4 class="modal-title">Magnet Uri</h4>
|
<h4 class="modal-title">Magnet Uri</h4>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<button type="button" class="close" aria-label="Close" (click)="hideModal()">
|
<button type="button" class="close" aria-label="Close" (click)="hide()">
|
||||||
<span aria-hidden="true">×</span>
|
<span aria-hidden="true">×</span>
|
||||||
</button>
|
</button>
|
||||||
<h4 class="modal-title">Share</h4>
|
<h4 class="modal-title">Share</h4>
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
|
import { setInterval, setTimeout } from 'timers'
|
||||||
import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
|
|
||||||
import { MetaService } from 'ng2-meta';
|
import { MetaService } from 'ng2-meta/src';
|
||||||
import * as videojs from 'video.js';
|
import * as videojs from 'video.js';
|
||||||
|
|
||||||
import { VideoMagnetComponent } from './video-magnet.component';
|
import { VideoMagnetComponent } from './video-magnet.component';
|
||||||
|
|
|
@ -46,6 +46,16 @@ import * as _ from 'lodash'
|
||||||
// support NodeJS modules without type definitions
|
// support NodeJS modules without type definitions
|
||||||
declare module '*';
|
declare module '*';
|
||||||
|
|
||||||
|
/*
|
||||||
|
// for legacy tslint etc to understand rename 'modern-lru' with your package
|
||||||
|
// then comment out `declare module '*';`. For each new module copy/paste
|
||||||
|
// this method of creating an `any` module type definition
|
||||||
|
declare module 'modern-lru' {
|
||||||
|
let x: any;
|
||||||
|
export = x;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
// Extra variables that live on Global that will be replaced by webpack DefinePlugin
|
// Extra variables that live on Global that will be replaced by webpack DefinePlugin
|
||||||
declare var ENV: string;
|
declare var ENV: string;
|
||||||
declare var HMR: boolean;
|
declare var HMR: boolean;
|
||||||
|
@ -56,8 +66,8 @@ interface SystemJS {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface GlobalEnvironment {
|
interface GlobalEnvironment {
|
||||||
ENV;
|
ENV: string;
|
||||||
HMR;
|
HMR: boolean;
|
||||||
SystemJS: SystemJS;
|
SystemJS: SystemJS;
|
||||||
System: SystemJS;
|
System: SystemJS;
|
||||||
}
|
}
|
||||||
|
@ -76,7 +86,6 @@ type AsyncRoutes = {
|
||||||
FactoryPromise
|
FactoryPromise
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
type IdleCallbacks = Es6PromiseLoader |
|
type IdleCallbacks = Es6PromiseLoader |
|
||||||
Function |
|
Function |
|
||||||
FactoryEs6PromiseLoader |
|
FactoryEs6PromiseLoader |
|
||||||
|
@ -98,7 +107,6 @@ interface WebpackModule {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
interface WebpackRequire {
|
interface WebpackRequire {
|
||||||
(id: string): any;
|
(id: string): any;
|
||||||
(paths: string[], callback: (...modules: any[]) => void): void;
|
(paths: string[], callback: (...modules: any[]) => void): void;
|
||||||
|
@ -114,7 +122,6 @@ interface ErrorStackTraceLimit {
|
||||||
stackTraceLimit: number;
|
stackTraceLimit: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Extend typings
|
// Extend typings
|
||||||
interface NodeRequire extends WebpackRequire {}
|
interface NodeRequire extends WebpackRequire {}
|
||||||
interface ErrorConstructor extends ErrorStackTraceLimit {}
|
interface ErrorConstructor extends ErrorStackTraceLimit {}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { platformBrowser } from '@angular/platform-browser';
|
||||||
|
import { decorateModuleRef } from './app/environment';
|
||||||
|
/*
|
||||||
|
* App Module
|
||||||
|
* our top level module that holds all of our components
|
||||||
|
*/
|
||||||
|
import { AppModuleNgFactory } from '../compiled/src/app/app.module.ngfactory';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Bootstrap our Angular app with a top level NgModule
|
||||||
|
*/
|
||||||
|
export function main(): Promise<any> {
|
||||||
|
return platformBrowser()
|
||||||
|
.bootstrapModuleFactory(AppModuleNgFactory)
|
||||||
|
.then(decorateModuleRef)
|
||||||
|
.catch((err) => console.error(err));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function bootstrapDomReady() {
|
||||||
|
document.addEventListener('DOMContentLoaded', main);
|
||||||
|
}
|
||||||
|
|
||||||
|
bootstrapDomReady();
|
|
@ -1,4 +1,4 @@
|
||||||
@import '../video.js/dist/video-js.css';
|
@import '../../node_modules/video.js/dist/video-js.css';
|
||||||
|
|
||||||
body {
|
body {
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
// For vendors for example jQuery, Lodash, angular2-jwt just import them here unless you plan on
|
|
||||||
// chunking vendors files for async loading. You would need to import the async loaded vendors
|
|
||||||
// at the entry point of the async loaded file. Also see custom-typings.d.ts as you also need to
|
|
||||||
// run `typings install x` where `x` is your module
|
|
||||||
|
|
||||||
// Angular 2
|
|
||||||
import '@angular/platform-browser';
|
|
||||||
import '@angular/platform-browser-dynamic';
|
|
||||||
import '@angular/core';
|
|
||||||
import '@angular/common';
|
|
||||||
import '@angular/forms';
|
|
||||||
import '@angular/http';
|
|
||||||
import '@angular/router';
|
|
||||||
|
|
||||||
import '@angularclass/hmr';
|
|
||||||
|
|
||||||
// RxJS
|
|
||||||
import 'rxjs/Observable';
|
|
||||||
import 'rxjs/Subject';
|
|
||||||
import 'rxjs/ReplaySubject';
|
|
||||||
import 'rxjs/add/operator/catch';
|
|
||||||
import 'rxjs/add/operator/mergeMap';
|
|
||||||
import 'rxjs/add/operator/map';
|
|
||||||
import 'rxjs/add/observable/throw';
|
|
||||||
|
|
||||||
import 'bootstrap-loader';
|
|
||||||
|
|
||||||
import 'angular-pipes/src/math/bytes.pipe';
|
|
||||||
import 'ng2-file-upload';
|
|
||||||
import 'video.js';
|
|
||||||
import 'ng2-meta';
|
|
||||||
import 'ng2-bootstrap/pagination';
|
|
||||||
import 'ng2-bootstrap/dropdown';
|
|
||||||
import 'ng2-bootstrap/progressbar';
|
|
||||||
import 'ng2-bootstrap/modal';
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es5",
|
||||||
|
"module": "es2015",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"emitDecoratorMetadata": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"noEmitHelpers": true,
|
||||||
|
"strictNullChecks": false,
|
||||||
|
"baseUrl": "./src",
|
||||||
|
"paths": [
|
||||||
|
],
|
||||||
|
"lib": [
|
||||||
|
"dom",
|
||||||
|
"es6"
|
||||||
|
],
|
||||||
|
"types": [
|
||||||
|
"node",
|
||||||
|
"source-map",
|
||||||
|
"uglify-js",
|
||||||
|
"videojs",
|
||||||
|
"webpack"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
"dist"
|
||||||
|
],
|
||||||
|
"awesomeTypescriptLoaderOptions": {
|
||||||
|
"forkChecker": true,
|
||||||
|
"useWebpackText": true
|
||||||
|
},
|
||||||
|
"angularCompilerOptions": {
|
||||||
|
"genDir": "./compiled",
|
||||||
|
"skipMetadataEmit": true
|
||||||
|
},
|
||||||
|
"compileOnSave": false,
|
||||||
|
"buildOnSave": false,
|
||||||
|
"atom": { "rewriteTsconfig": false }
|
||||||
|
}
|
Loading…
Reference in New Issue