Last active
May 8, 2023 09:07
-
-
Save niespodd/1fa82da6f8c901d1c33d2fcbb762947d to your computer and use it in GitHub Desktop.
Making web3/bitcore-lib work with Angular 6-11 and >=11
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
{... | |
"scripts": { | |
"postinstall": "node patch.js", | |
... | |
} | |
} |
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
// Angular >= 11 | |
const fs = require('fs') | |
const f = 'node_modules/@angular-devkit/build-angular/src/webpack/configs/browser.js' | |
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: "empty"}') | |
fs.writeFile(f, result, 'utf8', function(err) { | |
if (err) return console.log(err) | |
}) | |
}); | |
// ---- | |
// For Angular <11 | |
const fs = require('fs'); | |
const f = 'node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js'; | |
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); | |
}); | |
}); | |
// ---- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes I was modifying browser.js as well, but now it's gone, and I find a new way:
My currently version: @angular/cli@v15.2.7", electron": "^24.1.3", "electron-builder": "^23.6.0".
APPROCH 1:
npm install --save-dev @angular-builders/custom-webpack@^15.0.0
APPROCH 2: Here again we modify the config file :p
Your scripts now should update this file:
node_modules\@angular-devkit\build-angular\src\webpack\configs\common.js
And make sure the target will be replaced to 'electron'-renderer' only.
replace old > target: [isPlatformServer ? 'node' : 'web', 'es2015'],
to > target: ['electron-renderer'],