react and reactdom in webpack + window

This commit is contained in:
Jean Ouina 2020-05-26 16:14:09 +02:00
parent 1cf3433a88
commit 1cdc0efc9c
4 changed files with 27 additions and 3 deletions

1
BetterDiscordApp/src/react-dom.js vendored Normal file
View File

@ -0,0 +1 @@
module.exports = window.ReactDOM

1
BetterDiscordApp/src/react.js vendored Normal file
View File

@ -0,0 +1 @@
module.exports = window.React

View File

@ -29,7 +29,11 @@ module.exports = {
modules: [ modules: [
path.resolve("src", "builtins"), path.resolve("src", "builtins"),
path.resolve("src", "modules") path.resolve("src", "modules")
] ],
alias: {
react$: path.resolve(__dirname, "src", "react.js"),
"react-dom$": path.resolve(__dirname, "src", "react-dom.js")
}
}, },
module: { module: {
rules: [ rules: [
@ -45,6 +49,10 @@ module.exports = {
} }
}], "@babel/react"] }], "@babel/react"]
} }
},
{
test: /\.svg$/,
use: ['@svgr/webpack'],
} }
] ]
}, },

View File

@ -43,6 +43,20 @@ async function privateInit(){
//disabling sentry //disabling sentry
BDModules.get(e => e.getCurrentHub)[0].getCurrentHub().getClient().getOptions().enabled = false BDModules.get(e => e.getCurrentHub)[0].getCurrentHub().getClient().getOptions().enabled = false
// setting react in require cache
try{
window.React = require("react")
}catch(e){
const React = ModuleLoader.get(e => !["Component", "PureComponent", "Children", "createElement", "cloneElement"].map(c => !!e[c]).includes(false))[0]
window.React = React
}
try{
window.ReactDOM = require("react-dom")
}catch(e){
const ReactDOM = ModuleLoader.get(e => e.findDOMNode)[0]
window.ReactDOM = ReactDOM
}
let original = BDModules.get((e) => e.createSound)[0].createSound let original = BDModules.get((e) => e.createSound)[0].createSound
BDModules.get((e) => e.createSound)[0].createSound = function(sound){ BDModules.get((e) => e.createSound)[0].createSound = function(sound){
@ -55,9 +69,9 @@ async function privateInit(){
}, },
set(data){ set(data){
console.log("Attempting to set call_ringing value. Canceling "+data) console.log("Attempting to set call_ringing value. Canceling "+data)
} },
configurable: false
}) })
console.log(returned)
return returned return returned
}else{ }else{
return original(...arguments) return original(...arguments)