From c0a338fb4155360c5fdb875ad18c641a74b40cb5 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Thu, 22 Feb 2024 12:43:19 -0500 Subject: [PATCH 01/14] Make deprecation-workflow-built-in --- .../0000-move-deprecation-workflow-to-apps.md | 327 ++++++++++++++++++ 1 file changed, 327 insertions(+) create mode 100644 text/0000-move-deprecation-workflow-to-apps.md diff --git a/text/0000-move-deprecation-workflow-to-apps.md b/text/0000-move-deprecation-workflow-to-apps.md new file mode 100644 index 0000000000..d0e02478b9 --- /dev/null +++ b/text/0000-move-deprecation-workflow-to-apps.md @@ -0,0 +1,327 @@ +--- +stage: accepted +start-date: 2024-02-22T00:00.000Z +release-date: # In format YYYY-MM-DDT00:00:00.000Z +release-versions: +teams: # delete teams that aren't relevant + - cli + - data + - framework + - learning + - steering + - typescript +prs: + accepted: # Fill this in with the URL for the Proposal RFC PR +project-link: +suite: +--- + + + +<-- Replace "RFC title" with the title of your RFC --> +# Move the deprecation workflow to apps by default + +## Summary + +Historically, folks have benefitted from [ember-cli-deprecation-workflow](https://github.com/mixonic/ember-cli-deprecation-workflow). This behavior is _so useful_, that it should be built in to folks applications by default. + +tl;dr: move `setupDeprecationWorkflow` to `@ember/debug` + +> One paragraph explanation of the feature. + +## Motivation + +Everyone needs a deprecation-workflow, and yet `ember-cli-deprecation-workflow` is not part of the default blueprint. It probably doesn't need to be as the code it provides (if implemented in an app) is ~ 20 lines (but is slightly more if we want all features). + +This RFC proposes how we can ship deprecation workflow handling behavior in apps by default, which may give us a blessed path for better integrating with build time deprecations as well (though that is not the focus of this RFC). + + +## Detailed design + +There are only a few features of `ember-cli-deprecation-workflow` that we need to worry about: +- enabled or not - do we check deprecations at all, or ignore everything (current default) +- `throwOnUnhandled` - this is the most aggressive way to stay on top of your deprecations, but can be frustrating for folks who may not be willing to fix things in `node_modules` when new deprecations are introduced. + +- `window.flushDeprecations()` - prints the list of deprecations encountered since the last page refresh +- Matchers - a fuzzier way to match deprecation messages rather than strictly matching on the deprecation id (sometimes deprecation messages have information about surrounding / relevant context, and these could be used to more fine-grainedly work through large-in-numbers deprecations) +- Logging / Ignoring / Throwing - when encountering a matched deprecation (whether by id or by regex, how should it be handled?) + + +However, folks can get a basic deprecation-handling workflow going in their apps without the above features, + +1. applications must have `@embroider/macros` installed by default. +2. the app.js or app.ts can conditionally import a file which sets up the deprecation workflow + ```diff app/app.js + import Application from '@ember/application'; + + import { importSync, isDevelopingApp, macroCondition } from '@embroider/macros'; + + import loadInitializers from 'ember-load-initializers'; + import Resolver from 'ember-resolver'; + import config from 'test-app/config/environment'; + + + if (macroCondition(isDevelopingApp())) { + + importSync('/deprecation-workflow'); + + } + + export default class App extends Application { + modulePrefix = config.modulePrefix; + podModulePrefix = config.podModulePrefix; + Resolver = Resolver; + } + + loadInitializers(App, config.modulePrefix); + ``` + this conditional import is now easily customizable for folks in their apps, so they could opt to _not_ strip deprecation messages in production, and see where deprecated code is being hit by users (reported via Sentry, BugSnag, or some other reporting tool) -- which may be handy for folks who have a less-than-perfect test suite (tests being the only current way to automatically detect where deprecated code lives). +3. the `app/deprecation-workflow.js` would use the already public API, [`registerDeprecationHandler`](https://api.emberjs.com/ember/5.6/functions/@ember%2Fdebug/registerDeprecationHandler) + ```js + import { registerDeprecationHandler } from '@ember/debug'; + + import config from '/config/environment'; + + const SHOULD_THROW = config.environment !== 'production'; + const SILENCED_DEPRECATIONS: string[] = [ + // Add ids of deprecations you temporarily want to silence here. + ]; + + registerDeprecationHandler((message, options, next) => { + if (!options) { + console.error('Missing options'); + throw new Error(message); + } + + if (SILENCED_DEPRECATIONS.includes(options.id)) { + return; + } else if (SHOULD_THROW) { + throw new Error(message); + } + + next(message, options); + }); + ``` + + +This simple implementation of deprrecation workflow may work for libraries' test-apps, but it is not as robust as what `ember-cli-deprecation-workflow` offers, per the above-listed set of features that folks are used to. + +To get all of that, taken from the [Modernization PR on ember-cli-deprecation-workflow](https://github.com/mixonic/ember-cli-deprecation-workflow/pull/159), this is what the deprecation-workflow file could look like: +```js +import { registerDeprecationHandler } from '@ember/debug'; + +const LOG_LIMIT = 100; + +export default function setupDeprecationWorkflow(config) { + self.deprecationWorkflow = self.deprecationWorkflow || {}; + self.deprecationWorkflow.deprecationLog = { + messages: {}, + }; + + registerDeprecationHandler((message, options, next) => + handleDeprecationWorkflow(config, message, options, next), + ); + + registerDeprecationHandler(deprecationCollector); + + self.deprecationWorkflow.flushDeprecations = flushDeprecations; +} + +let preamble = `import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow'; + +setupDeprecationWorkflow({ + workflow: [ +`; + +let postamble = ` ] +});`; + +export function detectWorkflow(config, message, options) { + if (!config || !config.workflow) { + return; + } + + let i, workflow, matcher, idMatcher; + for (i = 0; i < config.workflow.length; i++) { + workflow = config.workflow[i]; + matcher = workflow.matchMessage; + idMatcher = workflow.matchId; + + if (typeof idMatcher === 'string' && options && idMatcher === options.id) { + return workflow; + } else if (typeof matcher === 'string' && matcher === message) { + return workflow; + } else if (matcher instanceof RegExp && matcher.exec(message)) { + return workflow; + } + } +} + +export function flushDeprecations() { + let messages = self.deprecationWorkflow.deprecationLog.messages; + let logs = []; + + for (let message in messages) { + logs.push(messages[message]); + } + + let deprecations = logs.join(',\n') + '\n'; + + return preamble + deprecations + postamble; +} + +export function handleDeprecationWorkflow(config, message, options, next) { + let matchingWorkflow = detectWorkflow(config, message, options); + if (!matchingWorkflow) { + if (config && config.throwOnUnhandled) { + throw new Error(message); + } else { + next(message, options); + } + } else { + switch (matchingWorkflow.handler) { + case 'silence': + // no-op + break; + case 'log': { + let key = (options && options.id) || message; + + if (!self.deprecationWorkflow.logCounts) { + self.deprecationWorkflow.logCounts = {}; + } + + let count = self.deprecationWorkflow.logCounts[key] || 0; + self.deprecationWorkflow.logCounts[key] = ++count; + + if (count <= LOG_LIMIT) { + console.warn('DEPRECATION: ' + message); + if (count === LOG_LIMIT) { + console.warn( + 'To avoid console overflow, this deprecation will not be logged any more in this run.', + ); + } + } + + break; + } + case 'throw': + throw new Error(message); + default: + next(message, options); + break; + } + } +} + +export function deprecationCollector(message, options, next) { + let key = (options && options.id) || message; + let matchKey = options && key === options.id ? 'matchId' : 'matchMessage'; + + self.deprecationWorkflow.deprecationLog.messages[key] = + ' { handler: "silence", ' + matchKey + ': ' + JSON.stringify(key) + ' }'; + + next(message, options); +} +``` + +and at this point, we may as well build in in to `ember` and not use an additional library at all, **and this is what the primary proposal of this RFC is proposing: built the deprecation workflow setup function in to ember**, so re-running thorugh the setup steps: + +1. applications must have `@embroider/macros` installed by default. +2. the app.js or app.ts can conditionally import a file which sets up the deprecation workflow + ```diff app/app.js + import Application from '@ember/application'; + + import { importSync, isDevelopingApp, macroCondition } from '@embroider/macros'; + + import loadInitializers from 'ember-load-initializers'; + import Resolver from 'ember-resolver'; + import config from 'test-app/config/environment'; + + + if (macroCondition(isDevelopingApp())) { + + importSync('/deprecation-workflow'); + + } + + export default class App extends Application { + modulePrefix = config.modulePrefix; + podModulePrefix = config.podModulePrefix; + Resolver = Resolver; + } + + loadInitializers(App, config.modulePrefix); + ``` + this conditional import is now easily customizable for folks in their apps, so they could opt to _not_ strip deprecation messages in production, and see where deprecated code is being hit by users (reported via Sentry, BugSnag, or some other reporting tool) -- which may be handy for folks who have a less-than-perfect test suite (tests being the only current way to automatically detect where deprecated code lives). +3. the `app/deprecation-workflow.js` would use the already public API, [`registerDeprecationHandler`](https://api.emberjs.com/ember/5.6/functions/@ember%2Fdebug/registerDeprecationHandler) + ```js + import { setupDeprecationWorkflow } from '@ember/debug'; + + setupDeprecationWorkflow({ + htrowOnUnhandled: true, + handlers: [ + /* ... handlers ... */ + ] + }); + ``` + + + + +## How we teach this + +We'd want to add a new section in the guides under [`Application Concerns`](https://guides.emberjs.com/release/applications/) that talks about deprecations, how and how to work through those deprecations. + +All of this content already exists using a similar strategy as above, here, [under "Configuring Ember"](https://guides.emberjs.com/release/configuring-ember/handling-deprecations/#toc_deprecation-workflow), and also walks through how to use `ember-cli-deprecation-workflow`. +When adapting the existing content, we'd want to remove so much focus on `ember-cli-deprecation-workflow`, as the behavior would be "built in". + +## Drawbacks + +For older projects, this could be _a_ migration. But as it is additional blueprint boilerplate, it is optional, and `ember-cli-deprecation-workflow` would continue to be a viable option for those already using it. + +## Alternatives + +Have `ember-cli-deprecation-workflow` installed by default, (and) transferring `ember-cli-deprecation-workflow` to the emberjs org. +(note: dependent on [This PR](https://github.com/mixonic/ember-cli-deprecation-workflow/pull/159)) + +1. applications must have `@embroider/macros` installed by default. +2. the app.js or app.ts can conditionally import a file which sets up the deprecation workflow + ```diff app/app.js + import Application from '@ember/application'; + + import { importSync, isDevelopingApp, macroCondition } from '@embroider/macros'; + + import loadInitializers from 'ember-load-initializers'; + import Resolver from 'ember-resolver'; + import config from 'test-app/config/environment'; + + + if (macroCondition(isDevelopingApp())) { + + importSync('/deprecation-workflow'); + + } + + export default class App extends Application { + modulePrefix = config.modulePrefix; + podModulePrefix = config.podModulePrefix; + Resolver = Resolver; + } + + loadInitializers(App, config.modulePrefix); + ``` +3. the `app/deprecation-workflow.js` would use the already public API, [`registerDeprecationHandler`](https://api.emberjs.com/ember/5.6/functions/@ember%2Fdebug/registerDeprecationHandler) + ```js + import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow'; + + setupDeprecationWorkflow({ + htrowOnUnhandled: true, + handlers: [ + /* ... handlers ... */ + ] + }); + ``` + +## Unresolved questions + +n/a From 2ef5ac27d39e3a3eb2c77316e3e878a860f27ed6 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Thu, 22 Feb 2024 12:45:45 -0500 Subject: [PATCH 02/14] Update --- text/0000-move-deprecation-workflow-to-apps.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/text/0000-move-deprecation-workflow-to-apps.md b/text/0000-move-deprecation-workflow-to-apps.md index d0e02478b9..37ecc4557f 100644 --- a/text/0000-move-deprecation-workflow-to-apps.md +++ b/text/0000-move-deprecation-workflow-to-apps.md @@ -114,7 +114,10 @@ However, folks can get a basic deprecation-handling workflow going in their apps This simple implementation of deprrecation workflow may work for libraries' test-apps, but it is not as robust as what `ember-cli-deprecation-workflow` offers, per the above-listed set of features that folks are used to. -To get all of that, taken from the [Modernization PR on ember-cli-deprecation-workflow](https://github.com/mixonic/ember-cli-deprecation-workflow/pull/159), this is what the deprecation-workflow file could look like: +To get all of those features from `ember-cli-deprecation-workflow`, we could define a function, `setupDeprecationWorkflow`, taken from the [Modernization PR on ember-cli-deprecation-workflow](https://github.com/mixonic/ember-cli-deprecation-workflow/pull/159), this is what the deprecation-workflow file could look like: + +
ember-cli-deprecation-workflow/index.js + ```js import { registerDeprecationHandler } from '@ember/debug'; @@ -232,6 +235,8 @@ export function deprecationCollector(message, options, next) { } ``` +
+ and at this point, we may as well build in in to `ember` and not use an additional library at all, **and this is what the primary proposal of this RFC is proposing: built the deprecation workflow setup function in to ember**, so re-running thorugh the setup steps: 1. applications must have `@embroider/macros` installed by default. From 4304c238b3a02f9077e4a2003b189e016c0f305d Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Thu, 22 Feb 2024 12:47:13 -0500 Subject: [PATCH 03/14] Rename file --- ...ow-to-apps.md => 1009-move-deprecation-workflow-to-apps.md} | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) rename text/{0000-move-deprecation-workflow-to-apps.md => 1009-move-deprecation-workflow-to-apps.md} (99%) diff --git a/text/0000-move-deprecation-workflow-to-apps.md b/text/1009-move-deprecation-workflow-to-apps.md similarity index 99% rename from text/0000-move-deprecation-workflow-to-apps.md rename to text/1009-move-deprecation-workflow-to-apps.md index 37ecc4557f..2d1fddb938 100644 --- a/text/0000-move-deprecation-workflow-to-apps.md +++ b/text/1009-move-deprecation-workflow-to-apps.md @@ -11,7 +11,7 @@ teams: # delete teams that aren't relevant - steering - typescript prs: - accepted: # Fill this in with the URL for the Proposal RFC PR + accepted: https://github.com/emberjs/rfcs/pull/1009 project-link: suite: --- @@ -30,7 +30,6 @@ project-link: Leave as is suite: Leave as is --> -<-- Replace "RFC title" with the title of your RFC --> # Move the deprecation workflow to apps by default ## Summary From c638e8b1a12172dbcc84b297de17c80d229d1fd6 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Thu, 22 Feb 2024 12:49:55 -0500 Subject: [PATCH 04/14] answer why not this --- text/1009-move-deprecation-workflow-to-apps.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/text/1009-move-deprecation-workflow-to-apps.md b/text/1009-move-deprecation-workflow-to-apps.md index 2d1fddb938..bddd90d80a 100644 --- a/text/1009-move-deprecation-workflow-to-apps.md +++ b/text/1009-move-deprecation-workflow-to-apps.md @@ -326,6 +326,8 @@ Have `ember-cli-deprecation-workflow` installed by default, (and) transferring ` }); ``` +Why _not_ just do this tiny change to the blueprint? The whole implementation is _very small_, and it's something the framework ultimately has to support anyway, so building it in to `@ember/debug` provides a convinient way to for folks to get started. We also have a bit of a too-many-imports problem at the moment. + ## Unresolved questions n/a From ffece8ba90ba0f4012f7e5f7f7acde3fb08a6c70 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Thu, 22 Feb 2024 15:21:22 -0500 Subject: [PATCH 05/14] Forgat a :00 --- text/1009-move-deprecation-workflow-to-apps.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/1009-move-deprecation-workflow-to-apps.md b/text/1009-move-deprecation-workflow-to-apps.md index bddd90d80a..6eac899505 100644 --- a/text/1009-move-deprecation-workflow-to-apps.md +++ b/text/1009-move-deprecation-workflow-to-apps.md @@ -1,6 +1,6 @@ --- stage: accepted -start-date: 2024-02-22T00:00.000Z +start-date: 2024-02-22T00:00:00.000Z release-date: # In format YYYY-MM-DDT00:00:00.000Z release-versions: teams: # delete teams that aren't relevant From d36dcef37ee5aa957e8dc5552d356f4eb4984d11 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Thu, 22 Feb 2024 16:04:51 -0500 Subject: [PATCH 06/14] Update text/1009-move-deprecation-workflow-to-apps.md Co-authored-by: MrChocolatine <47531779+MrChocolatine@users.noreply.github.com> --- text/1009-move-deprecation-workflow-to-apps.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/1009-move-deprecation-workflow-to-apps.md b/text/1009-move-deprecation-workflow-to-apps.md index 6eac899505..b656f1a27d 100644 --- a/text/1009-move-deprecation-workflow-to-apps.md +++ b/text/1009-move-deprecation-workflow-to-apps.md @@ -236,7 +236,7 @@ export function deprecationCollector(message, options, next) { -and at this point, we may as well build in in to `ember` and not use an additional library at all, **and this is what the primary proposal of this RFC is proposing: built the deprecation workflow setup function in to ember**, so re-running thorugh the setup steps: +and at this point, we may as well build it into `ember` and not use an additional library at all, **and this is what the primary proposal of this RFC: build the deprecation workflow setup function in to ember**, so re-running through the setup steps: 1. applications must have `@embroider/macros` installed by default. 2. the app.js or app.ts can conditionally import a file which sets up the deprecation workflow From 2e9c5914ea423a1736be952422e4bc72b501ddff Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Thu, 22 Feb 2024 16:04:57 -0500 Subject: [PATCH 07/14] Update text/1009-move-deprecation-workflow-to-apps.md Co-authored-by: MrChocolatine <47531779+MrChocolatine@users.noreply.github.com> --- text/1009-move-deprecation-workflow-to-apps.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/1009-move-deprecation-workflow-to-apps.md b/text/1009-move-deprecation-workflow-to-apps.md index b656f1a27d..5d815e7856 100644 --- a/text/1009-move-deprecation-workflow-to-apps.md +++ b/text/1009-move-deprecation-workflow-to-apps.md @@ -111,7 +111,7 @@ However, folks can get a basic deprecation-handling workflow going in their apps ``` -This simple implementation of deprrecation workflow may work for libraries' test-apps, but it is not as robust as what `ember-cli-deprecation-workflow` offers, per the above-listed set of features that folks are used to. +This simple implementation of deprecation workflow may work for libraries' test-apps, but it is not as robust as what `ember-cli-deprecation-workflow` offers, per the above-listed set of features that folks are used to. To get all of those features from `ember-cli-deprecation-workflow`, we could define a function, `setupDeprecationWorkflow`, taken from the [Modernization PR on ember-cli-deprecation-workflow](https://github.com/mixonic/ember-cli-deprecation-workflow/pull/159), this is what the deprecation-workflow file could look like: From ad9a9bc8427bb246749e804e0d60e36a1cd72fcd Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Thu, 22 Feb 2024 16:05:03 -0500 Subject: [PATCH 08/14] Update text/1009-move-deprecation-workflow-to-apps.md Co-authored-by: MrChocolatine <47531779+MrChocolatine@users.noreply.github.com> --- text/1009-move-deprecation-workflow-to-apps.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/1009-move-deprecation-workflow-to-apps.md b/text/1009-move-deprecation-workflow-to-apps.md index 5d815e7856..65ede6965a 100644 --- a/text/1009-move-deprecation-workflow-to-apps.md +++ b/text/1009-move-deprecation-workflow-to-apps.md @@ -266,7 +266,7 @@ and at this point, we may as well build it into `ember` and not use an additiona import { setupDeprecationWorkflow } from '@ember/debug'; setupDeprecationWorkflow({ - htrowOnUnhandled: true, + throwOnUnhandled: true, handlers: [ /* ... handlers ... */ ] From 759ee007a1899fd37d6933ceb09a24b8e569163c Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Thu, 22 Feb 2024 16:05:07 -0500 Subject: [PATCH 09/14] Update text/1009-move-deprecation-workflow-to-apps.md Co-authored-by: MrChocolatine <47531779+MrChocolatine@users.noreply.github.com> --- text/1009-move-deprecation-workflow-to-apps.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/1009-move-deprecation-workflow-to-apps.md b/text/1009-move-deprecation-workflow-to-apps.md index 65ede6965a..3e8ca32f60 100644 --- a/text/1009-move-deprecation-workflow-to-apps.md +++ b/text/1009-move-deprecation-workflow-to-apps.md @@ -319,7 +319,7 @@ Have `ember-cli-deprecation-workflow` installed by default, (and) transferring ` import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow'; setupDeprecationWorkflow({ - htrowOnUnhandled: true, + throwOnUnhandled: true, handlers: [ /* ... handlers ... */ ] From 45f675ad18241679e15b3505e62a032e59fb42b1 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Thu, 22 Feb 2024 16:05:13 -0500 Subject: [PATCH 10/14] Update text/1009-move-deprecation-workflow-to-apps.md Co-authored-by: MrChocolatine <47531779+MrChocolatine@users.noreply.github.com> --- text/1009-move-deprecation-workflow-to-apps.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/1009-move-deprecation-workflow-to-apps.md b/text/1009-move-deprecation-workflow-to-apps.md index 3e8ca32f60..7f8ea540f5 100644 --- a/text/1009-move-deprecation-workflow-to-apps.md +++ b/text/1009-move-deprecation-workflow-to-apps.md @@ -326,7 +326,7 @@ Have `ember-cli-deprecation-workflow` installed by default, (and) transferring ` }); ``` -Why _not_ just do this tiny change to the blueprint? The whole implementation is _very small_, and it's something the framework ultimately has to support anyway, so building it in to `@ember/debug` provides a convinient way to for folks to get started. We also have a bit of a too-many-imports problem at the moment. +Why _not_ just do this tiny change to the blueprint? The whole implementation is _very small_, and it's something the framework ultimately has to support anyway, so building it in to `@ember/debug` provides a convenient way for folks to get started. We also have a bit of a too-many-imports problem at the moment. ## Unresolved questions From f920ec251d8d438ab0ae7435a2754ab1c7beb3a4 Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Thu, 22 Feb 2024 16:05:18 -0500 Subject: [PATCH 11/14] Update text/1009-move-deprecation-workflow-to-apps.md Co-authored-by: MrChocolatine <47531779+MrChocolatine@users.noreply.github.com> --- text/1009-move-deprecation-workflow-to-apps.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/1009-move-deprecation-workflow-to-apps.md b/text/1009-move-deprecation-workflow-to-apps.md index 7f8ea540f5..d7586396da 100644 --- a/text/1009-move-deprecation-workflow-to-apps.md +++ b/text/1009-move-deprecation-workflow-to-apps.md @@ -84,7 +84,7 @@ However, folks can get a basic deprecation-handling workflow going in their apps ``` this conditional import is now easily customizable for folks in their apps, so they could opt to _not_ strip deprecation messages in production, and see where deprecated code is being hit by users (reported via Sentry, BugSnag, or some other reporting tool) -- which may be handy for folks who have a less-than-perfect test suite (tests being the only current way to automatically detect where deprecated code lives). 3. the `app/deprecation-workflow.js` would use the already public API, [`registerDeprecationHandler`](https://api.emberjs.com/ember/5.6/functions/@ember%2Fdebug/registerDeprecationHandler) - ```js + ```ts import { registerDeprecationHandler } from '@ember/debug'; import config from '/config/environment'; From 9310137035a094ccc1675aff66af73c0691a047c Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Wed, 27 Mar 2024 12:11:20 -0400 Subject: [PATCH 12/14] Update text/1009-move-deprecation-workflow-to-apps.md Co-authored-by: Katie Gengler --- text/1009-move-deprecation-workflow-to-apps.md | 1 - 1 file changed, 1 deletion(-) diff --git a/text/1009-move-deprecation-workflow-to-apps.md b/text/1009-move-deprecation-workflow-to-apps.md index d7586396da..1105e84b66 100644 --- a/text/1009-move-deprecation-workflow-to-apps.md +++ b/text/1009-move-deprecation-workflow-to-apps.md @@ -8,7 +8,6 @@ teams: # delete teams that aren't relevant - data - framework - learning - - steering - typescript prs: accepted: https://github.com/emberjs/rfcs/pull/1009 From 41e4eed904da7b346e12314f0f8641d54ac3374b Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:06:25 -0400 Subject: [PATCH 13/14] Flip the suggestion to prefer using the addon in the blueprint --- .../1009-move-deprecation-workflow-to-apps.md | 113 ++++++++++-------- 1 file changed, 60 insertions(+), 53 deletions(-) diff --git a/text/1009-move-deprecation-workflow-to-apps.md b/text/1009-move-deprecation-workflow-to-apps.md index 1105e84b66..f0c14c272f 100644 --- a/text/1009-move-deprecation-workflow-to-apps.md +++ b/text/1009-move-deprecation-workflow-to-apps.md @@ -48,6 +48,66 @@ This RFC proposes how we can ship deprecation workflow handling behavior in apps ## Detailed design + +Have `ember-cli-deprecation-workflow` installed by default. + +1. applications must have `@embroider/macros` installed by default. +2. the app.js or app.ts can conditionally import a file which sets up the deprecation workflow + ```diff app/app.js + import Application from '@ember/application'; + + import { importSync, isDevelopingApp, macroCondition } from '@embroider/macros'; + + import loadInitializers from 'ember-load-initializers'; + import Resolver from 'ember-resolver'; + import config from 'test-app/config/environment'; + + + if (macroCondition(isDevelopingApp())) { + + importSync('./deprecation-workflow'); + + } + + export default class App extends Application { + modulePrefix = config.modulePrefix; + podModulePrefix = config.podModulePrefix; + Resolver = Resolver; + } + + loadInitializers(App, config.modulePrefix); + ``` +3. then in `app/deprecation-workflow.js` would use the already public API, + ```js + import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow'; + + setupDeprecationWorkflow({ + /** + false by default, but if a developer / team wants to be more aggressive about being proactive with + handling their deprecations, this should be set to "true" + */ + throwOnUnhandled: false, + handlers: [ + /* ... handlers ... */ + ] + }); + ``` + + +This follows the README of [ember-cli-deprecation-workflow](https://github.com/ember-cli/ember-cli-deprecation-workflow?tab=readme-ov-file#getting-started). + + + +## How we teach this + +We'd want to add a new section in the guides under [`Application Concerns`](https://guides.emberjs.com/release/applications/) that talks about deprecations, how and how to work through those deprecations. + +All of this content already exists using a similar strategy as above, here, [under "Configuring Ember"](https://guides.emberjs.com/release/configuring-ember/handling-deprecations/#toc_deprecation-workflow), and also walks through how to use `ember-cli-deprecation-workflow`. + +This README of [ember-cli-deprecation-workflow](https://github.com/ember-cli/ember-cli-deprecation-workflow?tab=readme-ov-file#getting-started) also explains, in detail, how to use this tool / workflow, and that content can be copied in to the guides. + +## Drawbacks + +For older projects, this could be _a_ migration. But as it is additional blueprint boilerplate, it is optional, and `ember-cli-deprecation-workflow` would continue to be a viable option for those already using it. + +## Alternatives + There are only a few features of `ember-cli-deprecation-workflow` that we need to worry about: - enabled or not - do we check deprecations at all, or ignore everything (current default) - `throwOnUnhandled` - this is the most aggressive way to stay on top of your deprecations, but can be frustrating for folks who may not be willing to fix things in `node_modules` when new deprecations are introduced. @@ -273,59 +333,6 @@ and at this point, we may as well build it into `ember` and not use an additiona ``` - - -## How we teach this - -We'd want to add a new section in the guides under [`Application Concerns`](https://guides.emberjs.com/release/applications/) that talks about deprecations, how and how to work through those deprecations. - -All of this content already exists using a similar strategy as above, here, [under "Configuring Ember"](https://guides.emberjs.com/release/configuring-ember/handling-deprecations/#toc_deprecation-workflow), and also walks through how to use `ember-cli-deprecation-workflow`. -When adapting the existing content, we'd want to remove so much focus on `ember-cli-deprecation-workflow`, as the behavior would be "built in". - -## Drawbacks - -For older projects, this could be _a_ migration. But as it is additional blueprint boilerplate, it is optional, and `ember-cli-deprecation-workflow` would continue to be a viable option for those already using it. - -## Alternatives - -Have `ember-cli-deprecation-workflow` installed by default, (and) transferring `ember-cli-deprecation-workflow` to the emberjs org. -(note: dependent on [This PR](https://github.com/mixonic/ember-cli-deprecation-workflow/pull/159)) - -1. applications must have `@embroider/macros` installed by default. -2. the app.js or app.ts can conditionally import a file which sets up the deprecation workflow - ```diff app/app.js - import Application from '@ember/application'; - + import { importSync, isDevelopingApp, macroCondition } from '@embroider/macros'; - - import loadInitializers from 'ember-load-initializers'; - import Resolver from 'ember-resolver'; - import config from 'test-app/config/environment'; - - + if (macroCondition(isDevelopingApp())) { - + importSync('/deprecation-workflow'); - + } - - export default class App extends Application { - modulePrefix = config.modulePrefix; - podModulePrefix = config.podModulePrefix; - Resolver = Resolver; - } - - loadInitializers(App, config.modulePrefix); - ``` -3. the `app/deprecation-workflow.js` would use the already public API, [`registerDeprecationHandler`](https://api.emberjs.com/ember/5.6/functions/@ember%2Fdebug/registerDeprecationHandler) - ```js - import setupDeprecationWorkflow from 'ember-cli-deprecation-workflow'; - - setupDeprecationWorkflow({ - throwOnUnhandled: true, - handlers: [ - /* ... handlers ... */ - ] - }); - ``` - -Why _not_ just do this tiny change to the blueprint? The whole implementation is _very small_, and it's something the framework ultimately has to support anyway, so building it in to `@ember/debug` provides a convenient way for folks to get started. We also have a bit of a too-many-imports problem at the moment. ## Unresolved questions From 68f9b4d07b7562c9af61f203cb5d55828ceb7daa Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:08:09 -0400 Subject: [PATCH 14/14] Updates --- text/1009-move-deprecation-workflow-to-apps.md | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/text/1009-move-deprecation-workflow-to-apps.md b/text/1009-move-deprecation-workflow-to-apps.md index f0c14c272f..c62922b3e0 100644 --- a/text/1009-move-deprecation-workflow-to-apps.md +++ b/text/1009-move-deprecation-workflow-to-apps.md @@ -29,19 +29,15 @@ project-link: Leave as is suite: Leave as is --> -# Move the deprecation workflow to apps by default +# Move the deprecation workflow library to be installed in apps by default ## Summary Historically, folks have benefitted from [ember-cli-deprecation-workflow](https://github.com/mixonic/ember-cli-deprecation-workflow). This behavior is _so useful_, that it should be built in to folks applications by default. -tl;dr: move `setupDeprecationWorkflow` to `@ember/debug` - -> One paragraph explanation of the feature. - ## Motivation -Everyone needs a deprecation-workflow, and yet `ember-cli-deprecation-workflow` is not part of the default blueprint. It probably doesn't need to be as the code it provides (if implemented in an app) is ~ 20 lines (but is slightly more if we want all features). +Everyone needs a deprecation-workflow, and yet `ember-cli-deprecation-workflow` is not part of the default blueprint. This RFC proposes how we can ship deprecation workflow handling behavior in apps by default, which may give us a blessed path for better integrating with build time deprecations as well (though that is not the focus of this RFC). @@ -104,7 +100,7 @@ This README of [ember-cli-deprecation-workflow](https://github.com/ember-cli/emb ## Drawbacks -For older projects, this could be _a_ migration. But as it is additional blueprint boilerplate, it is optional, and `ember-cli-deprecation-workflow` would continue to be a viable option for those already using it. +For older projects, this could be _a_ migration. But as it is additional blueprint boilerplate, it is optional. ## Alternatives @@ -130,7 +126,7 @@ However, folks can get a basic deprecation-handling workflow going in their apps import config from 'test-app/config/environment'; + if (macroCondition(isDevelopingApp())) { - + importSync('/deprecation-workflow'); + + importSync('./deprecation-workflow'); + } export default class App extends Application {