DEV: Extract global compat code into module (#20901)

Moves a couple things from discourse-boot.js to a different JS file imported from app/app.js.

This is a forwards compatible technique to import and throw data on the window.

One thing to make note of, though, is that if the virtual-dom and discourse-widget-hbs/helpers were previously included in the build elsewhere, they will now become part of the app bundle.
Later, when using embroider, all bundles will be chunks, and webpack will optimize which chunk contains which modules appropriately.
This commit is contained in:
NullVoxPopuli 2023-04-06 05:09:12 -04:00 committed by GitHub
parent 9014cd6a6f
commit 97d8614811
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View File

@ -1,3 +1,5 @@
import "./global-compat";
import Application from "@ember/application";
import { buildResolver } from "discourse-common/resolver";
import { isTesting } from "discourse-common/config/environment";

View File

@ -0,0 +1,7 @@
import virtualDom from "virtual-dom";
import widgetHelpers from "discourse-widget-hbs/helpers";
window.__widget_helpers = widgetHelpers;
// TODO: Eliminate this global
window.virtualDom = virtualDom;

View File

@ -10,11 +10,6 @@
// https://github.com/emberjs/ember.js/blob/0c5518ea7b/packages/%40ember/-internals/glimmer/lib/helper.ts#L134-L138
require("ember");
window.__widget_helpers = require("discourse-widget-hbs/helpers").default;
// TODO: Eliminate this global
window.virtualDom = require("virtual-dom");
let element = document.querySelector(
`meta[name="discourse/config/environment"]`
);