@@ -67,6 +67,7 @@ type Options = {
6767 retainAllFiles : boolean ,
6868 rootDir : string ,
6969 roots : Array < string > ,
70+ skipHastePackages ? : boolean ,
7071 throwOnModuleCollision ?: boolean ,
7172 useWatchman ?: boolean ,
7273 watch ?: boolean ,
@@ -90,6 +91,7 @@ type InternalOptions = {
9091 retainAllFiles : boolean ,
9192 rootDir : string ,
9293 roots : Array < string > ,
94+ skipHastePackages : boolean ,
9395 throwOnModuleCollision : boolean ,
9496 useWatchman : boolean ,
9597 watch : boolean ,
@@ -108,6 +110,7 @@ export type FS = HasteFS;
108110const CHANGE_INTERVAL = 30 ;
109111const MAX_WAIT_TIME = 240000 ;
110112const NODE_MODULES = path . sep + 'node_modules' + path . sep ;
113+ const PACKAGE_JSON = path . sep + 'package.json' ;
111114
112115const canUseWatchman = ( ( ) : boolean => {
113116 try {
@@ -251,6 +254,7 @@ class HasteMap extends EventEmitter {
251254 retainAllFiles : options . retainAllFiles ,
252255 rootDir : options . rootDir ,
253256 roots : Array . from ( new Set ( options . roots ) ) ,
257+ skipHastePackages : ! ! options . skipHastePackages ,
254258 throwOnModuleCollision : ! ! options . throwOnModuleCollision ,
255259 useWatchman : options . useWatchman == null ? true : options . useWatchman ,
256260 watch : ! ! options . watch ,
@@ -620,6 +624,12 @@ class HasteMap extends EventEmitter {
620624 }
621625
622626 for ( const relativeFilePath of hasteMap . files . keys ( ) ) {
627+ if (
628+ this . _options . skipHastePackages &&
629+ relativeFilePath . endsWith ( PACKAGE_JSON )
630+ ) {
631+ continue ;
632+ }
623633 // SHA-1, if requested, should already be present thanks to the crawler.
624634 const filePath = fastPath . resolve (
625635 this . _options . rootDir ,
0 commit comments