With a JavaScript 'class' (not really a class, I know), it's possible to break up a big definition by putting methods in separate files, like this:
var Foo = function () {
console.log('initializing foo');
};
Foo.prototype.render = require('./render');
But with ES6 classes, it looks like the syntax rules out this approach – it seems the methods always have to be written as function literals inside the class block.
I tried this in the 6to5 REPL:
class Foo {
constructor() {
console.log('initializing foo');
}
require('./render');
}
...but it errors.
As an example, CoffeeScript's class syntax allows me to do this:
class Foo
constructor: ->
console.log 'initializing foo'
render: require './render'
Is there really no way to do this with ES6 classes?