@@ -2129,27 +2129,7 @@ namespace ts {
21292129 || positionIsSynthesized ( node . end ) ;
21302130 }
21312131
2132- export function createBundle ( sourceFiles : SourceFile [ ] ) {
2133- const node = < Bundle > createNode ( SyntaxKind . Bundle ) ;
2134- node . sourceFiles = sourceFiles ;
2135- return node ;
2136- }
2137-
2138- export function updateBundle ( node : Bundle , sourceFiles : SourceFile [ ] ) {
2139- if ( node . sourceFiles !== sourceFiles ) {
2140- return createBundle ( sourceFiles ) ;
2141- }
2142- return node ;
2143- }
2144-
2145- export function getOriginalSourceFileOrBundle ( sourceFileOrBundle : SourceFile | Bundle ) {
2146- if ( sourceFileOrBundle . kind === SyntaxKind . Bundle ) {
2147- return updateBundle ( sourceFileOrBundle , sameMap ( sourceFileOrBundle . sourceFiles , getOriginalSourceFile ) ) ;
2148- }
2149- return getOriginalSourceFile ( sourceFileOrBundle ) ;
2150- }
2151-
2152- function getOriginalSourceFile ( sourceFile : SourceFile ) {
2132+ export function getOriginalSourceFile ( sourceFile : SourceFile ) {
21532133 return getParseTreeNode ( sourceFile , isSourceFile ) || sourceFile ;
21542134 }
21552135
@@ -2664,62 +2644,6 @@ namespace ts {
26642644 return ! ( options . noEmitForJsFiles && isSourceFileJavaScript ( sourceFile ) ) && ! sourceFile . isDeclarationFile && ! isSourceFileFromExternalLibrary ( sourceFile ) ;
26652645 }
26662646
2667- /**
2668- * Iterates over the source files that are expected to have an emit output.
2669- *
2670- * @param host An EmitHost.
2671- * @param action The action to execute.
2672- * @param sourceFilesOrTargetSourceFile
2673- * If an array, the full list of source files to emit.
2674- * Else, calls `getSourceFilesToEmit` with the (optional) target source file to determine the list of source files to emit.
2675- */
2676- export function forEachEmittedFile (
2677- host : EmitHost , action : ( emitFileNames : EmitFileNames , sourceFileOrBundle : SourceFile | Bundle , emitOnlyDtsFiles : boolean ) => void ,
2678- sourceFilesOrTargetSourceFile ?: SourceFile [ ] | SourceFile ,
2679- emitOnlyDtsFiles ?: boolean ) {
2680-
2681- const sourceFiles = isArray ( sourceFilesOrTargetSourceFile ) ? sourceFilesOrTargetSourceFile : getSourceFilesToEmit ( host , sourceFilesOrTargetSourceFile ) ;
2682- const options = host . getCompilerOptions ( ) ;
2683- if ( options . outFile || options . out ) {
2684- if ( sourceFiles . length ) {
2685- const jsFilePath = options . outFile || options . out ;
2686- const sourceMapFilePath = getSourceMapFilePath ( jsFilePath , options ) ;
2687- const declarationFilePath = options . declaration ? removeFileExtension ( jsFilePath ) + ".d.ts" : "" ;
2688- action ( { jsFilePath, sourceMapFilePath, declarationFilePath } , createBundle ( sourceFiles ) , emitOnlyDtsFiles ) ;
2689- }
2690- }
2691- else {
2692- for ( const sourceFile of sourceFiles ) {
2693- const jsFilePath = getOwnEmitOutputFilePath ( sourceFile , host , getOutputExtension ( sourceFile , options ) ) ;
2694- const sourceMapFilePath = getSourceMapFilePath ( jsFilePath , options ) ;
2695- const declarationFilePath = ! isSourceFileJavaScript ( sourceFile ) && ( emitOnlyDtsFiles || options . declaration ) ? getDeclarationEmitOutputFilePath ( sourceFile , host ) : undefined ;
2696- action ( { jsFilePath, sourceMapFilePath, declarationFilePath } , sourceFile , emitOnlyDtsFiles ) ;
2697- }
2698- }
2699- }
2700-
2701- function getSourceMapFilePath ( jsFilePath : string , options : CompilerOptions ) {
2702- return options . sourceMap ? jsFilePath + ".map" : undefined ;
2703- }
2704-
2705- // JavaScript files are always LanguageVariant.JSX, as JSX syntax is allowed in .js files also.
2706- // So for JavaScript files, '.jsx' is only emitted if the input was '.jsx', and JsxEmit.Preserve.
2707- // For TypeScript, the only time to emit with a '.jsx' extension, is on JSX input, and JsxEmit.Preserve
2708- function getOutputExtension ( sourceFile : SourceFile , options : CompilerOptions ) : string {
2709- if ( options . jsx === JsxEmit . Preserve ) {
2710- if ( isSourceFileJavaScript ( sourceFile ) ) {
2711- if ( fileExtensionIs ( sourceFile . fileName , ".jsx" ) ) {
2712- return ".jsx" ;
2713- }
2714- }
2715- else if ( sourceFile . languageVariant === LanguageVariant . JSX ) {
2716- // TypeScript source file preserving JSX syntax
2717- return ".jsx" ;
2718- }
2719- }
2720- return ".js" ;
2721- }
2722-
27232647 export function getSourceFilePathInNewDir ( sourceFile : SourceFile , host : EmitHost , newDirPath : string ) {
27242648 let sourceFilePath = getNormalizedAbsolutePath ( sourceFile . fileName , host . getCurrentDirectory ( ) ) ;
27252649 const commonSourceDirectory = host . getCommonSourceDirectory ( ) ;
0 commit comments