Skip to content

exports lib packages in package.json #5000

@trim21

Description

@trim21

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions