DEV: Silence 3.x deprecations

This prevents a storm of deprecation messages in the developer console. We'll be working through and enabling these one-by-one over the coming weeks/months.

A dummy `discourse-ensure-deprecation-order` package is introduced to ensure that deprecation-workflow is loaded before `@ember/jquery`. This ensures that the `@ember/jquery`-triggered deprecation warnings can be silenced correctly

This also introduces a system for silencing CLI warnings.
This commit is contained in:
David Taylor 2022-07-13 22:21:15 +01:00
parent 0ac90abcfa
commit 20fd81c2dc
6 changed files with 58 additions and 1 deletions

View File

@ -0,0 +1,5 @@
"use strict";
module.exports = {
name: require("./package").name,
};

View File

@ -0,0 +1,14 @@
{
"name": "discourse-ensure-deprecation-order",
"version": "1.0.0",
"description": "A dummy addon which ensures ember-cli-deprecation-workflow is loaded before @ember/jquery",
"author": "Discourse",
"license": "GPL-2.0-only",
"keywords": [
"ember-addon"
],
"ember-addon": {
"before": "@ember/jquery",
"after": "ember-cli-deprecation-workflow"
}
}

View File

@ -2,5 +2,26 @@ globalThis.deprecationWorkflow = globalThis.deprecationWorkflow || {};
globalThis.deprecationWorkflow.config = {
// We're using RAISE_ON_DEPRECATION in environment.js instead of
// `throwOnUnhandled` here since it is easier to toggle.
workflow: [],
workflow: [
{ handler: "silence", matchId: "ember-global" },
{ handler: "silence", matchId: "ember-string.prototype-extensions" },
{ handler: "silence", matchId: "ember.built-in-components.reopen" },
{ handler: "silence", matchId: "ember.built-in-components.import" },
{ handler: "silence", matchId: "implicit-injections" },
{ handler: "silence", matchId: "route-render-template" },
{ handler: "silence", matchId: "routing.transition-methods" },
{ handler: "silence", matchId: "route-disconnect-outlet" },
{ handler: "silence", matchId: "setting-on-hash" },
{ handler: "silence", matchId: "this-property-fallback" },
{ handler: "silence", matchId: "ember.globals-resolver" },
{ handler: "silence", matchId: "globals-resolver" },
{
handler: "silence",
matchId: "deprecated-run-loop-and-computed-dot-access",
},
{
handler: "silence",
matchId: "ember.built-in-components.legacy-arguments",
},
],
};

View File

@ -10,10 +10,25 @@ const discourseScss = require("./lib/discourse-scss");
const generateScriptsTree = require("./lib/scripts");
const funnel = require("broccoli-funnel");
const SILENCED_WARN_PREFIXES = [
"Setting the `jquery-integration` optional feature flag",
"The Ember Classic edition has been deprecated",
"Setting the `template-only-glimmer-components` optional feature flag to `false`",
];
module.exports = function (defaults) {
let discourseRoot = resolve("../../../..");
let vendorJs = discourseRoot + "/vendor/assets/javascripts/";
// Silence the warnings listed in SILENCED_WARN_PREFIXES
const ui = defaults.project.ui;
const oldWriteWarning = ui.writeWarnLine.bind(ui);
ui.writeWarnLine = (message, ...args) => {
if (!SILENCED_WARN_PREFIXES.some((prefix) => message.startsWith(prefix))) {
return oldWriteWarning(message, ...args);
}
};
const isProduction = EmberApp.env().includes("production");
const isTest = EmberApp.env().includes("test");

View File

@ -36,6 +36,7 @@
"broccoli-asset-rev": "^3.0.0",
"deepmerge": "^4.2.2",
"discourse-common": "^1.0.0",
"discourse-ensure-deprecation-order": "^1.0.0",
"discourse-hbr": "^1.0.0",
"discourse-widget-hbs": "^1.0.0",
"ember-auto-import": "^2.4.2",

View File

@ -4,6 +4,7 @@
"discourse",
"admin",
"discourse-common",
"discourse-ensure-deprecation-order",
"discourse-hbr",
"discourse-widget-hbs",
"pretty-text",