mirror of
https://github.com/discourse/discourse.git
synced 2026-08-19 01:14:56 -05:00
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.
This commit is contained in:
@@ -31,3 +31,18 @@ define("ember-jquery-legacy", ["exports"], function (exports) {
|
||||
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,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user