aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-01-13 12:16:00 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-01-13 12:16:00 +0100
commitc16ce1de8e8c21ad2136335d3b0b7d230e6d2f24 (patch)
treee5177a26dae755833122c4ef73744c2a7f9b53fc
parent80deae8d198f6a376b477d780e76966f8fbb72ce (diff)
downloadPeerTube-c16ce1de8e8c21ad2136335d3b0b7d230e6d2f24.tar.gz
PeerTube-c16ce1de8e8c21ad2136335d3b0b7d230e6d2f24.tar.zst
PeerTube-c16ce1de8e8c21ad2136335d3b0b7d230e6d2f24.zip
Client: add basic aot support
-rw-r--r--client/.gitignore2
-rw-r--r--client/config/empty.js8
-rw-r--r--client/config/helpers.js9
-rw-r--r--client/config/resource-override.js0
-rw-r--r--client/config/webpack.common.js102
-rw-r--r--client/config/webpack.dev.js3
-rw-r--r--client/config/webpack.prod.js68
-rw-r--r--client/package.json21
-rw-r--r--client/src/app/account/account.service.ts2
-rw-r--r--client/src/app/admin/friends/shared/friend.service.ts2
-rw-r--r--client/src/app/admin/requests/request-stats/request-stats.component.ts1
-rw-r--r--client/src/app/admin/requests/shared/request.service.ts2
-rw-r--r--client/src/app/admin/users/shared/user.service.ts2
-rw-r--r--client/src/app/app.component.ts2
-rw-r--r--client/src/app/app.module.ts3
-rw-r--r--client/src/app/app.service.ts20
-rw-r--r--client/src/app/core/auth/auth.service.ts2
-rw-r--r--client/src/app/environment.ts13
-rw-r--r--client/src/app/shared/auth/auth-http.service.ts8
-rw-r--r--client/src/app/videos/shared/video.service.ts2
-rw-r--r--client/src/app/videos/video-watch/video-magnet.component.html2
-rw-r--r--client/src/app/videos/video-watch/video-share.component.html2
-rw-r--r--client/src/app/videos/video-watch/video-watch.component.ts3
-rw-r--r--client/src/custom-typings.d.ts17
-rw-r--r--client/src/main.browser.aot.ts23
-rw-r--r--client/src/main.browser.ts (renamed from client/src/main.ts)0
-rw-r--r--client/src/polyfills.browser.ts (renamed from client/src/polyfills.ts)0
-rw-r--r--client/src/sass/application.scss2
-rw-r--r--client/src/vendor.ts35
-rw-r--r--client/tsconfig.webpack.json42
30 files changed, 292 insertions, 106 deletions
diff --git a/client/.gitignore b/client/.gitignore
index 27e212f08..fa5433194 100644
--- a/client/.gitignore
+++ b/client/.gitignore
@@ -1,2 +1,4 @@
1/dist/ 1/dist/
2/node_modules 2/node_modules
3/compiled
4/stats.json
diff --git a/client/config/empty.js b/client/config/empty.js
new file mode 100644
index 000000000..33acae188
--- /dev/null
+++ b/client/config/empty.js
@@ -0,0 +1,8 @@
1module.exports = {
2 NgProbeToken: {},
3 HmrState: function () {},
4 _createConditionalRootRenderer: function (rootRenderer, extraTokens, coreTokens) {
5 return rootRenderer
6 },
7 __platform_browser_private__: {}
8}
diff --git a/client/config/helpers.js b/client/config/helpers.js
index 6268d2628..ca5923472 100644
--- a/client/config/helpers.js
+++ b/client/config/helpers.js
@@ -1,13 +1,17 @@
1const path = require('path') 1const path = require('path')
2 2
3// Helper functions
3const ROOT = path.resolve(__dirname, '..') 4const ROOT = path.resolve(__dirname, '..')
4 5const EVENT = process.env.npm_lifecycle_event || ''
5console.log('root directory:', root() + '\n')
6 6
7function hasProcessFlag (flag) { 7function hasProcessFlag (flag) {
8 return process.argv.join('').indexOf(flag) > -1 8 return process.argv.join('').indexOf(flag) > -1
9} 9}
10 10
11function hasNpmFlag (flag) {
12 return EVENT.includes(flag)
13}
14
11function isWebpackDevServer () { 15function isWebpackDevServer () {
12 return process.argv[1] && !!(/webpack-dev-server$/.exec(process.argv[1])) 16 return process.argv[1] && !!(/webpack-dev-server$/.exec(process.argv[1]))
13} 17}
@@ -18,5 +22,6 @@ function root (args) {
18} 22}
19 23
20exports.hasProcessFlag = hasProcessFlag 24exports.hasProcessFlag = hasProcessFlag
25exports.hasNpmFlag = hasNpmFlag
21exports.isWebpackDevServer = isWebpackDevServer 26exports.isWebpackDevServer = isWebpackDevServer
22exports.root = root 27exports.root = root
diff --git a/client/config/resource-override.js b/client/config/resource-override.js
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/client/config/resource-override.js
diff --git a/client/config/webpack.common.js b/client/config/webpack.common.js
index 7631af6b9..09d6f72b5 100644
--- a/client/config/webpack.common.js
+++ b/client/config/webpack.common.js
@@ -1,17 +1,20 @@
1const webpack = require('webpack')
2const helpers = require('./helpers') 1const helpers = require('./helpers')
3 2
4/* 3/*
5 * Webpack Plugins 4 * Webpack Plugins
6 */ 5 */
7 6
8const CopyWebpackPlugin = require('copy-webpack-plugin')
9const HtmlWebpackPlugin = require('html-webpack-plugin')
10const ForkCheckerPlugin = require('awesome-typescript-loader').ForkCheckerPlugin
11const AssetsPlugin = require('assets-webpack-plugin') 7const AssetsPlugin = require('assets-webpack-plugin')
8const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin')
12const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin') 9const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin')
10const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin')
11const CopyWebpackPlugin = require('copy-webpack-plugin')
12const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin
13const HtmlWebpackPlugin = require('html-webpack-plugin')
13const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin') 14const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin')
14const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin') 15const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin')
16const ngcWebpack = require('ngc-webpack')
17
15const WebpackNotifierPlugin = require('webpack-notifier') 18const WebpackNotifierPlugin = require('webpack-notifier')
16 19
17/* 20/*
@@ -29,7 +32,8 @@ const METADATA = {
29 * See: http://webpack.github.io/docs/configuration.html#cli 32 * See: http://webpack.github.io/docs/configuration.html#cli
30 */ 33 */
31module.exports = function (options) { 34module.exports = function (options) {
32 var isProd = options.env === 'production' 35 const isProd = options.env === 'production'
36 const AOT = isProd
33 37
34 return { 38 return {
35 39
@@ -49,9 +53,10 @@ module.exports = function (options) {
49 * See: http://webpack.github.io/docs/configuration.html#entry 53 * See: http://webpack.github.io/docs/configuration.html#entry
50 */ 54 */
51 entry: { 55 entry: {
52 'polyfills': './src/polyfills.ts', 56 'polyfills': './src/polyfills.browser.ts',
53 'vendor': './src/vendor.ts', 57 'main': AOT
54 'main': './src/main.ts' 58 ? './src/main.browser.aot.ts'
59 : './src/main.browser.ts'
55 }, 60 },
56 61
57 /* 62 /*
@@ -67,7 +72,7 @@ module.exports = function (options) {
67 */ 72 */
68 extensions: [ '.ts', '.js', '.json', '.scss' ], 73 extensions: [ '.ts', '.js', '.json', '.scss' ],
69 74
70 modules: [helpers.root('src'), 'node_modules'], 75 modules: [ helpers.root('src'), helpers.root('node_modules') ],
71 76
72 alias: { 77 alias: {
73 'video.js': 'video.js/dist/alt/video.novtt' 78 'video.js': 'video.js/dist/alt/video.novtt'
@@ -90,10 +95,18 @@ module.exports = function (options) {
90 */ 95 */
91 { 96 {
92 test: /\.ts$/, 97 test: /\.ts$/,
93 loaders: [ 98 use: [
94 '@angularclass/hmr-loader?pretty=' + !isProd + '&prod=' + isProd, 99 '@angularclass/hmr-loader?pretty=' + !isProd + '&prod=' + isProd,
95 'awesome-typescript-loader', 100 'awesome-typescript-loader?{configFileName: "tsconfig.webpack.json"}',
96 'angular2-template-loader' 101 'angular2-template-loader',
102 {
103 loader: 'ng-router-loader',
104 options: {
105 loader: 'async-system',
106 genDir: 'compiled',
107 aot: AOT
108 }
109 }
97 ], 110 ],
98 exclude: [/\.(spec|e2e)\.ts$/] 111 exclude: [/\.(spec|e2e)\.ts$/]
99 }, 112 },
@@ -110,10 +123,11 @@ module.exports = function (options) {
110 123
111 { 124 {
112 test: /\.(sass|scss)$/, 125 test: /\.(sass|scss)$/,
113 loaders: ['css-to-string-loader', 'css-loader?sourceMap', 'resolve-url', 'sass-loader?sourceMap'] 126 use: ['css-to-string-loader', 'css-loader?sourceMap', 'resolve-url-loader', 'sass-loader?sourceMap'],
127 exclude: [ helpers.root('src', 'styles') ]
114 }, 128 },
115 { test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'url?limit=10000&minetype=application/font-woff' }, 129 { test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, use: 'url-loader?limit=10000&minetype=application/font-woff' },
116 { test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, loader: 'file' }, 130 { test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, use: 'file-loader' },
117 131
118 /* Raw loader support for *.html 132 /* Raw loader support for *.html
119 * Returns file content as string 133 * Returns file content as string
@@ -148,7 +162,7 @@ module.exports = function (options) {
148 * 162 *
149 * See: https://github.com/s-panferov/awesome-typescript-loader#forkchecker-boolean-defaultfalse 163 * See: https://github.com/s-panferov/awesome-typescript-loader#forkchecker-boolean-defaultfalse
150 */ 164 */
151 new ForkCheckerPlugin(), 165 new CheckerPlugin(),
152 166
153 /* 167 /*
154 * Plugin: CommonsChunkPlugin 168 * Plugin: CommonsChunkPlugin
@@ -158,8 +172,21 @@ module.exports = function (options) {
158 * See: https://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin 172 * See: https://webpack.github.io/docs/list-of-plugins.html#commonschunkplugin
159 * See: https://github.com/webpack/docs/wiki/optimization#multi-page-app 173 * See: https://github.com/webpack/docs/wiki/optimization#multi-page-app
160 */ 174 */
161 new webpack.optimize.CommonsChunkPlugin({ 175 new CommonsChunkPlugin({
162 name: [ 'polyfills', 'vendor' ].reverse() 176 name: 'polyfills',
177 chunks: ['polyfills']
178 }),
179
180 // This enables tree shaking of the vendor modules
181 new CommonsChunkPlugin({
182 name: 'vendor',
183 chunks: ['main'],
184 minChunks: module => /node_modules\//.test(module.resource)
185 }),
186
187 // Specify the correct order the scripts will be injected in
188 new CommonsChunkPlugin({
189 name: ['polyfills', 'vendor'].reverse()
163 }), 190 }),
164 191
165 /** 192 /**
@@ -171,8 +198,11 @@ module.exports = function (options) {
171 */ 198 */
172 new ContextReplacementPlugin( 199 new ContextReplacementPlugin(
173 // The (\\|\/) piece accounts for path separators in *nix and Windows 200 // The (\\|\/) piece accounts for path separators in *nix and Windows
174 /angular(\\|\/)core(\\|\/)(esm(\\|\/)src|src)(\\|\/)linker/, 201 /angular(\\|\/)core(\\|\/)src(\\|\/)linker/,
175 helpers.root('src') // location of your src 202 helpers.root('src'), // location of your src
203 {
204 // your Angular Async Route paths relative to this root directory
205 }
176 ), 206 ),
177 207
178 /* 208 /*
@@ -255,6 +285,34 @@ module.exports = function (options) {
255 precision: 10 285 precision: 10
256 } 286 }
257 } 287 }
288 }),
289
290 // Fix Angular 2
291 new NormalModuleReplacementPlugin(
292 /facade(\\|\/)async/,
293 helpers.root('node_modules/@angular/core/src/facade/async.js')
294 ),
295 new NormalModuleReplacementPlugin(
296 /facade(\\|\/)collection/,
297 helpers.root('node_modules/@angular/core/src/facade/collection.js')
298 ),
299 new NormalModuleReplacementPlugin(
300 /facade(\\|\/)errors/,
301 helpers.root('node_modules/@angular/core/src/facade/errors.js')
302 ),
303 new NormalModuleReplacementPlugin(
304 /facade(\\|\/)lang/,
305 helpers.root('node_modules/@angular/core/src/facade/lang.js')
306 ),
307 new NormalModuleReplacementPlugin(
308 /facade(\\|\/)math/,
309 helpers.root('node_modules/@angular/core/src/facade/math.js')
310 ),
311
312 new ngcWebpack.NgcWebpackPlugin({
313 disabled: !AOT,
314 tsConfig: helpers.root('tsconfig.webpack.json'),
315 resourceOverride: helpers.root('config/resource-override.js')
258 }) 316 })
259 ], 317 ],
260 318
@@ -270,7 +328,9 @@ module.exports = function (options) {
270 process: true, 328 process: true,
271 module: false, 329 module: false,
272 clearImmediate: false, 330 clearImmediate: false,
273 setImmediate: false 331 setImmediate: false,
332 setInterval: false,
333 setTimeout: false
274 } 334 }
275 } 335 }
276} 336}
diff --git a/client/config/webpack.dev.js b/client/config/webpack.dev.js
index 964ea56a5..cea9d0306 100644
--- a/client/config/webpack.dev.js
+++ b/client/config/webpack.dev.js
@@ -1,6 +1,7 @@
1const helpers = require('./helpers') 1const helpers = require('./helpers')
2const webpackMerge = require('webpack-merge') // used to merge webpack configs 2const webpackMerge = require('webpack-merge') // used to merge webpack configs
3const commonConfig = require('./webpack.common.js') // the settings that are common to prod and dev 3const commonConfig = require('./webpack.common.js') // the settings that are common to prod and dev
4const path = require('path')
4 5
5/** 6/**
6 * Webpack Plugins 7 * Webpack Plugins
@@ -29,7 +30,7 @@ const METADATA = webpackMerge(commonConfig({env: ENV}).metadata, {
29 * See: http://webpack.github.io/docs/configuration.html#cli 30 * See: http://webpack.github.io/docs/configuration.html#cli
30 */ 31 */
31module.exports = function (env) { 32module.exports = function (env) {
32 return webpackMerge(commonConfig({env: ENV}), { 33 return webpackMerge(commonConfig({ env: ENV }), {
33 /** 34 /**
34 * Developer tool to enhance debugging 35 * Developer tool to enhance debugging
35 * 36 *
diff --git a/client/config/webpack.prod.js b/client/config/webpack.prod.js
index 447d47415..64d776f24 100644
--- a/client/config/webpack.prod.js
+++ b/client/config/webpack.prod.js
@@ -9,14 +9,15 @@ const commonConfig = require('./webpack.common.js') // the settings that are com
9/** 9/**
10 * Webpack Plugins 10 * Webpack Plugins
11 */ 11 */
12// const ProvidePlugin = require('webpack/lib/ProvidePlugin')
13const DefinePlugin = require('webpack/lib/DefinePlugin') 12const DefinePlugin = require('webpack/lib/DefinePlugin')
14const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin') 13const ExtractTextPlugin = require('extract-text-webpack-plugin')
14const IgnorePlugin = require('webpack/lib/IgnorePlugin')
15const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin') 15const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin')
16// const IgnorePlugin = require('webpack/lib/IgnorePlugin') 16const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin')
17// const DedupePlugin = require('webpack/lib/optimize/DedupePlugin') 17const ProvidePlugin = require('webpack/lib/ProvidePlugin')
18const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin') 18const UglifyJsPlugin = require('webpack/lib/optimize/UglifyJsPlugin')
19const WebpackMd5Hash = require('webpack-md5-hash') 19const WebpackMd5Hash = require('webpack-md5-hash')
20const V8LazyParseWebpackPlugin = require('v8-lazy-parse-webpack-plugin')
20 21
21/** 22/**
22 * Webpack Constants 23 * Webpack Constants
@@ -154,22 +155,67 @@ module.exports = function (env) {
154 // comments: true, //debug 155 // comments: true, //debug
155 156
156 beautify: false, // prod 157 beautify: false, // prod
158 output: {
159 comments: false
160 }, // prod
157 mangle: { 161 mangle: {
158 screw_ie8: true, 162 screw_ie8: true
159 keep_fnames: true
160 }, // prod 163 }, // prod
161 compress: { 164 compress: {
162 screw_ie8: true, 165 screw_ie8: true,
163 warnings: false 166 warnings: false,
164 }, // prod 167 conditionals: true,
165 comments: false // prod 168 unused: true,
169 comparisons: true,
170 sequences: true,
171 dead_code: true,
172 evaluate: true,
173 if_return: true,
174 join_vars: true,
175 negate_iife: false // we need this for lazy v8
176 }
166 }), 177 }),
167 178
168 new NormalModuleReplacementPlugin( 179 new NormalModuleReplacementPlugin(
169 /angular2-hmr/, 180 /angular2-hmr/,
170 helpers.root('config/modules/angular2-hmr-prod.js') 181 helpers.root('config/empty.js')
171 ), 182 ),
172 183
184 new NormalModuleReplacementPlugin(
185 /zone\.js(\\|\/)dist(\\|\/)long-stack-trace-zone/,
186 helpers.root('config/empty.js')
187 ),
188
189 // AoT
190 // new NormalModuleReplacementPlugin(
191 // /@angular(\\|\/)upgrade/,
192 // helpers.root('config/empty.js')
193 // ),
194 // new NormalModuleReplacementPlugin(
195 // /@angular(\\|\/)compiler/,
196 // helpers.root('config/empty.js')
197 // ),
198 // new NormalModuleReplacementPlugin(
199 // /@angular(\\|\/)platform-browser-dynamic/,
200 // helpers.root('config/empty.js')
201 // ),
202 // new NormalModuleReplacementPlugin(
203 // /dom(\\|\/)debug(\\|\/)ng_probe/,
204 // helpers.root('config/empty.js')
205 // ),
206 // new NormalModuleReplacementPlugin(
207 // /dom(\\|\/)debug(\\|\/)by/,
208 // helpers.root('config/empty.js')
209 // ),
210 // new NormalModuleReplacementPlugin(
211 // /src(\\|\/)debug(\\|\/)debug_node/,
212 // helpers.root('config/empty.js')
213 // ),
214 // new NormalModuleReplacementPlugin(
215 // /src(\\|\/)debug(\\|\/)debug_renderer/,
216 // helpers.root('config/empty.js')
217 // ),
218
173 /** 219 /**
174 * Plugin: IgnorePlugin 220 * Plugin: IgnorePlugin
175 * Description: Don’t generate modules for requests matching the provided RegExp. 221 * Description: Don’t generate modules for requests matching the provided RegExp.
@@ -228,7 +274,7 @@ module.exports = function (env) {
228 [/\*/, /(?:)/], 274 [/\*/, /(?:)/],
229 [/\[?\(?/, /(?:)/] 275 [/\[?\(?/, /(?:)/]
230 ], 276 ],
231 customAttrAssign: [/\)?]?=/] 277 customAttrAssign: [/\)?\]?=/]
232 }, 278 },
233 279
234 // FIXME: Remove 280 // FIXME: Remove
diff --git a/client/package.json b/client/package.json
index e9f41959d..5d09f4c54 100644
--- a/client/package.json
+++ b/client/package.json
@@ -20,6 +20,7 @@
20 "dependencies": { 20 "dependencies": {
21 "@angular/common": "~2.4.1", 21 "@angular/common": "~2.4.1",
22 "@angular/compiler": "~2.4.1", 22 "@angular/compiler": "~2.4.1",
23 "@angular/compiler-cli": "^2.4.3",
23 "@angular/core": "~2.4.1", 24 "@angular/core": "~2.4.1",
24 "@angular/forms": "~2.4.1", 25 "@angular/forms": "~2.4.1",
25 "@angular/http": "~2.4.1", 26 "@angular/http": "~2.4.1",
@@ -33,12 +34,13 @@
33 "@types/source-map": "^0.1.26", 34 "@types/source-map": "^0.1.26",
34 "@types/uglify-js": "^2.0.27", 35 "@types/uglify-js": "^2.0.27",
35 "@types/videojs": "0.0.30", 36 "@types/videojs": "0.0.30",
36 "@types/webpack": "^1.12.29", 37 "@types/webpack": "^2.0.0",
37 "angular-pipes": "^5.0.0", 38 "angular-pipes": "^5.0.0",
38 "angular2-template-loader": "^0.6.0", 39 "angular2-template-loader": "^0.6.0",
39 "assets-webpack-plugin": "^3.4.0", 40 "assets-webpack-plugin": "^3.4.0",
40 "awesome-typescript-loader": "^2.2.1", 41 "awesome-typescript-loader": "~3.0.0-beta.17",
41 "bootstrap-loader": "^2.0.0-beta.11", 42 "bootstrap": "^3.3.6",
43 "bootstrap-loader": "2.0.0-beta.18",
42 "bootstrap-sass": "^3.3.6", 44 "bootstrap-sass": "^3.3.6",
43 "copy-webpack-plugin": "^4.0.0", 45 "copy-webpack-plugin": "^4.0.0",
44 "core-js": "^2.4.1", 46 "core-js": "^2.4.1",
@@ -52,9 +54,11 @@
52 "intl": "^1.2.4", 54 "intl": "^1.2.4",
53 "json-loader": "^0.5.4", 55 "json-loader": "^0.5.4",
54 "ng2-bootstrap": "1.1.16-10", 56 "ng2-bootstrap": "1.1.16-10",
55 "ng2-file-upload": "^1.1.0", 57 "ng2-file-upload": "^1.1.4-2",
56 "ng2-meta": "^2.0.0", 58 "ng2-meta": "^2.0.0",
57 "node-sass": "^3.10.0", 59 "ng-router-loader": "^1.0.2",
60 "ngc-webpack": "^1.1.0",
61 "node-sass": "^4.1.1",
58 "normalize.css": "^5.0.0", 62 "normalize.css": "^5.0.0",
59 "raw-loader": "^0.5.1", 63 "raw-loader": "^0.5.1",
60 "reflect-metadata": "0.1.8", 64 "reflect-metadata": "0.1.8",
@@ -68,13 +72,14 @@
68 "ts-helpers": "^1.1.1", 72 "ts-helpers": "^1.1.1",
69 "tslint": "3.15.1", 73 "tslint": "3.15.1",
70 "tslint-loader": "^2.1.4", 74 "tslint-loader": "^2.1.4",
71 "typescript": "~2.0.9", 75 "typescript": "~2.1.0",
72 "url-loader": "^0.5.7", 76 "url-loader": "^0.5.7",
77 "v8-lazy-parse-webpack-plugin": "^0.3.0",
73 "video.js": "^5.11.9", 78 "video.js": "^5.11.9",
74 "videojs-dock": "^2.0.2", 79 "videojs-dock": "^2.0.2",
75 "webpack": "2.1.0-beta.25", 80 "webpack": "2.2.0-rc.3",
76 "webpack-md5-hash": "0.0.5", 81 "webpack-md5-hash": "0.0.5",
77 "webpack-merge": "^0.15.0", 82 "webpack-merge": "~2.3.1",
78 "webpack-notifier": "^1.3.0", 83 "webpack-notifier": "^1.3.0",
79 "webtorrent": "^0.98.0", 84 "webtorrent": "^0.98.0",
80 "zone.js": "~0.7.2" 85 "zone.js": "~0.7.2"
diff --git a/client/src/app/account/account.service.ts b/client/src/app/account/account.service.ts
index 0635c2533..046690347 100644
--- a/client/src/app/account/account.service.ts
+++ b/client/src/app/account/account.service.ts
@@ -1,4 +1,6 @@
1import { Injectable } from '@angular/core'; 1import { Injectable } from '@angular/core';
2import 'rxjs/add/operator/catch';
3import 'rxjs/add/operator/map';
2 4
3import { AuthService } from '../core'; 5import { AuthService } from '../core';
4import { AuthHttp, RestExtractor } from '../shared'; 6import { AuthHttp, RestExtractor } from '../shared';
diff --git a/client/src/app/admin/friends/shared/friend.service.ts b/client/src/app/admin/friends/shared/friend.service.ts
index 85ac04ba0..e97459385 100644
--- a/client/src/app/admin/friends/shared/friend.service.ts
+++ b/client/src/app/admin/friends/shared/friend.service.ts
@@ -1,5 +1,7 @@
1import { Injectable } from '@angular/core'; 1import { Injectable } from '@angular/core';
2import { Observable } from 'rxjs/Observable'; 2import { Observable } from 'rxjs/Observable';
3import 'rxjs/add/operator/catch';
4import 'rxjs/add/operator/map';
3 5
4import { Friend } from './friend.model'; 6import { Friend } from './friend.model';
5import { AuthHttp, RestExtractor, ResultList } from '../../../shared'; 7import { AuthHttp, RestExtractor, ResultList } from '../../../shared';
diff --git a/client/src/app/admin/requests/request-stats/request-stats.component.ts b/client/src/app/admin/requests/request-stats/request-stats.component.ts
index 9e2af219c..66075e4b5 100644
--- a/client/src/app/admin/requests/request-stats/request-stats.component.ts
+++ b/client/src/app/admin/requests/request-stats/request-stats.component.ts
@@ -1,3 +1,4 @@
1import { setInterval } from 'timers'
1import { Component, OnInit, OnDestroy } from '@angular/core'; 2import { Component, OnInit, OnDestroy } from '@angular/core';
2 3
3import { RequestService, RequestStats } from '../shared'; 4import { RequestService, RequestStats } from '../shared';
diff --git a/client/src/app/admin/requests/shared/request.service.ts b/client/src/app/admin/requests/shared/request.service.ts
index aeec37448..55b28bcfc 100644
--- a/client/src/app/admin/requests/shared/request.service.ts
+++ b/client/src/app/admin/requests/shared/request.service.ts
@@ -1,5 +1,7 @@
1import { Injectable } from '@angular/core'; 1import { Injectable } from '@angular/core';
2import { Observable } from 'rxjs/Observable'; 2import { Observable } from 'rxjs/Observable';
3import 'rxjs/add/operator/catch';
4import 'rxjs/add/operator/map';
3 5
4import { RequestStats } from './request-stats.model'; 6import { RequestStats } from './request-stats.model';
5import { AuthHttp, RestExtractor } from '../../../shared'; 7import { AuthHttp, RestExtractor } from '../../../shared';
diff --git a/client/src/app/admin/users/shared/user.service.ts b/client/src/app/admin/users/shared/user.service.ts
index 13be553c0..d9005b213 100644
--- a/client/src/app/admin/users/shared/user.service.ts
+++ b/client/src/app/admin/users/shared/user.service.ts
@@ -1,4 +1,6 @@
1import { Injectable } from '@angular/core'; 1import { Injectable } from '@angular/core';
2import 'rxjs/add/operator/catch';
3import 'rxjs/add/operator/map';
2 4
3import { AuthHttp, RestExtractor, ResultList, User } from '../../../shared'; 5import { AuthHttp, RestExtractor, ResultList, User } from '../../../shared';
4 6
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts
index ce4fc04ff..3f2f1ace0 100644
--- a/client/src/app/app.component.ts
+++ b/client/src/app/app.component.ts
@@ -1,7 +1,7 @@
1import { Component, ViewContainerRef } from '@angular/core'; 1import { Component, ViewContainerRef } from '@angular/core';
2import { Router } from '@angular/router'; 2import { Router } from '@angular/router';
3 3
4import { MetaService } from 'ng2-meta'; 4import { MetaService } from 'ng2-meta/src';
5@Component({ 5@Component({
6 selector: 'my-app', 6 selector: 'my-app',
7 templateUrl: './app.component.html', 7 templateUrl: './app.component.html',
diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts
index e9bb800f4..fb71787c4 100644
--- a/client/src/app/app.module.ts
+++ b/client/src/app/app.module.ts
@@ -2,7 +2,8 @@ import { ApplicationRef, NgModule } from '@angular/core';
2import { BrowserModule } from '@angular/platform-browser'; 2import { BrowserModule } from '@angular/platform-browser';
3import { removeNgStyles, createNewHosts } from '@angularclass/hmr'; 3import { removeNgStyles, createNewHosts } from '@angularclass/hmr';
4 4
5import { MetaModule, MetaConfig } from 'ng2-meta'; 5import { MetaModule, MetaConfig } from 'ng2-meta/src';
6import 'bootstrap-loader';
6 7
7import { ENV_PROVIDERS } from './environment'; 8import { ENV_PROVIDERS } from './environment';
8import { AppRoutingModule } from './app-routing.module'; 9import { AppRoutingModule } from './app-routing.module';
diff --git a/client/src/app/app.service.ts b/client/src/app/app.service.ts
index 033c21900..9b582e472 100644
--- a/client/src/app/app.service.ts
+++ b/client/src/app/app.service.ts
@@ -1,35 +1,35 @@
1
2import { Injectable } from '@angular/core'; 1import { Injectable } from '@angular/core';
3 2
3export type InternalStateType = {
4 [key: string]: any
5};
6
4@Injectable() 7@Injectable()
5export class AppState { 8export class AppState {
6 _state = { };
7 9
8 constructor() { ; } 10 public _state: InternalStateType = { };
9 11
10 // already return a clone of the current state 12 // already return a clone of the current state
11 get state() { 13 public get state() {
12 return this._state = this._clone(this._state); 14 return this._state = this._clone(this._state);
13 } 15 }
14 // never allow mutation 16 // never allow mutation
15 set state(value) { 17 public set state(value) {
16 throw new Error('do not mutate the `.state` directly'); 18 throw new Error('do not mutate the `.state` directly');
17 } 19 }
18 20
19 21 public get(prop?: any) {
20 get(prop?: any) {
21 // use our state getter for the clone 22 // use our state getter for the clone
22 const state = this.state; 23 const state = this.state;
23 return state.hasOwnProperty(prop) ? state[prop] : state; 24 return state.hasOwnProperty(prop) ? state[prop] : state;
24 } 25 }
25 26
26 set(prop: string, value: any) { 27 public set(prop: string, value: any) {
27 // internally mutate our state 28 // internally mutate our state
28 return this._state[prop] = value; 29 return this._state[prop] = value;
29 } 30 }
30 31
31 32 private _clone(object: InternalStateType) {
32 _clone(object) {
33 // simple object clone 33 // simple object clone
34 return JSON.parse(JSON.stringify( object )); 34 return JSON.parse(JSON.stringify( object ));
35 } 35 }
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts
index 1f0e322a9..bc276ed99 100644
--- a/client/src/app/core/auth/auth.service.ts
+++ b/client/src/app/core/auth/auth.service.ts
@@ -3,6 +3,8 @@ import { Headers, Http, Response, URLSearchParams } from '@angular/http';
3import { Router } from '@angular/router'; 3import { Router } from '@angular/router';
4import { Observable } from 'rxjs/Observable'; 4import { Observable } from 'rxjs/Observable';
5import { Subject } from 'rxjs/Subject'; 5import { Subject } from 'rxjs/Subject';
6import 'rxjs/add/operator/map';
7import 'rxjs/add/operator/mergeMap';
6 8
7// Do not use the barrel (dependency loop) 9// Do not use the barrel (dependency loop)
8import { AuthStatus } from '../../shared/auth/auth-status.model'; 10import { AuthStatus } from '../../shared/auth/auth-status.model';
diff --git a/client/src/app/environment.ts b/client/src/app/environment.ts
index 8bba89c4e..929e09490 100644
--- a/client/src/app/environment.ts
+++ b/client/src/app/environment.ts
@@ -4,19 +4,24 @@
4import { enableDebugTools, disableDebugTools } from '@angular/platform-browser'; 4import { enableDebugTools, disableDebugTools } from '@angular/platform-browser';
5import { enableProdMode, ApplicationRef } from '@angular/core'; 5import { enableProdMode, ApplicationRef } from '@angular/core';
6// Environment Providers 6// Environment Providers
7let PROVIDERS = [ 7let PROVIDERS: any[] = [
8 // common env directives 8 // common env directives
9]; 9];
10 10
11// Angular debug tools in the dev console 11// Angular debug tools in the dev console
12// https://github.com/angular/angular/blob/86405345b781a9dc2438c0fbe3e9409245647019/TOOLS_JS.md 12// https://github.com/angular/angular/blob/86405345b781a9dc2438c0fbe3e9409245647019/TOOLS_JS.md
13let _decorateModuleRef = function identity(value) { return value; }; 13let _decorateModuleRef = function identity<T>(value: T): T { return value; };
14 14
15if ('production' === ENV) { 15if ('production' === ENV) {
16 // Production
17 disableDebugTools();
18 enableProdMode(); 16 enableProdMode();
19 17
18 // Production
19 _decorateModuleRef = (modRef: any) => {
20 disableDebugTools();
21
22 return modRef;
23 };
24
20 PROVIDERS = [ 25 PROVIDERS = [
21 ...PROVIDERS, 26 ...PROVIDERS,
22 // custom providers in production 27 // custom providers in production
diff --git a/client/src/app/shared/auth/auth-http.service.ts b/client/src/app/shared/auth/auth-http.service.ts
index 602726570..c4114aa02 100644
--- a/client/src/app/shared/auth/auth-http.service.ts
+++ b/client/src/app/shared/auth/auth-http.service.ts
@@ -80,12 +80,14 @@ export class AuthHttp extends Http {
80 } 80 }
81} 81}
82 82
83export function useFactory(backend: XHRBackend, defaultOptions: RequestOptions, authService: AuthService) {
84 return new AuthHttp(backend, defaultOptions, authService);
85}
86
83export const AUTH_HTTP_PROVIDERS = [ 87export const AUTH_HTTP_PROVIDERS = [
84 { 88 {
85 provide: AuthHttp, 89 provide: AuthHttp,
86 useFactory: (backend: XHRBackend, defaultOptions: RequestOptions, authService: AuthService) => { 90 useFactory,
87 return new AuthHttp(backend, defaultOptions, authService);
88 },
89 deps: [ XHRBackend, RequestOptions, AuthService ] 91 deps: [ XHRBackend, RequestOptions, AuthService ]
90 }, 92 },
91]; 93];
diff --git a/client/src/app/videos/shared/video.service.ts b/client/src/app/videos/shared/video.service.ts
index f173ef06b..9d79b2f5e 100644
--- a/client/src/app/videos/shared/video.service.ts
+++ b/client/src/app/videos/shared/video.service.ts
@@ -1,6 +1,8 @@
1import { Injectable } from '@angular/core'; 1import { Injectable } from '@angular/core';
2import { Http } from '@angular/http'; 2import { Http } from '@angular/http';
3import { Observable } from 'rxjs/Observable'; 3import { Observable } from 'rxjs/Observable';
4import 'rxjs/add/operator/catch';
5import 'rxjs/add/operator/map';
4 6
5import { Search } from '../../shared'; 7import { Search } from '../../shared';
6import { SortField } from './sort-field.type'; 8import { SortField } from './sort-field.type';
diff --git a/client/src/app/videos/video-watch/video-magnet.component.html b/client/src/app/videos/video-watch/video-magnet.component.html
index 9108c7258..3fa82f1be 100644
--- a/client/src/app/videos/video-watch/video-magnet.component.html
+++ b/client/src/app/videos/video-watch/video-magnet.component.html
@@ -3,7 +3,7 @@
3 <div class="modal-content modal-lg"> 3 <div class="modal-content modal-lg">
4 4
5 <div class="modal-header"> 5 <div class="modal-header">
6 <button type="button" class="close" aria-label="Close" (click)="hideModal()"> 6 <button type="button" class="close" aria-label="Close" (click)="hide()">
7 <span aria-hidden="true">&times;</span> 7 <span aria-hidden="true">&times;</span>
8 </button> 8 </button>
9 <h4 class="modal-title">Magnet Uri</h4> 9 <h4 class="modal-title">Magnet Uri</h4>
diff --git a/client/src/app/videos/video-watch/video-share.component.html b/client/src/app/videos/video-watch/video-share.component.html
index 1c2fac1d7..88f59c063 100644
--- a/client/src/app/videos/video-watch/video-share.component.html
+++ b/client/src/app/videos/video-watch/video-share.component.html
@@ -3,7 +3,7 @@
3 <div class="modal-content"> 3 <div class="modal-content">
4 4
5 <div class="modal-header"> 5 <div class="modal-header">
6 <button type="button" class="close" aria-label="Close" (click)="hideModal()"> 6 <button type="button" class="close" aria-label="Close" (click)="hide()">
7 <span aria-hidden="true">&times;</span> 7 <span aria-hidden="true">&times;</span>
8 </button> 8 </button>
9 <h4 class="modal-title">Share</h4> 9 <h4 class="modal-title">Share</h4>
diff --git a/client/src/app/videos/video-watch/video-watch.component.ts b/client/src/app/videos/video-watch/video-watch.component.ts
index afc6fe01c..14aae9895 100644
--- a/client/src/app/videos/video-watch/video-watch.component.ts
+++ b/client/src/app/videos/video-watch/video-watch.component.ts
@@ -1,7 +1,8 @@
1import { setInterval, setTimeout } from 'timers'
1import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core'; 2import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core';
2import { ActivatedRoute } from '@angular/router'; 3import { ActivatedRoute } from '@angular/router';
3 4
4import { MetaService } from 'ng2-meta'; 5import { MetaService } from 'ng2-meta/src';
5import * as videojs from 'video.js'; 6import * as videojs from 'video.js';
6 7
7import { VideoMagnetComponent } from './video-magnet.component'; 8import { VideoMagnetComponent } from './video-magnet.component';
diff --git a/client/src/custom-typings.d.ts b/client/src/custom-typings.d.ts
index 95787181f..7cb57b62b 100644
--- a/client/src/custom-typings.d.ts
+++ b/client/src/custom-typings.d.ts
@@ -46,6 +46,16 @@ import * as _ from 'lodash'
46// support NodeJS modules without type definitions 46// support NodeJS modules without type definitions
47declare module '*'; 47declare module '*';
48 48
49/*
50// for legacy tslint etc to understand rename 'modern-lru' with your package
51// then comment out `declare module '*';`. For each new module copy/paste
52// this method of creating an `any` module type definition
53declare module 'modern-lru' {
54 let x: any;
55 export = x;
56}
57*/
58
49// Extra variables that live on Global that will be replaced by webpack DefinePlugin 59// Extra variables that live on Global that will be replaced by webpack DefinePlugin
50declare var ENV: string; 60declare var ENV: string;
51declare var HMR: boolean; 61declare var HMR: boolean;
@@ -56,8 +66,8 @@ interface SystemJS {
56} 66}
57 67
58interface GlobalEnvironment { 68interface GlobalEnvironment {
59 ENV; 69 ENV: string;
60 HMR; 70 HMR: boolean;
61 SystemJS: SystemJS; 71 SystemJS: SystemJS;
62 System: SystemJS; 72 System: SystemJS;
63} 73}
@@ -76,7 +86,6 @@ type AsyncRoutes = {
76 FactoryPromise 86 FactoryPromise
77}; 87};
78 88
79
80type IdleCallbacks = Es6PromiseLoader | 89type IdleCallbacks = Es6PromiseLoader |
81 Function | 90 Function |
82 FactoryEs6PromiseLoader | 91 FactoryEs6PromiseLoader |
@@ -98,7 +107,6 @@ interface WebpackModule {
98 }; 107 };
99} 108}
100 109
101
102interface WebpackRequire { 110interface WebpackRequire {
103 (id: string): any; 111 (id: string): any;
104 (paths: string[], callback: (...modules: any[]) => void): void; 112 (paths: string[], callback: (...modules: any[]) => void): void;
@@ -114,7 +122,6 @@ interface ErrorStackTraceLimit {
114 stackTraceLimit: number; 122 stackTraceLimit: number;
115} 123}
116 124
117
118// Extend typings 125// Extend typings
119interface NodeRequire extends WebpackRequire {} 126interface NodeRequire extends WebpackRequire {}
120interface ErrorConstructor extends ErrorStackTraceLimit {} 127interface ErrorConstructor extends ErrorStackTraceLimit {}
diff --git a/client/src/main.browser.aot.ts b/client/src/main.browser.aot.ts
new file mode 100644
index 000000000..29ecf7349
--- /dev/null
+++ b/client/src/main.browser.aot.ts
@@ -0,0 +1,23 @@
1import { platformBrowser } from '@angular/platform-browser';
2import { decorateModuleRef } from './app/environment';
3/*
4 * App Module
5 * our top level module that holds all of our components
6 */
7import { AppModuleNgFactory } from '../compiled/src/app/app.module.ngfactory';
8
9/*
10 * Bootstrap our Angular app with a top level NgModule
11 */
12export function main(): Promise<any> {
13 return platformBrowser()
14 .bootstrapModuleFactory(AppModuleNgFactory)
15 .then(decorateModuleRef)
16 .catch((err) => console.error(err));
17}
18
19export function bootstrapDomReady() {
20 document.addEventListener('DOMContentLoaded', main);
21}
22
23bootstrapDomReady();
diff --git a/client/src/main.ts b/client/src/main.browser.ts
index 70bf48537..70bf48537 100644
--- a/client/src/main.ts
+++ b/client/src/main.browser.ts
diff --git a/client/src/polyfills.ts b/client/src/polyfills.browser.ts
index 65e211459..65e211459 100644
--- a/client/src/polyfills.ts
+++ b/client/src/polyfills.browser.ts
diff --git a/client/src/sass/application.scss b/client/src/sass/application.scss
index cdb486557..30588067f 100644
--- a/client/src/sass/application.scss
+++ b/client/src/sass/application.scss
@@ -1,4 +1,4 @@
1@import '../video.js/dist/video-js.css'; 1@import '../../node_modules/video.js/dist/video-js.css';
2 2
3body { 3body {
4 padding: 20px; 4 padding: 20px;
diff --git a/client/src/vendor.ts b/client/src/vendor.ts
deleted file mode 100644
index 436c58f48..000000000
--- a/client/src/vendor.ts
+++ /dev/null
@@ -1,35 +0,0 @@
1// For vendors for example jQuery, Lodash, angular2-jwt just import them here unless you plan on
2// chunking vendors files for async loading. You would need to import the async loaded vendors
3// at the entry point of the async loaded file. Also see custom-typings.d.ts as you also need to
4// run `typings install x` where `x` is your module
5
6// Angular 2
7import '@angular/platform-browser';
8import '@angular/platform-browser-dynamic';
9import '@angular/core';
10import '@angular/common';
11import '@angular/forms';
12import '@angular/http';
13import '@angular/router';
14
15import '@angularclass/hmr';
16
17// RxJS
18import 'rxjs/Observable';
19import 'rxjs/Subject';
20import 'rxjs/ReplaySubject';
21import 'rxjs/add/operator/catch';
22import 'rxjs/add/operator/mergeMap';
23import 'rxjs/add/operator/map';
24import 'rxjs/add/observable/throw';
25
26import 'bootstrap-loader';
27
28import 'angular-pipes/src/math/bytes.pipe';
29import 'ng2-file-upload';
30import 'video.js';
31import 'ng2-meta';
32import 'ng2-bootstrap/pagination';
33import 'ng2-bootstrap/dropdown';
34import 'ng2-bootstrap/progressbar';
35import 'ng2-bootstrap/modal';
diff --git a/client/tsconfig.webpack.json b/client/tsconfig.webpack.json
new file mode 100644
index 000000000..a0830cada
--- /dev/null
+++ b/client/tsconfig.webpack.json
@@ -0,0 +1,42 @@
1{
2 "compilerOptions": {
3 "target": "es5",
4 "module": "es2015",
5 "moduleResolution": "node",
6 "emitDecoratorMetadata": true,
7 "experimentalDecorators": true,
8 "allowSyntheticDefaultImports": true,
9 "sourceMap": true,
10 "noEmitHelpers": true,
11 "strictNullChecks": false,
12 "baseUrl": "./src",
13 "paths": [
14 ],
15 "lib": [
16 "dom",
17 "es6"
18 ],
19 "types": [
20 "node",
21 "source-map",
22 "uglify-js",
23 "videojs",
24 "webpack"
25 ]
26 },
27 "exclude": [
28 "node_modules",
29 "dist"
30 ],
31 "awesomeTypescriptLoaderOptions": {
32 "forkChecker": true,
33 "useWebpackText": true
34 },
35 "angularCompilerOptions": {
36 "genDir": "./compiled",
37 "skipMetadataEmit": true
38 },
39 "compileOnSave": false,
40 "buildOnSave": false,
41 "atom": { "rewriteTsconfig": false }
42}