mirror of
https://github.com/discourse/discourse.git
synced 2024-12-22 19:44:44 +08:00
270e98e45f
By default, Ember uses a babel transformation to strip out calls to `deprecate()` in production builds. Given that Discourse is a development platform for third-party themes/plugins, having deprecation messages visible in production is essential - many themes/plugins do not have comprehensive test-suites, and rely on production feedback to prompt changes. This commit patches Ember to print its deprecation messages to the console in production. In future we intend to improve the visibility of these to hosting providers and/or site admins. There are two main parts to this commit: 1. Use yarn's 'resolutions' feature to point `babel-plugin-debug-macros` to a discourse-owned fork. This fork prevents `deprecate()` calls from being stripped. Relevant change can be found at https://github.com/discourse/babel-plugin-debug-macros/commit/d179d613bf 2. Introduce a production shim for Ember's deprecation library, including the `registerDeprecationHandler` API. The default implementation is stripped out of production builds via an `if(DEBUG)` wrapper. Long term we hope that this kind of functionality can be made available in Ember itself via a flag.
26 lines
784 B
JavaScript
26 lines
784 B
JavaScript
"use strict";
|
|
|
|
/**
|
|
* Ember's deprecation and registerDeprecationHandler APIs are stripped from production
|
|
* builds via the DEBUG flag. This file provides a minimal reimplementation of them
|
|
* to be used in production.
|
|
*
|
|
* Designed to be used alongside our fork of babel-plugin-debug-macros, which maintains
|
|
* deprecate calls in production builds. This fork is introduced via a custom yarn resolution
|
|
* in app/assets/javascripts/package.json.
|
|
*
|
|
* https://github.com/discourse/babel-plugin-debug-macros/commit/d179d613bf
|
|
*/
|
|
module.exports = {
|
|
name: require("./package").name,
|
|
|
|
included() {
|
|
this._super.included.apply(this, arguments);
|
|
this.app.import("vendor/ember-production-deprecations/deprecate-shim.js");
|
|
},
|
|
|
|
isDevelopingAddon() {
|
|
return true;
|
|
},
|
|
};
|