From 1199e7938b675a38c2705bc9cff3008d267651df Mon Sep 17 00:00:00 2001 From: Andrew Seier Date: Thu, 5 Dec 2024 09:45:26 -0800 Subject: [PATCH] Emit fewer deprecation warnings. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In theory, you want to see any unique issue, but in practice… that’s super annoying. Just changing this to key off the _message_ instead of the _stack_. This means we will get at most one warning per deprecated interface usage. --- ts/x-template.d.ts.map | 2 +- x-template.js | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/ts/x-template.d.ts.map b/ts/x-template.d.ts.map index cfdf25a..c37b760 100644 --- a/ts/x-template.d.ts.map +++ b/ts/x-template.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"x-template.d.ts","sourceRoot":"","sources":["../x-template.js"],"names":[],"mappings":"AA+gCA,yBAA2E;AAC3E,uBAAuE;AACvE,sBAAqE;AAGrE,sBAAqE;AACrE,uBAAuE;AACvE,6BAAmF;AACnF,4BAAiF;AACjF,4BAAiF;AACjF,0BAA6E;AAC7E,yBAA2E;AAG3E,8BAAqF;AACrF,+BAAuF;AACvF,wBAAyE;AACzE,2BAA+E;AAC/E,4BAAiF;AACjF,wBAAyE;AACzE,2BAA+E;AAC/E,kCAA6F;AAC7F,wBAAyE"} \ No newline at end of file +{"version":3,"file":"x-template.d.ts","sourceRoot":"","sources":["../x-template.js"],"names":[],"mappings":"AA8gCA,yBAA2E;AAC3E,uBAAuE;AACvE,sBAAqE;AAGrE,sBAAqE;AACrE,uBAAuE;AACvE,6BAAmF;AACnF,4BAAiF;AACjF,4BAAiF;AACjF,0BAA6E;AAC7E,yBAA2E;AAG3E,8BAAqF;AACrF,+BAAuF;AACvF,wBAAyE;AACzE,2BAA+E;AAC/E,4BAAiF;AACjF,wBAAyE;AACzE,2BAA+E;AAC/E,kCAA6F;AAC7F,wBAAyE"} \ No newline at end of file diff --git a/x-template.js b/x-template.js index aa8e3e8..c30381b 100644 --- a/x-template.js +++ b/x-template.js @@ -1016,14 +1016,13 @@ class TemplateEngine { } } - static #interfaceDeprecatedStacks = new Set(); + static #interfaceDeprecatedMessages = new Set(); static #interfaceDeprecated(name, callback) { return (...args) => { - const error = new Error(`Deprecated "${name}" from default templating engine interface.`); - const stack = error.stack; - if (!this.#interfaceDeprecatedStacks.has(stack)) { - this.#interfaceDeprecatedStacks.add(stack); - console.warn(error); // eslint-disable-line no-console + const message = `Deprecated "${name}" from default templating engine interface.`; + if (!this.#interfaceDeprecatedMessages.has(message)) { + this.#interfaceDeprecatedMessages.add(message); + console.warn(new Error(message)); // eslint-disable-line no-console } return callback(...args); };