Mock fs, tls, and net to support request in the browser

fs is mocked using memfs, which needs to be installed at all 3 layers because webpack is silly
This commit is contained in:
Travis Ralston 2018-10-24 16:59:14 -06:00
parent d080a204a3
commit e4025f1aff
3 changed files with 106 additions and 44 deletions

View file

@ -115,8 +115,21 @@ module.exports = {
// same goes for js-sdk
"matrix-js-sdk": path.resolve('./node_modules/matrix-js-sdk'),
// To make webpack happy
// Related: https://github.com/request/request/issues/1529
// (there's no mock available for fs, so we fake a mock by using
// an in-memory version of fs)
"fs": "memfs",
},
},
node: {
// Because webpack is made of fail
// https://github.com/request/request/issues/1529
// Note: 'mock' is the new 'empty'
net: 'mock',
tls: 'mock'
},
externals: {
// Don't try to bundle electron: leave it as a commonjs dependency
// (the 'commonjs' here means it will output a 'require')