@@ -545,7 +545,6 @@ export default class Runtime {
545
545
referencingIdentifier ,
546
546
specifier ,
547
547
this . _explicitShouldMockModule ,
548
- { conditions : this . esmConditions } ,
549
548
)
550
549
) {
551
550
return this . importMock ( referencingIdentifier , specifier , context ) ;
@@ -631,15 +630,12 @@ export default class Runtime {
631
630
referencingIdentifier ,
632
631
path ,
633
632
this . _explicitShouldMockModule ,
634
- { conditions : this . esmConditions } ,
635
633
)
636
634
) {
637
635
return this . importMock ( referencingIdentifier , path , context ) ;
638
636
}
639
637
640
- const resolved = await this . _resolveModule ( referencingIdentifier , path , {
641
- conditions : this . esmConditions ,
642
- } ) ;
638
+ const resolved = await this . _resolveModule ( referencingIdentifier , path ) ;
643
639
644
640
if (
645
641
this . _resolver . isCoreModule ( resolved ) ||
@@ -697,9 +693,7 @@ export default class Runtime {
697
693
698
694
const [ path , query ] = ( moduleName ?? '' ) . split ( '?' ) ;
699
695
700
- const modulePath = await this . _resolveModule ( from , path , {
701
- conditions : this . esmConditions ,
702
- } ) ;
696
+ const modulePath = await this . _resolveModule ( from , path ) ;
703
697
704
698
const module = await this . loadEsmModule ( modulePath , query ) ;
705
699
@@ -792,9 +786,7 @@ export default class Runtime {
792
786
const namedExports = new Set ( exports ) ;
793
787
794
788
reexports . forEach ( reexport => {
795
- const resolved = this . _resolveCjsModule ( modulePath , reexport , {
796
- conditions : this . esmConditions ,
797
- } ) ;
789
+ const resolved = this . _resolveCjsModule ( modulePath , reexport ) ;
798
790
799
791
const exports = this . getExportsOfCjs ( resolved ) ;
800
792
@@ -845,9 +837,7 @@ export default class Runtime {
845
837
}
846
838
847
839
if ( ! modulePath ) {
848
- modulePath = this . _resolveCjsModule ( from , moduleName , {
849
- conditions : this . cjsConditions ,
850
- } ) ;
840
+ modulePath = this . _resolveCjsModule ( from , moduleName ) ;
851
841
}
852
842
853
843
if ( this . unstable_shouldLoadAsEsm ( modulePath ) ) {
@@ -960,9 +950,7 @@ export default class Runtime {
960
950
961
951
let modulePath =
962
952
this . _resolver . getMockModule ( from , moduleName ) ||
963
- this . _resolveCjsModule ( from , moduleName , {
964
- conditions : this . cjsConditions ,
965
- } ) ;
953
+ this . _resolveCjsModule ( from , moduleName ) ;
966
954
967
955
let isManualMock =
968
956
manualMockOrStub &&
@@ -1066,11 +1054,7 @@ export default class Runtime {
1066
1054
}
1067
1055
1068
1056
try {
1069
- if (
1070
- this . _shouldMockCjs ( from , moduleName , this . _explicitShouldMock , {
1071
- conditions : this . cjsConditions ,
1072
- } )
1073
- ) {
1057
+ if ( this . _shouldMockCjs ( from , moduleName , this . _explicitShouldMock ) ) {
1074
1058
return this . requireMock < T > ( from , moduleName ) ;
1075
1059
} else {
1076
1060
return this . requireModule < T > ( from , moduleName ) ;
@@ -1305,20 +1289,20 @@ export default class Runtime {
1305
1289
this . isTornDown = true ;
1306
1290
}
1307
1291
1308
- private _resolveCjsModule (
1309
- from : string ,
1310
- to : string | undefined ,
1311
- options ?: ResolveModuleConfig ,
1312
- ) {
1313
- return to ? this . _resolver . resolveModule ( from , to , options ) : from ;
1292
+ private _resolveCjsModule ( from : string , to : string | undefined ) {
1293
+ return to
1294
+ ? this . _resolver . resolveModule ( from , to , {
1295
+ conditions : this . cjsConditions ,
1296
+ } )
1297
+ : from ;
1314
1298
}
1315
1299
1316
- private _resolveModule (
1317
- from : string ,
1318
- to : string | undefined ,
1319
- options ?: ResolveModuleConfig ,
1320
- ) {
1321
- return to ? this . _resolver . resolveModuleAsync ( from , to , options ) : from ;
1300
+ private _resolveModule ( from : string , to : string | undefined ) {
1301
+ return to
1302
+ ? this . _resolver . resolveModuleAsync ( from , to , {
1303
+ conditions : this . esmConditions ,
1304
+ } )
1305
+ : from ;
1322
1306
}
1323
1307
1324
1308
private _requireResolve (
@@ -1366,9 +1350,7 @@ export default class Runtime {
1366
1350
}
1367
1351
1368
1352
try {
1369
- return this . _resolveCjsModule ( from , moduleName , {
1370
- conditions : this . cjsConditions ,
1371
- } ) ;
1353
+ return this . _resolveCjsModule ( from , moduleName ) ;
1372
1354
} catch ( err ) {
1373
1355
const module = this . _resolver . getMockModule ( from , moduleName ) ;
1374
1356
@@ -1731,9 +1713,7 @@ export default class Runtime {
1731
1713
private _generateMock ( from : string , moduleName : string ) {
1732
1714
const modulePath =
1733
1715
this . _resolver . resolveStubModuleName ( from , moduleName ) ||
1734
- this . _resolveCjsModule ( from , moduleName , {
1735
- conditions : this . cjsConditions ,
1736
- } ) ;
1716
+ this . _resolveCjsModule ( from , moduleName ) ;
1737
1717
if ( ! this . _mockMetaDataCache . has ( modulePath ) ) {
1738
1718
// This allows us to handle circular dependencies while generating an
1739
1719
// automock
@@ -1777,8 +1757,8 @@ export default class Runtime {
1777
1757
from : string ,
1778
1758
moduleName : string ,
1779
1759
explicitShouldMock : Map < string , boolean > ,
1780
- options : ResolveModuleConfig ,
1781
1760
) : boolean {
1761
+ const options : ResolveModuleConfig = { conditions : this . cjsConditions } ;
1782
1762
const moduleID = this . _resolver . getModuleID (
1783
1763
this . _virtualMocks ,
1784
1764
from ,
@@ -1807,7 +1787,7 @@ export default class Runtime {
1807
1787
1808
1788
let modulePath ;
1809
1789
try {
1810
- modulePath = this . _resolveCjsModule ( from , moduleName , options ) ;
1790
+ modulePath = this . _resolveCjsModule ( from , moduleName ) ;
1811
1791
} catch ( e ) {
1812
1792
const manualMock = this . _resolver . getMockModule ( from , moduleName ) ;
1813
1793
if ( manualMock ) {
@@ -1848,8 +1828,8 @@ export default class Runtime {
1848
1828
from : string ,
1849
1829
moduleName : string ,
1850
1830
explicitShouldMock : Map < string , boolean > ,
1851
- options : ResolveModuleConfig ,
1852
1831
) : Promise < boolean > {
1832
+ const options : ResolveModuleConfig = { conditions : this . esmConditions } ;
1853
1833
const moduleID = await this . _resolver . getModuleIDAsync (
1854
1834
this . _virtualMocks ,
1855
1835
from ,
@@ -1878,7 +1858,7 @@ export default class Runtime {
1878
1858
1879
1859
let modulePath ;
1880
1860
try {
1881
- modulePath = await this . _resolveModule ( from , moduleName , options ) ;
1861
+ modulePath = await this . _resolveModule ( from , moduleName ) ;
1882
1862
} catch ( e ) {
1883
1863
const manualMock = await this . _resolver . getMockModuleAsync (
1884
1864
from ,
0 commit comments