-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[FEAT fetch] use ember-fetch instead of jQuery #5386
Conversation
addon/adapters/rest.js
Outdated
import Ember from 'ember'; | ||
import fetch, { Response } from 'fetch'; | ||
//FIXME: We need to add a direct export of `serializeQueryParams` | ||
import { serializeQueryParams } from 'ember-fetch/mixins/adapter-fetch'; |
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've been wondering where the best place for this to live is. In a jQuery-less world, $.param()
is gone and Ember should have some replacement.
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 feel like ember-fetch
is good place for now. I am planing on doing a PR to move it out of ember-fetch/mixins/adapter-fetch
. But a broader discussion is needed about fetch
usage: fetch
on it own is not a suitable replacement for $.ajax
in my opinion. fetch
is too low level.
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.
Another option might be to use URLSearchParams
provided by ember-url
(with polyfills). It is a standard, but might be less convenient then a $.param()
.
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.
what's better? URLSearchParams
from ember-url
, or serializerQueryParams
from the fetch adapter?
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.
Using URLSearchParams
is not an option after investigation – it won't serialise nested params. I think wee should expose something like import { param } from 'ember-fetch';
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.
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.
@tchak ember-fetch has been updated!
3a42f4a
to
16fe506
Compare
@tchak What's the status? Seems to be the last step for being able to use ED without jQuery. |
package.json
Outdated
@@ -48,6 +48,7 @@ | |||
"ember-cli-string-utils": "^1.1.0", | |||
"ember-cli-test-info": "^1.0.0", | |||
"ember-cli-version-checker": "^2.1.2", | |||
"ember-fetch": "^5.1.3", |
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 think we should we make this a peerDependency
instead to avoid trolling folks with multiple versions, and a devDependency
for our own use.
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 still needs to be removed from here. this was probably my bad when I did partial work on this.
@tchak @NullVoxPopuli think this needs updated for code style, there's also some broken tests |
I'll take a look. :) |
I probably won't be available today match, but I should be able to help if needed tomorrow |
copying this from the other PR: I think there should probably be a good amount of tests for fetch, which don't exist yet. So, I think for this feature to be complete, we need to find all the request url / headers / whatever related tests and make fetch versions of them. |
There is a couple of external tests failing. Ember Observer seems like a timeout. Ilios Frontend looks like some genuine errors. I will have to look in to it more closely. |
@tchak may also be flakiness, it passed when I restarted the job. cc @jrjohnson |
I can't see the failure, but we've been struggling terribly with flaky tests the last couple of days for reasons we haven't tracked down yet. If the error was something like https://github.com/ilios/frontend/issues/4046 then this may be the issue. |
build passed! (but hasn't reported back to github for some reason) |
@NullVoxPopuli anything remaining? I noticed this:
|
@runspired good catch -- this file: https://github.com/emberjs/data/pull/5386/files#diff-038a1249383849dd6526ee97d193e925R90 the ajax file needs a fetch equivalent. also, are coverage artifacts outputted somewhere? my hunch is that a lot of the new fetch stuff is missing most coverage |
tests and ember-fetch dep removed: tchak#3 |
do peerDependencies not solve this? |
@NullVoxPopuli I think it's just a warning when it comes to peerDependencies 🤔 but I could be wrong |
peerDependency just writes a warning. Forcing it to an error can be done by ember-cli-version-checker |
@xg-wang is correct, and likely that’s what we should do. |
I’m a bit hesitant to do something that forces folks to install ember-fetch as much as I want to eliminate jQuery. We should likely make whether it is required “optional” and only use version checker to enforce if the flag is not set to drop it. |
Si it should throw an error only if no |
@tchak I was thinking more broad: as in it should likely be the default that without jquery we expect fetch, but folks should be able to opt out of both. |
I think this could do it. To check top level & sibling ember-fetch existence should be done in ember-fetch self's cli hook. |
@runspired how do you see the opt out strategy? I guess the fallback would be on a non-polyfilled version of fetch (what about fastboot?). In module.exports = function(environment) {
var ENV = {
'ember-data': {
useNativeFetch: true // defaults to false
}
}
} @tchak I've done a PR (targeting yours) to throw an error in case of dependency mismatch. |
The quest to remove jQuery by default as per RFC386 is making good progress. Part of it is also resolving this issue. So is there a chance we can land this in the near future? Ideally in a forthcoming 3.9 release? (which is the version of Ember which will add the additional jQuery deprecations) |
where can we view the status of this? |
@dcyriller I think i'm going to skip on this requirement for now and add it as a feature later if folks need. Is all that is needed to land a rebase at this point? |
Closing in favor of #5900 |
depends on #5375, #5385 and #5375
will fix #5320