From 294f80f21e8a77d25f6fb5f0f26887fb4618ee2e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Sun, 11 Jun 2017 15:25:36 +0200 Subject: [PATCH] Bundle webtorrent with webpack. Closes https://github.com/Chocobozzz/PeerTube/issues/50 --- client/config/webpack.common.js | 4 ---- client/config/webpack.dev.js | 5 +---- client/config/webpack.prod.js | 5 +---- client/src/app/videos/video-watch/video-watch.component.ts | 6 +++--- client/src/app/videos/video-watch/webtorrent.service.ts | 2 +- client/src/index.html | 3 --- 6 files changed, 6 insertions(+), 19 deletions(-) diff --git a/client/config/webpack.common.js b/client/config/webpack.common.js index 459985880..a81bca9d2 100644 --- a/client/config/webpack.common.js +++ b/client/config/webpack.common.js @@ -260,10 +260,6 @@ module.exports = function (options) { from: 'src/assets', to: 'assets' }, - { - from: 'node_modules/webtorrent/webtorrent.min.js', - to: 'assets/webtorrent' - }, { from: 'src/standalone', to: 'standalone' diff --git a/client/config/webpack.dev.js b/client/config/webpack.dev.js index d6ebed730..42d9ca37e 100644 --- a/client/config/webpack.dev.js +++ b/client/config/webpack.dev.js @@ -83,10 +83,6 @@ module.exports = function (env) { libraryTarget: 'var' }, - externals: { - webtorrent: 'WebTorrent' - }, - module: { // Too slow, life is short @@ -246,6 +242,7 @@ module.exports = function (env) { node: { global: true, crypto: 'empty', + fs: 'empty', process: true, module: false, clearImmediate: false, diff --git a/client/config/webpack.prod.js b/client/config/webpack.prod.js index 3f063c7c6..c27a4f4b0 100644 --- a/client/config/webpack.prod.js +++ b/client/config/webpack.prod.js @@ -81,10 +81,6 @@ module.exports = function (env) { publicPath: '/client/' }, - externals: { - webtorrent: 'WebTorrent' - }, - /** * Add additional plugins to the compiler. * @@ -272,6 +268,7 @@ module.exports = function (env) { node: { global: true, crypto: 'empty', + fs: 'empty', process: false, module: false, clearImmediate: false, 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 32c847785..bcfebf2fd 100644 --- a/client/src/app/videos/video-watch/video-watch.component.ts +++ b/client/src/app/videos/video-watch/video-watch.component.ts @@ -21,15 +21,15 @@ import { WebTorrentService } from './webtorrent.service'; }) export class VideoWatchComponent implements OnInit, OnDestroy { - private static LOADTIME_TOO_LONG: number = 20000; + private static LOADTIME_TOO_LONG = 20000; @ViewChild('videoMagnetModal') videoMagnetModal: VideoMagnetComponent; @ViewChild('videoShareModal') videoShareModal: VideoShareComponent; @ViewChild('videoReportModal') videoReportModal: VideoReportComponent; downloadSpeed: number; - error: boolean = false; - loading: boolean = false; + error = false; + loading = false; numPeers: number; player: videojs.Player; playerElement: Element; diff --git a/client/src/app/videos/video-watch/webtorrent.service.ts b/client/src/app/videos/video-watch/webtorrent.service.ts index 630a5c469..8936e7992 100644 --- a/client/src/app/videos/video-watch/webtorrent.service.ts +++ b/client/src/app/videos/video-watch/webtorrent.service.ts @@ -1,7 +1,7 @@ import { Injectable } from '@angular/core'; import { Subject } from 'rxjs/Subject'; -declare const WebTorrent; +import * as WebTorrent from 'webtorrent'; @Injectable() export class WebTorrentService { diff --git a/client/src/index.html b/client/src/index.html index ea88bb15b..4346775b1 100644 --- a/client/src/index.html +++ b/client/src/index.html @@ -11,9 +11,6 @@ - - -