File tree 1 file changed +15
-3
lines changed
1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -483,6 +483,21 @@ function ensureTypeScriptInstance(loaderOptions: LoaderOptions, loader: any): {
483
483
}
484
484
} ) ;
485
485
486
+
487
+ // gather all declaration files from TypeScript and output them to webpack
488
+ Object . keys ( instance . files )
489
+ . filter ( filePath => ! ! filePath . match ( / \. t s ( x ? ) $ / ) )
490
+ . forEach ( filePath => {
491
+ let output = languageService . getEmitOutput ( filePath ) ;
492
+ let declarationFile = output . outputFiles . filter ( filePath => ! ! filePath . name . match ( / \. d .t s $ / ) ) . pop ( ) ;
493
+ if ( declarationFile ) {
494
+ compilation . assets [ declarationFile . name ] = {
495
+ source : ( ) => declarationFile . text ,
496
+ size : ( ) => declarationFile . text . length
497
+ } ;
498
+ }
499
+ } ) ;
500
+
486
501
callback ( ) ;
487
502
} ) ;
488
503
@@ -583,9 +598,6 @@ function loader(contents) {
583
598
584
599
var sourceMapFile = output . outputFiles . filter ( file => ! ! file . name . match ( / \. j s ( x ? ) \. m a p $ / ) ) . pop ( ) ;
585
600
if ( sourceMapFile ) { sourceMapText = sourceMapFile . text }
586
-
587
- var declarationFile = output . outputFiles . filter ( file => ! ! file . name . match ( / \. d .t s $ / ) ) . pop ( ) ;
588
- if ( declarationFile ) { this . emitFile ( path . relative ( this . options . context , declarationFile . name ) , declarationFile . text ) ; }
589
601
}
590
602
591
603
if ( outputText == null ) throw new Error ( `Typescript emitted no output for ${ filePath } ` ) ;
You can’t perform that action at this time.
0 commit comments