-
Notifications
You must be signed in to change notification settings - Fork 1k
pkg does not respect exports
entrypoints defined in package.json
#1873
Comments
PR? |
I'm currently deciphering to figure out how to implement a fix; I'll update if I end up not having time to make a PR. |
This could be a good starting point: https://github.com/vercel/pkg/wiki/Developers |
If I'm understanding how the walker/follower works, I believe the issue is because the |
I'm aware of #1291. This is unrelated to ESMs; as I stated in my issue description, this for a CJS project with a CJS dependency. While browserify/resolve#222 has |
Regardless, until In the meantime, a hacky |
I'm facing the same issue. |
Would switching to https://www.npmjs.com/package/enhanced-resolve be viable? |
yes, I'm facing the same issue. |
This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label |
refresh |
This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label |
This issue is still relevant. |
This is causing issues for us with |
What version of pkg are you using?
5.8.0
What version of Node.js are you using?
18.13.0
What operating system are you using?
Windows 11
What CPU architecture are you using?
x86_x64
What Node versions, OSs and CPU architectures are you building for?
node18-linux-x64
Describe the Bug
If you are using a CJS project that has
require("axios")
where you're using[email protected]
(1.3.4
at the time of reporting this is latest), the axiospackage.json
definesexports
that would resolve to./dist/node/axios.cjs
. Note, per the NodeJS docs,exports
is used when bothexports
andmain
are defined.To explain how the
require("axios") => require("axios/dist/node/axios.cjs")
works further,require("axios")
has a relative path of.
, so it then looks at the "." section, then it's not a types lookup or a browser environment, so it then goes to the "default" section, and since we're using require, it goes to the "require" section which is defined as./dist/node/axios.cjs
.When I look at my
pkg --debug
output, it shows it's just resolving toaxios/index.js
:The above is using
@open-match/[email protected]
whereimport axiosStatic from "axios"
gets compiled bytsc
toconst axios_1 = __importDefault(require("axios"));
Expected Behavior
pkg should respect the rules defined by
"exports"
inpackage.json
as defined in the NodeJS docs since that's how require statements are interpreted.To Reproduce
npm install axios
const axios = requie("axios");
pkg --debug
axios.cjs
file is never added to the queueThe text was updated successfully, but these errors were encountered: