Skip to content

How vitest resolves dependency exports #4233

Answered by sheremet-va
mkarajohn asked this question in Q&A
Discussion options

You must be logged in to vote

Vitest will completely ignore the module key, and it will go for main instead.

Vitest has to use Node.js resolution so you don't have multiple instances of the same package, and Node.js doesn't support module field.

Vitest will go for the import key, which is the expected behaviour when the consumer application has "type": "module".

This is not true. import key is chosen when the consumer uses import to import the module.

Is this described behaviour documented somewhere that I missed? Should this be documented? (I can open an issue and do that)

This is just a standard resolution: https://nodejs.org/api/esm.html#resolution-and-loading-algorithm

Replies: 5 comments 14 replies

Comment options

You must be logged in to vote
1 reply
@mkarajohn
Comment options

Answer selected by mkarajohn
Comment options

You must be logged in to vote
4 replies
@mkarajohn
Comment options

@mkarajohn
Comment options

@sheremet-va
Comment options

@deleugpn
Comment options

Comment options

You must be logged in to vote
2 replies
@mkarajohn
Comment options

@deleugpn
Comment options

Comment options

You must be logged in to vote
7 replies
@sheremet-va
Comment options

@AllanJard
Comment options

@mkarajohn
Comment options

@sheremet-va
Comment options

@AllanJard
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants