@@ -53,7 +53,18 @@ const es6ImportOnly = RegExp(/import\s?\(?('|")(.*)('|")\)?;?/, "gm");
53
53
* Grab any import/requires from inside the code and make a list of
54
54
* its dependencies
55
55
*/
56
- const parseFileForModuleReferences = ( sourceCode : string ) => {
56
+ const parseFileForModuleReferences = (
57
+ moduleName : string | undefined ,
58
+ sourceCode : string
59
+ ) => {
60
+ if ( moduleName === "react" ) {
61
+ // speed up, hardcode
62
+ return [ "csstype" , "prop-types" , "scheduler/tracing" ] ;
63
+ }
64
+ if ( moduleName && isBuiltInModule ( moduleName ) ) {
65
+ // speed up
66
+ return [ ] ;
67
+ }
57
68
const foundModules = new Set < string > ( ) ;
58
69
var match ;
59
70
@@ -531,7 +542,11 @@ const getDependenciesForModule = async (
531
542
config : ATAConfig
532
543
) => {
533
544
// Get all the import/requires for the file
534
- const filteredModulesToLookAt = parseFileForModuleReferences ( sourceCode ) ;
545
+ const filteredModulesToLookAt = parseFileForModuleReferences (
546
+ moduleName ,
547
+ sourceCode
548
+ ) ;
549
+
535
550
const promises = filteredModulesToLookAt . map ( async ( name ) => {
536
551
// console.log(sourceCode);
537
552
// Support grabbing the hard-coded node modules if needed
@@ -641,10 +656,13 @@ const getDependenciesForModule = async (
641
656
}
642
657
} ) ;
643
658
644
- // Also support the <reference> comments
645
- promises . push (
646
- getReferenceDependencies ( sourceCode , moduleName ! , path ! , config )
647
- ) ;
659
+ // speedup, exclude built-in
660
+ if ( ! moduleName || ! isBuiltInModule ( moduleName ) ) {
661
+ // Also support the <reference> comments
662
+ promises . push (
663
+ getReferenceDependencies ( sourceCode , moduleName ! , path ! , config )
664
+ ) ;
665
+ }
648
666
649
667
await Promise . all ( promises ) ;
650
668
} ;
0 commit comments