From 8695f5de04f418325816b8c0fb56bc711dfff783 Mon Sep 17 00:00:00 2001 From: Chris Thoburn Date: Sat, 11 May 2024 01:19:03 -0700 Subject: [PATCH 1/3] EmberData | deprecate Store extends EmberObject --- ...ta-deprecate-store-extends-ember-object.md | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 text/1026-ember-data-deprecate-store-extends-ember-object.md diff --git a/text/1026-ember-data-deprecate-store-extends-ember-object.md b/text/1026-ember-data-deprecate-store-extends-ember-object.md new file mode 100644 index 0000000000..507e54d07e --- /dev/null +++ b/text/1026-ember-data-deprecate-store-extends-ember-object.md @@ -0,0 +1,109 @@ +--- +stage: accepted +start-date: # In format 2024-05-11T00:00:00.000Z +release-date: # In format YYYY-MM-DDT00:00:00.000Z +release-versions: +teams: # delete teams that aren't relevant + - data +prs: + accepted: https://github.com/emberjs/rfcs/pull/1026 +project-link: +suite: +--- + +# EmberData | Deprecate Store extending EmberObject + +## Summary + +This RFC deprecates the Store extending from EmberObject. All EmberObject specific +APIs included. + +## Motivation + +There are two motivations: + +First, extending EmberObject is vestigial. The Store makes no use of any EmberObject API, +not even for use with Ember's container or service injection. + +Second, in order to support any Ember version, support any non-Ember framework, and support +EmberData running in non-browser environments we want to remove unnecessary coupling to Ember the framework. + +## Detailed design + +Instead of deprecating every EmberObject method, we will feature flag the store extending +EmberObject at the module level. This ensures the deprecation only prints once, and that +once resolved the store will no longer extend thereby making it feasible to utilize the +benefits of not extending EmberObject immediately. + +To resolve the deprecation, users will need to confirm they are not using EmberObject APIs +on the Store. Generally speaking, this has been limited to `.extend` e.g. + +```ts +const AppStore = Store.extend({}); +``` + +This pattern is now rare in the wild, but where it exists can be safely refactored to + +```ts +class AppStore extends Store {} +``` + +Once confirmed (or in order to confirm) that the Store in an app no longer requires +extending EmberObject, the deprecation config boolean may be used to both remove the +deprecation AND the deprecated code. + +```ts +const app = new EmberApp(defaults, { + emberData: { + deprecations: { + DEPRECATE_STORE_EXTENDS_EMBER_OBJECT: false + } + } +}); +``` + +An upcoming shift in how EmberData manages configuration would mean that applications +using the new configuration (not yet released) would do the following: + +```ts +'use strict'; + +const EmberApp = require('ember-cli/lib/broccoli/ember-app'); + +module.exports = async function (defaults) { + const { setConfig } = await import('@warp-drive/build-config'); + + const app = new EmberApp(defaults, {}); + + setConfig(app, __dirname, { + deprecations: { + DEPRECATE_STORE_EXTENDS_EMBER_OBJECT: false + } + }); + + return app.toTree(); +}; +``` + +## How we teach this + +Guides would be added for this deprecation to both the deprecation app and the api docs. + +Generally, folks do not tend to treat the store as an EmberObject or utilize legacy EmberObject +APIs with it, so both the teaching and the migration overhead are low. + +## Drawbacks + +none + +## Alternatives + +- deprecate every classic method to help folks find usage + - not chosen as its rare *and* setting the deprecation flag to false will cause any such locations to be findable via error +- create a new package `@warp-drive/core` or `@warp-drive/store` and have user's migrate by swapping import + locations. + - not chosen as this is too minimal a change + +## Unresolved questions + +None \ No newline at end of file From 37636318ad8621b8dfcc000579527c5f7e4c1615 Mon Sep 17 00:00:00 2001 From: Chris Thoburn Date: Sat, 11 May 2024 03:08:01 -0700 Subject: [PATCH 2/3] fix date --- text/1026-ember-data-deprecate-store-extends-ember-object.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/1026-ember-data-deprecate-store-extends-ember-object.md b/text/1026-ember-data-deprecate-store-extends-ember-object.md index 507e54d07e..30b999e48a 100644 --- a/text/1026-ember-data-deprecate-store-extends-ember-object.md +++ b/text/1026-ember-data-deprecate-store-extends-ember-object.md @@ -1,6 +1,6 @@ --- stage: accepted -start-date: # In format 2024-05-11T00:00:00.000Z +start-date: 2024-05-11T00:00:00.000Z release-date: # In format YYYY-MM-DDT00:00:00.000Z release-versions: teams: # delete teams that aren't relevant From 06a516f23999815a2c339ffa03feccde9a106863 Mon Sep 17 00:00:00 2001 From: Chris Thoburn Date: Sat, 11 May 2024 03:09:47 -0700 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: MrChocolatine <47531779+MrChocolatine@users.noreply.github.com> --- ...er-data-deprecate-store-extends-ember-object.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/text/1026-ember-data-deprecate-store-extends-ember-object.md b/text/1026-ember-data-deprecate-store-extends-ember-object.md index 30b999e48a..46ad7a0c4a 100644 --- a/text/1026-ember-data-deprecate-store-extends-ember-object.md +++ b/text/1026-ember-data-deprecate-store-extends-ember-object.md @@ -26,13 +26,13 @@ First, extending EmberObject is vestigial. The Store makes no use of any EmberOb not even for use with Ember's container or service injection. Second, in order to support any Ember version, support any non-Ember framework, and support -EmberData running in non-browser environments we want to remove unnecessary coupling to Ember the framework. +EmberData running in non-browser environments we want to remove unnecessary coupling to the Ember framework. ## Detailed design -Instead of deprecating every EmberObject method, we will feature flag the store extending +Instead of deprecating every EmberObject method, we will feature flag the Store extending EmberObject at the module level. This ensures the deprecation only prints once, and that -once resolved the store will no longer extend thereby making it feasible to utilize the +once resolved the Store will no longer extend thereby making it feasible to utilize the benefits of not extending EmberObject immediately. To resolve the deprecation, users will need to confirm they are not using EmberObject APIs @@ -87,9 +87,9 @@ module.exports = async function (defaults) { ## How we teach this -Guides would be added for this deprecation to both the deprecation app and the api docs. +Guides would be added for this deprecation to both the deprecation app and the API docs. -Generally, folks do not tend to treat the store as an EmberObject or utilize legacy EmberObject +Generally, folks do not tend to treat the Store as an EmberObject or utilize legacy EmberObject APIs with it, so both the teaching and the migration overhead are low. ## Drawbacks @@ -99,8 +99,8 @@ none ## Alternatives - deprecate every classic method to help folks find usage - - not chosen as its rare *and* setting the deprecation flag to false will cause any such locations to be findable via error -- create a new package `@warp-drive/core` or `@warp-drive/store` and have user's migrate by swapping import + - not chosen as it's rare *and* setting the deprecation flag to `false` will cause any such locations to be findable via error +- create a new package `@warp-drive/core` or `@warp-drive/store` and have users migrate by swapping import locations. - not chosen as this is too minimal a change