forked from web3/web3.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: patch the angular
browser.js
to allow `{crypto: true, stream: …
…true}` (web3#3136)
- Loading branch information
1 parent
af89325
commit c789651
Showing
2 changed files
with
19 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters