DEV: Support components under /index paths in themes/plugins (#23876)

Normally, modules defined under `blah/index` can be imported as `blah`. This is also true of Ember resolver lookups - `<MyComponent />` should resolve to the same as `<MyComponent::Index />`. This was working as expected in Discourse core, but we had not implemented the same in our custom resolver logic for themes/plugins.

This commit implements the `/index` fallback, and adds a test for the behaviour.
This commit is contained in:
David Taylor
2023-10-10 16:29:40 +01:00
committed by GitHub
parent 3f8a85ed49
commit ef5cb6e7ed
3 changed files with 31 additions and 1 deletions

View File

@@ -147,7 +147,14 @@ function lookupModuleBySuffix(suffix) {
}
});
}
return moduleSuffixTrie.withSuffix(suffix, 1)[0];
return (
moduleSuffixTrie.withSuffix(suffix, 1)[0] ||
moduleSuffixTrie.withSuffix(`${suffix}/index`, 1)[0]
);
}
export function expireModuleTrieCache() {
moduleSuffixTrie = null;
}
export function buildResolver(baseName) {