JavaScript - class extending another in separate files

// class1.js
Class1 = class {
  // ...
}
if (Class2) Object.setPrototypeOf(Class2.prototype, Class1.prototype);
// class2.js
Class2 = class extends (window.Class1 ?? Object) {
  // ...
}

If class1.js is loaded before class2.js, Class2 will extend Class1. If it is loaded after, it will set the prototype of Class2 to extend Class1.