refactor: parity

This commit is contained in:
cha0s 2022-03-10 14:21:15 -06:00
parent 47a3f19881
commit 068c02dbfc

View File

@ -107,9 +107,13 @@ module.exports = (async () => {
if (Object.keys(aliases).length > 0) {
const code = [
`const aliases = ${JSON.stringify(aliases)};`,
`const stubs = ${JSON.stringify(stubs)};`,
'const {Module} = require("module");',
'const {require: Mr} = Module.prototype;',
'Module.prototype.require = function hackedRequire(request, options) {',
' if (-1 !== stubs.indexOf(request)) {',
' return undefined;',
' }',
' if (aliases[request]) {',
' return Mr.call(this, aliases[request], options);',
' }',