Plugins should not give a name to the returned class:
module.exports = (Model) => {
// Always return an anonymous class
return class extends Model {
};
};
@vladshcherbin pointed out in #473 that anonymous class extensions keep their parent class's name from node 8 onward:
class X {}
const f = (C) => class extends C {}
const Y = f(X);
console.log(Y.name); // --> 'X'
this allows you to use plugins like this:
class Person extends Model {
}
export default plugin(Person)
without losing the actual class name.
This solves the same problem when plugins are used as decorators:
@plugin
@pluginWithOptions({foo: 'bar'})
export default class Person extends Model {
}