Skip to content
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

[CHORE] najax deprecation when ember-fetch is also installed #7230

Merged
merged 10 commits into from
Oct 9, 2020

Conversation

snewcomer
Copy link
Contributor

@snewcomer snewcomer commented Jun 16, 2020

close #7219

This PR seeks to add a deprecation notice for najax (in fastboot) if installed. We want to encourage users to install ember-fetch if they haven't already. useFetch = true will be the default for ember data's adapters.

Copy link
Contributor

@runspired runspired left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a deprecation flag to the deprecation infra and use it to allow this code path to be stripped in favor of the fetch code path.

packages/adapter/addon/rest.js Show resolved Hide resolved
packages/adapter/addon/rest.js Outdated Show resolved Hide resolved
} else if (hasNajax || hasJQuery) {
return false;
} else {
return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

our return value here needs to be set to this._useFetch

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We appear to still not cache off the value for some of the return branches

packages/adapter/addon/rest.js Outdated Show resolved Hide resolved
packages/adapter/addon/rest.js Outdated Show resolved Hide resolved
packages/adapter/addon/rest.js Outdated Show resolved Hide resolved
packages/adapter/addon/rest.js Show resolved Hide resolved
packages/adapter/addon/rest.js Show resolved Hide resolved
packages/private-build-infra/addon/current-deprecations.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@runspired runspired left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall very close to ready :)

until: '4.0',
}
);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should add and else that straigh up deprecates najax even when fetch is not present and tells folks to use something like ember-fetch

packages/adapter/addon/rest.js Outdated Show resolved Hide resolved
packages/adapter/addon/rest.js Outdated Show resolved Hide resolved
@snewcomer snewcomer self-assigned this Jul 20, 2020
@snewcomer snewcomer added internal code-review Tracks PRs that require a code-review labels Jul 20, 2020
@@ -5,12 +5,14 @@
*/

import { getOwner } from '@ember/application';
import { deprecate } from '@ember/application/deprecations';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should import from @ember/debug

Comment on lines 1070 to 1086
deprecate(
'You have ember-fetch and jquery installed. To use ember-fetch, set `useFetch: true` in your adapter. In 4.0, ember-data will fallback to ember-fetch instead of najax when both ember-fetch and jquery are installed in FastBoot.',
false,
{
id: 'ember-data:najax-fallback',
until: '4.0',
}
);
} else {
deprecate(
'In 4.0, ember-data will default to ember-fetch instead of najax in FastBoot. It is recommended that you install ember-fetch or similar as a fetch polyfill in FastBoot.',
false,
{
id: 'ember-data:najax-fallback',
until: '4.0',
}
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, maybe we should move this deprecation to happen in the useFetch computed and funnel everything through that still? The thing I'm concerned with is a massive flood of deprecations to the console that are all exactly the same. AFAICT, we are going to trigger this deprecation every AJAX request we need to make...

Comment on lines 315 to 317
if (this._useFetch !== undefined) {
return this._useFetch;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a symbol here?

} else if (DEPRECATE_NAJAX && typeof najax !== 'undefined') {
if (has('fetch')) {
deprecate(
'You have ember-fetch and jquery installed. To use ember-fetch instead of najax, set `useFetch: true` in your adapter. In 4.0, ember-data will default to ember-fetch instead of najax when both ember-fetch and jquery are installed in FastBoot.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we tweak this to be "native class" first (e.g. instead of useFetch: true say useFetch = true)?

);
} else {
deprecate(
'In 4.0, ember-data will default to ember-fetch instead of najax in FastBoot. It is recommended that you install ember-fetch or similar fetch polyfill in FastBoot.',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here...

} else {
return true;
}
useFetch: computed({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets move this down into the if (DEPRECATE_NAJAX) { conditional, and here (for all users) we'd say useFetch: true.

That way users that opt-in to deprecation stripping of DEPRECATE_NAJAX deprecation can reduce the overall payload, and we avoid the work all together...

otherwise, if the consuming app has compatWith > 3.22, any najax related code will be stripped
@snewcomer snewcomer requested a review from rwjblue October 9, 2020 04:29
@rwjblue rwjblue merged commit 8ed1472 into emberjs:master Oct 9, 2020
snewcomer pushed a commit that referenced this pull request Oct 9, 2020
[CHORE] najax deprecation when ember-fetch is also installed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-review Tracks PRs that require a code-review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fetch + fastboot + jquery detection problem
3 participants