fix: fix export for React Native and Browserify (#7386)

Browserify and React Native projects (that aren't using
`unstable_enablePackageExports`) use the `main` field as the package

entrypoint. A recent PR (#5756) updated `main` to use a CommonJS bundle
for Node.js, which caused Browserify and React Native projects to
use the Node.js bundle. This led to many reports of broken React Native
builds.

This has been fixed by adding an entry to `browser` and `react-native`
to re-map the Node.js CommonJS bundle to the browser CommonJS bundle.
This commit is contained in:
Mark Stacey 2026-02-10 03:04:23 -03:30 committed by GitHub
parent 29f75425f0
commit 335b79ffb6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -149,11 +149,13 @@
"typescript": "^4.9.5"
},
"browser": {
"./dist/node/axios.cjs": "./dist/browser/axios.cjs",
"./lib/adapters/http.js": "./lib/helpers/null.js",
"./lib/platform/node/index.js": "./lib/platform/browser/index.js",
"./lib/platform/node/classes/FormData.js": "./lib/helpers/null.js"
},
"react-native": {
"./dist/node/axios.cjs": "./dist/browser/axios.cjs",
"./lib/adapters/http.js": "./lib/helpers/null.js",
"./lib/platform/node/index.js": "./lib/platform/browser/index.js",
"./lib/platform/node/classes/FormData.js": "./lib/helpers/null.js"