-
-
Notifications
You must be signed in to change notification settings - Fork 174
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
breaking: upgrades to Ember 5.3 / drops Ember 4.4 #735
base: main
Are you sure you want to change the base?
breaking: upgrades to Ember 5.3 / drops Ember 4.4 #735
Conversation
- otherwise the ember-4.4-lts test scenario throws Error
- otherwise ember s throws Error
…ent.filter - because PromiseManyArray.filter no longer exists in Ember 5
- as it is no longer allowed on Ember 5
- otherwise the following tests sometimes fail: - Integration | Validations | Factory - General: debounced validations - Integration | Validations | Factory - General: debounced validator should only be called once
- otherwise relevant Ember 4.4 test scenario throws Error: - required module @ember/renderer is missing
@@ -74,7 +74,8 @@ export function getValidatableValue(value) { | |||
} | |||
|
|||
if (isDSManyArray(value)) { | |||
return emberArray(value.filter((v) => isValidatable(v))); | |||
value.content = value.content.filter((v) => isValidatable(v)); |
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.
PromiseManyArray.filter
no longer exists in Ember 5 but I'm not sure if this is an acceptable solution.
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.
@runspired can you help?
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 found
emberArray(value.toArray().filter((v) => isValidatable(v)));
on the qonto fork qonto@82a5816
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.
folks need to resolve the promise array upfront, either by awaiting or by using record.hasMany('foo').value()
to get it synchronously
13b36c7
to
6533ee4
Compare
@Pixelik I'll do a review in the next days! |
6533ee4
to
a61c20f
Compare
Thank you @fsmanuel 🙏 |
- otherwise the embroider test scenarios throw Error: - "EmberObject.create no longer supports defining computed properties"
68a2e7f
to
33e99af
Compare
did you get a chance to have a look @fsmanuel ? 🙂 it would be nice to make a v6 release asap 🙏 |
@MelSumner do you think we could merge this and make a release? 🙏 |
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.
@Pixelik sorry to keep you waiting so long. I finally found the time to do a review. Thanks for all the work you put into this!
I looked into the decorator/descriptor topic:
- Support ember 3.10, drops support for decorators #641 added the code to make it work for ember >= 3.10
- Support Ember 3.13 (redux) #668 made it work for ember >= 3.13
- 89d8307 I changed it to an
import
So it seems this internal import is stable since ember 3.13 and we no longer need the fallbacks. More in the comments.
I'm a little hesitant to have a breaking release without a proper version that support ember until 4.12. So my suggestion would be we cherry pick the decorator changes and I'll do the ember-cli update to 4.12 tomorrow. After that is released you can rebase and we release a new major version. What do you think?
Hello @fsmanuel, thanks for the review 🙏 Could you please add commit/code suggestions instead ? I'm not sure I understand what changes you'd like me to make. Please note that some of my refactoring is needed for the embroider scenarios to pass. Also, this PR runs tests on Ember 4.12, so I'm not sure why we need a separate release that has ember-cp-validations on 4.12 since this one has it on 5.3 but tests against 4.12 are passing just fine, but I'm fine with it either way 🤷♂️ |
Sure thing! Let's take the current // >> This internal import is stable since 3.13
import __EMBER_METAL__ from '@ember/-internals/metal/index';
export function isDescriptor(o) {
// >> This is always true since 3.13
if (__EMBER_METAL__ && __EMBER_METAL__.isClassicDecorator) {
return __EMBER_METAL__.isClassicDecorator(o);
// >> This will never be reached
} else {
return (
o && (typeof o === 'object' || typeof o === 'function') && o.isDescriptor
);
}
} so we can refactore it to: import { isClassicDecorator } from '@ember/-internals/metal/index';
export function isDescriptor(o) {
return isClassicDecorator(o);
} The same goes for import {
descriptorForDecorator,
isClassicDecorator,
} from '@ember/-internals/metal/index';
export function getDependentKeys(descriptorOrDecorator) {
const descriptor = descriptorForDecorator(descriptorOrDecorator);
// TODO: Figure out why the fallback `|| [descriptor.altKey]` is needed
return descriptor._dependentKeys || [descriptor.altKey];
}
// New decorator implementations that are not detected by isClassicDecorator()
// TODO: Figure out if there is an alternative to isClassicDecorator + this exceptions
const DECORATOR_IMPLEMENTATIONS = [
'AliasDecoratorImpl',
'ComputedDecoratorImpl',
];
export function isDescriptor(o) {
return (
isClassicDecorator(o) ||
DECORATOR_IMPLEMENTATIONS.includes(o.constructor?.name)
);
} Now I'm currious how the use of I would also appreciate if we could address this change in a separate PR, like you originally did, to document it in the change log. |
I activated the scenarios to see what is failing. With ember-data 4.8 (current master) and the embroider safe scenario we get:
With ember-data 4.11 and the embroider safe scenario we get:
So that seems connected to the decorator topic and will hopefully fixed by your fix. I totally agree with you, that we want them activated for a ember 5 compatible release.
Yeah, lets see what needs to be done to get them green for #736 or decide to leave it to your PR to get it working. It's not needed for the current release cycle because we did not support it in the past. |
@Pixelik looks like there are some conflicts to be resolved, can you work on those when you get a chance? TYSM! |
@@ -50,7 +49,6 @@ export function isDSManyArray(o) { | |||
return !!( | |||
DS && | |||
o && | |||
isArray(o) && | |||
(o instanceof DS.PromiseManyArray || o instanceof DS.ManyArray) |
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.
This check will not work in EmberData 5.0+
@@ -74,7 +72,8 @@ export function getValidatableValue(value) { | |||
} | |||
|
|||
if (isDSManyArray(value)) { | |||
return emberArray(value.filter((v) => isValidatable(v))); | |||
value.content = value.content.filter((v) => isValidatable(v)); |
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.
content
is private and not stable. the other option of toArray
is also not valid. Just treat EmberData things as native arrays, unless its a PromiseManyArray in which case you should error. PromiseManyArray can be detected in 5.0+ by something being a thenable and not having usual array methods but having a forEach method.
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.
Requires updates to support EmberData 5.x.
Uncertain if support for 4.x is also desired ... but the current approach does not adequately support 4.x either.
Resolves #733
Chore
ember s
throwsError
Refactor
PromiseManyArray.filter
no longer exists in Ember 5Integration | Validations | Factory - General: debounced validations
Integration | Validations | Factory - General: debounced validator should only be called once
Breaking
Error: required module @ember/renderer is missing
Tasks: