DEV: Run implicit-injections shim earlier in boot

We need these Ember framework class overrides to be applied before anything attempts to extend them. An initializer is too late, because initializer files may `import` a module which defines classes which extend the framework classes.

In the past this rarely mattered because Ember's legacy `SomeObject.extend` is quite forgiving - it will respect changes made to `SomeObject` right up until the first `.create()` call. However, the native class syntax (`class extends SomeObject`) will 'freeze' `SomeObject` as soon as the class is defined.
This commit is contained in:
David Taylor 2023-08-02 20:23:54 +01:00
parent fbabea5c76
commit 5aaf5cbaf4
2 changed files with 4 additions and 4 deletions

View File

@ -5,6 +5,7 @@ import Application from "@ember/application";
import { buildResolver } from "discourse-common/resolver";
import { isTesting } from "discourse-common/config/environment";
import { normalizeEmberEventHandling } from "./lib/ember-events";
import { registerDiscourseImplicitInjections } from "discourse/lib/implicit-injections";
const _pluginCallbacks = [];
let _unhandledThemeErrors = [];
@ -28,6 +29,9 @@ const Discourse = Application.extend({
// between Glimmer and Classic components.
normalizeEmberEventHandling(this);
// Register Discourse's standard implicit injections on common framework classes.
registerDiscourseImplicitInjections();
if (Error.stackTraceLimit) {
// We need Errors to have full stack traces for `lib/source-identifier`
Error.stackTraceLimit = Infinity;

View File

@ -6,8 +6,6 @@ import Session from "discourse/models/session";
import Site from "discourse/models/site";
import User from "discourse/models/user";
import { registerDiscourseImplicitInjections } from "discourse/lib/implicit-injections";
export default {
after: "discourse-bootstrap",
@ -38,8 +36,6 @@ export default {
app.register("location:discourse-location", DiscourseLocation);
registerDiscourseImplicitInjections();
startTracking(this.topicTrackingState);
},