The Road to ES6
It’s pretty great. When our Ember application wants to resolve something, it will first check for an ES6 module. If one does not exist, it will look for a global.
We won’t have to rely on globals (ie
Discourse.XYZ) to access code. When everything is global any piece of code can reach in and access any other piece easily, even if logically they shouldn’t! With ES6 modules, most of the time you just let Ember wire up modules for you. If Ember doesn’t require the thing you need automatically, you have to explicitly state your intent to require it.
Ember has converted to ES6. So we will be able to only include the parts of Ember we want to use. That means that even if Ember grows to add many more features, we can conceivably include just the parts we want.
However, the more exciting reason is that it removes our dependency on Rails’ asset pipeline.
Over time I, like many Rails developers, have grown sour with the asset pipeline. Don’t get me wrong, I know a lot of talented people have put lots of hard work into it. My feeling was for a long time that the asset pipeline was the worst possible way to manage assets… except for every other way.
Once we have migrated to ES6 modules, we can move our entire EmberJS application to use ember-cli. If you are an EmberJS developer and haven’t tried out ember-cli yet I highly recommend you do, it’s like magic! Take a look at one of the screencasts I made to see it in action.
What I’d like to see is something like this:
You check out the Discourse project from github.
The root has a
serverfolder, for the ember and rails apps respectively.
clientproject uses ember-cli for development. It will not need you to run the rails server. ember-cli comes with a proxy built in, which you could point at our http://try.discourse.org server or perhaps another public staging server we’ll set up.
This is awesome for many reasons; so many people want to contribute to Discourse but can’t get the Rails server running. Setting up ember-cli is much easier, and even works on Windows!
When we deploy new releases, our deployment process will be smart enough to not deploy the entire Rails application if the server code does not change. I really fell in love with Luke Melia’s RailsConf presentation on the topic. Deploys in seconds!
ETA for all of this?
This is a long term goal. I am converting our code slowly and it will take some time to get there. I don’t have an ETA and it certainly cannot interfere with other goals Discourse has for features. But I have made great progress! So far the vast majority of our components, controllers and views are using ES6!
It will take a few more passes but it’s going very smoothly with few regressions so far. Again this is a testament to Ember’s resolver architecture and how fantastic it is for migrating a large application like Discourse.
Be sure to let me know any thoughts, criticisms, advice and all that fun stuff as usual. Cheers!