-
Notifications
You must be signed in to change notification settings - Fork 291
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
Update Babel Configuration to Support toSorted()
Method
#7571
Comments
ACs 👍🏻 |
I took a deeper look into this and it appears that this doesn't actually have anything to do with the Babel configuration. The Array.prototype.toSorted() MDN browser compatibility section says that it only supports NodeJS 20 and up, not even LTS. Realistically, we use a much older NodeJS version for everything to work in Site Kit (14). Since it doesn't appear that we will be updating to support this, does this make sense to close this issue? |
Hi @nfmohit, thanks for taking a look at this one. Actually, unless I have missed something myself I do think it should be resolvable via Babel - with the intention to use site-kit-wp/tests/js/jest.config.js Lines 13 to 15 in 5aafc62
site-kit-wp/tests/e2e/babel-transform.js Lines 6 to 8 in 5aafc62
Lines 181 to 191 in 5aafc62
etc. I think The documentation for our current version of this package mentions extending the Babel capabilities via additional plugins... More recent versions also mention a separate polyfill. So, I guess the thing to do here is to look into what it would take to extend our Babel configuration in a sensible manner. While this issue is focused on It's arguably a lot of work for the sake of a single small refactor, but the thought of enabling a new set of language features for us to use is quite appealing so I think it would be worthwhile in the long run. Those are my thoughts on the matter, I'm interested to see what others think too. |
@nfmohit Just a reminder on this one, please. :) |
@techanvil, I've taken a look through this today and the
In my experimentation I couldn't find a clear path for this to work. Point 1 seemed the best approach however it caused all tests to fail as mentioned above. I've pushed a draft PR with the setup I've been using to evaluate options for other developers to evaluate the same: #8216 Small side note, as @techanvil correctly identified |
Hi @benbowler, thanks for taking a look into this. With regard to Anyhow - looking into it a bit further, I don't think that
It would be preferable for our test transpilation config not to diverge too much from dev and production. We might end up inadvertently providing support for language features that are not available in dev/prod, for one thing. Looking into As alluded to, We could install However, it might be more appropriate to upgrade to a more recent Seeing as there's no clear timeframe for getting these upgrades done, I would suggest a bit of investigation into an early upgrade to |
Thanks @techanvil, I had some more time to look at this today and you were correct that |
Hey @benbowler, thanks for looking into this further. It's good to see things working, but having to explicitly import the polyfill like that seems a bit cumbersome to put into practice. Really we want something that just gets out of the way and lets us use the language features naturally. Also, for this tooling upgrade to make sense, we should be aiming to provide full JS language support up to and inclusive of ES2023 rather than focusing on I had suggested looking into the So, this would seem like the way forward here, the only problem though is our use of This might seem like a bit of a tangent, the relevance though is that I don't know if it makes sense for us to jump through too many hoops to work around a tooling choice that has effectively been made for us through following a standard WordPress toolchain configuration. I've also noted that So, with all the above in mind, I am inclined to think the right thing to do here is to put this one on hold until we've made the necessary package upgrades to be able to upgrade How does that sound to you? |
Hey @techanvil thanks for the review and considered response. I agree with your points and will un-assign myself from this one. Should we move to Stalled and and perhaps mark it as blocked by tickets such as #6026? And/or create an issue to investigate upgrading |
Thanks @benbowler. I've moved this to Stalled and added #6026 and #6357 as dependencies, we can keep an eye on them and move this issue forward if and when one of them unblocks it. I've not created a separate issue to upgrade |
Feature Description
While developing #7458, we encountered an issue regarding the Redux state mutation using the
state.sort()
method in thegetAnalyticsConfigByMeasurementIDs
selector. We used cloning as a temporary solution to maintain immutability. However, updating the Babel configuration to support thetoSorted()
method is considered a more efficient and long-term solution for better maintainability and cleaner code.Update: As discussed below, we are going to hold off on this one until we have upgraded, or are in a position to upgrade
@wordpress/babel-preset-default
to version7.22.0
or above. Issues #6026 and #6357 may facilitate this, so have been added as speculative dependencies.Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
toSorted()
.getAnalyticsConfigByMeasurementIDs
selector being implemented in Create API endpoints and Redux store infrastructure for "Enable enhanced measurement" feature. #7458 withtoSorted()
and verify that it works as intended.Implementation Brief
[email protected]
as a dev dependency to for this version to be installed.import 'core-js/actual/array/to-sorted';
intoassets/js/modules/analytics-4/datastore/webdatastreams.js
summaries.sort(...
ingetAnalyticsConfigByMeasurementIDs
withconst sortedSummaries = toSorted(...
and update the use ofsummaries
below to usesortedSummaries
.Test Coverage
assets/js/modules/analytics-4/datastore/webdatastreams.test.js
tests.QA Brief
Changelog entry
The text was updated successfully, but these errors were encountered: