Совсем "по правилам" надо так добавлять
test.js
const methods = {
function test() {
console.log(this.name)
}
}
module.exports = methods
const methods = require('./test')
class Tmp {
constructor(name) {
//....
}
home() {
//...
}
}
methods.__proto__ = Tmp.prototype.__proto__
Object.defineProperty(Tmp.prototype, 'test', {
writable: true,
enumerable: false,
configurable: true,
value: methods.test,
});