2 * (NB: this resolver is slightly different from the one under each 'applications/' tests, as here we
3 * also need to manually resolve 'browser' exports, probably due to different Jest presets).
5 * Jest seems to never resolve the 'import' or 'browser' conditions from the package.json `exports`,
6 * and instead it only looks for e.g. ['require', 'default', 'node', 'node-addons']
7 * Since we rely on babel to transform ESM file, we can force the resolver to also consider
8 * the 'import' and 'browser' fields, if the default resolution method fails.
9 * However, this means that the CJS conditions always have priority in the module resolution,
10 * which might cause unexpected issues in some packages (but not in the ones we currently use).
12 module
.exports = function (request
, options
) {
14 return options
.defaultResolver(request
, options
);
16 if (options
.conditions
) {
17 return options
.defaultResolver(request
, { ...options
, conditions
: ['browser', 'import'] });