To make it 100% dynamic, you can even use the dynamic import() statement. See code splitting with webpack.
create() {
let someCondition = true
if (someCondition)
import(/* webpackChunkName: "mainScene" */ './mainScene').then(mainScene => {
this.scene.add('MainScene', mainScene.default, true)
})
else console.log('The mainScene class will not even be loaded by the browser')
}
Edit:
I have just added support for it in both of my templates.