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

Convert to v2, addon. Just wrap fetch. #754

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

NullVoxPopuli
Copy link
Contributor

@NullVoxPopuli NullVoxPopuli commented Nov 5, 2024

This PR is (what I think is) the goal.
We can decide if we want to move towards this goal incrementally or deciding that this is what we want and skip all the in-between.

To move incrementally, we'd need to resolve the following PRs:

Which... we can do -- I'm not sure it's worth keeping CI green through all that though. ember-fetch is in a bit of disrepair.

Support:

  • 3.28+ (easily), maybe 3.4+
  • ember-auto-import @ v2+ or embroider
  • @ember/test-waiters v3+
  • any node (node doesn't matter anymore)
  • continue the renamed-modules support (import from fetch)

I'm not sure what the fastboot support story would be, but Node natively has fetch, AbortController, etc.

Dropped Support:

  • Configuration: PREFER_NATIVE, NATIVE_PROMISE
  • jQuery AJAX
  • You no longer import AbortController. AbortController exists on globalThis
  • You no longer import Headers. Headers exists on globalThis
  • You no longer import Response. Response exists on globalThis

Since ember-auto-import tests against 3.4.0, and ember-auto-import is the only real requirement for this change, there is no change in supported ember-source.

If anything, the constraining function is @ember/test-waiters

Changes:

  • delete the old addon
  • create new fetch export
  • copy over old utils as separate exports
    • remove './types', because these exist all natively
    • remove './utils/determine-body-promise' because it used jQuery AJAX options
    • remove './utils/mung-fetch-options' because it used jQuery AJAX options
  • no build -- folks can just point at git to test this
  • separate test app
  • yarn -> pnpm

After this PR:

  • Add release plan
  • remove release-it

@NullVoxPopuli NullVoxPopuli marked this pull request as ready for review November 6, 2024 16:20
function isPlainObject(obj) {
return Object.prototype.toString.call(obj) === '[object Object]';
}

/**
* Helper function that turns the data/body of a request into a query param string.
* This is directly copied from jQuery.param.
Copy link
Member

Choose a reason for hiding this comment

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

There's also https://github.com/knowledgecode/jquery-param, so wondering if we should still include this in ember-fetch?

@NullVoxPopuli
Copy link
Contributor Author

NullVoxPopuli commented Dec 5, 2024

Todo (RFC):

  • remove ember-fetch from blueprints
  • write docs for the guides on "centralized place to manage requests"

Todo (This PR):

  • waitForPromise around the response.json() and response.body()
  • get reviewed, merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants