DEV: add loader.js shims for packages used across bundles (#22703)

This adds a new `loaderShim()` function to ensure certain modules
are present in the `loader.js` registry and therefore runtime
`require()`-able.

Currently, the classic build pipeline puts a lot of things in the
runtime `loader.js` registry automatically. For example, all of
the ember-auto-import packages are in there.

Going forward, and especially as we switch to the Embroider build
pipeline, this will not be guarenteed. We need to keep an eye on
what modules (packages) our "external" bundles (admin, wizard,
markdown-it, plugins, etc) are expecting to be present and put
them into the registry proactively.
This commit is contained in:
Godfrey Chan
2023-08-09 04:04:41 -07:00
committed by GitHub
parent a846226e92
commit 923b51ad25
12 changed files with 185 additions and 1 deletions

View File

@ -1,3 +1,21 @@
define("@embroider/macros", ["exports", "require"], function (
__require__,
__exports__
) {
__exports__.importSync = __require__;
});
define("discourse-common/lib/loader-shim", ["exports", "require"], function (
__exports__,
__require__
) {
__exports__.default = (id, callback) => {
if (!__require__.has(id)) {
define(id, callback);
}
};
});
define("xss", ["exports"], function (__exports__) {
__exports__.default = window.filterXSS;
});