Issue 1:
Describe the bug

After upgrading axios from 0.19.0 to 0.19.1 all tests that use nock got broken. They now produce the following error:

Error: Cross origin http://localhost forbidden

To Reproduce

Repo with minimal test case that reproduces the issue: https://github.com/EvgenyOrekhov/js-framework/tree/axios-bug.

Note that previous commit (which has axios 0.19.0) works fine, the test passes.

import axios from "axios";
import nock from "nock";

it("makes HTTP requests", async done => {
const scope = nock("https://example.com/foo/")
.get("/bar")
.reply(200, { foo: "bar" });

await axios.get("https://example.com/foo/bar");

scope.done();
done();
});

Expected behavior

The test should pass.

Environment:

Axios Version: 0.19.1

OS: Ubuntu 19.10

Browser: n/a

Browser Version: n/a

Additional Library Versions: nock 11.7.2

Additional context/Screenshots

Jest error with stack trace:

FAIL src/http.test.js
✕ makes HTTP requests (34ms)

● makes HTTP requests

Network Error

at createError (node_modules/axios/lib/core/createError.js:16:15)
at XMLHttpRequest.handleError (node_modules/axios/lib/adapters/xhr.js:83:14)
at XMLHttpRequest.<anonymous> (node_modules/jsdom/lib/jsdom/living/helpers/create-event-accessor.js:33:32)
at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:193:27)
at XMLHttpRequestEventTargetImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:119:9)
at XMLHttpRequestEventTargetImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:82:17)
at XMLHttpRequest.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:157:21)
at requestErrorSteps (node_modules/jsdom/lib/jsdom/living/xhr-utils.js:132:7)
at dispatchError (node_modules/jsdom/lib/jsdom/living/xhr-utils.js:62:3)
at Object.validCORSHeaders (node_modules/jsdom/lib/jsdom/living/xhr-utils.js:77:5)
at receiveResponse (node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:847:21)
at Request.<anonymous> (node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:679:38)
at Request.onRequestResponse (node_modules/request/request.js:1066:10)
at respond (node_modules/nock/lib/playback_interceptor.js:299:11)
at respondUsingInterceptor (node_modules/nock/lib/playback_interceptor.js:341:7)
at node_modules/nock/lib/playback_interceptor.js:281:7

console.error node_modules/jsdom/lib/jsdom/virtual-console.js:29
Error: Cross origin http://localhost forbidden
at dispatchError (/home/user/my-app/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:65:19)
at Object.validCORSHeaders (/home/user/my-app/node_modules/jsdom/lib/jsdom/living/xhr-utils.js:77:5)
at receiveResponse (/home/user/my-app/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:847:21)
at Request.<anonymous> (/home/user/my-app/node_modules/jsdom/lib/jsdom/living/xmlhttprequest.js:679:38)
at Request.emit (events.js:321:20)
at Request.onRequestResponse (/home/user/my-app/node_modules/request/request.js:1066:10)
at OverriddenClientRequest.emit (events.js:321:20)
at respond (/home/user/my-app/node_modules/nock/lib/playback_interceptor.js:299:11)
at respondUsingInterceptor (/home/user/my-app/node_modules/nock/lib/playback_interceptor.js:341:7)
at /home/user/my-app/node_modules/nock/lib/playback_interceptor.js:281:7 undefined

Issue 2:
TLDR：

Oh, yeah I don't think we will ever export that.

#5000 (comment)

Is your feature request related to a problem? Please describe.

Yes. I'm writing a adaptor to be used in userscript like tampermonkey or Violentmonkey,

it use a xhr provided be broser extension GM.xmlHttpRequest to make cors request.

And to make it behavior like axios' xhr adaptor, I'm using some axios' helper functions directly by

import buildFullPath from "axios/lib/core/buildFullPath";
import settle from "axios/lib/core/settle";
import buildURL from "axios/lib/helpers/buildURL";
import parseHeaders from "axios/lib/helpers/parseHeaders";
import utils from "axios/lib/utils";

But after axios 1.0.0 is released, a exports field is added to package.json, and lib directory is no longer exported anymore, this make me unable to use helper function provided by axios anymore.

axios/package.json

Lines 6 to 17
in
484aa4f

"exports": {

".": {

"browser": {

"require": "./index.js",

"default": "./index.js"

},

"default": {

"require": "./dist/node/axios.cjs",

"default": "./index.js"

}

}

},

modern js bundler will raise a error for this: Package subpath './lib/core/buildFullPath' is not defined by "exports" in .../node_modules/axios/package.json by bundler.

Describe the solution you'd like

add lib dir to package.json#exports