Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Bundle webtorrent with webpack. Closes https://github.com/Chocobozzz/PeerTube/issues/50

Chocobozzz294f80f21e8a
diff --git a/client/config/webpack.common.js b/client/config/webpack.common.js
index 4599858803..a81bca9d28 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 d6ebed7300..42d9ca37ea 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 3f063c7c68..c27a4f4b03 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 32c8477852..bcfebf2fd1 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 630a5c4698..8936e79925 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 ea88bb15b6..4346775b1a 100644
--- a/client/src/index.html
+++ b/client/src/index.html
@@ -11,9 +11,6 @@
<!-- opengraph tags -->
<!-- Do not remove it! -->
- <!-- TODO: bundle it with webpack when https://github.com/webpack/webpack/pull/1931 will be merged -->
- <!-- <script src="/client/assets/webtorrent/webtorrent.min.js"></script> -->
-
<link rel="icon" type="image/png" href="/client/assets/favicon.png" />
<!-- base url -->