DEV: Remove Ember.TEMPLATES and centralize template resolution rules (#19220)

In the past, the result of template compilation would be stored directly in `Ember.TEMPLATES`. Following the move to more modern ember-cli-based compilation, templates are now compiled to es6 modules. To handle forward/backwards compatibility during these changes we had logic in `discourse-boot` which would extract templates from the es6 modules and store them into the legacy-style `Ember.TEMPLATES` object.

This commit removes that shim, and updates our resolver to fetch templates directly from es6 modules. This is closer to how 'vanilla' Ember handles template resolution. We still have a lot of discourse-specific logic, but now it is centralised in one location and should be easier to understand and normalize in future.

This commit should not introduce any behaviour change.
This commit is contained in:
David Taylor
2022-11-29 10:24:35 +00:00
committed by GitHub
parent 8b2c2e5c34
commit c139767055
18 changed files with 457 additions and 273 deletions

View File

@ -1,3 +1,4 @@
import DiscourseTemplateMap from "discourse-common/lib/discourse-template-map";
let _allCategories = null;
let _sectionsById = {};
let _notes = {};
@ -30,7 +31,7 @@ export function allCategories() {
// Find a list of sections based on what templates are available
// eslint-disable-next-line no-undef
Object.keys(Ember.TEMPLATES).forEach((e) => {
DiscourseTemplateMap.keys().forEach((e) => {
let regexp = new RegExp(`styleguide\/(${paths})\/(\\d+)?\\-?([^\\/]+)$`);
let matches = e.match(regexp);
if (matches) {