Autoload widgets since they are named when created, not by file

This commit is contained in:
Robin Ward 2016-03-18 16:31:59 -04:00
parent b83b9d2b75
commit fbf45426e4
3 changed files with 17 additions and 14 deletions

View File

@ -0,0 +1,15 @@
export function autoLoadModules() {
Ember.keys(requirejs.entries).forEach(entry => {
if ((/\/helpers\//).test(entry)) {
require(entry, null, null, true);
}
if ((/\/widgets\//).test(entry)) {
require(entry, null, null, true);
}
});
}
export default {
name: 'auto-load-modules',
initialize: autoLoadModules
};

View File

@ -1,12 +0,0 @@
export function loadAllHelpers() {
Ember.keys(requirejs.entries).forEach(entry => {
if ((/\/helpers\//).test(entry)) {
require(entry, null, null, true);
}
});
}
export default {
name: 'load-all-helpers',
initialize: loadAllHelpers
};

View File

@ -1,6 +1,6 @@
import AppEvents from 'discourse/lib/app-events';
import createStore from 'helpers/create-store';
import { loadAllHelpers } from 'discourse/initializers/load-all-helpers';
import { autoLoadModules } from 'discourse/initializers/auto-load-modules';
export default function(name, opts) {
opts = opts || {};
@ -18,7 +18,7 @@ export default function(name, opts) {
this.siteSettings = Discourse.SiteSettings;
loadAllHelpers();
autoLoadModules();
if (opts.setup) {
const store = createStore();