-
-
Notifications
You must be signed in to change notification settings - Fork 407
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate Ember Utils #334
Conversation
64c4e52
to
84d396e
Compare
I think these methods are useful. They are quite a few Ember objects (DS.RecordArray, Ember.SafeString) that need custom logic to be checked properly for emptiness, length/blank, etc. In a distant future we may be able to subclass native JS arrays and strings for all these cases, and at that point it may make sense to deprecate these. Until then we should keep them. Also, I don't think the ecosystem churn caused by deprecating these is worth the gain in a slightly slimmer core. |
Ember is moving towards a model where parts of the Ember codebase can be extracted to dedicated addons without any deprecations. Due to those plans I don't understand the motivation for deprecating functionality only to reintroduce it in a separate addon again. |
So perhaps should this be reworded to state they may be deprecated in the future? |
this is also should mention corresponding computed properties |
@bekzod I think the CPMs are still useful. If those were also removed, people would need to define CPs for them: hasText: computed('text', function() {
return !!this.txet;
}), It's boilerplate code, but more error prone (see what I did there?) and less telling than Whether to have them in proper Ember or in an add-on is another question. |
@balinterdi was not suggesting to remove them, just suggesting RFC should mention what to do about them maybe |
These methods help annoying things in JS be less annoying. I would like them to stay. |
I don't think these utility methods are ready to go yet. I think these should be moved to separate package and nothing more at this point, opening up opt out possibility. On the other hand I agree that code without these methods might be more readable as it is more explicit what type of values are checked. Currently engineers have to go digging in the API docs to understand how method X is supposed to work. |
I agree with this part but I think more because some of the utility methods seem poorly named.
I've now changed my mind. I think only Personally I would rather And lastly I also support the rfc if the auto import library works well enough to not have any big downsides (I need to test build times) since I could just import these things from lodash. |
Sorry for the delays here y'all, some replies below... From @Turbo87:
There are two different things at play here. We are working towards enabling the codebase to be extracted, but we also want folks to directly add those addons as a dependency when it doesn't need to exist in "the core". From @bekzod:
Agreed. From @robclancy:
I completely agree that these methods are convenient in some cases (though I think a number of other cases are better served by checking against your expected values). I don't think the goal is "remove them", but instead to move them into an addon that you would have as a dependency. From @raido:
Agree, but the path to doing this is to deprecate using them from |
FWIW, as far as I can tell, the RFC is already stating what I (and a number of others have said) in the comments. The RFC mentions that these functions will be deprecated as part of |
As long as I can still use these helpers with no changes other than to my package.json, I'm good with this |
@snewcomer can we update this RFC to suggest codemods for adopting the extracted addon as another way to reduce friction as we transition? It may also be useful to do a code search to identify popular addons that rely on these utilities and encourage them to leverage vanilla JS alternatives to avoid forcing apps to opt-in to the extracted addon or lodash. |
I've updated the RFC with everyone's comments! Based on what was said, it seems we are all in the same boat. In addition to helping implement this RFC, I'll work on a codemod right away (great idea @elwayman02) to make the transition as easy as possible. |
Thanks @snewcomer! I think this RFC does a good job of covering the concerns brought up in my recent discussion; what's the next step to move this forward? |
BTW, if you want to make the RFC title more succinct, you could name it something like "Deprecate Existence Utils & Computed Properties". That might make it easier for people to quickly understand what this is about rather than reading the names of all the methods. |
@snewcomer Your What about the import paths of the helper function from the new addon? As it seems to not cover all modules from For the related CP macros, I also think they are quite useful and more readable than re-defining them all the time using a plain Re: the codemod, it could be clarified if it does one of the following transforms, or even both:
|
I disagree that the CP macros should stay in core. They are implementations using these utils, and as such as subject to the same problems in understanding the logic being executed. I don't use the CP macros any more than I use the utils themselves, and for the same reasons; they're confusing to developers who aren't intimately familiar with the internal implementation details, which does a lot to defeat their purpose. To be clear, removing these methods isn't just about making core slimmer; it's because they are actually problematic and hard to reason about. |
@simonihmig Great point! 👍Codemod details need to be clarified. On point #2, my initial feeling is we would avoid rewriting to a vanilla JS implementation to avoid any surprises.
Overall I think all utils are extracted and computed macros are left so we can move forward with this RFC. Would love to hear everybody's opinions! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally love the CP macros, but after reading @elwayman02's point and also seeing our team use them inconsistently (usually just when it comes up in code review), I'm in favor of removing them as well. The two main features they offered me (over the better syntax) are:
- automatically inferring dependent keys
- safe navigation
Both seem like "nice to have" features, and can be seen as adding unnecessary surface area / learning curve.
👍 for merging this RFC.
text/0000-deprecate-some-utils.md
Outdated
|
||
`Ember.isEmpty`, `Ember.isBlank`, `Ember.isNone`, `Ember.isPresent`, `notEmpty`, `empty`, and `none` will be deprecated at first with an addon that extracts these methods for users that still find value in these utility methods. Any instantiation of one of these functions will log a deprecation warning, notifying the user that this method is deprecated and provide a link to the supported addon. | ||
|
||
Addons that previously relied on these utility methods would also be expected to install this package. Moreover, to ease adoption of the external addon, a codemod will become available for the community. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also in favor of answering @simonihmig's question here about what the codemod would do (replacing the code or updating the import). Either is acceptable, IMO.
👋 @pzuraq What are your feelings on this RFC? Willing to help move forward if the community thinks it is a good idea. |
I don't think we should extract the computed property macros. These are tied very directly to computed properties as a whole, and it would make deprecating those harder. That will be a long deprecation path anyways, but I don't think it's worth causing extra churn in the meantime. That would effectively block this deprecation until CPs are deprecated I believe, since the timeline would have to have the utils fully removed after CPs. I don't think this is necessarily a bad thing, since these utils are highly tree-shakeable on their own. |
You should just use lodash because it provides more feature than what you think it is. |
text/0000-deprecate-some-utils.md
Outdated
|
||
Addons that previously relied on these utility methods would also be expected to install this package. Moreover, to ease adoption of the external addon, a codemod will become available for the community. | ||
|
||
## How we teach this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this section, we are asking RFC authors to submit prose and code samples that can be used in the guides. Please update this section to reflect that. Thank you!
We discussed this in the core team meeting today, and after talking it over I think my original reservations were not actually meaningful. So I'm +1, and once Mel's comments are address and there is some prose for the deprecation guide added I think we can review it again! |
70fb865
to
6e3cac6
Compare
Happy to tackle this after 4.0 is released for 5.0 removal. |
We discussed this at today's framework and decided to put this into FCP! |
We discussed at the meeting today and since no new concerns have come up, we decided to proceed. |
Plan to deprecate
compare
,isEmpty
,isNone
,isPresent
,isBlank
,tryInvoke
,typeOf
,notEmpty
,none
,empty
. They will be extracted to an addon.Rendered
Closes #333.