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

feat(adapters): add fetch adapter #5146

Closed
wants to merge 77 commits into from
Closed

Commits on Apr 11, 2024

  1. feat: add fetch adapter with cross-platform support

    This changeset adds a `fetch`-based adapter implementation to
    `axios`, powered by `cross-fetch`[1]. The implementation may thus
    be used on either Node or in browser environments.
    
    Changes enclosed:
    - Add `fetch` adapter implementation
    - Add `fetch` to standard built-in adapters
    - Add initial Node-side tests for `fetch`
    - Slight refactor to tests to use common setup / teardown code
    
    Still pending:
    - Upload/download progress events
    - Browser-side testing
    
    Fixes and closes axios#1219, and supersedes axios#2891.
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    d8bc138 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ac79b8c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    847571c View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    a584083 View commit details
    Browse the repository at this point in the history
  5. feat(fetch): continue with implementation of Fetch adapter + API

    - Add support for `axios(URL(...))` and `axios({url: URL(...)})`
    - Add config support for `fetcher`, `fetchOptions` and `parsedUrl`
    - Translate `config.url = URL(...)` to string
    - Implement override for `config.fetcher`
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    6add26b View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    84171fd View commit details
    Browse the repository at this point in the history
  7. feat(fetch): implement mock fetch for testing

    - Mock fetch implementation for testing
    - Spawn fetch adapter configs for testing
    - Test for expected instance/static props related to fetch adapter
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    97b38cd View commit details
    Browse the repository at this point in the history
  8. feat(fetch): add browser-side test suite

    - Add initial browser tests for fetch adapter
    - Test for acceptance of `URL`
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    b57d896 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    0ea0b0a View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    3b79be5 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    b141d45 View commit details
    Browse the repository at this point in the history
  12. feat(fetch): add new generic library target (ESM/pure JS)

    - Add pure JS Node polyfill deps
    - Add new `generic` dist target for Workers, Deno, etc.
    - Move to typealiases in `lib/platform/...` rather than direct use
    - Adapt tests for new alias imports
    - Drop `cross-fetch`, any need for Node polyfills in pure JS envs
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    079e193 View commit details
    Browse the repository at this point in the history
  13. feat(fetch): implement structure for abstract fetch testsuite

    - Implement abstract testsuite structure for fetch
    - Move browser fetch tests to new implementation + API
    - Implement pure-JS test for Deno, based on new API
    - Add test command for Deno (`npm run test:deno`)
    - Add alias test command for Node (`npm run test:node`)
    - Add alias to run all tests (`npm run test:all`)
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    d327984 View commit details
    Browse the repository at this point in the history
  14. feat(fetch): add Deno benchmark and example

    - Add basic fetch overhead benchmark
    - Add example using new `generic` output
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    21ee695 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    5cf9879 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    c823ca6 View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    f783bc4 View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    53f5733 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    fac5d2b View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    78f857f View commit details
    Browse the repository at this point in the history
  21. fix: browser example fixes

    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    dbe9353 View commit details
    Browse the repository at this point in the history
  22. feat(fetch): platform-driven default adapters for each build

    - Define `knownAdapters` for each platform type
    - Import `knownAdapters` for library defaults
    - Alias XHR adapter to `#xhrAdapter`, only include in browser libs
    - Add `.generic.d.*ts` type entries which omit XHR adapter
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    7125e21 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    dd6bc2e View commit details
    Browse the repository at this point in the history
  24. feat(fetch): tools to analyze browser/generic bundle sizes

    Temporary: will probably drop before merge
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    4c1f890 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    c75abe9 View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    ca226d9 View commit details
    Browse the repository at this point in the history
  27. chore: test against Node 19

    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    77f765d View commit details
    Browse the repository at this point in the history
  28. fix: labs CI matrix

    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    e29bdb8 View commit details
    Browse the repository at this point in the history
  29. feat(fetch): platform-specific defaults for fetchOptions

    - Setup baseline default and platform-specific `fetchOption`s
    - Avoids issue with some environments not supporting `cache`
    - Allows shipping bundles with reasonable defaults for each env
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    223cca0 View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    3665213 View commit details
    Browse the repository at this point in the history
  31. fix: tweaks to fetch examples

    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    6817bbd View commit details
    Browse the repository at this point in the history
  32. Configuration menu
    Copy the full SHA
    b3375dc View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    d23fa4f View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    ccd2b81 View commit details
    Browse the repository at this point in the history
  35. Configuration menu
    Copy the full SHA
    5a33664 View commit details
    Browse the repository at this point in the history
  36. feat(fetch): better debug logging, assertions, support for Blob

    - Support for blob responses (when not identifiable as text)
    - Small logging enhancements for fetch debug logs
    - Internal assertions which can be disabled and dropped from `min`
      bundles, and which ensure correct internal fetch state
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    f0e3861 View commit details
    Browse the repository at this point in the history
  37. Configuration menu
    Copy the full SHA
    111a96a View commit details
    Browse the repository at this point in the history
  38. Configuration menu
    Copy the full SHA
    e586ee6 View commit details
    Browse the repository at this point in the history
  39. fix(fetch): refactor and cleanup response handler selection

    - Break response handler selection into dedicated function
    - Only check for body if response code carries one by spec
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    62db627 View commit details
    Browse the repository at this point in the history
  40. fix(fetch): fixes for Fetch adapter in CloudFlare Workers env

    - Don't duck-type response based on `response.type`, which is not
      implemented in CloudFlare Workers' runtime
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    a7dda93 View commit details
    Browse the repository at this point in the history
  41. feat(fetch): sample for CloudFlare Workers

    - Sample which implements the CORS endpoint for testing Axios/Fetch
    - Serves the Axios Fetch-branch library, but with CORS
    - Enables testing of ESM
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    ae675b9 View commit details
    Browse the repository at this point in the history
  42. Configuration menu
    Copy the full SHA
    baa0553 View commit details
    Browse the repository at this point in the history
  43. Configuration menu
    Copy the full SHA
    a80dab3 View commit details
    Browse the repository at this point in the history
  44. feat(fetch): pure-ESM web testing

    - Add `web-test-runner` and associated dependencies
    - Add invocation point for pure ESM tests
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    640bcca View commit details
    Browse the repository at this point in the history
  45. Configuration menu
    Copy the full SHA
    cbd5c42 View commit details
    Browse the repository at this point in the history
  46. Configuration menu
    Copy the full SHA
    72ea94a View commit details
    Browse the repository at this point in the history
  47. Configuration menu
    Copy the full SHA
    d110264 View commit details
    Browse the repository at this point in the history
  48. Configuration menu
    Copy the full SHA
    79b4d06 View commit details
    Browse the repository at this point in the history
  49. feat(fetch): treeshaking and terser tweaks, optimize license

    - Tweak treeshaking to be more aggressive on modern platforms
    - Move license comment to bottom of output targets
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    5a304e8 View commit details
    Browse the repository at this point in the history
  50. Configuration menu
    Copy the full SHA
    44a6fc4 View commit details
    Browse the repository at this point in the history
  51. feat(fetch): improvements to fetch typings

    - Structured type for `FetchOptions`
    - Better type export for `Fetcher`
    - Better type export for `AxiosFetchAdapter`
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    a8de64a View commit details
    Browse the repository at this point in the history
  52. chore: cleanup abstract fetch testsuite

    - Add support for `beforeEach`/`afterEach`
    - Add full typings for abstract test types
    - Prep to extend abstract test suite to Node
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    0e7cd28 View commit details
    Browse the repository at this point in the history
  53. Configuration menu
    Copy the full SHA
    8445ed8 View commit details
    Browse the repository at this point in the history
  54. Configuration menu
    Copy the full SHA
    a4d2ba6 View commit details
    Browse the repository at this point in the history
  55. Configuration menu
    Copy the full SHA
    e4cfe15 View commit details
    Browse the repository at this point in the history
  56. fix: handler selection with no Content-Type present

    - Skip checking config for handler type if no `responseType` param
      is present
    - Only resolve handler from `Content-Type` if header is available
      in response
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    358d896 View commit details
    Browse the repository at this point in the history
  57. Configuration menu
    Copy the full SHA
    71dbee0 View commit details
    Browse the repository at this point in the history
  58. Configuration menu
    Copy the full SHA
    e6771b3 View commit details
    Browse the repository at this point in the history
  59. chore: package spec cleanup

    - Move properties around to avoid stray changes in diffs
    - Move `cross-fetch` to optional deps
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    a0e215f View commit details
    Browse the repository at this point in the history
  60. Configuration menu
    Copy the full SHA
    7310032 View commit details
    Browse the repository at this point in the history
  61. Configuration menu
    Copy the full SHA
    d791176 View commit details
    Browse the repository at this point in the history
  62. fix: pass relative URLs directly to the underlying fetcher

    - Instead of failing, bypass URL parsing, and pass the URL verbatim
      to the underlying fetch implementation
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    3c42865 View commit details
    Browse the repository at this point in the history
  63. test: ESM API spec

    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    2f4802b View commit details
    Browse the repository at this point in the history
  64. chore: cleanup abstract fetch testsuite

    - Move abstract fetch testsuite tests into basic test spec file
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    bdf4b15 View commit details
    Browse the repository at this point in the history
  65. Configuration menu
    Copy the full SHA
    07a8770 View commit details
    Browse the repository at this point in the history
  66. fix: drop missing test

    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    39af694 View commit details
    Browse the repository at this point in the history
  67. fix: allow version tag in user-agent test

    Signed-off-by: Sam Gammon <sam@elide.ventures>
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    29fc3e6 View commit details
    Browse the repository at this point in the history
  68. chore: version bump for fetch testing → 1.6.8-fetch

    Signed-off-by: Sam Gammon <sam@elide.ventures>
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    baa53f6 View commit details
    Browse the repository at this point in the history
  69. chore: lock packages, rebuild dist

    Signed-off-by: Sam Gammon <sam@elide.ventures>
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    b004d39 View commit details
    Browse the repository at this point in the history
  70. fixup! amend testsuite to fix combineURLs updates

    Signed-off-by: Sam Gammon <sam@elide.ventures>
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    ae14db6 View commit details
    Browse the repository at this point in the history
  71. test: add entrypoint for bun testing

    Signed-off-by: Sam Gammon <sam@elide.ventures>
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    3a968e0 View commit details
    Browse the repository at this point in the history
  72. chore: shutoff debug logging for release at 1.6.8

    Relates to axios#5146
    
    Signed-off-by: Sam Gammon <sam@elide.ventures>
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    41c787c View commit details
    Browse the repository at this point in the history
  73. chore: rebuild dist

    Signed-off-by: Sam Gammon <sam@elide.ventures>
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    060f45f View commit details
    Browse the repository at this point in the history
  74. fixup! disable ci matrix failfast, upgrade bun in ci

    Signed-off-by: Sam Gammon <sam@elide.ventures>
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    746a6ef View commit details
    Browse the repository at this point in the history
  75. chore: add node 21.x to test matrices

    Signed-off-by: Sam Gammon <sam@elide.ventures>
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    ca8ac8d View commit details
    Browse the repository at this point in the history
  76. fixup! deno test await

    Signed-off-by: Sam Gammon <sam@elide.ventures>
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    cde5fd8 View commit details
    Browse the repository at this point in the history
  77. fixup! browser fetch mock polyfill

    Signed-off-by: Sam Gammon <sam@elide.ventures>
    sgammon committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    7b83ff9 View commit details
    Browse the repository at this point in the history