File tree Expand file tree Collapse file tree
packages/jest-resolve/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 * LICENSE file in the root directory of this source tree.
66 */
77
8+ import { resolve } from 'path' ;
89import * as fs from 'graceful-fs' ;
910import pnpResolver from 'jest-pnp-resolver' ;
1011import { Opts as ResolveOpts , sync as resolveSync } from 'resolve' ;
@@ -175,11 +176,24 @@ function createPackageFilter(
175176 }
176177 }
177178
178- return function packageFilter ( pkg : PkgJson , ... rest ) {
179+ return function packageFilter ( pkg : PkgJson , path ) {
179180 let filteredPkg = pkg ;
180181
181182 if ( userFilter ) {
182- filteredPkg = userFilter ( filteredPkg , ...rest ) ;
183+ filteredPkg = userFilter ( filteredPkg , path ) ;
184+ }
185+
186+ if ( filteredPkg . main ) {
187+ return filteredPkg ;
188+ }
189+
190+ const indexInRoot = resolve ( path , './index.js' ) ;
191+
192+ // if the module contains an `index.js` file in root, `resolve` will request
193+ // that if there is no `main`. Since we don't wanna break that, add this
194+ // check
195+ if ( isFile ( indexInRoot ) ) {
196+ return filteredPkg ;
183197 }
184198
185199 return {
You can’t perform that action at this time.
0 commit comments