@@ -565,19 +565,42 @@ private void extractSource() throws IOException {
565565 extractTypeScript (
566566 defaultExtractor , filesToExtract , tsconfigFiles , dependencyInstallationResult );
567567
568+ boolean hasTypeScriptFiles = extractedFiles .size () > 0 ;
569+
568570 // extract remaining files
569571 for (Path f : filesToExtract ) {
570- if (extractedFiles .add (f )) {
571- FileExtractor extractor = defaultExtractor ;
572- if (!fileTypes .isEmpty ()) {
573- String extension = FileUtil .extension (f );
574- if (customExtractors .containsKey (extension )) extractor = customExtractors .get (extension );
575- }
576- extract (extractor , f , null );
572+ if (extractedFiles .contains (f ))
573+ continue ;
574+ if (hasTypeScriptFiles && isFileDerivedFromTypeScriptFile (f , extractedFiles )) {
575+ continue ;
576+ }
577+ extractedFiles .add (f );
578+ FileExtractor extractor = defaultExtractor ;
579+ if (!fileTypes .isEmpty ()) {
580+ String extension = FileUtil .extension (f );
581+ if (customExtractors .containsKey (extension )) extractor = customExtractors .get (extension );
577582 }
583+ extract (extractor , f , null );
578584 }
579585 }
580586
587+ /**
588+ * Returns true if the given path is likely the output of compiling a TypeScript file
589+ * which we have already extracted.
590+ */
591+ private boolean isFileDerivedFromTypeScriptFile (Path path , Set <Path > extractedFiles ) {
592+ String name = path .getFileName ().toString ();
593+ if (!name .endsWith (".js" ))
594+ return false ;
595+ String stem = name .substring (0 , name .length () - ".js" .length ());
596+ for (String ext : FileType .TYPESCRIPT .getExtensions ()) {
597+ if (extractedFiles .contains (path .getParent ().resolve (stem + ext ))) {
598+ return true ;
599+ }
600+ }
601+ return false ;
602+ }
603+
581604 /** Returns true if yarn is installed, otherwise prints a warning and returns false. */
582605 private boolean verifyYarnInstallation () {
583606 ProcessBuilder pb = new ProcessBuilder (Arrays .asList ("yarn" , "-v" ));
0 commit comments