@@ -546,14 +546,16 @@ class HasteMap extends EventEmitter {
546546 if ( this . _options . retainAllFiles && filePath . includes ( NODE_MODULES ) ) {
547547 if ( computeSha1 ) {
548548 return this . _getWorker ( workerOptions )
549- . getSha1 ( {
550- computeDependencies : this . _options . computeDependencies ,
551- computeSha1,
552- dependencyExtractor : this . _options . dependencyExtractor ,
553- filePath,
554- hasteImplModulePath : this . _options . hasteImplModulePath ,
555- rootDir,
556- } )
549+ . then ( workerInstance =>
550+ workerInstance . getSha1 ( {
551+ computeDependencies : this . _options . computeDependencies ,
552+ computeSha1,
553+ dependencyExtractor : this . _options . dependencyExtractor ,
554+ filePath,
555+ hasteImplModulePath : this . _options . hasteImplModulePath ,
556+ rootDir,
557+ } ) ,
558+ )
557559 . then ( workerReply , workerError ) ;
558560 }
559561
@@ -622,14 +624,16 @@ class HasteMap extends EventEmitter {
622624 }
623625
624626 return this . _getWorker ( workerOptions )
625- . worker ( {
626- computeDependencies : this . _options . computeDependencies ,
627- computeSha1,
628- dependencyExtractor : this . _options . dependencyExtractor ,
629- filePath,
630- hasteImplModulePath : this . _options . hasteImplModulePath ,
631- rootDir,
632- } )
627+ . then ( workerInstance =>
628+ workerInstance . worker ( {
629+ computeDependencies : this . _options . computeDependencies ,
630+ computeSha1,
631+ dependencyExtractor : this . _options . dependencyExtractor ,
632+ filePath,
633+ hasteImplModulePath : this . _options . hasteImplModulePath ,
634+ rootDir,
635+ } ) ,
636+ )
633637 . then ( workerReply , workerError ) ;
634638 }
635639
@@ -714,17 +718,19 @@ class HasteMap extends EventEmitter {
714718 /**
715719 * Creates workers or parses files and extracts metadata in-process.
716720 */
717- private _getWorker ( options ?: { forceInBand : boolean } ) : WorkerInterface {
721+ private async _getWorker ( options ?: {
722+ forceInBand : boolean ;
723+ } ) : Promise < WorkerInterface > {
718724 if ( ! this . _worker ) {
719725 if ( ( options && options . forceInBand ) || this . _options . maxWorkers <= 1 ) {
720726 this . _worker = { getSha1, worker} ;
721727 } else {
722728 // @ts -expect-error: assignment of a worker with custom properties.
723- this . _worker = new Worker ( require . resolve ( './worker' ) , {
729+ this . _worker = ( await Worker . create ( require . resolve ( './worker' ) , {
724730 exposedMethods : [ 'getSha1' , 'worker' ] ,
725731 maxRetries : 3 ,
726732 numWorkers : this . _options . maxWorkers ,
727- } ) as WorkerInterface ;
733+ } ) ) as WorkerInterface ;
728734 }
729735 }
730736
0 commit comments