I’m currently investigating how I could load Ember CLI Addons dynamically (dynamically meaning I want to decide which addons to load when I serve the index.html). The idea is to have a base application with a certain feature set and depending on the capabilities of the device (the project is a device configuration UI where index.html is served directly from the device) dynamically load other JS files that define more routes, controller, templates etc. for features that only certain devices are capable of.
Of course I can simply change the default
<script src="assets/vendor.js"></script>
<script src="assets/<app-name>.js"></script>
to
<script src="assets/vendor.js"></script>
<script src="assets/<addon-name>.js"></script>
<script src="assets/<app-name>.js"></script>
The problem is I cannot build that assets/<addon-name>.js
deliverable with Ember CLI as I have to install the Addon into the project where it automatically gets built into assets/<app-name>.js
. The way I currently do it I build the application once without the Addon installed and once with the Addon installed and then take the diff of the 2 deliverables as assets/<addon-name>.js
. Of course that’s not really a great way to build an app.
I was wondering whether other people have had projects with similar requirements or wether there are other ways to solve this that I didn’t think of yet. I think this might also be something that could be interesting to support in some way in Ember CLI (I think there’s already some discussion going on on the topic os splitting up an application into multiple JS files?).