This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/public/assets/scripts/module-shims.js
David Taylor 2b53c2cfca
DEV: Enable @cached decorator for themes and plugins (#19261)
`ember-cached-decorator-polyfill` uses a Babel transformation to apply this polyfill in core. Adding that Babel transformation to themes and plugins will be complex, so we use this to patch it at runtime. This can be removed once `@glimmer/tracking` is updated to a version
with native `@cached` support.
2022-11-30 15:53:54 +00:00

49 lines
1.8 KiB
JavaScript

define("I18n", ["exports"], function (exports) {
return I18n;
});
define("htmlbars-inline-precompile", ["exports"], function (exports) {
exports.default = function tag(strings) {
return Ember.Handlebars.compile(strings[0]);
};
});
define("ember-addons/ember-computed-decorators", [
"discourse-common/utils/decorators",
"discourse-common/lib/deprecated",
], function (decorators, deprecated) {
deprecated.default(
"ember-addons/ember-computed-decorators is deprecated. Use discourse-common/utils/decorators instead.",
{ since: "2.4", dropFrom: "3.0" }
);
return decorators;
});
// Based on https://github.com/emberjs/ember-jquery-legacy
// The addon has out-of-date dependences, but it's super simple so we can reproduce here instead:
define("ember-jquery-legacy", ["exports"], function (exports) {
exports.normalizeEvent = function (e) {
if (e instanceof Event) {
return e;
}
// __originalEvent is a private escape hatch of Ember's EventDispatcher to allow accessing `originalEvent` without
// triggering a deprecation message.
return e.__originalEvent || e.originalEvent;
};
});
// ember-cached-decorator-polyfill uses a Babel transformation to apply this polyfill in core.
// Adding that Babel transformation to themes and plugins will be complex, so we use this to
// patch it at runtime. This can be removed once `@glimmer/tracking` is updated to a version
// with native `@cached` support.
const glimmerTracking = require("@glimmer/tracking");
if (glimmerTracking.cached) {
console.error(
"@glimmer/tracking natively supports the @cached decorator. The polyfill can be removed."
);
} else {
Object.defineProperty(glimmerTracking, "cached", {
get: () => require("ember-cached-decorator-polyfill").cached,
});
}