Skip to content

chore: migrate axios to fetch#1609

Open
yifancong wants to merge 2 commits intomainfrom
chore/axios-migrate-to-fetch
Open

chore: migrate axios to fetch#1609
yifancong wants to merge 2 commits intomainfrom
chore/axios-migrate-to-fetch

Conversation

@yifancong
Copy link
Copy Markdown
Contributor

@yifancong yifancong commented Apr 1, 2026

Summary

This pull request removes the dependency on axios across multiple packages and refactors all HTTP requests to use the native fetch API (with a fallback to undici for Node.js environments). It introduces utility functions to handle fetch requests, updates all relevant code to use these utilities, and adds tests for the new request logic. Additionally, it updates build configurations to reflect the removal of axios and ensures proper handling of Node.js built-in modules in the client build.

These changes collectively simplify the codebase, reduce dependencies, and improve compatibility across environments by standardizing on the fetch API for HTTP requests.

Used this skill: https://github.com/yifancong/yifan-skills.

Related Links

Copilot AI review requested due to automatic review settings April 1, 2026 10:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates internal HTTP requests from axios to the platform fetch API across core, CLI, and UI packages, and removes the axios dependency accordingly.

Changes:

  • Replaced axios GET/POST usages with fetch implementations (including basic timeout handling via AbortController).
  • Removed axios from package dependencies/prebundle config and updated client chunk-splitting rules.
  • Added unit tests for the new request helpers in packages/components and packages/cli.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pnpm-lock.yaml Removes axios from workspace importers in the lockfile.
packages/core/src/inner-plugins/utils/loader.ts Replaces loader report POSTs from axios to fetch with timeout/AbortController.
packages/core/prebundle.config.mjs Removes axios from prebundle dependencies list.
packages/core/package.json Drops axios devDependency from core package.
packages/components/src/utils/request.ts Reimplements request helpers (fetchJSONByUrl, postServerAPI, dev URL rewrite) on top of fetch.
packages/components/src/utils/request.test.ts Adds tests for the new fetch-based request utilities.
packages/components/src/components/Alert/change.tsx Migrates Apply Fix action from axios.post to fetch.
packages/components/package.json Removes axios dependency.
packages/client/rsbuild.config.ts Removes axios from vendor chunk split regex.
packages/cli/src/utils.ts Migrates fetchText/remote JSON loading from axios to fetch.
packages/cli/src/utils.test.ts Adds tests for CLI fetch utilities.
packages/cli/package.json Removes axios dependency.
packages/ai/package.json Removes axios dependency.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)

packages/core/package.json:90

  • After removing axios, @types/node-fetch appears unused (no node-fetch imports/references found in packages/core). Since @types/node already provides fetch typings on modern Node, consider removing @types/node-fetch to avoid carrying an extra (now stale) types package.
  "devDependencies": {
    "@rspack/core": "2.0.0-canary-20260116",
    "@scripts/test-helper": "workspace:*",
    "@types/fs-extra": "^11.0.4",
    "@types/node": "^22.8.1",
    "@types/node-fetch": "^2.6.13",
    "@types/semver": "^7.7.1",

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yifancong yifancong requested a review from fi3ework April 1, 2026 12:09
@fi3ework
Copy link
Copy Markdown
Member

fi3ework commented Apr 1, 2026

@codex review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants