Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: patch the angular browser.js to allow `{crypto: true, stream: … #2262

Merged
merged 2 commits into from
Feb 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/web3/angular-patch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const fs = require('fs');
const f = '../../node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js';

// This is because we have to replace the `node:false` in the `/angular-cli-files/models/webpack-configs/browser.js`
// with `node: {crypto: true, stream: true}` to allow web3 to work with angular (as they enforce node: false.)
// as explained here - https://github.com/ethereum/web3.js/issues/2260#issuecomment-458519127
if (fs.existsSync(f)) {
fs.readFile(f, 'utf8', function (err, data) {
if (err) {
return console.log(err);
}
var result = data.replace(/node: false/g, 'node: {crypto: true, stream: true}');
fs.writeFile(f, result, 'utf8', function (err) {
if (err) return console.log(err);
});
});
}
6 changes: 3 additions & 3 deletions packages/web3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
"API"
],
"author": "ethereum.org",
"authors": [
{
"authors": [{
"name": "Samuel Furter",
"email": "samuel@ethereum.org",
"homepage": "https://github.com/nivida"
Expand Down Expand Up @@ -52,7 +51,8 @@
"build": "rollup -c",
"dev": "rollup -c -w",
"test": "jest",
"dtslint": "dtslint types --onlyTestTsNext"
"dtslint": "dtslint types --onlyTestTsNext",
"postinstall": "node angular-patch.js"
},
"types": "types",
"dependencies": {
Expand Down