This repo contains code to reproduce a bug in resolve.exports
and jest.
By default jest
uses jest-resolve
to resolve imports between files. If an import is to another nodejs package which has exports
field in package.json
, it uses resolve.exports
package to resolve the import. resolve.exports
does not work correctly with files that start with dot (.
).
aws-cdk-lib
defines such an export mapping in its package.json
:
{
...
"exports": {
...
"./.warnings.jsii.js": "./.warnings.jsii.js",
...
}
}
The bug is on this line
Run the tests using npm test
Define custom resolver that explicitly points to the correct file to import. See resolver.js
and jest.config.js
.