diff options
author | William Lahti <wilahti@gmail.com> | 2018-06-28 06:53:04 -0700 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-06-28 15:53:04 +0200 |
commit | 3ea9a1c311c3e3c55fb95560d4dd99a77c52df4a (patch) | |
tree | d2c409d6c5f247cf0b1fc2d76bd1370fddd3fa3c | |
parent | 9e01e51099c2949036f29d01f7305dff4d2b8748 (diff) | |
download | PeerTube-3ea9a1c311c3e3c55fb95560d4dd99a77c52df4a.tar.gz PeerTube-3ea9a1c311c3e3c55fb95560d4dd99a77c52df4a.tar.zst PeerTube-3ea9a1c311c3e3c55fb95560d4dd99a77c52df4a.zip |
Replace angular-cli patch with something less risky (#742)
* Replace angular-cli patch with something less risky
* path.join() is needed, provide a naive implementation
* technically, webpack provided a polyfill for Buffer, we should too
* process polyfill matches webpack; peertube depends on nextTick
* polyfill for path to match webpack
* http/https polyfills as per webpack
-rw-r--r-- | client/angular-cli-patch.js | 15 | ||||
-rw-r--r-- | client/package.json | 7 | ||||
-rw-r--r-- | client/src/polyfills.ts | 6 | ||||
-rw-r--r-- | client/src/shims/http.ts | 1 | ||||
-rw-r--r-- | client/src/shims/https.ts | 1 | ||||
-rw-r--r-- | client/src/shims/noop.ts | 3 | ||||
-rw-r--r-- | client/src/shims/path.ts | 1 | ||||
-rw-r--r-- | client/tsconfig.json | 8 |
8 files changed, 25 insertions, 17 deletions
diff --git a/client/angular-cli-patch.js b/client/angular-cli-patch.js deleted file mode 100644 index 0829631c2..000000000 --- a/client/angular-cli-patch.js +++ /dev/null | |||
@@ -1,15 +0,0 @@ | |||
1 | // Remove patch when https://github.com/angular/angular-cli/issues/10681#issuecomment-389160125 is closed | ||
2 | |||
3 | const fs = require('fs'); | ||
4 | const f = 'node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js'; | ||
5 | |||
6 | fs.readFile(f, 'utf8', function (err,data) { | ||
7 | if (err) { | ||
8 | return console.log(err); | ||
9 | } | ||
10 | var result = data.replace(/node: false/g, 'node: { global: true, crypto: "empty", fs: "empty", process: true, module: false, clearImmediate: false, setImmediate: false }'); | ||
11 | |||
12 | fs.writeFile(f, result, 'utf8', function (err) { | ||
13 | if (err) return console.log(err); | ||
14 | }); | ||
15 | }); | ||
diff --git a/client/package.json b/client/package.json index 0c2fdcafe..1264891ec 100644 --- a/client/package.json +++ b/client/package.json | |||
@@ -17,7 +17,7 @@ | |||
17 | "webpack": "webpack", | 17 | "webpack": "webpack", |
18 | "tslint": "tslint", | 18 | "tslint": "tslint", |
19 | "ng": "ng", | 19 | "ng": "ng", |
20 | "postinstall": "npm rebuild node-sass && test -f angular-cli-patch.js && node angular-cli-patch.js || true", | 20 | "postinstall": "npm rebuild node-sass", |
21 | "webpack-bundle-analyzer": "webpack-bundle-analyzer", | 21 | "webpack-bundle-analyzer": "webpack-bundle-analyzer", |
22 | "webdriver-manager": "webdriver-manager", | 22 | "webdriver-manager": "webdriver-manager", |
23 | "ngx-extractor": "ngx-extractor" | 23 | "ngx-extractor": "ngx-extractor" |
@@ -61,6 +61,7 @@ | |||
61 | "angular2-notifications": "^1.0.2", | 61 | "angular2-notifications": "^1.0.2", |
62 | "awesome-typescript-loader": "5.0.0", | 62 | "awesome-typescript-loader": "5.0.0", |
63 | "bootstrap-sass": "^3.3.7", | 63 | "bootstrap-sass": "^3.3.7", |
64 | "buffer": "^5.1.0", | ||
64 | "cache-chunk-store": "^2.0.0", | 65 | "cache-chunk-store": "^2.0.0", |
65 | "codelyzer": "^4.0.2", | 66 | "codelyzer": "^4.0.2", |
66 | "core-js": "^2.4.1", | 67 | "core-js": "^2.4.1", |
@@ -69,6 +70,7 @@ | |||
69 | "extract-text-webpack-plugin": "4.0.0-beta.0", | 70 | "extract-text-webpack-plugin": "4.0.0-beta.0", |
70 | "file-loader": "^1.1.5", | 71 | "file-loader": "^1.1.5", |
71 | "html-webpack-plugin": "^3.2.0", | 72 | "html-webpack-plugin": "^3.2.0", |
73 | "https-browserify": "^1.0.0", | ||
72 | "jasmine-core": "^3.1.0", | 74 | "jasmine-core": "^3.1.0", |
73 | "jasmine-spec-reporter": "^4.2.1", | 75 | "jasmine-spec-reporter": "^4.2.1", |
74 | "karma": "^2.0.2", | 76 | "karma": "^2.0.2", |
@@ -85,7 +87,9 @@ | |||
85 | "ngx-pipes": "^2.1.7", | 87 | "ngx-pipes": "^2.1.7", |
86 | "node-sass": "^4.1.1", | 88 | "node-sass": "^4.1.1", |
87 | "npm-font-source-sans-pro": "^1.0.2", | 89 | "npm-font-source-sans-pro": "^1.0.2", |
90 | "path-browserify": "^1.0.0", | ||
88 | "primeng": "^6.0.0-rc.1", | 91 | "primeng": "^6.0.0-rc.1", |
92 | "process": "^0.11.10", | ||
89 | "protractor": "^5.3.2", | 93 | "protractor": "^5.3.2", |
90 | "purify-css": "^1.2.5", | 94 | "purify-css": "^1.2.5", |
91 | "purifycss-webpack": "^0.7.0", | 95 | "purifycss-webpack": "^0.7.0", |
@@ -95,6 +99,7 @@ | |||
95 | "sanitize-html": "^1.16.3", | 99 | "sanitize-html": "^1.16.3", |
96 | "sass-loader": "^7.0.1", | 100 | "sass-loader": "^7.0.1", |
97 | "sass-resources-loader": "^1.2.1", | 101 | "sass-resources-loader": "^1.2.1", |
102 | "stream-http": "^2.8.3", | ||
98 | "tslint": "^5.7.0", | 103 | "tslint": "^5.7.0", |
99 | "tslint-config-standard": "^7.0.0", | 104 | "tslint-config-standard": "^7.0.0", |
100 | "typescript": "2.7", | 105 | "typescript": "2.7", |
diff --git a/client/src/polyfills.ts b/client/src/polyfills.ts index 423a7b915..eec30760d 100644 --- a/client/src/polyfills.ts +++ b/client/src/polyfills.ts | |||
@@ -80,3 +80,9 @@ import 'zone.js/dist/zone' // Included with Angular CLI. | |||
80 | /*************************************************************************************************** | 80 | /*************************************************************************************************** |
81 | * APPLICATION IMPORTS | 81 | * APPLICATION IMPORTS |
82 | */ | 82 | */ |
83 | |||
84 | // global/process polyfills | ||
85 | |||
86 | ;(window as any).global = window; | ||
87 | ;(window as any).process = require('process/'); | ||
88 | ;(window as any).Buffer = require('buffer/').Buffer; | ||
diff --git a/client/src/shims/http.ts b/client/src/shims/http.ts new file mode 100644 index 000000000..a759400cb --- /dev/null +++ b/client/src/shims/http.ts | |||
@@ -0,0 +1 @@ | |||
module.exports = require('stream-http'); \ No newline at end of file | |||
diff --git a/client/src/shims/https.ts b/client/src/shims/https.ts new file mode 100644 index 000000000..1da6f8adb --- /dev/null +++ b/client/src/shims/https.ts | |||
@@ -0,0 +1 @@ | |||
module.exports = require('https-browserify'); \ No newline at end of file | |||
diff --git a/client/src/shims/noop.ts b/client/src/shims/noop.ts new file mode 100644 index 000000000..338e16104 --- /dev/null +++ b/client/src/shims/noop.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | // Does nothing. Used to shim out node.js modules | ||
2 | // which are no-ops in the browser. | ||
3 | export const NOOP = 0; \ No newline at end of file | ||
diff --git a/client/src/shims/path.ts b/client/src/shims/path.ts new file mode 100644 index 000000000..74b6913d8 --- /dev/null +++ b/client/src/shims/path.ts | |||
@@ -0,0 +1 @@ | |||
module.exports = require('path-browserify'); \ No newline at end of file | |||
diff --git a/client/tsconfig.json b/client/tsconfig.json index cb6d39245..60c343867 100644 --- a/client/tsconfig.json +++ b/client/tsconfig.json | |||
@@ -20,7 +20,13 @@ | |||
20 | "baseUrl": "src", | 20 | "baseUrl": "src", |
21 | "paths": { | 21 | "paths": { |
22 | "@app/*": [ "app/*" ], | 22 | "@app/*": [ "app/*" ], |
23 | "video.js": [ "../node_modules/video.js/dist/alt/video.core.js" ] | 23 | "video.js": [ "../node_modules/video.js/dist/alt/video.core.js" ], |
24 | "fs": [ "./shims/noop" ], | ||
25 | "http": [ "./shims/http" ], | ||
26 | "https": [ "./shims/https" ], | ||
27 | "path": [ "./shims/path" ], | ||
28 | "stream": [ "./shims/noop" ], | ||
29 | "crypto": [ "./shims/noop" ] | ||
24 | } | 30 | } |
25 | } | 31 | } |
26 | } | 32 | } |