-
Notifications
You must be signed in to change notification settings - Fork 7
Doesn't Appear to work with Top level node Exports #11
Comments
That |
oh right! i failed to mention, i actually desire the To be clear, i have something like this: const JsdomEnv = require("jest-environment-jsdom");
module.exports = class MyEnv extends JsdomEnv {
exportConditions() {
return ["browser"];
}
}; and I'm using this env in jest's console logging in |
Do you have a test case that we can replicate? |
@piranna good idea. i should have just done this from the get go. https://github.com/dairyisscary/jest-enviorn-root $ node --version
v16.13.0
$ npm install
$ npm test if the test fails, that means that jest is using the server version of |
I've published a new version 1.1.5, can you check if it works? |
@piranna its working swimmingly! thank you so much for your efforts. I consider this issue closed. (side note, i was able to pull your 1.1.5 from npm but it looks like you've forgotten to push your changes to github too -- just a heads up) |
Hello!
Thanks for the great package! However, I ran into an issue with packages that use a exports for the "top-level" node modules export. This package only appears to work if the import request is for a submodule like
import x from "my-node-package/submodule";
. it is possible for a package to use theexports
field for root likeimport x from "my-node-package";
.For an example of this, see solid js which uses exports quite extensively to support different code paths in the server vs the browser.
https://github.com/solidjs/solid/blob/main/packages/solid/package.json#L37
In other words,
jest-node-exports-resolver
seems to work correctly when importingsolid-js/web
but notsolid-js
. i was able to work around this by making two changes to the resolver:i also needed to add a check on
conditions
since this change alone broke for the packageexpect
(which has aconditions
ofundefined
) as far as i can tell, this is a good change regardless since we can skip theresolveExport
function in more casesI have no idea if these changes are good in general. i'd be happy to make a PR if you think this is good idea.
The text was updated successfully, but these errors were encountered: